refactor(prefs): KVStore 统一 encode/decode 命名并移除旧配置迁移
读写方法对齐 MMKV 命名;decode 异常时清除对应键并返回默认值。
This commit is contained in:
1 parent
024def0017
commit
a3ee06c0f1
15 files changed
+78
-106
No files matched your search
@@ -12,7 +12,6 @@ import com.arialyy.aria.core.Aria;
|
||||
import com.fuying.sn.BuildConfig;
|
||||
import com.fuying.sn.core.common.sync.DeviceSyncGateways;
|
||||
import com.fuying.sn.core.common.system.AppEnvironment;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
import com.fuying.sn.core.data.repository.DeviceRepository;
|
||||
import com.fuying.sn.platform.app.RunningAppManager;
|
||||
import com.fuying.sn.platform.time.TimeControlManager;
|
||||
@@ -101,8 +100,6 @@ public class BaseApplication extends Application {
|
||||
private void utilsInint() {
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.e(TAG, "mmkv root: " + rootDir);
|
||||
// MMKV 初始化完成后把旧版 SharedPreferences 的配置一次性迁移过来
|
||||
KVStore.migrateLegacy(this);
|
||||
|
||||
PushManager.init(this);
|
||||
aliyunPushInit();
|
||||
|
||||
@@ -252,7 +252,7 @@ public class HardwareInfoUtils {
|
||||
Log.e(TAG, "getHardware: storage = " + storage);
|
||||
double use_space = getUse_space(context);
|
||||
Log.e(TAG, "getHardware: use_space = " + use_space);
|
||||
long wifi_time = KVStore.getLong("wifi_last_connect_time", 0L) / 1000;
|
||||
long wifi_time = KVStore.decodeLong("wifi_last_connect_time", 0L) / 1000;
|
||||
Log.e(TAG, "getHardware: wifi_time" + wifi_time);
|
||||
int CPU = getNumCores();
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(WIFI_SERVICE);
|
||||
|
||||
@@ -48,6 +48,6 @@ public final class AppEnvironment {
|
||||
* @return 调试模式返回 true
|
||||
*/
|
||||
public static boolean isDebugMode() {
|
||||
return BuildConfig.DEBUG || KVStore.getBoolean(CommonConfig.EnableDebug, false);
|
||||
return BuildConfig.DEBUG || KVStore.decodeBool(CommonConfig.EnableDebug, false);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.fuying.sn.core.data.local.prefs;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
@@ -12,21 +10,11 @@ import java.util.Map;
|
||||
/**
|
||||
* 本地键值存储统一入口,底层使用 MMKV。
|
||||
* <p>
|
||||
* 业务层统一通过本类读写轻量配置,不再直接使用 SharedPreferences / SPUtils。
|
||||
* 读写方法命名与 MMKV 保持一致(encode / decodeXxx),业务层不要直接持有 MMKV 实例。
|
||||
*/
|
||||
public final class KVStore {
|
||||
private static final String TAG = "KVStore";
|
||||
|
||||
/**
|
||||
* 旧版 SharedPreferences 文件名,仅用于一次性迁移
|
||||
*/
|
||||
private static final String LEGACY_SP_NAME = "share_data";
|
||||
|
||||
/**
|
||||
* 迁移完成标记,避免每次启动重复读取旧 SP
|
||||
*/
|
||||
private static final String KEY_LEGACY_MIGRATED = "kv_legacy_sp_migrated";
|
||||
|
||||
private KVStore() {
|
||||
}
|
||||
|
||||
@@ -34,36 +22,52 @@ public final class KVStore {
|
||||
return MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
}
|
||||
|
||||
public static int getInt(String key, int defaultValue) {
|
||||
return store().decodeInt(key, defaultValue);
|
||||
}
|
||||
|
||||
public static void putInt(String key, int value) {
|
||||
public static void encode(String key, int value) {
|
||||
store().encode(key, value);
|
||||
}
|
||||
|
||||
public static String getString(String key, String defaultValue) {
|
||||
return store().decodeString(key, defaultValue);
|
||||
}
|
||||
|
||||
public static void putString(String key, String value) {
|
||||
public static void encode(String key, String value) {
|
||||
store().encode(key, value);
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String key, boolean defaultValue) {
|
||||
return store().decodeBool(key, defaultValue);
|
||||
}
|
||||
|
||||
public static void putBoolean(String key, boolean value) {
|
||||
public static void encode(String key, boolean value) {
|
||||
store().encode(key, value);
|
||||
}
|
||||
|
||||
public static long getLong(String key, long defaultValue) {
|
||||
return store().decodeLong(key, defaultValue);
|
||||
public static void encode(String key, long value) {
|
||||
store().encode(key, value);
|
||||
}
|
||||
|
||||
public static void putLong(String key, long value) {
|
||||
store().encode(key, value);
|
||||
public static int decodeInt(String key, int defaultValue) {
|
||||
try {
|
||||
return store().decodeInt(key, defaultValue);
|
||||
} catch (Throwable e) {
|
||||
return removeAndReturn(key, e, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static String decodeString(String key, String defaultValue) {
|
||||
try {
|
||||
return store().decodeString(key, defaultValue);
|
||||
} catch (Throwable e) {
|
||||
return removeAndReturn(key, e, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean decodeBool(String key, boolean defaultValue) {
|
||||
try {
|
||||
return store().decodeBool(key, defaultValue);
|
||||
} catch (Throwable e) {
|
||||
return removeAndReturn(key, e, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static long decodeLong(String key, long defaultValue) {
|
||||
try {
|
||||
return store().decodeLong(key, defaultValue);
|
||||
} catch (Throwable e) {
|
||||
return removeAndReturn(key, e, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,44 +78,15 @@ public final class KVStore {
|
||||
}
|
||||
|
||||
/**
|
||||
* 一次性把旧版 SharedPreferences("share_data") 的数据迁移到 MMKV。
|
||||
* 迁移完成后写入标记,后续不再读取 SharedPreferences。
|
||||
* 解码失败时清除该键,避免损坏数据在后续读取时持续报错。
|
||||
*/
|
||||
public static void migrateLegacy(Context context) {
|
||||
if (context == null || store().decodeBool(KEY_LEGACY_MIGRATED, false)) {
|
||||
return;
|
||||
}
|
||||
private static <T> T removeAndReturn(String key, Throwable error, T defaultValue) {
|
||||
Log.e(TAG, "decode " + key + " 失败,已清除该键: " + error.getMessage());
|
||||
try {
|
||||
SharedPreferences legacy = context.getSharedPreferences(LEGACY_SP_NAME, Context.MODE_PRIVATE);
|
||||
Map<String, ?> values = legacy.getAll();
|
||||
if (values != null) {
|
||||
for (Map.Entry<String, ?> entry : values.entrySet()) {
|
||||
encodeObject(entry.getKey(), entry.getValue());
|
||||
}
|
||||
Log.d(TAG, "migrateLegacy: 已迁移旧配置 " + values.size() + " 项");
|
||||
}
|
||||
store().encode(KEY_LEGACY_MIGRATED, true);
|
||||
} catch (Throwable e) {
|
||||
Log.e(TAG, "migrateLegacy: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void encodeObject(String key, Object value) {
|
||||
if (key == null || value == null) {
|
||||
return;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
store().encode(key, (String) value);
|
||||
} else if (value instanceof Integer) {
|
||||
store().encode(key, (Integer) value);
|
||||
} else if (value instanceof Boolean) {
|
||||
store().encode(key, (Boolean) value);
|
||||
} else if (value instanceof Float) {
|
||||
store().encode(key, (Float) value);
|
||||
} else if (value instanceof Long) {
|
||||
store().encode(key, (Long) value);
|
||||
} else {
|
||||
store().encode(key, String.valueOf(value));
|
||||
store().removeValueForKey(key);
|
||||
} catch (Throwable removeError) {
|
||||
Log.e(TAG, "remove " + key + " 失败: " + removeError.getMessage());
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
if (DeviceManager.isDebugMode()) {
|
||||
return true;
|
||||
} else {
|
||||
return KVStore.getBoolean(CommonConfig.userDebugMode, false);
|
||||
return KVStore.decodeBool(CommonConfig.userDebugMode, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
mDEBUGHits[mDEBUGHits.length - 1] = SystemClock.uptimeMillis();
|
||||
if (mDEBUGHits[0] >= SystemClock.uptimeMillis() - DEBUGDURATION) {
|
||||
mDEBUGHits = new long[DEBUGCOUNTS]; //重新初始化数组
|
||||
if (KVStore.getBoolean(CommonConfig.EnableDebug, false)) {
|
||||
if (KVStore.decodeBool(CommonConfig.EnableDebug, false)) {
|
||||
ToastUtil.show("已经是Debug模式");
|
||||
} else {
|
||||
showDebugDialog();
|
||||
@@ -226,7 +226,7 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
@Override
|
||||
public void onPositiveClick() {
|
||||
if (DebugPasswordVerifier.verify(dialog.getEdittext())) {
|
||||
KVStore.putBoolean(CommonConfig.EnableDebug, true);
|
||||
KVStore.encode(CommonConfig.EnableDebug, true);
|
||||
|
||||
AndroidSettingsWriter.putInt(HomeActivity.this, AndroidSettingsWriter.NAMESPACE_GLOBAL, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
|
||||
AndroidSettingsWriter.putInt(HomeActivity.this, AndroidSettingsWriter.NAMESPACE_GLOBAL, Settings.Global.ADB_ENABLED, 1);
|
||||
|
||||
@@ -359,7 +359,7 @@ public class JgyUtils {
|
||||
}
|
||||
|
||||
public void cleanLauncherCache() {
|
||||
int cleaned = KVStore.getInt("fristcleanLauncherCache", 0);
|
||||
int cleaned = KVStore.decodeInt("fristcleanLauncherCache", 0);
|
||||
if (cleaned != 0) {
|
||||
return;
|
||||
}
|
||||
@@ -367,7 +367,7 @@ public class JgyUtils {
|
||||
// 清理最多会等待 60 秒,交给异步任务,避免安装广播的主线程被阻塞
|
||||
ApkUtils.cleanApplicationUserDataAsync(mContext, "com.android.launcher3", succeeded -> {
|
||||
if (succeeded) {
|
||||
KVStore.putInt("fristcleanLauncherCache", 1);
|
||||
KVStore.encode("fristcleanLauncherCache", 1);
|
||||
}
|
||||
Log.e(TAG, "cleanLauncherCache: end " + succeeded);
|
||||
});
|
||||
@@ -669,7 +669,7 @@ public class JgyUtils {
|
||||
|
||||
public ArrayList<String> getForbidList() {
|
||||
ArrayList<String> disableApp = new ArrayList<>();
|
||||
int search_topic = KVStore.getInt("search_topic", 0);
|
||||
int search_topic = KVStore.decodeInt("search_topic", 0);
|
||||
Log.e(TAG, "getForbidList: search_topic = " + search_topic);
|
||||
Log.e(TAG, "getForbidList: " + GsonUtils.toJSONString(KVStore.getAll()));
|
||||
|
||||
@@ -715,7 +715,7 @@ public class JgyUtils {
|
||||
}
|
||||
|
||||
public ArrayList<String> getHideList() {
|
||||
String appString = KVStore.getString("Hide_APP_List", "");
|
||||
String appString = KVStore.decodeString("Hide_APP_List", "");
|
||||
Log.e(TAG, "Hide_APP_List: " + appString);
|
||||
if (TextUtils.isEmpty(appString)) {
|
||||
return new ArrayList<>();
|
||||
|
||||
@@ -930,7 +930,7 @@ public class PushManager {
|
||||
Log.e(TAG, "searchTopic: " + jsonString);
|
||||
JsonObject jsonObject = GsonUtils.getJsonObject(jsonString);
|
||||
int search_topic = jsonObject.get("search_topic").getAsInt();
|
||||
KVStore.putInt("search_topic", search_topic);
|
||||
KVStore.encode("search_topic", search_topic);
|
||||
Log.e(TAG, "searchTopic: put = " + search_topic);
|
||||
JgyUtils.getInstance().updateForbidList();
|
||||
}
|
||||
@@ -1560,7 +1560,7 @@ public class PushManager {
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
// intent.putExtra("name", name);
|
||||
KVStore.putInt(LOCK_STATE, type);
|
||||
KVStore.encode(LOCK_STATE, type);
|
||||
if (1 == type) {
|
||||
intent.setAction(ManagerService.ACTION_LOCK);
|
||||
} else if (0 == type) {
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ApkInstallReceiver extends BroadcastReceiver {
|
||||
.observeOn(RxSchedulers.io())
|
||||
.subscribe(packageName -> {
|
||||
Log.e("sendAppInfo", "onNext: " + packageName);
|
||||
int isLogined = KVStore.getInt(CommonConfig.isLogined, 2);
|
||||
int isLogined = KVStore.decodeInt(CommonConfig.isLogined, 2);
|
||||
if (isLogined != 2) {
|
||||
// AppPolicySync.getInstance().getForceInstall();
|
||||
// AppInventorySync.getInstance().getAppInside();
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ManagerService extends BaseService implements NetworkUtils.OnNetwor
|
||||
@Override
|
||||
public void onNext(Long aLong) {
|
||||
Log.e("TimeObserver", "onNext: " + aLong);
|
||||
int isLogined = KVStore.getInt(CommonConfig.isLogined, 2);
|
||||
int isLogined = KVStore.decodeInt(CommonConfig.isLogined, 2);
|
||||
if (isLogined == 2) {
|
||||
|
||||
}
|
||||
@@ -157,7 +157,7 @@ public class ManagerService extends BaseService implements NetworkUtils.OnNetwor
|
||||
} else {
|
||||
// 服务端明确返回非锁定(未绑定/未登录等):直接解锁
|
||||
hideFloatingWindow();
|
||||
KVStore.putInt(LOCK_STATE, 0);
|
||||
KVStore.encode(LOCK_STATE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,10 +179,10 @@ public class ManagerService extends BaseService implements NetworkUtils.OnNetwor
|
||||
private void setLockedState(int lockedState) {
|
||||
if (lockedState == 1) {
|
||||
showFloatingWindow("屏幕已锁定");
|
||||
KVStore.putInt(LOCK_STATE, 1);
|
||||
KVStore.encode(LOCK_STATE, 1);
|
||||
} else {
|
||||
hideFloatingWindow();
|
||||
KVStore.putInt(LOCK_STATE, 0);
|
||||
KVStore.encode(LOCK_STATE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class ManagerService extends BaseService implements NetworkUtils.OnNetwor
|
||||
if (pwdUnlocked) {
|
||||
return 0;
|
||||
}
|
||||
return KVStore.getInt(LOCK_STATE, 0);
|
||||
return KVStore.decodeInt(LOCK_STATE, 0);
|
||||
}
|
||||
|
||||
private void showFloatingWindow(String name) {
|
||||
|
||||
@@ -160,7 +160,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
if (screenOnReconnect) {
|
||||
// 使用记录补传仍按亮屏重连的原有条件执行。
|
||||
AppUsageReporter.getInstance().reUploadAppUsageRecords();
|
||||
KVStore.putInt(CommonConfig.JGY_FIRST_BOOT, 1);
|
||||
KVStore.encode(CommonConfig.JGY_FIRST_BOOT, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
private static final String DEFAULT_SOURCE = "com.fuying.sn,com.fuying.appstore,com.fuying.fuxiaoying";
|
||||
|
||||
private void versionIsUpdate() {
|
||||
int oldVersionCode = KVStore.getInt(CommonConfig.SN_VERSIONCODE, 0);
|
||||
int oldVersionCode = KVStore.decodeInt(CommonConfig.SN_VERSIONCODE, 0);
|
||||
if (oldVersionCode < BuildConfig.VERSION_CODE) {
|
||||
Log.e(TAG, "onCreate: " + "upgrade successful");
|
||||
try {
|
||||
@@ -278,7 +278,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
} else {
|
||||
|
||||
}
|
||||
KVStore.putInt(CommonConfig.SN_VERSIONCODE, BuildConfig.VERSION_CODE);
|
||||
KVStore.encode(CommonConfig.SN_VERSIONCODE, BuildConfig.VERSION_CODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -282,7 +282,7 @@ public class MainServiceModel extends BaseAndroidViewModel {
|
||||
if (!SystemUtils.isServiceAlive(getApplication(), ManagerService.class.getName())) {
|
||||
getApplication().startService(new Intent(getApplication(), ManagerService.class));
|
||||
}
|
||||
KVStore.putInt(ManagerService.LOCK_STATE, is_screen_lock);
|
||||
KVStore.encode(ManagerService.LOCK_STATE, is_screen_lock);
|
||||
Intent intent = new Intent();
|
||||
// intent.putExtra("name", name);
|
||||
if (1 == is_screen_lock) {
|
||||
@@ -293,7 +293,7 @@ public class MainServiceModel extends BaseAndroidViewModel {
|
||||
getApplication().sendBroadcast(intent);
|
||||
} else {
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// KVStore.putInt(ManagerService.LOCK_STATE, 1);
|
||||
// KVStore.encode(ManagerService.LOCK_STATE, 1);
|
||||
// Intent intent = new Intent();
|
||||
// intent.setAction(ManagerService.ACTION_LOCK);
|
||||
// getApplication().sendBroadcast(intent);
|
||||
|
||||
@@ -249,7 +249,7 @@ public final class AppPolicySync {
|
||||
}
|
||||
}
|
||||
String jsonString = GsonUtils.toJSONString(hideAPPList);
|
||||
KVStore.putString("Hide_APP_List", String.join(",", jsonString));
|
||||
KVStore.encode("Hide_APP_List", String.join(",", jsonString));
|
||||
JgyUtils.getInstance().updateHideList();
|
||||
Log.e(TAG, "Hide_APP_List: " + jsonString);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public final class AppUsageReporter {
|
||||
|
||||
public void sendAppUsageRecord(String packageName, long openTime, long closeTime, CompleteCallback completeCallback) {
|
||||
Log.e(TAG, "sendAppUsageRecord: packageName = " + packageName + ", openTime = " + openTime + ", closeTime = " + closeTime);
|
||||
int isLogined = KVStore.getInt(CommonConfig.isLogined, 2);
|
||||
int isLogined = KVStore.decodeInt(CommonConfig.isLogined, 2);
|
||||
if (isLogined != 1) {
|
||||
Log.e(TAG, "sendAppUsageRecord: 没有绑定");
|
||||
// TODO: 2025/6/13 延迟获取不了数据
|
||||
@@ -167,7 +167,7 @@ public final class AppUsageReporter {
|
||||
|
||||
@Deprecated
|
||||
public void sendCloseApp(String packageName, CompleteCallback completeCallback) {
|
||||
int isLogined = KVStore.getInt(CommonConfig.isLogined, 2);
|
||||
int isLogined = KVStore.decodeInt(CommonConfig.isLogined, 2);
|
||||
if (isLogined != 1) {
|
||||
Log.e(TAG, "sendCloseApp: 没有绑定");
|
||||
// TODO: 2025/6/13 延迟获取不了数据
|
||||
|
||||
@@ -92,32 +92,32 @@ public final class DeviceProfileSync {
|
||||
@Override
|
||||
public void onNext(BaseResponse<SnInfo> userInfoBaseResponse) {
|
||||
Log.e("getSnInfo", "onNext: " + userInfoBaseResponse);
|
||||
KVStore.putInt(CommonConfig.JGY_FIRST_CONNECT, 1);
|
||||
KVStore.encode(CommonConfig.JGY_FIRST_CONNECT, 1);
|
||||
if (callback != null)
|
||||
callback.onNext(userInfoBaseResponse);
|
||||
int code = userInfoBaseResponse.code;
|
||||
if (code == 200 && userInfoBaseResponse.data != null) {
|
||||
KVStore.putInt(CommonConfig.isLogined, 1);
|
||||
KVStore.encode(CommonConfig.isLogined, 1);
|
||||
SnInfo snInfo = userInfoBaseResponse.data;
|
||||
// 统一交由 TimeConfigRepository 落库 + 回调,保证数据源唯一
|
||||
TimeConfigRepository.getInstance().applySnInfo(snInfo);
|
||||
AndroidSettingsWriter.putString(mContext, AndroidSettingsWriter.NAMESPACE_SYSTEM, "UserInfo_username", snInfo.getSn_name());
|
||||
AndroidSettingsWriter.putString(mContext, AndroidSettingsWriter.NAMESPACE_SYSTEM, "UserInfo_grade", snInfo.getGrade());
|
||||
KVStore.putInt("sn_id", snInfo.getId());
|
||||
KVStore.encode("sn_id", snInfo.getId());
|
||||
if (!TextUtils.isEmpty(snInfo.getSn_name())) {
|
||||
KVStore.putString("USERINFO_NAME", snInfo.getSn_name());
|
||||
KVStore.encode("USERINFO_NAME", snInfo.getSn_name());
|
||||
}
|
||||
if (!TextUtils.isEmpty(snInfo.getSchool())) {
|
||||
KVStore.putString("USERINFO_SCHOOL", snInfo.getSchool());
|
||||
KVStore.encode("USERINFO_SCHOOL", snInfo.getSchool());
|
||||
}
|
||||
if (!TextUtils.isEmpty(snInfo.getGrade())) {
|
||||
KVStore.putString("USERINFO_GRADE", snInfo.getGrade());
|
||||
KVStore.encode("USERINFO_GRADE", snInfo.getGrade());
|
||||
}
|
||||
} else if (code == 300) {
|
||||
KVStore.putInt(CommonConfig.isLogined, 0);
|
||||
KVStore.encode(CommonConfig.isLogined, 0);
|
||||
AndroidSettingsWriter.putInt(mContext, AndroidSettingsWriter.NAMESPACE_SYSTEM, CommonConfig.KEY_IS_CONTROL, 0);
|
||||
} else if (code == 401) {
|
||||
KVStore.putInt(CommonConfig.isLogined, 2);
|
||||
KVStore.encode(CommonConfig.isLogined, 2);
|
||||
AndroidSettingsWriter.putInt(mContext, AndroidSettingsWriter.NAMESPACE_SYSTEM, CommonConfig.KEY_IS_CONTROL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public final class DeviceSettingsSync {
|
||||
@Override
|
||||
public void onNext(BaseResponse<SystemSettingsSet> systemSettingsBaseResponse) {
|
||||
Log.e("getSystemSettings", "onNext: " + systemSettingsBaseResponse);
|
||||
KVStore.putInt("is_first_connection", 0);
|
||||
KVStore.encode("is_first_connection", 0);
|
||||
|
||||
int code = systemSettingsBaseResponse.code;
|
||||
if (code == 200) {
|
||||
@@ -177,7 +177,7 @@ public final class DeviceSettingsSync {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
if (KVStore.getInt("is_first_connection", 1) == 1) {
|
||||
if (KVStore.decodeInt("is_first_connection", 1) == 1) {
|
||||
ControlManager.getInstance().setDisableSetting();
|
||||
}
|
||||
Log.e("getSystemSettings", "onError: " + e.getMessage());
|
||||
|
||||
Reference in new issue
Block a user