refactor(prefs): 全工程 MMKV 调用收敛到 KVStore
移除 19 个类的 MMKV 字段与 3 个未使用字段,读写统一走 KVStore,KVStore 补充 encode(double)/decodeDouble/remove。
This commit is contained in:
1 parent
a3ee06c0f1
commit
93464e9aa1
24 files changed
+146
-134
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package com.fuying.sn.core.common.config;
|
||||
|
||||
public class CommonConfig {
|
||||
public static final String MMKV_ID = "InterProcessKV";
|
||||
|
||||
public static final String MAP_LOCATION_JSON_KEY = "MAPLOCATION_JSON_STRING";
|
||||
public static final String MAP_LONGITUDE_KEY = "map_longitude_key";
|
||||
|
||||
@@ -15,11 +15,13 @@ import java.util.Map;
|
||||
public final class KVStore {
|
||||
private static final String TAG = "KVStore";
|
||||
|
||||
private static final String MMKV_ID = "InterProcessKV";
|
||||
|
||||
private KVStore() {
|
||||
}
|
||||
|
||||
private static MMKV store() {
|
||||
return MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
return MMKV.mmkvWithID(MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
}
|
||||
|
||||
public static void encode(String key, int value) {
|
||||
@@ -38,6 +40,14 @@ public final class KVStore {
|
||||
store().encode(key, value);
|
||||
}
|
||||
|
||||
public static void encode(String key, double value) {
|
||||
store().encode(key, value);
|
||||
}
|
||||
|
||||
public static void remove(String key) {
|
||||
store().removeValueForKey(key);
|
||||
}
|
||||
|
||||
public static int decodeInt(String key, int defaultValue) {
|
||||
try {
|
||||
return store().decodeInt(key, defaultValue);
|
||||
@@ -70,6 +80,14 @@ public final class KVStore {
|
||||
}
|
||||
}
|
||||
|
||||
public static double decodeDouble(String key, double defaultValue) {
|
||||
try {
|
||||
return store().decodeDouble(key, defaultValue);
|
||||
} catch (Throwable e) {
|
||||
return removeAndReturn(key, e, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MMKV 中的全部键值,仅用于诊断日志
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.fuying.sn.core.data.local.db.time.TimeControlDao;
|
||||
import com.fuying.sn.core.data.local.db.time.TimeControlDatabase;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -54,7 +54,7 @@ public class TimeConfigRepository {
|
||||
private static final long RETRY_INTERVAL = 60; // 重试间隔(秒)
|
||||
private static final int MAX_RETRY_COUNT = 10; // 最大重试次数,超过后停止重试
|
||||
|
||||
private final MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private final Gson mGson = new Gson();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@@ -154,7 +154,7 @@ public class TimeConfigRepository {
|
||||
*/
|
||||
public void loadLocalConfig() {
|
||||
// 从 MMKV 恢复设备(SN)信息缓存,保证离线可用
|
||||
String snInfoJson = mMMKV.decodeString(SN_INFO, "");
|
||||
String snInfoJson = KVStore.decodeString(SN_INFO, "");
|
||||
if (!TextUtils.isEmpty(snInfoJson)) {
|
||||
try {
|
||||
mSnInfo = mGson.fromJson(snInfoJson, new TypeToken<SnInfo>() {
|
||||
@@ -162,11 +162,11 @@ public class TimeConfigRepository {
|
||||
Log.e(TAG, "Loaded SN info from cache.");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to load SN info from cache: " + e.getMessage());
|
||||
mMMKV.remove(SN_INFO);
|
||||
KVStore.remove(SN_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
String snJson = mMMKV.decodeString(SN_TIME_CONTROL_INFO, "");
|
||||
String snJson = KVStore.decodeString(SN_TIME_CONTROL_INFO, "");
|
||||
if (!TextUtils.isEmpty(snJson)) {
|
||||
try {
|
||||
mSnTimeControlInfo = mGson.fromJson(snJson, new TypeToken<SnTimeControlInfo>() {
|
||||
@@ -174,7 +174,7 @@ public class TimeConfigRepository {
|
||||
Log.e(TAG, "Loaded SN local config from cache.");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to load SN local config: " + e.getMessage());
|
||||
mMMKV.remove(SN_TIME_CONTROL_INFO);
|
||||
KVStore.remove(SN_TIME_CONTROL_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public class TimeConfigRepository {
|
||||
}
|
||||
|
||||
// Room 无数据时,退回 MMKV 缓存
|
||||
String appJson = mMMKV.decodeString(APP_TIME_CONTROL_INFO, "");
|
||||
String appJson = KVStore.decodeString(APP_TIME_CONTROL_INFO, "");
|
||||
if (!TextUtils.isEmpty(appJson)) {
|
||||
try {
|
||||
mAppTimeControlList = mGson.fromJson(appJson, new TypeToken<List<AppTimeControlInfo>>() {
|
||||
@@ -202,7 +202,7 @@ public class TimeConfigRepository {
|
||||
Log.e(TAG, "Loaded App local config from MMKV cache.");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to load App local config: " + e.getMessage());
|
||||
mMMKV.remove(APP_TIME_CONTROL_INFO);
|
||||
KVStore.remove(APP_TIME_CONTROL_INFO);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ public class TimeConfigRepository {
|
||||
return;
|
||||
}
|
||||
mSnInfo = info;
|
||||
mMMKV.encode(SN_INFO, GsonUtils.toJSONString(mSnInfo));
|
||||
KVStore.encode(SN_INFO, GsonUtils.toJSONString(mSnInfo));
|
||||
Log.e(TAG, "SN info applied: " + info);
|
||||
if (mListener != null) {
|
||||
mListener.onSnInfoUpdated(mSnInfo);
|
||||
@@ -336,7 +336,7 @@ public class TimeConfigRepository {
|
||||
}
|
||||
mSnTimeControlInfo = info;
|
||||
mSnControlFetched = true;
|
||||
mMMKV.encode(SN_TIME_CONTROL_INFO, GsonUtils.toJSONString(mSnTimeControlInfo));
|
||||
KVStore.encode(SN_TIME_CONTROL_INFO, GsonUtils.toJSONString(mSnTimeControlInfo));
|
||||
Log.e(TAG, "SN config applied: " + info);
|
||||
if (mListener != null) {
|
||||
mListener.onSnConfigUpdated(mSnTimeControlInfo);
|
||||
@@ -370,7 +370,7 @@ public class TimeConfigRepository {
|
||||
}
|
||||
mAppTimeControlList = list;
|
||||
mAppControlFetched = true;
|
||||
mMMKV.encode(APP_TIME_CONTROL_INFO, GsonUtils.toJSONString(mAppTimeControlList));
|
||||
KVStore.encode(APP_TIME_CONTROL_INFO, GsonUtils.toJSONString(mAppTimeControlList));
|
||||
// 同步写入 Room,保证重启后立即恢复
|
||||
saveAppControlsToDb(mAppTimeControlList);
|
||||
Log.e(TAG, "App config applied, size=" + mAppTimeControlList.size());
|
||||
@@ -443,11 +443,11 @@ public class TimeConfigRepository {
|
||||
// --- 剩余时长持久化(与 RunningAppManager 共享同一 MMKV key) ---
|
||||
|
||||
public long loadGlobalRemainingTime() {
|
||||
return mMMKV.decodeLong(GLOBAL_REMAINING_TIME_KEY, 0);
|
||||
return KVStore.decodeLong(GLOBAL_REMAINING_TIME_KEY, 0);
|
||||
}
|
||||
|
||||
public void saveGlobalRemainingTime(long remainingTime) {
|
||||
mMMKV.encode(GLOBAL_REMAINING_TIME_KEY, remainingTime);
|
||||
KVStore.encode(GLOBAL_REMAINING_TIME_KEY, remainingTime);
|
||||
}
|
||||
|
||||
// --- 对象转换 ---
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.fuying.sn.core.common.device.HardwareInfoUtils;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.jakewharton.rxbinding4.view.RxView;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DeviceFragment extends BaseMvvmFragment<DeviceViewModel, FragmentDe
|
||||
private static final String TAG = "DeviceFragment";
|
||||
private Activity mContext;
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
private Disposable mClickDisposable;
|
||||
// 2秒防抖时间
|
||||
|
||||
@@ -44,7 +44,7 @@ import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.formatter.ValueFormatter;
|
||||
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet;
|
||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
import net.lucode.hackware.magicindicator.MagicIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
|
||||
@@ -61,7 +61,6 @@ import java.util.List;
|
||||
public class UsageFragment extends BaseMvvmFragment<UsageViewModel, FragmentUsageBinding> {
|
||||
private static final String TAG = "UsageFragment";
|
||||
private Activity mContext;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private HorizontalBarChart mBarChart;
|
||||
private TextView mTvTotalTime;
|
||||
@@ -108,7 +107,7 @@ public class UsageFragment extends BaseMvvmFragment<UsageViewModel, FragmentUsag
|
||||
|
||||
@Override
|
||||
protected void observeViewModel() {
|
||||
String address = mMMKV.decodeString(CommonConfig.MAP_ADDRESS_KEY, "正在定位");
|
||||
String address = KVStore.decodeString(CommonConfig.MAP_ADDRESS_KEY, "正在定位");
|
||||
if (!TextUtils.isEmpty(address)) {
|
||||
mViewDataBinding.tvAddress.setText(address);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.fuying.sn.core.data.dto.statistics.ControlStatusInfo;
|
||||
import com.fuying.sn.core.data.dto.statistics.RemainingTimeBean;
|
||||
import com.fuying.sn.core.data.repository.DeviceRepository;
|
||||
import com.fuying.sn.core.data.repository.StatisticsRepository;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -47,7 +47,6 @@ public class UsageViewModel extends BaseViewModel {
|
||||
private static final String REQ_APP_CONTROL_DETAIL = "appControlDetail";
|
||||
|
||||
private final StatisticsRepository mRepository = StatisticsRepository.getInstance();
|
||||
private final MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
// 本轮刷新中尚未返回的请求,以及成功计数,用于判断整页是否全部成功
|
||||
private final Set<String> mPendingRequests = new HashSet<>();
|
||||
@@ -120,7 +119,7 @@ public class UsageViewModel extends BaseViewModel {
|
||||
return;
|
||||
}
|
||||
if (mSuccessCount >= mTotalRequests) {
|
||||
mMMKV.encode(CommonConfig.LAST_SYNC_TIME_KEY, System.currentTimeMillis());
|
||||
KVStore.encode(CommonConfig.LAST_SYNC_TIME_KEY, System.currentTimeMillis());
|
||||
refreshLastSyncTime();
|
||||
}
|
||||
mSuccessCount = 0;
|
||||
@@ -128,7 +127,7 @@ public class UsageViewModel extends BaseViewModel {
|
||||
|
||||
/** 读取本地缓存的同步时间戳(0 表示暂无),供视图层格式化展示 */
|
||||
public void refreshLastSyncTime() {
|
||||
lastSyncTime.setValue(mMMKV.decodeLong(CommonConfig.LAST_SYNC_TIME_KEY, 0));
|
||||
lastSyncTime.setValue(KVStore.decodeLong(CommonConfig.LAST_SYNC_TIME_KEY, 0));
|
||||
}
|
||||
|
||||
public void loadSettingData() {
|
||||
|
||||
@@ -17,14 +17,14 @@ import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.fuying.sn.core.data.dto.statistics.AppControlDetail;
|
||||
import com.fuying.sn.core.common.image.GlideLoadUtils;
|
||||
import com.fuying.sn.platform.time.TimeUtils;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AppControlDetailAdapter extends RecyclerView.Adapter<AppControlDetailAdapter.ViewHolder> {
|
||||
private static final String TAG = "DesktopItemAdapter";
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private List<AppControlDetail> mAppTimeControlInfos;
|
||||
|
||||
@@ -49,7 +49,7 @@ import com.fuying.sn.platform.system.SystemUtils;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.DateFormat;
|
||||
@@ -83,7 +83,6 @@ public class RunningAppManager {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static RunningAppManager sInstance;
|
||||
private Context mContext;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
public static final String RemainingTimeMap = "RemainingTimeMap_KEY";
|
||||
|
||||
@@ -122,8 +121,8 @@ public class RunningAppManager {
|
||||
this.mContext = context.getApplicationContext();
|
||||
registerTimeReceiver(mContext);
|
||||
|
||||
globalRemainingTime = mMMKV.decodeLong(GLOBAL_REMAINING_TIME_KEY, 0);
|
||||
String remainsTimeJson = mMMKV.decodeString(RemainingTimeMap, "");
|
||||
globalRemainingTime = KVStore.decodeLong(GLOBAL_REMAINING_TIME_KEY, 0);
|
||||
String remainsTimeJson = KVStore.decodeString(RemainingTimeMap, "");
|
||||
Log.e(TAG, "remainsTimeJson: " + remainsTimeJson);
|
||||
Gson gson = new Gson();
|
||||
Type remainsTimeType = new TypeToken<HashMap<String, AppRunTimeBean>>() {
|
||||
@@ -133,7 +132,7 @@ public class RunningAppManager {
|
||||
mRemainingTimeMap = remainingTimeMap;
|
||||
}
|
||||
|
||||
String globalUsageTimeJson = mMMKV.decodeString(GlobalUsageTimeMap, "");
|
||||
String globalUsageTimeJson = KVStore.decodeString(GlobalUsageTimeMap, "");
|
||||
Log.e(TAG, "globalUsageTimeJson: " + globalUsageTimeJson);
|
||||
Type globalUsageTimeType = new TypeToken<HashMap<String, AppUsageTime>>() {
|
||||
}.getType();
|
||||
@@ -142,7 +141,7 @@ public class RunningAppManager {
|
||||
mGlobalUsageTime = appUsageTimeHashMap;
|
||||
}
|
||||
|
||||
String allAppUsageTimeJson = mMMKV.decodeString(AllApplUsageTimeMap, "");
|
||||
String allAppUsageTimeJson = KVStore.decodeString(AllApplUsageTimeMap, "");
|
||||
Log.e(TAG, "allAppUsageTimeJson: " + globalUsageTimeJson);
|
||||
Type allAppUsageTimeType = new TypeToken<HashMap<String, AppUsageTime>>() {
|
||||
}.getType();
|
||||
@@ -208,7 +207,7 @@ public class RunningAppManager {
|
||||
// }
|
||||
// });
|
||||
}
|
||||
mMMKV.encode(RUNNING_APP_PACKAGENAME, "");
|
||||
KVStore.encode(RUNNING_APP_PACKAGENAME, "");
|
||||
AppUsedTimeUtils.getInstance().setApp_package("");
|
||||
return;
|
||||
}
|
||||
@@ -235,7 +234,7 @@ public class RunningAppManager {
|
||||
AppUsedTimeUtils.getInstance().setStart_time(System.currentTimeMillis() / 1000);
|
||||
}
|
||||
}
|
||||
mMMKV.encode(RUNNING_APP_PACKAGENAME, "");
|
||||
KVStore.encode(RUNNING_APP_PACKAGENAME, "");
|
||||
Log.e(TAG, "checkForegroundAppName: allow: " + topPackage);
|
||||
return;
|
||||
}
|
||||
@@ -370,9 +369,9 @@ public class RunningAppManager {
|
||||
public void onNext(@io.reactivex.rxjava3.annotations.NonNull Long aLong) {
|
||||
Log.e("getConfig", "onNext: " + aLong);
|
||||
//清除数据保证及时性
|
||||
mMMKV.encode(RemainingTimeMap, "");
|
||||
mMMKV.encode(GlobalUsageTimeMap, "");
|
||||
mMMKV.encode(AllApplUsageTimeMap, "");
|
||||
KVStore.encode(RemainingTimeMap, "");
|
||||
KVStore.encode(GlobalUsageTimeMap, "");
|
||||
KVStore.encode(AllApplUsageTimeMap, "");
|
||||
mRemainingTimeMap.clear();
|
||||
mGlobalUsageTime.clear();
|
||||
mAllAppUsageTime.clear();
|
||||
@@ -500,26 +499,26 @@ public class RunningAppManager {
|
||||
* @param packageName
|
||||
*/
|
||||
public void recordPackageOpenTime(String packageName) {
|
||||
mMMKV.encode(RUNNING_APP_PACKAGENAME, packageName);
|
||||
mMMKV.encode(RUNNING_APP_ONCLICK_TIME, System.currentTimeMillis() / 1000);
|
||||
KVStore.encode(RUNNING_APP_PACKAGENAME, packageName);
|
||||
KVStore.encode(RUNNING_APP_ONCLICK_TIME, System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
public String getAppPackageName() {
|
||||
String packageName = mMMKV.decodeString(RUNNING_APP_PACKAGENAME, "");
|
||||
String packageName = KVStore.decodeString(RUNNING_APP_PACKAGENAME, "");
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public long getOnClickTime() {
|
||||
long onClickTime = mMMKV.decodeLong(RUNNING_APP_ONCLICK_TIME, 0L);
|
||||
long onClickTime = KVStore.decodeLong(RUNNING_APP_ONCLICK_TIME, 0L);
|
||||
return onClickTime;
|
||||
}
|
||||
|
||||
public void setAppRunTime(long time) {
|
||||
mMMKV.encode(RUNNING_APP_RUN_TIME, time);
|
||||
KVStore.encode(RUNNING_APP_RUN_TIME, time);
|
||||
}
|
||||
|
||||
public long getAppRunTime() {
|
||||
long appRunTime = mMMKV.decodeLong(RUNNING_APP_RUN_TIME, 0L);
|
||||
long appRunTime = KVStore.decodeLong(RUNNING_APP_RUN_TIME, 0L);
|
||||
return appRunTime;
|
||||
}
|
||||
|
||||
@@ -528,7 +527,7 @@ public class RunningAppManager {
|
||||
if (globalRemainingTime < 0) {
|
||||
globalRemainingTime = 0;
|
||||
}
|
||||
mMMKV.encode(GLOBAL_REMAINING_TIME_KEY, globalRemainingTime);
|
||||
KVStore.encode(GLOBAL_REMAINING_TIME_KEY, globalRemainingTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -567,7 +566,7 @@ public class RunningAppManager {
|
||||
}
|
||||
}
|
||||
String singleString = GsonUtils.toJSONString(mAllAppUsageTime);
|
||||
mMMKV.encode(AllApplUsageTimeMap, singleString);
|
||||
KVStore.encode(AllApplUsageTimeMap, singleString);
|
||||
Log.e(TAG, "syncAllAppUsageTime: " + mAllAppUsageTime);
|
||||
}
|
||||
|
||||
@@ -576,11 +575,11 @@ public class RunningAppManager {
|
||||
*/
|
||||
public void saveAppRemainingTime() {
|
||||
String jsonString = GsonUtils.toJSONString(mRemainingTimeMap);
|
||||
mMMKV.encode(RemainingTimeMap, jsonString);
|
||||
KVStore.encode(RemainingTimeMap, jsonString);
|
||||
String timeString = GsonUtils.toJSONString(mGlobalUsageTime);
|
||||
mMMKV.encode(GlobalUsageTimeMap, timeString);
|
||||
KVStore.encode(GlobalUsageTimeMap, timeString);
|
||||
String singleString = GsonUtils.toJSONString(mAllAppUsageTime);
|
||||
mMMKV.encode(AllApplUsageTimeMap, singleString);
|
||||
KVStore.encode(AllApplUsageTimeMap, singleString);
|
||||
}
|
||||
|
||||
private long getAppTodayRunTime(String pkg) {
|
||||
@@ -717,7 +716,7 @@ public class RunningAppManager {
|
||||
if (TextUtils.isEmpty(pkg)) {
|
||||
return "未知";
|
||||
}
|
||||
String jsonString = mMMKV.decodeString(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
String jsonString = KVStore.decodeString(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
if (!TextUtils.isEmpty(jsonString)) {
|
||||
Type type = new TypeToken<List<AppInfo>>() {
|
||||
}.getType();
|
||||
|
||||
@@ -9,7 +9,7 @@ import android.util.Log;
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.fuying.sn.platform.system.AndroidSettingsWriter;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -22,7 +22,7 @@ import java.util.HashSet;
|
||||
*/
|
||||
public class AppWhitelistUtils {
|
||||
|
||||
private static final MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
/**
|
||||
* 更新应用白名单禁止升级
|
||||
@@ -38,7 +38,7 @@ public class AppWhitelistUtils {
|
||||
String upgrade_disallow = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_DISALLOW_UPGRADE);
|
||||
//所有app
|
||||
String only_jgy_shortcut_list = Settings.System.getString(context.getContentResolver(), CommonConfig.ONLY_SHORTCUT_LIST);
|
||||
String overall_app_list = mMMKV.decodeString(CommonConfig.AOLE_ACTION_OVERALL_APP, "");
|
||||
String overall_app_list = KVStore.decodeString(CommonConfig.AOLE_ACTION_OVERALL_APP, "");
|
||||
Log.e("writeDisableUpdateList", "aole_app_forbid: " + now);
|
||||
HashSet<String> nowList = new HashSet<>();
|
||||
HashSet<String> disallowList = new HashSet<>();
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.fuying.sn.platform.system.AndroidSettingsWriter;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;␍
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;␍
|
||||
import com.fuying.sn.platform.system.DeviceManager;
|
||||
|
||||
/**
|
||||
@@ -31,7 +31,7 @@ public class ControlManager {
|
||||
private static ControlManager sInstance;
|
||||
private Context mContext;
|
||||
private ContentResolver mResolver;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
private ControlManager(Context context) {
|
||||
if (context == null) {
|
||||
@@ -666,26 +666,26 @@ public class ControlManager {
|
||||
String desktop_app = settings.getDesktop_app();
|
||||
Log.e(TAG, "setDefaultApp: desktop_app = " + desktop_app);
|
||||
if (!TextUtils.isEmpty(desktop_app)) {
|
||||
mMMKV.encode(CommonConfig.DESKTOP_APP_KEY, desktop_app);
|
||||
KVStore.encode(CommonConfig.DESKTOP_APP_KEY, desktop_app);
|
||||
JgyUtils.getInstance().setDefaultDesktop(desktop_app);
|
||||
} else {
|
||||
mMMKV.encode(CommonConfig.DESKTOP_APP_KEY, "");
|
||||
KVStore.encode(CommonConfig.DESKTOP_APP_KEY, "");
|
||||
}
|
||||
String browser_app = settings.getBrowser_app();
|
||||
Log.e(TAG, "setDefaultApp: browser_app = " + browser_app);
|
||||
if (!TextUtils.isEmpty(browser_app)) {
|
||||
mMMKV.encode(CommonConfig.BROWSER_APP_KEY, browser_app);
|
||||
KVStore.encode(CommonConfig.BROWSER_APP_KEY, browser_app);
|
||||
JgyUtils.getInstance().setDefaultBrowser(browser_app);
|
||||
} else {
|
||||
mMMKV.encode(CommonConfig.BROWSER_APP_KEY, "");
|
||||
KVStore.encode(CommonConfig.BROWSER_APP_KEY, "");
|
||||
}
|
||||
String typewriting_app = settings.getTypewriting_app();
|
||||
Log.e(TAG, "setDefaultApp: typewriting_app = " + typewriting_app);
|
||||
if (!TextUtils.isEmpty(typewriting_app)) {
|
||||
mMMKV.encode(CommonConfig.TYPEWRITING_APP_KEY, typewriting_app);
|
||||
KVStore.encode(CommonConfig.TYPEWRITING_APP_KEY, typewriting_app);
|
||||
JgyUtils.getInstance().setDefaultInputMethod(typewriting_app);
|
||||
} else {
|
||||
mMMKV.encode(CommonConfig.TYPEWRITING_APP_KEY, "");
|
||||
KVStore.encode(CommonConfig.TYPEWRITING_APP_KEY, "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,17 +693,17 @@ public class ControlManager {
|
||||
* 应用安装之后重新设置
|
||||
*/
|
||||
public void setDefaultApp() {
|
||||
String desktop_app = mMMKV.decodeString(CommonConfig.DESKTOP_APP_KEY, "");
|
||||
String desktop_app = KVStore.decodeString(CommonConfig.DESKTOP_APP_KEY, "");
|
||||
Log.e(TAG, "setDefaultApp: desktop_app = " + desktop_app);
|
||||
if (!TextUtils.isEmpty(desktop_app)) {
|
||||
JgyUtils.getInstance().setDefaultDesktop(desktop_app);
|
||||
}
|
||||
String browser_app = mMMKV.decodeString(CommonConfig.BROWSER_APP_KEY, "");
|
||||
String browser_app = KVStore.decodeString(CommonConfig.BROWSER_APP_KEY, "");
|
||||
Log.e(TAG, "setDefaultApp: browser_app = " + browser_app);
|
||||
if (!TextUtils.isEmpty(browser_app)) {
|
||||
JgyUtils.getInstance().setDefaultBrowser(browser_app);
|
||||
}
|
||||
String typewriting_app = mMMKV.decodeString(CommonConfig.TYPEWRITING_APP_KEY, "");
|
||||
String typewriting_app = KVStore.decodeString(CommonConfig.TYPEWRITING_APP_KEY, "");
|
||||
Log.e(TAG, "setDefaultApp: typewriting_app = " + typewriting_app);
|
||||
if (!TextUtils.isEmpty(typewriting_app)) {
|
||||
JgyUtils.getInstance().setDefaultInputMethod(typewriting_app);
|
||||
|
||||
@@ -7,7 +7,7 @@ import android.hardware.usb.UsbManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
/**
|
||||
* 控制面板管理类
|
||||
@@ -19,7 +19,7 @@ public class ControlPanelManager {
|
||||
private static ControlPanelManager sInstance;
|
||||
private Context mContext;
|
||||
private ContentResolver mResolver;
|
||||
private final MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private UsbManager mUsbManager;
|
||||
|
||||
public static final String KEY_USB_STATUS = "KEY_USB_STATUS";
|
||||
@@ -64,7 +64,7 @@ public class ControlPanelManager {
|
||||
break;
|
||||
default:
|
||||
}
|
||||
mmkv.encode(KEY_USB_STATUS, action);
|
||||
KVStore.encode(KEY_USB_STATUS, action);
|
||||
try {
|
||||
mUsbManager.setCurrentFunction(functions, true);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -16,15 +16,13 @@ import com.fuying.sn.core.common.sync.DeviceSyncGateways;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.jeremyliao.liveeventbus.LiveEventBus;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class AmapManager {
|
||||
private static final String TAG = "AmapManager";
|
||||
|
||||
MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static AmapManager sInstance;
|
||||
private Context mContext;
|
||||
@@ -85,7 +83,7 @@ public class AmapManager {
|
||||
|
||||
startLocation();
|
||||
|
||||
String jsonString = mMMKV.decodeString(CommonConfig.MAP_LOCATION_JSON_KEY, "");
|
||||
String jsonString = KVStore.decodeString(CommonConfig.MAP_LOCATION_JSON_KEY, "");
|
||||
if (!TextUtils.isEmpty(jsonString)) {
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<MapBean>() {
|
||||
@@ -121,12 +119,12 @@ public class AmapManager {
|
||||
|
||||
Log.e(TAG, "onLocationChanged: " + aMapLocation.getAddress());
|
||||
sb.append(aMapLocation.getAddress()).append("\n");
|
||||
mMMKV.encode(CommonConfig.MAP_onLocationChanged_time_KEY, System.currentTimeMillis());
|
||||
KVStore.encode(CommonConfig.MAP_onLocationChanged_time_KEY, System.currentTimeMillis());
|
||||
} else {
|
||||
//定位失败
|
||||
sb.append("定位失败" + "\n");
|
||||
sb.append(aMapLocation.getErrorInfo());
|
||||
mMMKV.encode(CommonConfig.MAP_ERROR_KEY, aMapLocation.getErrorInfo());
|
||||
KVStore.encode(CommonConfig.MAP_ERROR_KEY, aMapLocation.getErrorInfo());
|
||||
Log.e(TAG, "onLocationChanged: " + "定位失败");
|
||||
}
|
||||
Log.e(TAG, "amap: " + sb.toString());
|
||||
@@ -160,15 +158,15 @@ public class AmapManager {
|
||||
|
||||
private void saveMapResult(MapBean mapBean) {
|
||||
Log.e(TAG, "saveMapResult: " + GsonUtils.toJSONString(mapBean));
|
||||
mMMKV.encode(CommonConfig.MAP_LOCATION_JSON_KEY, GsonUtils.toJSONString(mapBean));
|
||||
mMMKV.encode(CommonConfig.MAP_LONGITUDE_KEY, mapBean.getLongitude());
|
||||
mMMKV.encode(CommonConfig.MAP_LATITUDE_KEY, mapBean.getLatitude());
|
||||
mMMKV.encode(CommonConfig.MAP_ADDRESS_KEY, mapBean.getAddress());
|
||||
mMMKV.encode(CommonConfig.MAP_PROVINCE_KEY, mapBean.getProvince());
|
||||
mMMKV.encode(CommonConfig.MAP_CITY_KEY, mapBean.getCity());
|
||||
mMMKV.encode(CommonConfig.MAP_DISTRICT_KEY, mapBean.getDistrict());
|
||||
mMMKV.encode(CommonConfig.MAP_STREET_KEY, mapBean.getStreet());
|
||||
mMMKV.encode(CommonConfig.MAP_LOCATION_DESCRIBE_KEY, mapBean.getLocationDescribe());
|
||||
KVStore.encode(CommonConfig.MAP_LOCATION_JSON_KEY, GsonUtils.toJSONString(mapBean));
|
||||
KVStore.encode(CommonConfig.MAP_LONGITUDE_KEY, mapBean.getLongitude());
|
||||
KVStore.encode(CommonConfig.MAP_LATITUDE_KEY, mapBean.getLatitude());
|
||||
KVStore.encode(CommonConfig.MAP_ADDRESS_KEY, mapBean.getAddress());
|
||||
KVStore.encode(CommonConfig.MAP_PROVINCE_KEY, mapBean.getProvince());
|
||||
KVStore.encode(CommonConfig.MAP_CITY_KEY, mapBean.getCity());
|
||||
KVStore.encode(CommonConfig.MAP_DISTRICT_KEY, mapBean.getDistrict());
|
||||
KVStore.encode(CommonConfig.MAP_STREET_KEY, mapBean.getStreet());
|
||||
KVStore.encode(CommonConfig.MAP_LOCATION_DESCRIBE_KEY, mapBean.getLocationDescribe());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ import com.fuying.sn.core.common.gson.GsonUtils;
|
||||
import com.fuying.sn.core.common.sync.DeviceSyncGateways;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -73,7 +73,7 @@ public class JgyUtils {
|
||||
private static JgyUtils sInstance;
|
||||
private Context mContext;
|
||||
private ContentResolver resolver;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
// 平台编号已迁到 core 层,这里保留同名常量做别名,避免全仓调用点改动。
|
||||
public static final int UnknowPlatform = PlatformUtils.UNKNOWN_PLATFORM;
|
||||
@@ -195,7 +195,7 @@ public class JgyUtils {
|
||||
}
|
||||
|
||||
public HashSet<String> getAppAndWhite() {
|
||||
String pkgString = mMMKV.decodeString(CommonConfig.BUILT_IN_APPS, "");
|
||||
String pkgString = KVStore.decodeString(CommonConfig.BUILT_IN_APPS, "");
|
||||
if (TextUtils.isEmpty(pkgString)) {
|
||||
return new HashSet<>();
|
||||
} else {
|
||||
@@ -204,7 +204,7 @@ public class JgyUtils {
|
||||
}
|
||||
|
||||
public void putBuiltInApps() {
|
||||
String pkgString = mMMKV.decodeString(CommonConfig.BUILT_IN_APPS, "");
|
||||
String pkgString = KVStore.decodeString(CommonConfig.BUILT_IN_APPS, "");
|
||||
Set<String> stringSet = new HashSet<>(Arrays.asList(pkgString.split(",")));
|
||||
Set<String> filter = stringSet.stream().filter(new Predicate<String>() {
|
||||
@Override
|
||||
|
||||
@@ -5,11 +5,11 @@ import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.fuying.sn.core.common.config.CommonConfig;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
public class FuyingActivityController extends IActivityController.Stub {
|
||||
private static final String TAG = "AoleyunActivityController";
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
@Override
|
||||
public boolean activityStarting(Intent intent, String pkg) {
|
||||
|
||||
@@ -55,7 +55,7 @@ import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.fuying.sn.platform.app.AppProcessUtils;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -83,7 +83,7 @@ import okhttp3.RequestBody;
|
||||
public class PushManager {
|
||||
private static final String TAG = "PushManager";
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static volatile PushManager sInstance;
|
||||
@@ -1395,7 +1395,7 @@ public class PushManager {
|
||||
return;
|
||||
}
|
||||
mUpgradeHandler.post(() -> {
|
||||
mMMKV.encode(KEY_PENDING_UPGRADE, jsonString);
|
||||
KVStore.encode(KEY_PENDING_UPGRADE, jsonString);
|
||||
runPendingUpgrade();
|
||||
});
|
||||
}
|
||||
@@ -1417,7 +1417,7 @@ public class PushManager {
|
||||
Log.e(TAG, "runPendingUpgrade: 已有升级任务等待执行,忽略本次");
|
||||
return;
|
||||
}
|
||||
String jsonString = mMMKV.decodeString(KEY_PENDING_UPGRADE, "");
|
||||
String jsonString = KVStore.decodeString(KEY_PENDING_UPGRADE, "");
|
||||
if (TextUtils.isEmpty(jsonString)) {
|
||||
return;
|
||||
}
|
||||
@@ -1426,7 +1426,7 @@ public class PushManager {
|
||||
// 否则窗口一到还会把旧包重新下载、重新静默安装一次。
|
||||
if (!isPendingUpgradeStillNeeded(jsonString)) {
|
||||
Log.e(TAG, "runPendingUpgrade: 本地版本已不低于目标版本(可能已手动升级),丢弃遗留任务");
|
||||
mMMKV.remove(KEY_PENDING_UPGRADE);
|
||||
KVStore.remove(KEY_PENDING_UPGRADE);
|
||||
return;
|
||||
}
|
||||
if (!TimeUtils.isInNightWindow()) {
|
||||
@@ -1452,8 +1452,8 @@ public class PushManager {
|
||||
}
|
||||
|
||||
// 下载前读取最新的待办。错峰等待期间收到的推送或进程重启都不会丢掉待办。
|
||||
String pendingUpgrade = mMMKV.decodeString(KEY_PENDING_UPGRADE, "");
|
||||
mMMKV.remove(KEY_PENDING_UPGRADE);
|
||||
String pendingUpgrade = KVStore.decodeString(KEY_PENDING_UPGRADE, "");
|
||||
KVStore.remove(KEY_PENDING_UPGRADE);
|
||||
if (TextUtils.isEmpty(pendingUpgrade) || !isPendingUpgradeStillNeeded(pendingUpgrade)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import com.fuying.sn.runtime.service.DownloadService;
|
||||
import com.fuying.sn.runtime.service.ManagerService;
|
||||
import com.fuying.sn.runtime.service.SocketService;
|
||||
import com.fuying.sn.runtime.service.main.MainService;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
public class
|
||||
BootReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "BootReceiver";
|
||||
public static final String BOOT_COMPLETED = CommonConfig.ACTION_ZUOYEOS_BOOT_COMPLETED;
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -24,7 +24,7 @@ BootReceiver extends BroadcastReceiver {
|
||||
Log.e("SNBootReceiver", action);
|
||||
switch (action) {
|
||||
case Intent.ACTION_BOOT_COMPLETED:
|
||||
mMMKV.encode(CommonConfig.DEVICES_REBOOT, true);
|
||||
KVStore.encode(CommonConfig.DEVICES_REBOOT, true);
|
||||
case BOOT_COMPLETED:
|
||||
case "android.intent.action.BATTERY_LEVEL_CHANGED":
|
||||
context.startService(new Intent(context, MainService.class));
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.fuying.sn.runtime.receiver.BootReceiver;
|
||||
import com.fuying.sn.core.common.system.ReceiverCompat;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import com.tuo.customview.VerificationCodeView;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -49,7 +49,7 @@ public class ManagerService extends BaseService implements NetworkUtils.OnNetwor
|
||||
private final DeviceRepository mRepository = DeviceRepository.getInstance();
|
||||
private static final String TAG = "ManagerService";
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
public static final String ACTION_LOCK = "LockScreenReceiver_lockscreen";
|
||||
public static final String ACTION_UNLOCK = "LockScreenReceiver_unlockscreen";
|
||||
@@ -336,7 +336,7 @@ public class ManagerService extends BaseService implements NetworkUtils.OnNetwor
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "inputComplete: " + content);
|
||||
String password = mMMKV.decodeString(UrlAddress.LOCK_SCREEN_PWD, DEFAULT_PASSWORD);
|
||||
String password = KVStore.decodeString(UrlAddress.LOCK_SCREEN_PWD, DEFAULT_PASSWORD);
|
||||
if (content.equals(password)) {
|
||||
hide();
|
||||
} else {
|
||||
|
||||
@@ -54,7 +54,7 @@ import com.fuying.sn.platform.time.TimeUtils;
|
||||
import com.fuying.sn.core.common.ui.ToastUtil;
|
||||
import com.fuying.sn.core.common.device.DeviceIdUtils;
|
||||
import com.fuying.sn.core.common.device.HardwareInfoUtils;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -93,7 +93,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
return TimeUtils.randomDelay(baseDelay, baseDelay + STARTUP_DELAY_SPREAD);
|
||||
}
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
private MainServiceModel mViewModel;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
AliyunPushManager.getInstance().checkChannelStatus();
|
||||
|
||||
scheduleDeviceSync(false);
|
||||
mMMKV.encode(CommonConfig.DEVICES_REBOOT, false);
|
||||
KVStore.encode(CommonConfig.DEVICES_REBOOT, false);
|
||||
}
|
||||
|
||||
private final Handler mDeviceSyncHandler = new Handler(Looper.getMainLooper());
|
||||
@@ -221,7 +221,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
AndroidSettingsWriter.putString(this, AndroidSettingsWriter.NAMESPACE_SYSTEM, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, "");
|
||||
|
||||
scheduleDeviceSync(true);
|
||||
mMMKV.encode(CommonConfig.DEVICES_REBOOT, false);
|
||||
KVStore.encode(CommonConfig.DEVICES_REBOOT, false);
|
||||
|
||||
Log.e(TAG, "onCreate: IMEI = " + DeviceIdUtils.getIMEI(MainService.this));
|
||||
String aole_app_forbid = Settings.System.getString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
|
||||
@@ -441,7 +441,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
|
||||
//获取当前wifi名称
|
||||
String oldSSID = mMMKV.decodeString("WiFiSSID", "");
|
||||
String oldSSID = KVStore.decodeString("WiFiSSID", "");
|
||||
Log.e(TAG, "oldSSID " + oldSSID);
|
||||
String newSSID = wifiInfo.getSSID();
|
||||
Log.e(TAG, "连接到网络 " + newSSID);
|
||||
@@ -453,7 +453,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
"connect to: " + newSSID + " time: "
|
||||
+ TimeUtils.transferLongToDate(System.currentTimeMillis()));
|
||||
}
|
||||
mMMKV.encode("WiFiSSID", HardwareInfoUtils.getWifiAlias(context));
|
||||
KVStore.encode("WiFiSSID", HardwareInfoUtils.getWifiAlias(context));
|
||||
}
|
||||
break;
|
||||
//wifi打开与否
|
||||
@@ -516,7 +516,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
|
||||
private void getAppControl() {
|
||||
Log.e(TAG, "getAppControl: ");
|
||||
long lastTime = mMMKV.decodeLong(UrlAddress.GET_APP_TIME_CONTROL + "_time", System.currentTimeMillis());
|
||||
long lastTime = KVStore.decodeLong(UrlAddress.GET_APP_TIME_CONTROL + "_time", System.currentTimeMillis());
|
||||
Log.e(TAG, "getAppControl: lastTime = " + lastTime);
|
||||
Log.e(TAG, "getAppControl: lastTime = " + TimeUtils.getDate(lastTime));
|
||||
if (TimeUtils.isTodayWithJavaTime(lastTime)) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.fuying.sn.runtime.sync.TimePolicySync;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
import com.fuying.sn.platform.system.SystemUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,7 +39,7 @@ import io.reactivex.rxjava3.observers.DisposableObserver;
|
||||
|
||||
public class MainServiceModel extends BaseAndroidViewModel {
|
||||
private final DeviceRepository mRepository = DeviceRepository.getInstance();
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
public MainServiceModel(@androidx.annotation.NonNull Application application) {
|
||||
super(application);
|
||||
@@ -144,9 +144,9 @@ public class MainServiceModel extends BaseAndroidViewModel {
|
||||
if (snBindStateBaseResponse.code == 200) {
|
||||
SnBindState snBindState = snBindStateBaseResponse.data;
|
||||
int is_bind = snBindState.getIs_bind();
|
||||
mMMKV.encode(CommonConfig.DEVICES_IS_BIND_KEY, is_bind);
|
||||
KVStore.encode(CommonConfig.DEVICES_IS_BIND_KEY, is_bind);
|
||||
} else {
|
||||
mMMKV.encode(CommonConfig.DEVICES_IS_BIND_KEY, 0);
|
||||
KVStore.encode(CommonConfig.DEVICES_IS_BIND_KEY, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.fuying.sn.core.data.remote.UrlAddress;
|
||||
import com.fuying.sn.platform.app.ApkUtils;
|
||||
import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -57,7 +57,7 @@ public final class AppInventorySync {
|
||||
private final Context mContext;
|
||||
private final ContentResolver crv;
|
||||
private final DeviceRepository repository;
|
||||
private final MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
private AppInventorySync(Context context) {
|
||||
mContext = context;
|
||||
@@ -309,12 +309,12 @@ public final class AppInventorySync {
|
||||
public void onNext(@NonNull HashSet<AppInfo> appInfos) {
|
||||
Log.e("getAppWhiteList", "onNext: " + appInfos);
|
||||
if (appInfos.size() == 0) {
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
KVStore.encode(UrlAddress.GET_ALL_PACKAGE, "");
|
||||
ApkUtils.writeAppPackageList(mContext, "");
|
||||
} else {
|
||||
HashSet<String> pkgList = new HashSet<>(appInfos.stream().map(AppInfo::getApp_package).collect(Collectors.toSet()));
|
||||
String pkgListString = String.join(",", pkgList);
|
||||
mMMKV.encode(UrlAddress.GET_ALL_PACKAGE, GsonUtils.toJSONString(appInfos));
|
||||
KVStore.encode(UrlAddress.GET_ALL_PACKAGE, GsonUtils.toJSONString(appInfos));
|
||||
ApkUtils.writeAppPackageList(mContext, pkgListString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
import com.fuying.sn.platform.control.AppWhitelistUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -61,7 +61,7 @@ public final class AppPolicySync {
|
||||
private final ContentResolver crv;
|
||||
private final CacheHelper mCacheHelper;
|
||||
private final DeviceRepository repository;
|
||||
private final MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
private AppPolicySync(Context context, CacheHelper cacheHelper) {
|
||||
mContext = context;
|
||||
@@ -580,11 +580,11 @@ public final class AppPolicySync {
|
||||
if (appAndWhiteList != null) {
|
||||
List<String> pkgList = appAndWhiteList.stream().map(AppAndWhiteBean::getApp_package).collect(Collectors.toList());
|
||||
String pkgString = String.join(",", pkgList);
|
||||
mMMKV.encode(CommonConfig.BUILT_IN_APPS, pkgString);
|
||||
KVStore.encode(CommonConfig.BUILT_IN_APPS, pkgString);
|
||||
Log.e("getAppAndWhite", "onNext: " + pkgString);
|
||||
}
|
||||
} else {
|
||||
mMMKV.remove(CommonConfig.BUILT_IN_APPS);
|
||||
KVStore.remove(CommonConfig.BUILT_IN_APPS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.fuying.sn.platform.control.AppWhitelistUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
@@ -52,7 +52,7 @@ public final class AppUpdateCoordinator {
|
||||
private final Context mContext;
|
||||
private final CacheHelper mCacheHelper;
|
||||
private final DeviceRepository repository;
|
||||
private final MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
private AppUpdateCoordinator(Context context, CacheHelper cacheHelper) {
|
||||
mContext = context;
|
||||
@@ -391,7 +391,7 @@ public final class AppUpdateCoordinator {
|
||||
}
|
||||
String packageList = overallAppBeanList.stream().map(OverallAppBean::getApp_package).collect(Collectors.joining(","));
|
||||
Log.e(TAG, "installOverallApp: " + packageList);
|
||||
mMMKV.encode(CommonConfig.AOLE_ACTION_OVERALL_APP, packageList);
|
||||
KVStore.encode(CommonConfig.AOLE_ACTION_OVERALL_APP, packageList);
|
||||
AppWhitelistUtils.writeDisableUpdateList(mContext);
|
||||
Log.e(TAG, "installOverallApp: " + packageList);
|
||||
for (OverallAppBean overallAppBean : overallAppBeanList) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.fuying.sn.platform.system.JgyUtils;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
import com.fuying.sn.core.common.device.HardwareInfoUtils;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
@@ -40,7 +40,7 @@ public final class DeviceProfileSync {
|
||||
private final Context mContext;
|
||||
private final ContentResolver crv;
|
||||
private final DeviceRepository repository;
|
||||
private final MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
private DeviceProfileSync(Context context) {
|
||||
mContext = context;
|
||||
@@ -141,9 +141,9 @@ public final class DeviceProfileSync {
|
||||
|
||||
|
||||
public void updateAdminInfo() {
|
||||
String address = String.valueOf(mMMKV.decodeString(CommonConfig.MAP_ADDRESS_KEY, "-"));
|
||||
String longitude = String.valueOf(mMMKV.decodeDouble(CommonConfig.MAP_LONGITUDE_KEY, 0L));
|
||||
String latitude = String.valueOf(mMMKV.decodeDouble(CommonConfig.MAP_LATITUDE_KEY, 0L));
|
||||
String address = String.valueOf(KVStore.decodeString(CommonConfig.MAP_ADDRESS_KEY, "-"));
|
||||
String longitude = String.valueOf(KVStore.decodeDouble(CommonConfig.MAP_LONGITUDE_KEY, 0L));
|
||||
String latitude = String.valueOf(KVStore.decodeDouble(CommonConfig.MAP_LATITUDE_KEY, 0L));
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("address", address);
|
||||
jsonObject.addProperty("longitude", longitude);
|
||||
@@ -173,7 +173,7 @@ public final class DeviceProfileSync {
|
||||
nowJson.addProperty("hardware", hardware);
|
||||
nowJson.addProperty("software", software);
|
||||
String string = GsonUtils.toJSONString(nowJson);
|
||||
String oldString = mMMKV.decodeString(UrlAddress.UPDATE_SN_INFO, "");
|
||||
String oldString = KVStore.decodeString(UrlAddress.UPDATE_SN_INFO, "");
|
||||
Log.e(TAG, "updateAdminInfo: oldString = " + oldString);
|
||||
Log.e(TAG, "updateAdminInfo: string = " + string);
|
||||
if (oldString.equals(string)) {
|
||||
@@ -190,7 +190,7 @@ public final class DeviceProfileSync {
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
if (baseResponse.code == 200) {
|
||||
mMMKV.encode(UrlAddress.UPDATE_SN_INFO, string);
|
||||
KVStore.encode(UrlAddress.UPDATE_SN_INFO, string);
|
||||
}
|
||||
Log.e("updateAdminInfo", "onNext: " + baseResponse);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.fuying.sn.core.data.remote.UrlAddress;
|
||||
import com.fuying.sn.runtime.sync.RequestCallbacks.CompleteCallback;
|
||||
import com.fuying.sn.core.data.local.prefs.KVStore;
|
||||
import com.google.gson.Gson;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
|
||||
import io.reactivex.rxjava3.annotations.NonNull;
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
@@ -39,7 +39,7 @@ public final class DeviceSettingsSync {
|
||||
private final Context mContext;
|
||||
private final CacheHelper mCacheHelper;
|
||||
private final DeviceRepository repository;
|
||||
private final MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
|
||||
private DeviceSettingsSync(Context context, CacheHelper cacheHelper) {
|
||||
mContext = context;
|
||||
@@ -167,7 +167,7 @@ public final class DeviceSettingsSync {
|
||||
}
|
||||
|
||||
//imei是否绑定
|
||||
// int is_bind = mMMKV.decodeInt(CommonConfig.DEVICES_IS_BIND_KEY, 0);
|
||||
// int is_bind = KVStore.decodeInt(CommonConfig.DEVICES_IS_BIND_KEY, 0);
|
||||
// if (is_bind == 1) {
|
||||
//
|
||||
// } else {
|
||||
@@ -223,11 +223,11 @@ public final class DeviceSettingsSync {
|
||||
mCacheHelper.put(UrlAddress.LOCK_SCREEN_PWD, "");
|
||||
} else {
|
||||
mCacheHelper.put(UrlAddress.LOCK_SCREEN_PWD, GsonUtils.toJSONString(screenPassword));
|
||||
mMMKV.encode(UrlAddress.LOCK_SCREEN_PWD, screenPassword.getPwd());
|
||||
KVStore.encode(UrlAddress.LOCK_SCREEN_PWD, screenPassword.getPwd());
|
||||
}
|
||||
} else {
|
||||
mCacheHelper.put(UrlAddress.LOCK_SCREEN_PWD, "");
|
||||
mMMKV.remove(UrlAddress.LOCK_SCREEN_PWD);
|
||||
KVStore.remove(UrlAddress.LOCK_SCREEN_PWD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user