Files
CubeAoleyunSN/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java
tongtongstudio cdaaaaed91 version: cude 5.1
fix:
update:适配台电
2022-06-11 17:58:04 +08:00

761 lines
34 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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.mdm.SuperPower;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.comm.JGYActions;
import java.util.ArrayList;
import java.util.List;
public class SysSettingUtils {
private static final String TAG = SysSettingUtils.class.getSimpleName();
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 = JSON.parseObject(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);
JSONObject navJson = jsonObject.getJSONObject("setting_nav");
SPUtils.put(context, JGYActions.ACTION_STATUSBAR_STATUS, jsonObject.getJSONObject("setting_nav").toJSONString());
setStatusBar(context, navJson);
setBrowserInput(context, jsonObject);
// TODO: 2022/4/11 不是酷比定制的会报错,无法抛出异常
setUSBstate(context, jsonObject);
}
/**
* @param context 关闭所有功能
*/
public static void setDisableSetting(Context context) {
ToastUtil.betaShow("关闭所有功能");
Log.e("setDisableSetting", "Close all settings: ");
setPhoneList(context, 1);
setUSBstate(context, 1);
setBluetooth(context, 1);
setHotspot(context, 1);
setBar(context, 1);
setCamera(context, 1);
setTF(context, 1);
setIcon(context, 1);
setWallpaper(context, 0);
setCanReset(context, 1);
setAutoTime(context, 1);
setBrowserInput(context, 1);
if (!BuildConfig.DEBUG) {
JGYUtils.getInstance().setDeveloperOptions(1);
}
setStatusBar(context, 1);
}
/**
* @param context 开启所有功能
*/
public static void setEnableSetting(Context context) {
ToastUtil.betaShow("打开所有功能");
setPhoneList(context, 0);
// setUSBstate(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, 0);
JGYUtils.getInstance().setDeveloperOptions(0);
}
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.getInteger("setting_call"));
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.getInteger("setting_phone"));
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.getString("setting_phones");
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);
}
//存储卡
int setting_memory = changeNum(jsonObject.getInteger("setting_memory"));
boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, setting_memory);
Log.e(TAG, "aole_sdcard_forbid_on:" + aole_sdcard_forbid_on);
} catch (Exception e) {
Log.e(TAG, "setPhoneList: " + e.getMessage());
}
}
private static void setUSBstate(Context context, int state) {
//USB数据功能管控
//仅充电usb_charge
//MTP模式usb_mtp
//Midi模式usb_midi
if (!BuildConfig.DEBUG) {
try {
SuperPower mService = (SuperPower) context.getSystemService("mdm");
mService.setUSBDataDisabled(true);
boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", "usb_charge");
Log.e(TAG, "aole_usb_choose:" + aole_usb_choose);
String usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE;
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
context.sendBroadcast(usbIntent);
} catch (NoClassDefFoundError | Exception e) {
Log.e(TAG, "setUSBstate: " + e.getMessage());
}
}
}
private static void setUSBstate(Context context, JSONObject jsonObject) {
//USB数据功能管控
//仅充电usb_charge
//MTP模式usb_mtp
//Midi模式usb_midi
String setting_usb = jsonObject.getString("setting_usb");
if (!BuildConfig.DEBUG) {
if (JGYUtils.isCubeDevice()) {
SuperPower mService = (SuperPower) context.getSystemService("mdm");
switch (setting_usb) {
case "usb_charge":
mService.setUSBDataDisabled(true);
break;
case "usb_mtp":
mService.setUSBDataDisabled(false);
break;
default:
}
} else {
boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb);
Log.e("setUSBstate", "aole_usb_choose: " + aole_usb_choose);
String usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE;
switch (setting_usb) {
case "usb_charge":
usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE;
break;
case "usb_mtp":
usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP;
break;
case "usb_midi":
usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MIDI;
break;
default:
}
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
context.sendBroadcast(usbIntent);
}
}
}
private static void setBluetooth(Context context, int state) {
try {
boolean aole_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, state);
//写入系统数据库
Log.e(TAG, "aole_bht_forbid_on:" + aole_bht_forbid_on);
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (aole_bht_forbid_on) {
//成功
if (null == mBluetoothAdapter) {
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
//获取默认蓝牙适配器
}
//蓝牙总开关开启
Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, "Empty");
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, state);
mBluetoothAdapter.disable();
//设置关闭时关闭蓝牙
}
} catch (Exception e) {
Log.e(TAG, "setBluetooth: " + e.getMessage());
}
}
private static void setBluetooth(Context context, JSONObject jsonObject) {
try {
//蓝牙开关
int setting_bht = changeNum(jsonObject.getInteger("setting_bht"));
//总开关
int setting_bhtvideo = changeNum(jsonObject.getInteger("setting_bhtvideo"));
//蓝牙音频开关
int setting_bluetooth = changeNum(jsonObject.getInteger("setting_bluetooth"));
//蓝牙传输开关
boolean aole_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, setting_bht);
Log.e(TAG, "aole_bht_forbid_on:" + aole_bht_forbid_on);
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (aole_bht_forbid_on) {
//成功
if (null == mBluetoothAdapter) {
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
//获取默认蓝牙适配器
}
if (setting_bht == 0) {
//蓝牙总开关开启
String setting_context = jsonObject.getString("setting_context");
if (setting_bhtvideo == 0) {
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");
}
Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, setting_bluetooth);
} else {
mBluetoothAdapter.disable();
//设置关闭时关闭蓝牙
}
}
} catch (Exception e) {
Log.e(TAG, "setBluetooth: " + e.getMessage());
}
}
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);
} catch (Exception e) {
Log.e(TAG, "setHotspot: " + e.getMessage());
}
}
private static void setHotspot(Context context, JSONObject jsonObject) {
try {
int setting_hotspot = changeNum(jsonObject.getInteger("setting_hotspot"));//热点
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);
} 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;
}
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;
}
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.getInteger("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;
}
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
context.sendBroadcast(navIntent);
//状态栏显示开关
int setting_statusbar = changeNum(jsonObject.getInteger("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;
}
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
context.sendBroadcast(statusIntent);
}
}
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.getInteger("setting_camera"));
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);
} catch (Exception e) {
Log.e(TAG, "setCamera: " + e.getMessage());
}
}
private static void setTF(Context context, int state) {
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) {
try {
int setting_tfmedia = jsonObject.getInteger("setting_tfmedia");
// 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 = null;
jSONArray = jsonObject.getJSONArray("setting_tfmedia_format");
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < jSONArray.size(); i++) {
stringBuffer.append(jSONArray.getString(i));
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) {
try {
//设置5个app的开关
//时钟
// int deskclock = 1;
Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", 0);
ApkUtils.hideSystemSettingAPP(context, "com.android.deskclock");
Log.e(TAG, "qch_app_deskclock" + state);
//录音机
// int soundrecorder = 1;
Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", state);
ApkUtils.hideSystemSettingAPP(context, "com.android.soundrecorder");
Log.e(TAG, "qch_app_soundrecorder" + state);
//音乐
// int music = 1;
Settings.System.putInt(context.getContentResolver(), "qch_app_music", state);
ApkUtils.hideSystemSettingAPP(context, "com.android.music");
Log.e(TAG, "qch_app_music" + state);
//图库
// int gallery = 1;
Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", state);
ApkUtils.hideSystemSettingAPP(context, "com.android.gallery3d");
Log.e(TAG, "qch_app_gallery" + state);
//文件管理器
// int filemanager = 1;
Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", state);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
ApkUtils.hideSystemSettingAPP(context, "com.mediatek.filemanager");
} else {
ApkUtils.hideSystemSettingAPP(context, "com.android.documentsui");
}
Log.e(TAG, "qch_app_filemanager" + state);
Settings.System.putInt(context.getContentResolver(), "qch_app_browser", state);
Log.e(TAG, "qch_app_browser" + state);
} catch (Exception e) {
Log.e(TAG, "setIcon: " + e.getMessage());
}
}
private static void setIcon(Context context, JSONObject jsonObject) {
try {
//added:2019.12.6
//设置5个app的开关
//时钟
int deskclock = changeNum(jsonObject.getInteger("setting_clock"));
Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", deskclock);
ApkUtils.hideSystemSettingAPP(context, "com.android.deskclock");
Log.e(TAG, "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = changeNum(jsonObject.getInteger("setting_recording"));
Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
ApkUtils.hideSystemSettingAPP(context, "com.android.soundrecorder");
Log.e(TAG, "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = changeNum(jsonObject.getInteger("setting_music"));
Settings.System.putInt(context.getContentResolver(), "qch_app_music", music);
ApkUtils.hideSystemSettingAPP(context, "com.android.music");
Log.e(TAG, "qch_app_music" + music);
//图库
int gallery = changeNum(jsonObject.getInteger("setting_picture"));
Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", gallery);
ApkUtils.hideSystemSettingAPP(context, "com.android.gallery3d");
Log.e(TAG, "qch_app_gallery" + gallery);
//壁纸
int wallpaper = changeNum(jsonObject.getInteger("setting_wallpaper"));
setWallpaper(context, wallpaper);
//文件管理器
int filemanager = changeNum(jsonObject.getInteger("setting_file"));
Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", filemanager);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
ApkUtils.hideSystemSettingAPP(context, "com.mediatek.filemanager");
} else {
ApkUtils.hideSystemSettingAPP(context, "com.android.documentsui");
}
Log.e(TAG, "qch_app_filemanager" + filemanager);
//浏览器
int browser = changeNum(jsonObject.getInteger("setting_browser"));
Settings.System.putInt(context.getContentResolver(), "qch_app_browser", browser);
Log.e(TAG, "qch_app_browser" + browser);
} catch (Exception e) {
Log.e(TAG, "setIcon: " + e.getMessage());
}
}
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) {
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0);
Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on);
//默认打开
}
//aole_restore_forbid_on=1禁止恢复出厂设置
//aole_restore_forbid_on=0允许恢复出厂设置
private static void setCanReset(Context context, JSONObject jsonObject) {
int mode = jsonObject.getInteger("qch_restore");
if (mode == 1) {
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0);
Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on);
} else {
boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 1);
Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on);
}
}
//系统默认“使用网络提供时间”且不可点击
//后台设置“使用网络提供时间”:
//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.getString("setting_autotime");
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.toJSONString());
if (null != jsonObject) {
int whole = jsonObject.getInteger("whole");
if (whole == 1) {
setStatusBar(context, 0);
} else {
List<Integer> disableWhat = new ArrayList<>();
int home = jsonObject.getInteger("home");
if (home == 0) {
disableWhat.add(StatusBarManager.DISABLE_HOME);
}
int returnKey = jsonObject.getInteger("returnKey");
if (returnKey == 0) {
disableWhat.add(StatusBarManager.DISABLE_BACK);
}
int taskbar = jsonObject.getInteger("taskbar");
if (taskbar == 0) {
disableWhat.add(StatusBarManager.DISABLE_RECENT);
}
int what = 0;
for (Integer integer : disableWhat) {
if (what == 0) {
what = integer;
}
what |= integer;
}
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);//显示隐藏的虚拟按键
}
/**
* 设置浏览器禁止输入
*
* @param context
* @param jsonObject
*/
private static void setBrowserInput(Context context, JSONObject jsonObject) {
int state = 1;
try {
state = jsonObject.getInteger("setting_browserInput");
Log.e(TAG, "setBrowserInput: " + state);
String json = jsonObject.getString("setting_browserInput");
if (TextUtils.isEmpty(json)) {
state = 1;
}
} catch (Exception e) {
Log.e(TAG, "setBrowserInput: e: " + e.getMessage());
}
Log.e(TAG, "setBrowserInput: " + state);
//后台没有这个选项默认打开
if (state == 0) {
Settings.System.putInt(context.getContentResolver(), "qch_Browser_input", 1);
} else {
Settings.System.putInt(context.getContentResolver(), "qch_Browser_input", 0);
}
}
/**
* 置浏览器禁止输入,默认打开
*
* @param context
* @param state
*/
private static void setBrowserInput(Context context, int state) {
Settings.System.putInt(context.getContentResolver(), "qch_Browser_input", 0);
}
}