version:1.0
update:2021-10-13 18:52:13 fix:去除okgo,rxAndroid1,优化依赖 add:切换到奥乐云平台
This commit is contained in:
760
app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java
Normal file
760
app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java
Normal file
@@ -0,0 +1,760 @@
|
||||
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.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aoleyun.sn.BuildConfig;
|
||||
import com.aoleyun.sn.action.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);
|
||||
setUSBstate(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_STATUS_BAR_STATUS, jsonObject.getJSONObject("setting_nav").toJSONString());
|
||||
setStatusBar(context, navJson);
|
||||
setBrowserInput(context, jsonObject);
|
||||
//otg开关
|
||||
// int setting_otg = changeNum(jsonObject.getInteger("setting_otg"));
|
||||
// Logutils.e(TAG, "setting_otg---------" + setting_otg);
|
||||
// String otgStatus = "";
|
||||
// switch (setting_otg) {
|
||||
// case 0:
|
||||
// otgStatus = "qch_otg_open";
|
||||
// break;
|
||||
// case 1:
|
||||
// otgStatus = "qch_otg_forbid";
|
||||
// break;
|
||||
// }
|
||||
// Intent otgIntent = new Intent(otgStatus);
|
||||
// sendBroadcast(otgIntent);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context 关闭所有功能
|
||||
*/
|
||||
public static void setDisableSetting(Context context) {
|
||||
ToastUtil.betaShow("关闭所有功能");
|
||||
Logutils.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);
|
||||
Logutils.e(TAG, "qch_call_forbid:" + qch_call_forbid);
|
||||
|
||||
boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", state);
|
||||
Logutils.e(TAG, "qch_white_list_on:" + qch_white_list_on);
|
||||
|
||||
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", "");
|
||||
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
||||
Logutils.e(TAG, "qch_white_list_Array:" + qch_white_list_Array + "---" + qch_white_list_Array);
|
||||
|
||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", state);
|
||||
Logutils.e(TAG, "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
||||
} catch (Exception e) {
|
||||
Logutils.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);
|
||||
Logutils.e(TAG, "qch_call_forbid:" + qch_call_forbid);
|
||||
//电话白名单开关
|
||||
int setting_phone = changeNum(jsonObject.getInteger("setting_phone"));
|
||||
boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", setting_phone);
|
||||
Logutils.e(TAG, "qch_white_list_on:" + qch_white_list_on);
|
||||
//白名单列表
|
||||
if (setting_phone == 1) {
|
||||
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", "empty");
|
||||
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
||||
Logutils.e(TAG, "qch_white_list_Array:" + qch_white_list_Array);
|
||||
} else {
|
||||
String setting_phones = jsonObject.getString("setting_phones");
|
||||
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", setting_phones);
|
||||
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
||||
Logutils.e(TAG, "qch_white_list_Array:" + qch_white_list_Array + "---" + setting_phones);
|
||||
}
|
||||
//存储卡
|
||||
int setting_memory = changeNum(jsonObject.getInteger("setting_memory"));
|
||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
|
||||
Logutils.e(TAG, "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
||||
} catch (Exception e) {
|
||||
Logutils.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 {
|
||||
boolean qch_usb_choose = Settings.System.putString(context.getContentResolver(), "qch_usb_choose", "usb_charge");
|
||||
Logutils.e(TAG, "qch_usb_choose:" + qch_usb_choose);
|
||||
String usbStatus = "qch_action_usb_usb_charge";
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
context.sendBroadcast(usbIntent);
|
||||
} catch (Exception e) {
|
||||
Logutils.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) {
|
||||
try {
|
||||
boolean qch_usb_choose = Settings.System.putString(context.getContentResolver(), "qch_usb_choose", setting_usb);
|
||||
Logutils.e(TAG, "qch_usb_choose---------" + qch_usb_choose);
|
||||
String usbStatus = "";
|
||||
switch (setting_usb) {
|
||||
case "usb_charge":
|
||||
usbStatus = "qch_action_usb_usb_charge";
|
||||
break;
|
||||
case "usb_mtp":
|
||||
usbStatus = "qch_action_usb_usb_mtp";
|
||||
break;
|
||||
case "usb_midi":
|
||||
usbStatus = "qch_action_usb_usb_midi";
|
||||
break;
|
||||
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
context.sendBroadcast(usbIntent);
|
||||
} catch (Exception e) {
|
||||
Logutils.e(TAG, "setUSBstate: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBluetooth(Context context, int state) {
|
||||
try {
|
||||
boolean qch_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bht_forbid_on", state);
|
||||
//写入系统数据库
|
||||
Logutils.e(TAG, "qch_bht_forbid_on:" + qch_bht_forbid_on);
|
||||
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (qch_bht_forbid_on) {
|
||||
//成功
|
||||
if (null == mBluetoothAdapter) {
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
//获取默认蓝牙适配器
|
||||
}
|
||||
//蓝牙总开关开启
|
||||
Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_bt_forbid_on", state);
|
||||
mBluetoothAdapter.disable();
|
||||
//设置关闭时关闭蓝牙
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logutils.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 qch_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bht_forbid_on", setting_bht);
|
||||
|
||||
Logutils.e(TAG, "qch_bht_forbid_on:" + qch_bht_forbid_on);
|
||||
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if (qch_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 && !setting_context.equals("") && !setting_context.equals(" ") && !setting_context.equals("null")) {
|
||||
Logutils.e(TAG, "setting_context:" + setting_context);
|
||||
Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", setting_context);
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
||||
}
|
||||
} else if (setting_bhtvideo == 1) {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
||||
}
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
|
||||
} else {
|
||||
mBluetoothAdapter.disable();
|
||||
//设置关闭时关闭蓝牙
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logutils.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 qch_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_hotspot_forbid_on", state);
|
||||
Logutils.e(TAG, "qch_hotspot_forbid_on:" + qch_hotspot_forbid_on);
|
||||
} catch (Exception e) {
|
||||
Logutils.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 qch_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_hotspot_forbid_on", setting_hotspot);
|
||||
Logutils.e(TAG, "qch_hotspot_forbid_on---------" + setting_hotspot);
|
||||
Logutils.e(TAG, "qch_hotspot_forbid_on---------" + qch_hotspot_forbid_on);
|
||||
} catch (Exception e) {
|
||||
Logutils.e(TAG, "setHotspot: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBar(Context context, int state) {
|
||||
//系统导航条显示开关
|
||||
int setting_navigation = 0;
|
||||
//写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示
|
||||
boolean qch_hide_navigationBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
|
||||
Logutils.e(TAG, "qch_hide_navigationBar---------" + qch_hide_navigationBar);
|
||||
|
||||
String navigationStatus = "";
|
||||
switch (setting_navigation) {
|
||||
case 0:
|
||||
navigationStatus = "qch_show_NavigationBar";
|
||||
break;
|
||||
case 1:
|
||||
navigationStatus = "qch_hide_NavigationBar";
|
||||
break;
|
||||
|
||||
}
|
||||
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
||||
context.sendBroadcast(navIntent);
|
||||
|
||||
|
||||
//状态栏显示开关
|
||||
int setting_statusbar = 0;
|
||||
int oldNum = Settings.System.getInt(context.getContentResolver(), "qch_hide_statusBar", 0);
|
||||
if (oldNum != setting_statusbar) {
|
||||
//写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示
|
||||
boolean qch_hide_statusBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
|
||||
Logutils.e(TAG, "qch_hide_statusBar---------" + qch_hide_statusBar);
|
||||
String statusbarStatus = "";
|
||||
switch (setting_statusbar) {
|
||||
case 0:
|
||||
statusbarStatus = "qch_show_statusBar";
|
||||
break;
|
||||
case 1:
|
||||
statusbarStatus = "qch_hide_statusBar";
|
||||
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 qch_hide_navigationBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
|
||||
Logutils.e(TAG, "qch_hide_navigationBar---------" + qch_hide_navigationBar);
|
||||
|
||||
String navigationStatus = "";
|
||||
switch (setting_navigation) {
|
||||
case 0:
|
||||
navigationStatus = "qch_show_NavigationBar";
|
||||
break;
|
||||
case 1:
|
||||
navigationStatus = "qch_hide_NavigationBar";
|
||||
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(), "qch_hide_statusBar", 0);
|
||||
if (oldNum != setting_statusbar) {
|
||||
//写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示
|
||||
boolean qch_hide_statusBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
|
||||
Logutils.e(TAG, "qch_hide_statusBar---------" + qch_hide_statusBar);
|
||||
String statusbarStatus = "";
|
||||
switch (setting_statusbar) {
|
||||
case 0:
|
||||
statusbarStatus = "qch_show_statusBar";
|
||||
break;
|
||||
case 1:
|
||||
statusbarStatus = "qch_hide_statusBar";
|
||||
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", state);
|
||||
Logutils.e(TAG, "qch_app_camera1:" + state);
|
||||
// ApkUtils.hideSystemSettingAPP(context, "com.mediatek.camera");
|
||||
Logutils.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) {
|
||||
Logutils.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);
|
||||
Logutils.e(TAG, "qch_app_camera2:" + setting_camera);
|
||||
// ApkUtils.hideSystemSettingAPP(context, "com.mediatek.camera");
|
||||
Logutils.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) {
|
||||
Logutils.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);
|
||||
Logutils.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");//影音管控
|
||||
Logutils.e(TAG, "qch_tfmedia_filetypes:" + qch_tfmedia_filetypes);
|
||||
} else {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logutils.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);
|
||||
Logutils.e(TAG, "setting_tfmedia---------" + qch_tfmedia_forbid);
|
||||
String tfmediaStatus = "";
|
||||
switch (setting_tfmedia) {
|
||||
case 0:
|
||||
Logutils.e(TAG, "setting_tfmedia: " + "打开");
|
||||
tfmediaStatus = "qch_tfmedia_open";
|
||||
break;
|
||||
case 1:
|
||||
Logutils.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());//影音管控
|
||||
Logutils.e(TAG, "qch_tfmedia_filetypes---------" + stringBuffer.toString());
|
||||
} else {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logutils.e(TAG, "setTF: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setIcon(Context context, int state) {
|
||||
try {
|
||||
//added:2019.12.6
|
||||
//设置5个app的开关
|
||||
//时钟
|
||||
// int deskclock = 1;
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", state);
|
||||
ApkUtils.hideSystemSettingAPP(context, "com.android.deskclock");
|
||||
Logutils.e(TAG, "qch_app_deskclock" + state);
|
||||
//录音机
|
||||
// int soundrecorder = 1;
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", state);
|
||||
ApkUtils.hideSystemSettingAPP(context, "com.android.soundrecorder");
|
||||
Logutils.e(TAG, "qch_app_soundrecorder" + state);
|
||||
//音乐
|
||||
// int music = 1;
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_music", state);
|
||||
ApkUtils.hideSystemSettingAPP(context, "com.android.music");
|
||||
Logutils.e(TAG, "qch_app_music" + state);
|
||||
//图库
|
||||
// int gallery = 1;
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", state);
|
||||
ApkUtils.hideSystemSettingAPP(context, "com.android.gallery3d");
|
||||
Logutils.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");
|
||||
}
|
||||
Logutils.e(TAG, "qch_app_filemanager" + state);
|
||||
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_browser", state);
|
||||
Logutils.e(TAG, "qch_app_browser" + state);
|
||||
} catch (Exception e) {
|
||||
Logutils.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");
|
||||
Logutils.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");
|
||||
Logutils.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");
|
||||
Logutils.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");
|
||||
Logutils.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");
|
||||
}
|
||||
Logutils.e(TAG, "qch_app_filemanager" + filemanager);
|
||||
//浏览器
|
||||
int browser = changeNum(jsonObject.getInteger("setting_browser"));
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_browser", browser);
|
||||
Logutils.e(TAG, "qch_app_browser" + browser);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logutils.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);
|
||||
Logutils.e(TAG, "qch_app_wallpaper" + state);
|
||||
}
|
||||
|
||||
private static void setCanReset(Context context, int state) {
|
||||
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
||||
Logutils.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||
//默认打开
|
||||
}
|
||||
|
||||
//qch_restore_forbid_on=1,禁止恢复出厂设置
|
||||
//qch_restore_forbid_on=0,允许恢复出厂设置
|
||||
private static void setCanReset(Context context, JSONObject jsonObject) {
|
||||
int mode = jsonObject.getInteger("qch_restore");
|
||||
if (mode == 1) {
|
||||
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
||||
Logutils.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||
} else {
|
||||
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 1);
|
||||
Logutils.e(TAG, "qch_restore_forbid_on:" + qch_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;
|
||||
}
|
||||
}
|
||||
Logutils.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) {
|
||||
Logutils.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) {
|
||||
Logutils.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) {
|
||||
Logutils.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");
|
||||
Logutils.e(TAG, "setBrowserInput: " + state);
|
||||
String json = jsonObject.getString("setting_browserInput");
|
||||
if (TextUtils.isEmpty(json)) {
|
||||
state = 1;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logutils.e(TAG, "setBrowserInput: e: " + e.getMessage());
|
||||
}
|
||||
Logutils.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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user