package com.aoleyun.sn.utils; import android.annotation.SuppressLint; import android.app.StatusBarManager; import android.bluetooth.BluetoothAdapter; import android.content.Context; import android.content.Intent; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.activity.main.MainActivity; import com.aoleyun.sn.bean.BluetoothType; import com.aoleyun.sn.bean.SnSetting; import com.aoleyun.sn.comm.CommonConfig; import com.aoleyun.sn.comm.JGYActions; import com.aoleyun.sn.gson.GsonUtils; import com.aoleyun.sn.manager.AllwinnerCubeMdmManager; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; import com.hjq.toast.Toaster; import com.tencent.mmkv.MMKV; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; public class SysSettingUtils { private static final String TAG = "SysSettingUtils"; public SysSettingUtils() { } public SysSettingUtils(Context context) { } private static int changeNum(int status) { return status == 0 ? 1 : 0; } public static void setSystemSetting(Context context, String jsonObj) { if (null == context) { throw new RuntimeException("Context it's null"); } JsonObject jsonObject = GsonUtils.getJsonObject(jsonObj); setPhoneList(context, jsonObject); setBluetooth(context, jsonObject); setHotspot(context, jsonObject); setBar(context, jsonObject); setCamera(context, jsonObject); setTF(context, jsonObject); setIcon(context, jsonObject); setCanReset(context, jsonObject); setAutoTime(context, jsonObject); String navJsonString = jsonObject.get("setting_nav").getAsString(); JsonObject navJson = JsonParser.parseString(navJsonString).getAsJsonObject(); SPUtils.put(context, JGYActions.ACTION_STATUSBAR_STATUS, navJsonString); setStatusBar(context, navJson); setBrowserInput(context, jsonObject); // TODO: 2022/4/11 不是酷比定制的会报错,无法抛出异常 setUsbStatus(context, jsonObject); setAdminApp(context, jsonObject); setSystemAppDisable(context, jsonObject); setNotification(context, jsonObject); setPanelShow(context, jsonObject); setDisAllowCamera(context, jsonObject); setSettingsMenuShow(context, jsonObject); } /** * @param context 关闭所有功能 */ public static void setDisableSetting(Context context) { Toaster.debugShow("关闭所有功能"); Log.e("setDisableSetting", "Close all settings: "); setPhoneList(context, 1); setUsbStatus(context, 0); if (JgyUtils.getInstance().getAppPlatform().equals(JgyUtils.YXPD1TAG) || JgyUtils.getInstance().getAppPlatform().equals(JgyUtils.C2Tag) || JgyUtils.getInstance().getAppPlatform().equals(JgyUtils.ZR6016Tag) ) { setBluetooth(context, 0); } else { setBluetooth(context, 1); } setHotspot(context, 1); setBar(context, 1); setCamera(context, 1); setTF(context, 0); setIcon(context, 0); setWallpaper(context, 0); setCanReset(context, 0); setAutoTime(context, 1); setBrowserInput(context, 0); if (!BuildConfig.DEBUG) { // JgyUtils.getInstance().setDeveloperOptions(0); } setStatusBar(context, 1); setAdminApp(context, 1); setSystemAppDisable(context, 0); setNotification(context, 0); setSettingsMenuShow(context); } /** * @param context 开启所有功能 */ public static void setEnableSetting(Context context) { Toaster.debugShow("打开所有功能"); Log.e(TAG, "setEnableSetting: "); setPhoneList(context, 0); if (JgyUtils.C2Tag.equalsIgnoreCase(JgyUtils.getInstance().getAppPlatform())) { openMtp(context); } setUsbStatus(context, 0); setBluetooth(context, 0); setHotspot(context, 0); setBar(context, 0); setCamera(context, 0); setTF(context, 0); setIcon(context, 0); setWallpaper(context, 0); setCanReset(context, 0); setAutoTime(context, 0); setBrowserInput(context, 1); // JgyUtils.getInstance().setDeveloperOptions(1); setStatusBar(context, 0); setAdminApp(context, 0); setSystemAppDisable(context, 0); setNotification(context, 1); } public static void openMtp(Context context) { String usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP; Intent usbIntent = new Intent(usbStatus); context.sendBroadcast(usbIntent); } private static void setPhoneList(Context context, int state) { try { //设置电话功能,电话白名单 boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", state); Log.e(TAG, "qch_call_forbid:" + qch_call_forbid); boolean aole_white_list_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ON, state); Log.e(TAG, "aole_white_list_on:" + aole_white_list_on); boolean aole_white_list_Array = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ARRAY, ""); // ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+aole_white_list_Array+"---"+qch_call_forbid); Log.e(TAG, "aole_white_list_Array:" + aole_white_list_Array); boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, state); Log.e(TAG, "aole_sdcard_forbid_on:" + aole_sdcard_forbid_on); } catch (Exception e) { Log.e(TAG, "setPhoneList: " + e.getMessage()); } } private static void setPhoneList(Context context, JsonObject jsonObject) { try { //设置电话功能,电话白名单 //电话通话开关 int setting_call = changeNum(jsonObject.get("setting_call").getAsInt()); boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", setting_call); Log.e(TAG, "qch_call_forbid:" + qch_call_forbid); //电话白名单开关 int setting_phone = changeNum(jsonObject.get("setting_phone").getAsInt()); boolean aole_white_list_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ON, setting_phone); Log.e(TAG, "aole_white_list_on:" + aole_white_list_on); //白名单列表 if (setting_phone == 1) { boolean aole_white_list_Array = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ARRAY, "empty"); // ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+aole_white_list_Array+"---"+qch_call_forbid); Log.e(TAG, "aole_white_list_Array:" + aole_white_list_Array); } else { String setting_phones = jsonObject.get("setting_phones").getAsString(); boolean aole_white_list_Array = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ARRAY, setting_phones); // ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+aole_white_list_Array+"---"+qch_call_forbid); Log.e(TAG, "aole_white_list_Array:" + aole_white_list_Array + "---" + setting_phones); } } catch (Exception e) { Log.e(TAG, "setPhoneList: " + e.getMessage()); } } private static void setUsbStatus(Context context, int state) { Log.e(TAG, "setUsbStatus: " + state); //USB数据功能管控 //仅充电:usb_charge //MTP模式:usb_mtp //Midi模式:usb_midi // if (!BuildConfig.DEBUG) { if (JgyUtils.isCubeDevice()) { if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setUsbStatus(state); } else { // try { // SuperPower mService = (SuperPower) context.getSystemService("mdm"); // mService.setUsbDataDisabled(true); // } catch (Exception e) { // Log.e(TAG, "setUsbStatus: " + e.getMessage()); // } } } else { if (state == 0) { String oldUsb = Settings.System.getString(context.getContentResolver(), "aole_usb_choose"); if ("usb_charge".equals(oldUsb)) { Log.e(TAG, "setUsbStatus: oldUsb = " + oldUsb + " no changed , skip"); return; } boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", "usb_charge"); Log.e("setUsbStatus", "aole_usb_choose: " + aole_usb_choose); } else { boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", "usb_mtp"); Log.e("setUsbStatus", "aole_usb_choose: " + aole_usb_choose); } String usbStatus; switch (state) { default: case 0: usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; JgyUtils.getInstance().setMtpEnable(false); break; case 1: usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP; JgyUtils.getInstance().setMtpEnable(true); break; } if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform) { usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP; } Intent usbIntent = new Intent(usbStatus); if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform || JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform || JgyUtils.getInstance().checkAppPlatform() == JgyUtils.seewoPlatform ) { usbIntent.setPackage("com.android.settings"); } context.sendBroadcast(usbIntent); } // } } private static void setUsbStatus(Context context, JsonObject jsonObject) { //USB数据功能管控 //仅充电:usb_charge //MTP模式:usb_mtp //Midi模式:usb_midi String setting_usb = jsonObject.get("setting_usb").getAsString(); // if (!BuildConfig.DEBUG) { if (JgyUtils.isCubeDevice()) { // SuperPower mService = (SuperPower) context.getSystemService("mdm"); switch (setting_usb) { case "usb_mtp": // mService.setUsbDataDisabled(false); break; default: case "usb_midi": case "usb_charge": // mService.setUsbDataDisabled(true); break; } } else if (JgyUtils.isAllWinnerDevice()) { switch (setting_usb) { case "usb_charge": AllwinnerCubeMdmManager.getInstance().setUsbStatus(0); break; case "usb_mtp": AllwinnerCubeMdmManager.getInstance().setUsbStatus(1); break; case "usb_midi": AllwinnerCubeMdmManager.getInstance().setUsbStatus(2); break; default: } Log.e(TAG, "setUsbStatus: setting_usb = " + setting_usb); } else { String oldUsb = Settings.System.getString(context.getContentResolver(), "aole_usb_choose"); if (setting_usb.equals(oldUsb)) { Log.e(TAG, "setUsbStatus: oldUsb = " + oldUsb + " no changed , skip"); return; } boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb); Log.e("setUsbStatus", "aole_usb_choose: " + aole_usb_choose); String usbStatus; switch (setting_usb) { default: case "usb_charge": usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; JgyUtils.getInstance().setMtpEnable(false); break; case "usb_mtp": usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP; JgyUtils.getInstance().setMtpEnable(true); break; case "usb_midi": usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MIDI; JgyUtils.getInstance().setMtpEnable(false); break; } Intent usbIntent = new Intent(usbStatus); if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform || JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform ) { usbIntent.setPackage("com.android.settings"); } context.sendBroadcast(usbIntent); } // } } /** * @param context * @param state 1关闭 0打开 */ private static void setBluetoothTransmission(Context context, int state) { Log.e(TAG, "setBluetoothTransmission: setting_bluetooth = " + state); int old_setting_bluetooth = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, 1); if (old_setting_bluetooth != state) { Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, state); } else { Log.e(TAG, "setBluetoothTransmission: setting_bluetooth no changed"); } } /** * @param context * @param state 1关闭 0打开 */ public static void setBluetooth(Context context, int state) { Log.e(TAG, "setBluetooth: state = " + state); MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE); int old_setting_bht = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, 1); int old_setting_bluetooth = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, 1); int old_setting_bhtvideo = mmkv.decodeInt(CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, 1); if (old_setting_bht != state) { if (state == 1) {//总开关关闭 BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); mBluetoothAdapter.disable(); } Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, state); } else { Log.e(TAG, "setBluetooth: setting_bht no changed"); } if (old_setting_bluetooth != state) { Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, state); } else { Log.e(TAG, "setBluetooth: setting_bluetooth no changed"); } if (old_setting_bhtvideo != state) { mmkv.encode(CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, state); if (state == 1) { Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, "Empty"); } } else { Log.e(TAG, "setBluetooth: setting_bhtvideo no changed"); } JgyUtils.getInstance().setBluetoothEnable(state == 0); if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setBluetoothEnable(state == 0); } } /** * @param context * @param jsonObject 1关闭 0打开 */ private static void setBluetooth(Context context, JsonObject jsonObject) { MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE); //需要转换 //总开关 int setting_bht = changeNum(jsonObject.get("setting_bht").getAsInt()); Log.e(TAG, "setBluetooth: setting_bht = " + setting_bht); //蓝牙数据功能管控 int setting_bluetooth = changeNum(jsonObject.get("setting_bluetooth").getAsInt()); Log.e(TAG, "setBluetooth: setting_bluetooth = " + setting_bluetooth); //蓝牙音频功能管控 int setting_bhtvideo = changeNum(jsonObject.get("setting_bhtvideo").getAsInt()); Log.e(TAG, "setBluetooth: setting_bhtvideo = " + setting_bhtvideo); //蓝牙设备连接类型开关 int setting_bluetooth_type = changeNum(jsonObject.get("setting_bluetooth_type").getAsInt()); Log.e(TAG, "setBluetooth: setting_bluetooth_type = " + setting_bluetooth_type); if (setting_bluetooth_type == 1) { Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_DEVICE_TYPE, ""); } else { String bluetooth_type_control = jsonObject.get("bluetooth_type_control").getAsString(); Log.e(TAG, "setBluetooth: bluetooth_type_control = " + bluetooth_type_control); if (TextUtils.isEmpty(bluetooth_type_control)) { Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_DEVICE_TYPE, ""); } else { Gson gson = new Gson(); Type listType = new TypeToken() { }.getType(); BluetoothType bluetoothType = gson.fromJson(bluetooth_type_control, listType); if (bluetoothType == null) { Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_DEVICE_TYPE, ""); } else { List typeList = new ArrayList<>(); if (bluetoothType.getHeadset() == 1) { typeList.add(CommonConfig.AOLE_BT_HEADSET_KEY); } if (bluetoothType.getSound() == 1) { typeList.add(CommonConfig.AOLE_BT_BOX_KEY); } if (bluetoothType.getMobile() == 1) { typeList.add(CommonConfig.AOLE_BT_PHONE_KEY); } if (bluetoothType.getComputer() == 1) { typeList.add(CommonConfig.AOLE_BT_COMPUTER_KEY); } if (bluetoothType.getKeyboard() == 1) { typeList.add(CommonConfig.AOLE_BT_KEYBOARD_KEY); } Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_DEVICE_TYPE, String.join(",", typeList)); } } } int old_setting_bht = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, 1); Log.e(TAG, "setBluetooth: old_setting_bht = " + old_setting_bht); int old_setting_bluetooth = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, 1); Log.e(TAG, "setBluetooth: old_setting_bluetooth = " + old_setting_bluetooth); int old_setting_bhtvideo = mmkv.decodeInt(CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, 1); Log.e(TAG, "setBluetooth: old_setting_bhtvideo = " + old_setting_bhtvideo); if (old_setting_bht != setting_bht) { if (setting_bht == 1) {//总开关关闭 BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); mBluetoothAdapter.disable(); } Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, setting_bht); } else { Log.e(TAG, "setBluetooth: setting_bht no changed"); } if (old_setting_bluetooth != setting_bluetooth) { Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, setting_bluetooth); } else { Log.e(TAG, "setBluetooth: setting_bluetooth no changed"); } if (old_setting_bhtvideo != setting_bhtvideo) { mmkv.encode(CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, setting_bhtvideo); if (setting_bhtvideo == 0) { if (jsonObject.get("setting_context").isJsonNull()) { String setting_context = jsonObject.get("setting_context").getAsString(); if (null != setting_context && !"".equals(setting_context) && !" ".equals(setting_context) && !"null".equals(setting_context)) { Log.e(TAG, "setting_context:" + setting_context); Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, setting_context); } else { Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, "Empty"); } } } else if (setting_bhtvideo == 1) { Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, "Empty"); } } else { Log.e(TAG, "setBluetooth: setting_bhtvideo no changed"); } JgyUtils.getInstance().setBluetoothEnable(setting_bht == 0); if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setBluetoothEnable(setting_bht == 0); } } private static void setHotspot(Context context, int state) { try { Intent intent = new Intent(); intent.setAction("qch_hotspot_close"); intent.setPackage("com.android.settings"); context.sendStickyBroadcast(intent); boolean aole_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HOTSPOT_FORBID_ON, state); Log.e(TAG, "aole_hotspot_forbid_on:" + aole_hotspot_forbid_on); if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setWifiHotSpotStatus(state); } } catch (Exception e) { Log.e(TAG, "setHotspot: " + e.getMessage()); } } private static void setHotspot(Context context, JsonObject jsonObject) { try { int setting_hotspot = changeNum(jsonObject.get("setting_hotspot").getAsInt());//热点 if (setting_hotspot == 1) { Intent intent = new Intent(); intent.setAction("qch_hotspot_close"); intent.setPackage("com.android.settings"); context.sendStickyBroadcast(intent); } boolean aole_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HOTSPOT_FORBID_ON, setting_hotspot); Log.e(TAG, "aole_hotspot_forbid_on---------" + setting_hotspot); Log.e(TAG, "aole_hotspot_forbid_on---------" + aole_hotspot_forbid_on); if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setWifiHotSpotStatus(setting_hotspot); } } catch (Exception e) { Log.e(TAG, "setHotspot: " + e.getMessage()); } } private static void setBar(Context context, int state) { //系统导航条显示开关 int setting_navigation = 0; //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 boolean aole_hide_NavigationBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR, setting_navigation); Log.e(TAG, "aole_hide_NavigationBar---------" + aole_hide_NavigationBar); String navigationStatus = ""; switch (setting_navigation) { case 0: navigationStatus = CommonConfig.AOLE_ACTION_SHOW_NAVIGATION_BAR; break; case 1: navigationStatus = CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR; break; default: } Intent navIntent = new Intent(navigationStatus); // Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui"); context.sendBroadcast(navIntent); //状态栏显示开关 int setting_statusbar = 0; int oldNum = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0); if (oldNum != setting_statusbar) { //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 boolean aole_hide_statusBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, setting_statusbar); Log.e(TAG, "aole_hide_statusBar: " + aole_hide_statusBar); String statusbarStatus = ""; switch (setting_statusbar) { case 0: statusbarStatus = CommonConfig.AOLE_ACTION_SHOW_STATUS_BAR; break; case 1: statusbarStatus = CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR; break; default: } Intent statusIntent = new Intent(statusbarStatus); // Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); context.sendBroadcast(statusIntent); } } private static void setBar(Context context, JsonObject jsonObject) { //系统导航条显示开关 int setting_navigation = changeNum(jsonObject.get("setting_navigation").getAsInt()); Log.e(TAG, "setBar: setting_navigation = " + setting_navigation); //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 boolean aole_hide_NavigationBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR, setting_navigation); Log.e(TAG, "aole_hide_NavigationBar---------" + aole_hide_NavigationBar); String navigationStatus = ""; switch (setting_navigation) { case 0: navigationStatus = CommonConfig.AOLE_ACTION_SHOW_NAVIGATION_BAR; break; case 1: navigationStatus = CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR; break; default: } // Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui"); Intent navIntent = new Intent(navigationStatus); context.sendBroadcast(navIntent); if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setNavigationStatus(setting_navigation == 0); } //状态栏显示开关 int setting_statusbar = changeNum(jsonObject.get("setting_statusbar").getAsInt()); Log.e(TAG, "setting_statusbar: " + setting_statusbar); // int oldNum = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0); // if (oldNum != setting_statusbar) { //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 boolean aole_hide_statusBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, setting_statusbar); Log.e(TAG, "aole_hide_statusBar: " + aole_hide_statusBar); String statusbarStatus = ""; switch (setting_statusbar) { case 0: statusbarStatus = CommonConfig.AOLE_ACTION_SHOW_STATUS_BAR; break; case 1: statusbarStatus = CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR; break; default: } Intent statusIntent = new Intent(statusbarStatus); // Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); context.sendBroadcast(statusIntent); // } if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setStatusBarEnable(setting_statusbar == 0); } } private static void setCamera(Context context, int state) { try { //摄像头开关 boolean qch_app_camera = Settings.System.putInt(context.getContentResolver(), "qch_app_camera", 0); Log.e(TAG, "qch_app_camera1:" + state); // ApkUtils.hideSystemSettingAPP(context, "com.mediatek.camera"); Log.e(TAG, "setting_camera---------" + qch_app_camera); String cameraStatus = "qch_camera_forbid"; switch (state) { case 0: cameraStatus = "qch_camera_open"; break; case 1: cameraStatus = "qch_camera_forbid"; break; } Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings"); context.sendBroadcast(cameraIntent); } catch (Exception e) { Log.e(TAG, "setCamera: " + e.getMessage()); } } private static void setCamera(Context context, JsonObject jsonObject) { try { //摄像头开关 int setting_camera = changeNum(jsonObject.get("setting_camera").getAsInt()); Settings.System.putInt(context.getContentResolver(), "qch_app_camera", setting_camera); Log.e(TAG, "qch_app_camera2:" + setting_camera); // ApkUtils.hideSystemSettingAPP(context, "com.mediatek.camera"); Log.e(TAG, "setting_camera---------" + setting_camera); String cameraStatus = ""; switch (setting_camera) { case 0: cameraStatus = "qch_camera_open"; break; case 1: cameraStatus = "qch_camera_forbid"; break; } Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings"); context.sendBroadcast(cameraIntent); JgyUtils.getInstance().setCameraEnable(setting_camera == 1); } catch (Exception e) { Log.e(TAG, "setCamera: " + e.getMessage()); } } private static void setTF(Context context, int state) { //存储卡 if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setSDEnable(state == 0); } JgyUtils.getInstance().setSDOTGEnable(state == 0); boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, state); Log.e(TAG, "setTF: aole_sdcard_forbid_on = " + aole_sdcard_forbid_on); try { //tfmedia开关 // int setting_tfmedia = 1; boolean qch_tfmedia_forbid = Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", state); Log.e(TAG, "setting_tfmedia---------" + qch_tfmedia_forbid); String tfmediaStatus = ""; switch (state) { case 0: tfmediaStatus = "qch_tfmedia_open"; break; case 1: tfmediaStatus = "qch_tfmedia_forbid"; break; } Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings"); context.sendBroadcast(tfmediaIntent); if (state == 1) { boolean qch_tfmedia_filetypes = Settings.System.putString(context.getContentResolver(), "qch_tfmedia_filetypes", "Empty");//影音管控 Log.e(TAG, "qch_tfmedia_filetypes:" + qch_tfmedia_filetypes); } else { Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 0); } } catch (Exception e) { Log.e(TAG, "setTF: " + e.getMessage()); } } /** * @param context * @param jsonObject tfmedia开关 */ private static void setTF(Context context, JsonObject jsonObject) { //存储卡 int setting_memory = changeNum(jsonObject.get("setting_memory").getAsInt()); if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setSDEnable(setting_memory == 0); } Log.e(TAG, "setTF: setting_memory = " + setting_memory); JgyUtils.getInstance().setSDOTGEnable(setting_memory == 0); boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, setting_memory); Log.e(TAG, "setTF: aole_sdcard_forbid_on = " + aole_sdcard_forbid_on); try { int setting_tfmedia = jsonObject.get("setting_tfmedia").getAsInt(); // if (JgyUtils.isOfficialVersion() ) { // setting_tfmedia = changeNum(setting_tfmedia); // } boolean qch_tfmedia_forbid = Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", setting_tfmedia); Log.e(TAG, "setting_tfmedia---------" + qch_tfmedia_forbid); String tfmediaStatus = ""; switch (setting_tfmedia) { case 0: Log.e(TAG, "setting_tfmedia: " + "打开"); tfmediaStatus = "qch_tfmedia_open"; break; case 1: Log.e(TAG, "setting_tfmedia: " + "禁止"); tfmediaStatus = "qch_tfmedia_forbid"; break; } Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings"); context.sendBroadcast(tfmediaIntent); if (setting_tfmedia == 1) { JsonArray jSONArray = jsonObject.get("setting_tfmedia_format").getAsJsonArray(); StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < jSONArray.size(); i++) { stringBuffer.append(jSONArray.get(i).toString()); stringBuffer.append(","); } stringBuffer.deleteCharAt(stringBuffer.length() - 1); Settings.System.putString(context.getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控 Log.e(TAG, "qch_tfmedia_filetypes---------" + stringBuffer.toString()); } else { Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 0); } } catch (Exception e) { Log.e(TAG, "setTF: " + e.getMessage()); } } private static void setIcon(Context context, int state) { } private static void setIcon(Context context, JsonObject jsonObject) { } private static void setWallpaper(Context context, int state) { //壁纸 // int wallpaper = 1; Settings.System.putInt(context.getContentResolver(), "qch_app_wallpaper", state); Log.e(TAG, "qch_app_wallpaper" + state); } private static void setCanReset(Context context, int state) { Log.e(TAG, "setCanReset: state = " + state); Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, state); //默认打开 if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setResetFactoryEnable(state == 0); } } //aole_restore_forbid_on=1,禁止恢复出厂设置 //aole_restore_forbid_on=0,允许恢复出厂设置 private static void setCanReset(Context context, JsonObject jsonObject) { int mode = jsonObject.get("qch_restore").getAsInt(); Log.e(TAG, "setCanReset: mode = " + mode); if (mode == 1) { Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0); } else { Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 1); } if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setResetFactoryEnable(mode == 1); } } //系统默认“使用网络提供时间”且不可点击 //后台设置“使用网络提供时间”: //Intent intent32 = new Intent(); //intent32.setAction("qch_autotime_network"); //intent32.setPackage("com.android.settings"); //sendBroadcast(intent32); //后台设置“使用GPS提供时间”: //Intent intent33 = new Intent(); //intent33.setAction("qch_autotime_gps"); //intent33.setPackage("com.android.settings"); //sendBroadcast(intent33); //后台设置“关闭”(可以手动修改日期和时间): //Intent intent34 = new Intent(); //intent34.setAction("qch_autotime_off"); //intent34.setPackage("com.android.settings"); //sendBroadcast(intent34); private static void setAutoTime(Context context, JsonObject jsonObject) { String autoTime = jsonObject.get("setting_autotime").getAsString(); String action = "qch_autotime_network"; if (TextUtils.isEmpty(autoTime)) { action = "qch_autotime_network"; } else { switch (autoTime) { case "autotime_network": action = "qch_autotime_network"; break; case "autotime_gps": action = "qch_autotime_gps"; break; case "autotime_off": action = "qch_autotime_off"; break; default: action = "qch_autotime_network"; break; } } Log.e(TAG, "setAutoTime: " + "action=" + action); Intent intent = new Intent(); intent.setAction(action); intent.setPackage("com.android.settings"); context.sendBroadcast(intent); } private static void setAutoTime(Context context, int state) { Log.e(TAG, "setAutoTime: " + "default"); Intent intent = new Intent(); intent.setAction("qch_autotime_network"); intent.setPackage("com.android.settings"); context.sendBroadcast(intent); } @SuppressLint("NewApi") public static void setStatusBar(Context context, JsonObject jsonObject) { Log.e(TAG, "setStatusBar: " + jsonObject.toString()); if (null != jsonObject) { int whole = jsonObject.get("whole").getAsInt(); if (whole == 1) { setStatusBar(context, 0); } else { List disableWhat = new ArrayList<>(); int home = jsonObject.get("home").getAsInt(); if (home == 0) { disableWhat.add(StatusBarManager.DISABLE_HOME); } int returnKey = jsonObject.get("returnKey").getAsInt(); if (returnKey == 0) { disableWhat.add(StatusBarManager.DISABLE_BACK); } int taskbar = jsonObject.get("taskbar").getAsInt(); if (taskbar == 0) { disableWhat.add(StatusBarManager.DISABLE_RECENT); } int what = 0; for (Integer integer : disableWhat) { if (what == 0) { what = integer; } what |= integer; } if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setHomeEnable(home == 1); AllwinnerCubeMdmManager.getInstance().setRecentsEnable(taskbar == 1); } StatusBarManager mStatusBarManager = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE); mStatusBarManager.disable(what); } } } @SuppressLint("NewApi") private static void setStatusBar(Context context, int state) { Log.e(TAG, "setStatusBar: " + "default"); StatusBarManager mStatusBarManager = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE); mStatusBarManager.disable(StatusBarManager.DISABLE_BACK | StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME); mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);//显示隐藏的虚拟按键 if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setHomeEnable(true); AllwinnerCubeMdmManager.getInstance().setRecentsEnable(true); } } /** * 设置浏览器禁止输入 * * @param context * @param jsonObject */ private static void setBrowserInput(Context context, JsonObject jsonObject) { if (jsonObject.get("is_browser_network") != null) { int is_browser_network = jsonObject.get("is_browser_network").getAsInt(); Log.e(TAG, "setBrowserInput: is_browser_network = " + is_browser_network); Settings.Global.putInt(context.getContentResolver(), "is_browser_network", is_browser_network); } if (jsonObject.get("setting_browserInput") != null) { int qch_Browser_input = jsonObject.get("setting_browserInput").getAsInt(); Log.e(TAG, "setBrowserInput: qch_Browser_input = " + qch_Browser_input); Settings.System.putInt(context.getContentResolver(), "qch_Browser_input", qch_Browser_input); } if (jsonObject.get("browser_down") != null) { int browser_down = jsonObject.get("browser_down").getAsInt(); Settings.System.putInt(context.getContentResolver(), "aoleyun_browser_down", browser_down); } } /** * 置浏览器禁止输入,默认打开 * * @param context * @param state */ private static void setBrowserInput(Context context, int state) { Settings.System.putInt(context.getContentResolver(), "qch_Browser_input", state); Settings.Global.putInt(context.getContentResolver(), "is_browser_network", state); Settings.System.putInt(context.getContentResolver(), "aoleyun_browser_down", state); } private static void setAdminApp(Context context, JsonObject jsonObject) { JsonElement appInstall = jsonObject.get("is_app_install"); if (appInstall != null) { int is_app_install = appInstall.getAsInt(); Log.e(TAG, "setAdminApp: is_app_install = " + is_app_install); Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, is_app_install); if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setInstallPackageEnable(is_app_install == 1); } } else { Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, 0); } JsonElement adminApp = jsonObject.get("is_admin_app"); if (adminApp != null) { int is_admin_app = adminApp.getAsInt(); Log.e(TAG, "setAdminApp: is_admin_app = " + is_admin_app); Settings.Global.putInt(context.getContentResolver(), "is_admin_app", is_admin_app); } else { Settings.Global.putInt(context.getContentResolver(), "is_admin_app", 0); } JsonElement appCategory = jsonObject.get("admin_app_category"); if (appCategory != null && !appCategory.isJsonNull()) { String admin_app_category = appCategory.getAsString(); Settings.Global.putString(context.getContentResolver(), "admin_app_category", admin_app_category); } else { Settings.Global.putString(context.getContentResolver(), "admin_app_category", ""); } } private static void setAdminApp(Context context, int state) { Log.e(TAG, "setAdminApp: state = " + state); if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setInstallPackageEnable(state == 0); } Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, changeNum(state)); Settings.Global.putInt(context.getContentResolver(), "is_admin_app", changeNum(state)); } private static void setSystemAppDisable(Context context, JsonObject jsonObject) { JsonElement pictureCategory = jsonObject.get("setting_picture"); if (pictureCategory != null && !pictureCategory.isJsonNull()) { int setting_picture = pictureCategory.getAsInt(); Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", changeNum(setting_picture)); } else { Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", 0); } JsonElement fileCategory = jsonObject.get("setting_file"); if (fileCategory != null && !fileCategory.isJsonNull()) { int setting_file = fileCategory.getAsInt(); Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", changeNum(setting_file)); } else { Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", 0); } JsonElement clockCategory = jsonObject.get("setting_clock"); if (clockCategory != null && !clockCategory.isJsonNull()) { int setting_clock = clockCategory.getAsInt(); Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", changeNum(setting_clock)); } else { Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", 0); } JsonElement musicCategory = jsonObject.get("setting_music"); if (musicCategory != null && !musicCategory.isJsonNull()) { int setting_music = musicCategory.getAsInt(); Settings.System.putInt(context.getContentResolver(), "qch_app_music", changeNum(setting_music)); } else { Settings.System.putInt(context.getContentResolver(), "qch_app_music", 0); } JsonElement recordCategory = jsonObject.get("setting_recording"); if (recordCategory != null && !recordCategory.isJsonNull()) { int setting_recording = recordCategory.getAsInt(); Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", changeNum(setting_recording)); } else { Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", 0); } JsonElement browserCategory = jsonObject.get("setting_browser"); if (browserCategory != null && !browserCategory.isJsonNull()) { int setting_browser = browserCategory.getAsInt(); Settings.System.putInt(context.getContentResolver(), "qch_app_browser", changeNum(setting_browser)); } else { Settings.System.putInt(context.getContentResolver(), "qch_app_browser", 0); } Intent intent = new Intent("BrowserInternetControlKey"); intent.setPackage("com.aoleyun.browser"); context.sendBroadcast(intent); JsonElement smsCategory = jsonObject.get("setting_sms"); if (smsCategory != null && !smsCategory.isJsonNull()) { int setting_sms = smsCategory.getAsInt(); Settings.System.putInt(context.getContentResolver(), "qch_app_sms", changeNum(setting_sms)); } else { Settings.System.putInt(context.getContentResolver(), "qch_app_sms", 0); } } /** * @param context * @param status 0打开 1关闭 */ private static void setSystemAppDisable(Context context, int status) { Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", status); Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", status); Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", status); Settings.System.putInt(context.getContentResolver(), "qch_app_music", status); Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", status); Settings.System.putInt(context.getContentResolver(), "qch_app_browser", status); Settings.System.putInt(context.getContentResolver(), "qch_app_sms", status); } public static void setSnSetting(Context context, SnSetting snSetting) { if (snSetting != null) { int is_timecontrol = snSetting.getIs_timecontrol(); if (is_timecontrol == 0) { TimeUtils.setEmpty(context); TimeUtils.ContralTime c = TimeUtils.getDefaltContralTime(context); if (null != c) { Log.e("getTimeControl", c.toString()); } } else { String start_time = snSetting.getTimecontrol_start(); String end_time = snSetting.getTimecontrol_end(); TimeUtils.ContralTime c = TimeUtils.String2ContralTime(context, start_time + "-" + end_time); if (null != c) { Log.e("getTimeControl", "OK:" + c.toString()); } } int is_storeinstall = snSetting.getIs_storeinstall(); // TODO: 2024/10/12 待更换为 AOLEYUN_APPSTORE_INSTALL Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLEYUN_APPSTORE_INSTALL, is_storeinstall); int is_usb = snSetting.getIs_usb(); setUsb(context, is_usb); int is_bluetooth_file = snSetting.getIs_bluetooth_file(); setBluetoothTransmission(context, changeNum(is_bluetooth_file)); int is_developer = snSetting.getIs_developer(); JgyUtils.getInstance().setDeveloperOptions(is_developer); int is_restore = snSetting.getIs_restore(); setCanReset(context, changeNum(is_restore)); int is_topbar = snSetting.getIs_topbar(); setActionBar(context, changeNum(is_topbar)); int is_bottombar = snSetting.getIs_bottombar(); setNavigationBar(context, changeNum(is_bottombar)); int is_memory_card = snSetting.getIs_memory_card(); setTF(context, changeNum(is_memory_card)); } else { // TimeUtils.setEmpty(context); // TimeUtils.ContralTime c = TimeUtils.getDefaltContralTime(context); // if (null != c) { // Log.e("getTimeControl", c.toString()); // } // Settings.Global.putInt(context.getContentResolver(), CommonConfig.AOLEYUN_APPSTORE_INSTALL, 1); // setUsb(context, 0); // setBluetoothTransmission(context, 0); //// JgyUtils.getInstance().setDeveloperOptions(0); // setCanReset(context, 0); // setActionBar(context, 0); // setNavigationBar(context, 0); // setTF(context, 0); } } private static void setActionBar(Context context, int status) { //状态栏显示开关 int oldNum = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0); if (oldNum != status) { //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 boolean aole_hide_statusBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, status); Log.e(TAG, "aole_hide_statusBar: " + aole_hide_statusBar); String statusbarStatus = ""; switch (status) { case 0: statusbarStatus = CommonConfig.AOLE_ACTION_SHOW_STATUS_BAR; break; case 1: statusbarStatus = CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR; break; default: } Intent statusIntent = new Intent(statusbarStatus); // Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); context.sendBroadcast(statusIntent); } } private static void setNavigationBar(Context context, int status) { //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 boolean aole_hide_NavigationBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR, status); Log.e(TAG, "aole_hide_NavigationBar---------" + aole_hide_NavigationBar); String navigationStatus = ""; switch (status) { case 0: navigationStatus = CommonConfig.AOLE_ACTION_SHOW_NAVIGATION_BAR; break; case 1: navigationStatus = CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR; break; default: } Intent navIntent = new Intent(navigationStatus); // Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui"); context.sendBroadcast(navIntent); } private static void setUsb(Context context, int status) { Log.e(TAG, "setUsb: " + status); MMKV mmkv = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE); int oldStatus = mmkv.decodeInt(CommonConfig.AOLE_ACTION_USB_CODE, 0); if (oldStatus == status) { Log.e(TAG, "setUsb: oldStatus = " + oldStatus + " no changed"); return; } mmkv.encode(CommonConfig.AOLE_ACTION_USB_CODE, status); //USB数据功能管控 //仅充电:usb_charge //MTP模式:usb_mtp //Midi模式:usb_midi if (JgyUtils.isCubeDevice()) { // SuperPower mService = (SuperPower) context.getSystemService("mdm"); // switch (status) { // case 0: // mService.setUsbDataDisabled(true); // break; // case 1: // mService.setUsbDataDisabled(false); // break; // default: // } } else { String usbStatus; switch (status) { default: case 0: usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; JgyUtils.getInstance().setMtpEnable(false); break; case 1: usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP; JgyUtils.getInstance().setMtpEnable(true); break; case 2: usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MIDI; JgyUtils.getInstance().setMtpEnable(false); break; } Intent usbIntent = new Intent(usbStatus); if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.TeclastP20sPlatform || JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform ) { usbIntent.setPackage("com.android.settings"); } context.sendBroadcast(usbIntent); } } public static void setNotification(Context context, JsonObject jsonObject) { if (jsonObject.get("is_notification") != null) { int status = jsonObject.get("is_notification").getAsInt(); Log.e(TAG, "setNotification: status = " + status); setNotification(context, status); } else { Log.e(TAG, "setNotification: JsonElement not found"); } } /** * @param context * @param status 字段is notification 1开启 0 关闭 */ public static void setNotification(Context context, int status) { Intent intent = new Intent(); switch (status) { default: case 1: intent.setAction("aole_show_appinfo"); break; case 0: intent.setAction("aole_hide_appinfo"); break; } context.sendBroadcast(intent); if (JgyUtils.isAllWinnerDevice()) { AllwinnerCubeMdmManager.getInstance().setNotificationEnable(status == 1); } } private static void setPanelShow(Context context, JsonObject jsonObject) { JsonElement jsonElement = jsonObject.get("is_control_show"); if (jsonElement != null && !jsonElement.isJsonNull()) { int is_control_show = jsonElement.getAsInt(); Intent intent = new Intent(); switch (is_control_show) { case 1: intent.setAction(MainActivity.PANEL_SHOW); break; case 0: default: intent.setAction(MainActivity.PANEL_HIDE); break; } context.sendBroadcast(intent); } } public static void setDisAllowCamera(Context context, JsonObject jsonObject) { JsonElement jsonElement = jsonObject.get("camera_ctrl"); if (jsonElement != null && !jsonElement.isJsonNull()) { int camera_ctrl = jsonElement.getAsInt(); Log.e("setDisAllowCamera", "setDisAllowCamera: " + camera_ctrl); Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_DISALLOW_CAMERA, changeNum(camera_ctrl)); } } /** * @param context * @param jsonObject key的定义为:”wlan”:网络和互联网,”connected_devices”:已连接的设备,”apps”:应用,”notifications”:通知,”display”:显示, * ”sound”:提示音,”storage”:存储,”battery”:电池,”wallpaper”:壁纸,”location”:位置信息,”system”:系统,”about”:关于。 */ private static void setSettingsMenuShow(Context context, JsonObject jsonObject) { List menus = new ArrayList<>(); // // OTA升级管控 (默认允许) // int ota_upgrade_control = jsonObject.get("ota_upgrade_control").getAsInt(); // if (ota_upgrade_control == 0) { // menus.add("system_updates"); // } // // 生物识别和密码 (默认允许) // int biometric_and_password = jsonObject.get("biometric_and_password").getAsInt(); // if (biometric_and_password == 0) { // menus.add("biometrics_password"); // } // 省电模式 (默认允许) int power_saving_mode = jsonObject.get("power_saving_mode").getAsInt(); if (power_saving_mode == 0) { menus.add("battery"); } // // 安全 (默认允许) // int security = jsonObject.get("security").getAsInt(); // if (security == 0) { // menus.add("security"); // } // // 大屏特色功能 (默认允许) // int large_screen_features = jsonObject.get("large_screen_features").getAsInt(); // if (large_screen_features == 0) { //// menus.add(""); // } // // 辅助功能 (默认允许) // int accessibility = jsonObject.get("accessibility").getAsInt(); // if (accessibility == 0) { // menus.add("accessibility"); // } // // 隐私 (默认允许) // int privacy = jsonObject.get("privacy").getAsInt(); // if (privacy == 0) { // menus.add("privacy"); // } // // 更多链接 (默认允许) // int more_links = jsonObject.get("more_links").getAsInt(); // if (more_links == 0) { // menus.add("more_connections"); // } // 通知和状态栏 (默认允许) int notification_and_status_bar = jsonObject.get("notification_and_status_bar").getAsInt(); if (notification_and_status_bar == 0) { menus.add("notifications"); } // 应用管理 (默认允许) int app_management_general = jsonObject.get("app_management_general").getAsInt(); if (app_management_general == 0) { menus.add("apps"); } // // 荣耀账号登录 (默认禁止) // int honor_account_login = jsonObject.get("honor_account_login").getAsInt(); // if (honor_account_login == 0) { // menus.add("honor_id"); // } // // 智慧互联 (默认禁止) // int smart_interconnect = jsonObject.get("smart_interconnect").getAsInt(); // if (smart_interconnect == 0) { // menus.add("super_device"); // } // // VPN管控 (默认禁止) // int vpn_control = jsonObject.get("vpn_control").getAsInt(); // if (vpn_control == 0) { // menus.add("vpn_settings"); // } // // 默认应用 (默认禁止) // int default_applications = jsonObject.get("default_applications").getAsInt(); // if (default_applications == 0) { //// menus.add(""); // } // // 应用分身 (默认禁止) // int app_cloning = jsonObject.get("app_cloning").getAsInt(); // if (app_cloning == 0) { // menus.add("apps_clone"); // } // // 应用启动管理 (默认禁止) // int app_startup_management = jsonObject.get("app_startup_management").getAsInt(); // if (app_startup_management == 0) { // menus.add("apps_startup_management"); // } // 应用管理 (默认禁止) // int app_management_control = jsonObject.get("app_management_control").getAsInt(); // if (app_management_control == 0) { // menus.add("apps_management"); // menus.add("apps_honor_tips"); // } Log.e(TAG, "setSettingsMenuShow: " + menus); Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_SETTINGS_DISALLOW, String.join(",", menus)); } private static void setSettingsMenuShow(Context context) { Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_SETTINGS_DISALLOW, ""); } }