version:1.1
fix: add:应用使用数据统计
This commit is contained in:
656
app/src/main/java/com/uiui/sn/manager/ControlManager.java
Normal file
656
app/src/main/java/com/uiui/sn/manager/ControlManager.java
Normal file
@@ -0,0 +1,656 @@
|
||||
package com.uiui.sn.manager;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
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 android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.uiui.sn.bean.zuoye.SystemSettings;
|
||||
import com.uiui.sn.utils.ApkUtils;
|
||||
import com.uiui.sn.utils.JGYUtils;
|
||||
import com.uiui.sn.utils.SPUtils;
|
||||
import com.uiui.sn.utils.ToastUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
||||
/**
|
||||
* 系统管理处理
|
||||
* 所有数据 后台1是0否,底层0是1否
|
||||
*
|
||||
* @author jgy02
|
||||
*/
|
||||
public class ControlManager {
|
||||
private static final String TAG = ControlManager.class.getSimpleName();
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static ControlManager sInstance;
|
||||
private Context mContext;
|
||||
|
||||
private ControlManager(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public static void init(Context mContext) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new ControlManager(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
public static ControlManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
throw new IllegalStateException("You must be init ControlUtils first");
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private static int changeNum(int status) {
|
||||
return status == 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
public void setSystemSetting(Context context, String jsonString) {
|
||||
if (TextUtils.isEmpty(jsonString)) {
|
||||
return;
|
||||
}
|
||||
SystemSettings settings = JSON.parseObject(jsonString, SystemSettings.class);
|
||||
if (null != settings) {
|
||||
setUSBstate(context, settings);
|
||||
setPhoneList(context, settings);
|
||||
setBluetooth(context, settings);
|
||||
setHotspot(context, settings);
|
||||
setBar(context, settings);
|
||||
setCamera(context, settings);
|
||||
setTF(context, settings);
|
||||
setIcon(context, settings);
|
||||
setCanReset(context, jsonString);
|
||||
setDeveloperOptions(context, jsonString);
|
||||
setSearchTopic(context, jsonString);
|
||||
JGYUtils.getInstance().updateForbidList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭所有功能
|
||||
*/
|
||||
public void setDisableSetting() {
|
||||
Log.e("setDisableSetting", "Close all settings: ");
|
||||
setUSBstate(1);
|
||||
setPhoneList(1);
|
||||
setBluetooth(1);
|
||||
setHotspot(1);
|
||||
setCamera(1);
|
||||
setTF(1);
|
||||
setIcon(1);
|
||||
setWallpaper(0);
|
||||
setCanReset(1);
|
||||
setBrowserInput(1);
|
||||
if (!DeviceManager.isDebugMode()) {
|
||||
setDeveloperOptions(1);
|
||||
}
|
||||
setSearchTopic(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* usb连接模式管控
|
||||
*
|
||||
* @param mContext
|
||||
* @param settings
|
||||
*/
|
||||
private static void setUSBstate(Context mContext, SystemSettings settings) {
|
||||
//USB数据功能管控
|
||||
//仅充电:usb_charge
|
||||
//MTP模式:usb_mtp
|
||||
//Midi模式:usb_midi
|
||||
String setting_usb = settings.getSetting_usb();
|
||||
Log.e("SystemSetting", "setting_usb:" + setting_usb);
|
||||
if (!DeviceManager.isDebugMode()) {
|
||||
try {
|
||||
boolean qch_usb_choose = JGYUtils.putString(mContext.getContentResolver(), "qch_usb_choose", setting_usb);
|
||||
Log.e("SystemSetting", "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;
|
||||
default:
|
||||
usbStatus = "qch_action_usb_usb_charge";
|
||||
break;
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(usbIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setUSBstate: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* usb连接模式管控
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
public void setUSBstate(int state) {
|
||||
//USB数据功能管控
|
||||
//仅充电:usb_charge
|
||||
//MTP模式:usb_mtp
|
||||
//Midi模式:usb_midi
|
||||
if (!DeviceManager.isDebugMode()) {
|
||||
try {
|
||||
boolean qch_usb_choose = Settings.System.putString(mContext.getContentResolver(), "qch_usb_choose", "usb_charge");
|
||||
Log.e(TAG, "qch_usb_choose:" + qch_usb_choose);
|
||||
String usbStatus = "qch_action_usb_usb_charge";
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(usbIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setUSBstate: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setPhoneList(Context mContext, SystemSettings settings) {
|
||||
//设置电话功能,电话白名单
|
||||
int setting_call = changeNum(settings.getSetting_call());
|
||||
boolean qch_call_forbid = JGYUtils.putInt(mContext.getContentResolver(), "qch_call_forbid", setting_call);
|
||||
Log.e("SystemSetting", "qch_call_forbid: " + setting_call);
|
||||
|
||||
int setting_phone = changeNum(settings.getSetting_phone());
|
||||
boolean qch_white_list_on = JGYUtils.putInt(mContext.getContentResolver(), "qch_white_list_on", setting_phone);
|
||||
Log.e("SystemSetting", "qch_white_list_on: " + setting_phone);
|
||||
|
||||
String setting_phones = settings.getSetting_phones();
|
||||
boolean qch_white_list_Array = JGYUtils.putString(mContext.getContentResolver(), "qch_white_list_Array", setting_phones);
|
||||
Log.e("SystemSetting", "qch_white_list_Array: " + qch_white_list_Array + "=" + setting_phones);
|
||||
|
||||
int setting_memory = changeNum(settings.getSetting_memory());
|
||||
boolean qch_sdcard_forbid_on = JGYUtils.putInt(mContext.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
|
||||
Log.e("SystemSetting", "qch_sdcard_forbid_on: " + setting_memory);
|
||||
}
|
||||
|
||||
private void setPhoneList(int state) {
|
||||
try {
|
||||
//设置电话功能,电话白名单
|
||||
boolean qch_call_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_call_forbid", state);
|
||||
Log.e(TAG, "qch_call_forbid:" + qch_call_forbid);
|
||||
|
||||
boolean qch_white_list_on = Settings.System.putInt(mContext.getContentResolver(), "qch_white_list_on", state);
|
||||
Log.e(TAG, "qch_white_list_on:" + qch_white_list_on);
|
||||
|
||||
boolean qch_white_list_Array = Settings.System.putString(mContext.getContentResolver(), "qch_white_list_Array", "");
|
||||
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
||||
Log.e(TAG, "qch_white_list_Array:" + qch_white_list_Array + "---" + qch_white_list_Array);
|
||||
|
||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_sdcard_forbid_on", state);
|
||||
Log.e(TAG, "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBluetooth(Context mContext, SystemSettings settings) {
|
||||
try {
|
||||
//蓝牙开关
|
||||
int setting_bht = changeNum(settings.getSetting_bht());
|
||||
//总开关
|
||||
int setting_bhtvideo = changeNum(settings.getSetting_bhtvideo());
|
||||
//蓝牙音频开关
|
||||
int setting_bluetooth = changeNum(settings.getSetting_bluetooth());
|
||||
//蓝牙传输开关
|
||||
boolean qch_bht_forbid_on = JGYUtils.putInt(mContext.getContentResolver(), "qch_bht_forbid_on", setting_bht);
|
||||
//写入系统数据库
|
||||
Log.e("SystemSetting", "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 = settings.getSetting_context();
|
||||
if (setting_bhtvideo == 0) {
|
||||
if (null != setting_context && !"".equals(setting_context) && !" ".equals(setting_context) && !"null".equals(setting_context)) {
|
||||
Log.e("SystemSetting", "setting_context:" + setting_context);
|
||||
JGYUtils.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", setting_context);
|
||||
} else {
|
||||
JGYUtils.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
||||
}
|
||||
} else if (setting_bhtvideo == 1) {
|
||||
JGYUtils.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
||||
}
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
|
||||
} else {
|
||||
mBluetoothAdapter.disable();
|
||||
//设置关闭时关闭蓝牙
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setBluetooth: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void setBluetooth(int state) {
|
||||
try {
|
||||
boolean qch_bht_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_bht_forbid_on", state);
|
||||
//写入系统数据库
|
||||
Log.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(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_bt_forbid_on", state);
|
||||
mBluetoothAdapter.disable();
|
||||
//设置关闭时关闭蓝牙
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setBluetooth: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setHotspot(Context mContext, SystemSettings settings) {
|
||||
try {
|
||||
int setting_hotspot = changeNum(settings.getSetting_hotspot());//热点
|
||||
if (setting_hotspot == 1) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("qch_hotspot_close");
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendStickyBroadcast(intent);
|
||||
}
|
||||
boolean qch_hotspot_forbid_on = JGYUtils.putInt(mContext.getContentResolver(), "qch_hotspot_forbid_on", setting_hotspot);//写入系统数据库
|
||||
Log.e("SystemSetting", "qch_hotspot_forbid_on:" + setting_hotspot);
|
||||
Log.e("SystemSetting", "qch_hotspot_forbid_on:" + qch_hotspot_forbid_on);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setHotspot: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void setHotspot(int state) {
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("qch_hotspot_close");
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendStickyBroadcast(intent);
|
||||
boolean qch_hotspot_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_hotspot_forbid_on", state);
|
||||
Log.e(TAG, "qch_hotspot_forbid_on:" + qch_hotspot_forbid_on);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setHotspot: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setBar(Context mContext, SystemSettings settings) {
|
||||
//系统导航条显示开关
|
||||
int setting_navigation = changeNum(settings.getSetting_navigation());
|
||||
boolean qch_hide_navigationBar = JGYUtils.putInt(mContext.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
|
||||
Log.e("SystemSetting", "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");
|
||||
mContext.sendBroadcast(navIntent);
|
||||
|
||||
//状态栏显示开关
|
||||
int setting_statusbar = changeNum(settings.getSetting_statusbar());
|
||||
int oldNum = JGYUtils.getInt(mContext.getContentResolver(), "qch_hide_statusBar", 0);
|
||||
if (oldNum != setting_statusbar) {
|
||||
boolean qch_hide_statusBar = JGYUtils.putInt(mContext.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
|
||||
Log.e("SystemSetting", "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");
|
||||
mContext.sendBroadcast(statusIntent);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCamera(Context mContext, SystemSettings settings) {
|
||||
try {
|
||||
//摄像头开关
|
||||
int setting_camera = changeNum(settings.getSetting_camera());
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_app_camera", setting_camera);
|
||||
// ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.camera");
|
||||
Log.e("SystemSetting", "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");
|
||||
mContext.sendBroadcast(cameraIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setCamera: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void setCamera(int state) {
|
||||
try {
|
||||
//摄像头开关
|
||||
boolean qch_app_camera = Settings.System.putInt(mContext.getContentResolver(), "qch_app_camera", state);
|
||||
Log.e(TAG, "qch_app_camera1:" + state);
|
||||
// ApkUtils.hideSystemSettingAPP(mContext, "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");
|
||||
mContext.sendBroadcast(cameraIntent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setCamera: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private static void setTF(Context mContext, SystemSettings settings) {
|
||||
//tfmedia开关
|
||||
int setting_tfmedia = changeNum(settings.getSetting_tfmedia());
|
||||
boolean qch_tfmedia_forbid = JGYUtils.putInt(mContext.getContentResolver(), "qch_tfmedia_forbid", setting_tfmedia);
|
||||
Log.e("SystemSetting", "setting_tfmedia:" + qch_tfmedia_forbid);
|
||||
String tfmediaStatus = "";
|
||||
switch (setting_tfmedia) {
|
||||
case 0:
|
||||
tfmediaStatus = "qch_tfmedia_open";
|
||||
break;
|
||||
case 1:
|
||||
tfmediaStatus = "qch_tfmedia_forbid";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(tfmediaIntent);
|
||||
if (setting_tfmedia == 1) {
|
||||
String qch_tfmedia_filetypes = settings.getSetting_tfmedia_format();
|
||||
if (TextUtils.isEmpty(qch_tfmedia_filetypes)) {
|
||||
JGYUtils.putString(mContext.getContentResolver(), "qch_tfmedia_filetypes", "");//影音管控
|
||||
} else {
|
||||
HashSet<String> types = new HashSet<>(Arrays.asList(qch_tfmedia_filetypes.split(",")));
|
||||
types.removeIf(new Predicate<String>() {
|
||||
@Override
|
||||
public boolean test(String s) {
|
||||
return TextUtils.isEmpty(s);
|
||||
}
|
||||
});
|
||||
String typesString = String.join(",", types);
|
||||
JGYUtils.putString(mContext.getContentResolver(), "qch_tfmedia_filetypes", typesString);//影音管控
|
||||
Log.e("SystemSetting", "qch_tfmedia_filetypes :" + typesString);
|
||||
}
|
||||
} else {
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_tfmedia_forbid", 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTF(int state) {
|
||||
try {
|
||||
//tfmedia开关
|
||||
// int setting_tfmedia = 1;
|
||||
boolean qch_tfmedia_forbid = Settings.System.putInt(mContext.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");
|
||||
mContext.sendBroadcast(tfmediaIntent);
|
||||
if (state == 1) {
|
||||
boolean qch_tfmedia_filetypes = Settings.System.putString(mContext.getContentResolver(), "qch_tfmedia_filetypes", "Empty");//影音管控
|
||||
Log.e(TAG, "qch_tfmedia_filetypes:" + qch_tfmedia_filetypes);
|
||||
} else {
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_tfmedia_forbid", 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setTF: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setIcon(Context mContext, SystemSettings settings) {
|
||||
try {
|
||||
//added:2019.12.6
|
||||
//设置5个app的开关
|
||||
//时钟
|
||||
int deskclock = changeNum(settings.getSetting_clock());
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_app_deskclock", deskclock);
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.deskclock");
|
||||
Log.e("SystemSetting", "qch_app_deskclock:" + deskclock);
|
||||
//录音机
|
||||
int soundrecorder = changeNum(settings.getSetting_recording());
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.soundrecorder");
|
||||
Log.e("SystemSetting", "qch_app_soundrecorder:" + soundrecorder);
|
||||
//音乐
|
||||
int music = changeNum(settings.getSetting_music());
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_app_music", music);
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.music");
|
||||
Log.e("SystemSetting", "qch_app_music:" + music);
|
||||
//图库
|
||||
int gallery = changeNum(settings.getSetting_picture());
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_app_gallery", gallery);
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.gallery3d");
|
||||
Log.e("SystemSetting", "qch_app_gallery:" + gallery);
|
||||
//壁纸
|
||||
int wallpaper = changeNum(settings.getSetting_wallpaper());
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_app_wallpaper", wallpaper);
|
||||
Log.e("SystemSetting", "qch_app_wallpaper:" + wallpaper);
|
||||
//文件管理器
|
||||
int filemanager = changeNum(settings.getSetting_file());
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_app_filemanager", filemanager);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.filemanager");
|
||||
} else {
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.documentsui");
|
||||
}
|
||||
Log.e("SystemSetting", "qch_app_filemanager:" + filemanager);
|
||||
//浏览器
|
||||
int browser = changeNum(settings.getSetting_browser());
|
||||
JGYUtils.putInt(mContext.getContentResolver(), "qch_app_browser", browser);
|
||||
Log.e(TAG, "qch_app_browser" + browser);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setIcon: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void setIcon(int state) {
|
||||
try {
|
||||
//added:2019.12.6
|
||||
//设置5个app的开关
|
||||
//时钟
|
||||
// int deskclock = 1;
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_deskclock", state);
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.deskclock");
|
||||
Log.e(TAG, "qch_app_deskclock" + state);
|
||||
//录音机
|
||||
// int soundrecorder = 1;
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_soundrecorder", state);
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.soundrecorder");
|
||||
Log.e(TAG, "qch_app_soundrecorder" + state);
|
||||
//音乐
|
||||
// int music = 1;
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_music", state);
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.music");
|
||||
Log.e(TAG, "qch_app_music" + state);
|
||||
//图库
|
||||
// int gallery = 1;
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_gallery", state);
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.gallery3d");
|
||||
Log.e(TAG, "qch_app_gallery" + state);
|
||||
//文件管理器
|
||||
// int filemanager = 1;
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_filemanager", state);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.filemanager");
|
||||
} else {
|
||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.documentsui");
|
||||
}
|
||||
Log.e(TAG, "qch_app_filemanager" + state);
|
||||
//浏览器
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_browser", state);
|
||||
Log.e(TAG, "qch_app_browser" + state);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "setIcon: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void setWallpaper(int state) {
|
||||
//壁纸
|
||||
// int wallpaper = 1;
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_wallpaper", state);
|
||||
Log.e(TAG, "qch_app_wallpaper" + state);
|
||||
}
|
||||
|
||||
private static void setCanReset(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int mode = jsonObject.getIntValue("qch_restore");
|
||||
if (mode == 1) {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
||||
} else {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 1);
|
||||
}
|
||||
Log.e(TAG, "qch_restore_forbid_on:" + mode);
|
||||
}
|
||||
|
||||
private void setCanReset(int state) {
|
||||
boolean qch_restore_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_restore_forbid_on", 0);
|
||||
Log.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||
//默认打开
|
||||
}
|
||||
|
||||
/**
|
||||
* 置浏览器禁止输入,默认打开
|
||||
*
|
||||
* @param state
|
||||
*/
|
||||
private void setBrowserInput(int state) {
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_Browser_input", 0);
|
||||
}
|
||||
|
||||
public void setDeveloperOptions(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int dev_mode = changeNum(jsonObject.getIntValue("dev_mode"));
|
||||
Log.e(TAG, "getDeveloper: " + dev_mode);
|
||||
if (!DeviceManager.isDebugMode()) {
|
||||
JGYUtils.putInt(context.getContentResolver(), "qch_Developeroptions", dev_mode);
|
||||
if (dev_mode == 1) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("qch_developeroptions_close");
|
||||
intent.setPackage("com.android.settings");
|
||||
context.sendBroadcast(intent);
|
||||
Log.e(TAG, "getDeveloper: " + "关闭开发者模式");
|
||||
ToastUtil.debugShow("关闭开发者模式");
|
||||
} else {
|
||||
Log.e(TAG, "getDeveloper: " + "打开开发者模式");
|
||||
ToastUtil.debugShow("打开开发者模式");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDeveloperOptions(int state) {
|
||||
Log.e(TAG, "getDeveloper: " + state);
|
||||
if (!DeviceManager.isDebugMode()) {
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", state);
|
||||
if (state == 1) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("qch_developeroptions_close");
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent);
|
||||
Log.e(TAG, "getDeveloper: " + "关闭开发者模式");
|
||||
} else {
|
||||
Log.e(TAG, "getDeveloper: " + "打开开发者模式");
|
||||
// ToastUtil.show("打开开发者模式");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSearchTopic(Context context, String jsonString) {
|
||||
JSONObject jsonObject = JSON.parseObject(jsonString);
|
||||
int mode = jsonObject.getIntValue("search_topic");
|
||||
SPUtils.put(context, "search_topic", mode);
|
||||
Log.e(TAG, "search_topic:" + mode);
|
||||
}
|
||||
|
||||
public void setSearchTopic(int state) {
|
||||
SPUtils.put(mContext, "search_topic", state);
|
||||
Log.e(TAG, "search_topic:" + state);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开机管控usb
|
||||
*/
|
||||
public void setDefaultUSBstate() {
|
||||
//USB数据功能管控
|
||||
//仅充电:usb_charge
|
||||
//MTP模式:usb_mtp
|
||||
//Midi模式:usb_midi
|
||||
String setting_usb = JGYUtils.getString(mContext.getContentResolver(), "qch_usb_choose");
|
||||
Log.e("SystemSetting", "setting_usb:" + setting_usb);
|
||||
String usbStatus = "";
|
||||
if (TextUtils.isEmpty(setting_usb)) {
|
||||
usbStatus = "qch_action_usb_usb_charge";
|
||||
} else {
|
||||
if (!DeviceManager.isDebugMode()) {
|
||||
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;
|
||||
default:
|
||||
usbStatus = "qch_action_usb_usb_charge";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(usbIntent);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user