feat: 修复壁纸,应用锁密码,浏览器书签失效,增加护眼入口管控,对接专注模式开关
This commit is contained in:
@@ -3,13 +3,16 @@ package com.aoleyun.sn.utils;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.StatusBarManager;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.activity.EyeProtectionActivity;
|
||||
import com.aoleyun.sn.activity.main.MainActivity;
|
||||
import com.aoleyun.sn.bean.BluetoothType;
|
||||
import com.aoleyun.sn.bean.SnSetting;
|
||||
@@ -73,7 +76,7 @@ public class SysSettingUtils {
|
||||
setPanelShow(context, jsonObject);
|
||||
setDisAllowCamera(context, jsonObject);
|
||||
setSettingsMenuShow(context, jsonObject);
|
||||
|
||||
setEyeProtectionModeEntrance(context, jsonObject);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,7 +112,7 @@ public class SysSettingUtils {
|
||||
setSystemAppDisable(context, 0);
|
||||
setNotification(context, 0);
|
||||
setSettingsMenuShow(context);
|
||||
|
||||
setEyeProtectionModeEntrance(context, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,6 +141,7 @@ public class SysSettingUtils {
|
||||
setAdminApp(context, 0);
|
||||
setSystemAppDisable(context, 0);
|
||||
setNotification(context, 1);
|
||||
setEyeProtectionModeEntrance(context, 1);
|
||||
}
|
||||
|
||||
public static void openMtp(Context context) {
|
||||
@@ -1365,4 +1369,43 @@ public class SysSettingUtils {
|
||||
private static void setSettingsMenuShow(Context context) {
|
||||
Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_SETTINGS_DISALLOW, "");
|
||||
}
|
||||
|
||||
private static void setEyeProtectionModeEntrance(Context context, JsonObject jsonObject) {
|
||||
Log.e(TAG, "setEyeProtectionModeEntrance: " + jsonObject);
|
||||
if (jsonObject.has("eye_protection_mode_entrance")) {
|
||||
int app_management_general = jsonObject.get("eye_protection_mode_entrance").getAsInt();
|
||||
if (app_management_general == 0) {
|
||||
// 禁用 Launcher 入口
|
||||
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
|
||||
} else {
|
||||
// 启用 Launcher 入口
|
||||
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
|
||||
}
|
||||
} else {
|
||||
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setEyeProtectionModeEntrance(Context context, int status) {
|
||||
Log.e(TAG, "setEyeProtectionModeEntrance: status = " + status);
|
||||
if (status == 0) {
|
||||
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
|
||||
} else {
|
||||
setComponentEnabledSetting(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean setComponentEnabledSetting(Context context, int componentState) {
|
||||
Log.e(TAG, "setComponentEnabledSetting: componentState = " + componentState);
|
||||
|
||||
PackageManager pm = context.getPackageManager();
|
||||
ComponentName componentName = new ComponentName(context, EyeProtectionActivity.class);
|
||||
try {
|
||||
pm.setComponentEnabledSetting(componentName, componentState, PackageManager.DONT_KILL_APP);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setComponentEnabledSetting: " + e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user