update:2020.12.04
fix:修复强制安装得应用可以删除bug,上传列表不显示系统应用,加入远程结束app
add:
This commit is contained in:
2020-12-04 18:36:54 +08:00
parent fc826c656c
commit ad3d6745b1
20 changed files with 1902 additions and 887 deletions

View File

@@ -1,5 +1,6 @@
package com.mjsheng.myappstore.utils;
import android.app.ActivityManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
@@ -18,12 +19,17 @@ import android.os.Build;
import android.provider.Settings;
import android.support.annotation.RequiresApi;
import android.support.v4.content.FileProvider;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.google.gson.Gson;
import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.R;
import com.mjsheng.myappstore.bean.UploadAppInfo;
import com.mjsheng.myappstore.network.Network;
import com.mjsheng.myappstore.network.api.UploadAppInfoApi;
import com.mjsheng.myappstore.server.InitJpushServer;
import java.io.BufferedReader;
@@ -42,6 +48,8 @@ import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import io.reactivex.disposables.Disposable;
import okhttp3.ResponseBody;
import rx.Observable;
import rx.Observer;
import rx.Subscriber;
@@ -613,6 +621,7 @@ public class ApkUtils {
public static List<String> systemapp = new ArrayList<String>() {{
//需要管控的系统应用
this.add("com.android.gallery3d");//图库
this.add("com.android.settings");//图库
this.add("com.android.deskclock");//时钟
this.add("com.android.music");//音乐
this.add("com.mediatek.camera");//相机
@@ -792,6 +801,9 @@ public class ApkUtils {
}
public static void addShortcut(Context context, String packageList) {
if (TextUtils.isEmpty(packageList)) {
return;
}
String[] stringList = packageList.split(",");
List<String> packages = new ArrayList<>(Arrays.asList(stringList));
String installedList = "";
@@ -817,4 +829,86 @@ public class ApkUtils {
Log.e("addShortcut", "putstring:" + qch_force_app);
}
public static void getAppInfo(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> infoList = activityManager.getRunningServices(Integer.MAX_VALUE);
for (ActivityManager.RunningServiceInfo info:infoList){
// Log.e("fht", "getAppInfo1: "+info.process);
// Log.e("fht", "getAppInfo2: "+info.service.getPackageName());
// Log.e("fht", "getAppInfo3: "+info.service.getClassName());
}
ArrayList<UploadAppInfo> appList = new ArrayList<UploadAppInfo>(); //用来存储获取的应用信息数据
List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0);
for (int i = 0; i < packages.size(); i++) {
PackageInfo packageInfo = packages.get(i);
if (ApkUtils.systemapp.contains(packageInfo.packageName)
||ApkUtils.show_canremove_systemapp.contains(packageInfo.packageName)
||ApkUtils.canremove_systemapp.contains(packageInfo.packageName)
) {
continue;
}
UploadAppInfo uploadAppInfo = new UploadAppInfo();
uploadAppInfo.setApp_name(packageInfo.applicationInfo.loadLabel(context.getPackageManager()).toString());
uploadAppInfo.setPackage_name(packageInfo.packageName);
uploadAppInfo.setId(i);
String firstInstallTime = Utils.transferLongToDate(packageInfo.firstInstallTime);
uploadAppInfo.setInstall_time(firstInstallTime);
uploadAppInfo.setVersionCode(String.valueOf(packageInfo.versionCode));
uploadAppInfo.setState(0);
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
} else {
for (ActivityManager.RunningServiceInfo info:infoList){
if (info.process.contains(packageInfo.packageName)){
uploadAppInfo.setState(1);
Log.e("fht", "getAppInfo running: "+packageInfo.packageName);
}
}
appList.add(uploadAppInfo);
}
}
// Log.e("mjsheng", "UploadAppInfo========" + appList.toString());
Gson gson = new Gson();
String jsonString = gson.toJson(appList);
// Log.e("mjsheng", "json========" + jsonString);
UploadAppInfoApi uploadAppInfoApi = Network.getUploadAppInfoApi();
uploadAppInfoApi.getUploadAppInfoApi(Configure.HTTP_KEY, Utils.getSerial(), jsonString)
.subscribeOn(io.reactivex.schedulers.Schedulers.io())
.observeOn(io.reactivex.android.schedulers.AndroidSchedulers.mainThread())
.subscribe(new io.reactivex.Observer<ResponseBody>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(ResponseBody responseBody) {
try {
Log.e("mjhseng", "上传的结果" + responseBody.string());
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onError(Throwable e) {
Log.e("mjsheng", "UploadAppInfoApi=onError:");
}
@Override
public void onComplete() {
}
});
}
}

View File

@@ -95,6 +95,7 @@ public class Configure {
// public static final String HTTP_TAG_DOWNLOAD_URL = HTTP_TAG_HEAD + "Down?baoming=";
public static final String HTTP_TAG_DOWNLOAD_URL = HTTP_TAG_HEAD_NEW + "count/index";
public static final String SEND_DOWNLOAD_FILE_INFO = HTTP_TAG_HEAD_NEW + "app/downloadApp";
// app详细窗口 相关推荐接口
public static final String HTTP_TAG_APPDETAIL_URL = HTTP_TAG_HEAD + "Tuij/xiang?aid=";
@@ -210,4 +211,6 @@ public class Configure {
//上传截图
public static final String UPDATE_DEVICEINFO = HTTP_TAG_HEAD_NEW + "Mac/getInfo";
//上传我的设备
public final static String GET_LOCK_SCREEN_STATE = HTTP_TAG_HEAD_NEW + "Sn/getSnScreen";
//获取霸屏状态
}

View File

@@ -2,6 +2,7 @@ package com.mjsheng.myappstore.utils;
import android.app.ActivityManager;
import android.content.Context;
import android.util.Log;
import com.mjsheng.myappstore.MyApplication;
@@ -12,13 +13,14 @@ public class ServiceAliveUtils {
ActivityManager manager =
(ActivityManager) MyApplication.getAppContext().getSystemService(Context.ACTIVITY_SERVICE);
if (manager == null) {
return true;
return false;
}
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
if ("demo.lgm.com.keepalivedemo.service.DownloadService".equals(service.service.getClassName())) {
if ("com.mjsheng.myappstore.server.InitJpushServer".equals(service.service.getClassName())) {
isServiceRunning = true;
}
}
Log.e("ServiceAliveUtils", "isServiceAlice: " + isServiceRunning);
return isServiceRunning;
}
}

View File

@@ -0,0 +1,532 @@
package com.mjsheng.myappstore.utils;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mjsheng.myappstore.BuildConfig;
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 mContext, String jsonObj) {
if (null == mContext) {
throw new RuntimeException("Context it's null");
}
JSONObject jsonObject = JSON.parseObject(jsonObj);
setPhoneList(mContext, jsonObject);
setUSBstate(mContext, jsonObject);
setBluetooth(mContext, jsonObject);
setHotspot(mContext, jsonObject);
setBar(mContext, jsonObject);
setCamera(mContext, jsonObject);
setTF(mContext, jsonObject);
setIcon(mContext, jsonObject);
//otg开关
// int setting_otg = changeNum(jsonObject.getInteger("setting_otg"));
// Log.e("SystemSetting", "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);
}
public static void setDefaultSetting(Context mContext) {
setPhoneList(mContext);
setUSBstate(mContext);
setBluetooth(mContext);
setHotspot(mContext);
setBar(mContext);
setCamera(mContext);
setTF(mContext);
setIcon(mContext);
}
private static void setPhoneList(Context mContext) {
try {
//设置电话功能,电话白名单
boolean qch_call_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_call_forbid", 1);
Log.e("SystemSetting", "qch_call_forbid:" + qch_call_forbid);
boolean qch_white_list_on = Settings.System.putInt(mContext.getContentResolver(), "qch_white_list_on", 1);
Log.e("SystemSetting", "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("SystemSetting", "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", 1);
Log.e("SystemSetting", "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
} catch (Exception e) {
Log.e(TAG, "setPhoneList: " + e.getMessage());
}
}
private static void setPhoneList(Context mContext, JSONObject jsonObject) {
try {
//设置电话功能,电话白名单
int setting_call = changeNum(jsonObject.getInteger("setting_call"));
boolean qch_call_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_call_forbid", setting_call);
Log.e("SystemSetting", "qch_call_forbid---------" + qch_call_forbid);
int setting_phone = changeNum(jsonObject.getInteger("setting_phone"));
boolean qch_white_list_on = Settings.System.putInt(mContext.getContentResolver(), "qch_white_list_on", setting_phone);
Log.e("SystemSetting", "qch_white_list_on---------" + qch_white_list_on);
String setting_phones = jsonObject.getString("setting_phones");
boolean qch_white_list_Array = Settings.System.putString(mContext.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);
Log.e("SystemSetting", "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(mContext.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
Log.e("SystemSetting", "qch_sdcard_forbid_on---------" + qch_sdcard_forbid_on);
} catch (Exception e) {
Log.e(TAG, "setPhoneList: " + e.getMessage());
}
}
private static void setUSBstate(Context mContext) {
//USB数据功能管控
//仅充电usb_charge
//MTP模式usb_mtp
//Midi模式usb_midi
if (!BuildConfig.DEBUG) {
try {
boolean qch_usb_choose = Settings.System.putString(mContext.getContentResolver(), "qch_usb_choose", "usb_charge");
Log.e("SystemSetting", "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 setUSBstate(Context mContext, 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(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;
}
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
mContext.sendBroadcast(usbIntent);
} catch (Exception e) {
Log.e(TAG, "setUSBstate: " + e.getMessage());
}
}
}
private static void setBluetooth(Context mContext) {
try {
boolean qch_bht_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_bht_forbid_on", 1);
//写入系统数据库
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();
//获取默认蓝牙适配器
}
//蓝牙总开关开启
Settings.System.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
Settings.System.putInt(mContext.getContentResolver(), "qch_bt_forbid_on", 1);
mBluetoothAdapter.disable();
//设置关闭时关闭蓝牙
}
} catch (Exception e) {
Log.e(TAG, "setBluetooth: " + e.getMessage());
}
}
private static void setBluetooth(Context mContext, 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(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 = jsonObject.getString("setting_context");
if (setting_bhtvideo == 0) {
if (null != setting_context && !setting_context.equals("") && !setting_context.equals(" ") && !setting_context.equals("null")) {
Log.e("SystemSetting", "setting_context:" + setting_context);
Settings.System.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", setting_context);
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
}
} else if (setting_bhtvideo == 1) {
Settings.System.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
}
Settings.System.putInt(mContext.getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
} else {
mBluetoothAdapter.disable();
//设置关闭时关闭蓝牙
}
}
} catch (Exception e) {
Log.e(TAG, "setBluetooth: " + e.getMessage());
}
}
private static void setHotspot(Context mContext) {
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", 1);//写入系统数据库
Log.e("SystemSetting", "qch_hotspot_forbid_on:" + qch_hotspot_forbid_on);
} catch (Exception e) {
Log.e(TAG, "setHotspot: " + e.getMessage());
}
}
private static void setHotspot(Context mContext, 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");
mContext.sendStickyBroadcast(intent);
}
boolean qch_hotspot_forbid_on = Settings.System.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 static void setBar(Context mContext) {
//系统导航条显示开关
int setting_navigation = 0;
boolean qch_hide_navigationBar = Settings.System.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 = 0;
int oldNum = Settings.System.getInt(mContext.getContentResolver(), "qch_hide_statusBar", 0);
if (oldNum != setting_statusbar) {
boolean qch_hide_statusBar = Settings.System.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 setBar(Context mContext, JSONObject jsonObject) {
//系统导航条显示开关
int setting_navigation = changeNum(jsonObject.getInteger("setting_navigation"));
boolean qch_hide_navigationBar = Settings.System.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(jsonObject.getInteger("setting_statusbar"));
int oldNum = Settings.System.getInt(mContext.getContentResolver(), "qch_hide_statusBar", 0);
if (oldNum != setting_statusbar) {
boolean qch_hide_statusBar = Settings.System.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) {
try {
//摄像头开关
boolean qch_app_camera = Settings.System.putInt(mContext.getContentResolver(), "qch_app_camera", 1);
// ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.camera");
Log.e("SystemSetting", "setting_camera---------" + qch_app_camera);
String cameraStatus = "qch_camera_forbid";
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
mContext.sendBroadcast(cameraIntent);
} catch (Exception e) {
Log.e(TAG, "setCamera: " + e.getMessage());
}
}
private static void setCamera(Context mContext, JSONObject jsonObject) {
try {
//摄像头开关
int setting_camera = changeNum(jsonObject.getInteger("setting_camera"));
Settings.System.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 static void setTF(Context mContext) {
try {
//tfmedia开关
int setting_tfmedia = 1;
boolean qch_tfmedia_forbid = Settings.System.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;
}
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
mContext.sendBroadcast(tfmediaIntent);
if (setting_tfmedia == 1) {
boolean qch_tfmedia_filetypes = Settings.System.putString(mContext.getContentResolver(), "qch_tfmedia_filetypes", "Empty");//影音管控
Log.e("SystemSetting", "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 setTF(Context mContext, JSONObject jsonObject) {
try {
//tfmedia开关
int setting_tfmedia = changeNum(jsonObject.getInteger("setting_tfmedia"));
boolean qch_tfmedia_forbid = Settings.System.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;
}
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
mContext.sendBroadcast(tfmediaIntent);
if (setting_tfmedia == 1) {
JSONArray jSONArray = null;
jSONArray = jsonObject.getJSONArray("setting_tfmedia_format");
int i = 0;
StringBuffer stringBuffer = new StringBuffer();
while (!jSONArray.isEmpty()) {
stringBuffer.append(jSONArray.getString(i));
stringBuffer.append(",");
i++;
}
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
Settings.System.putString(mContext.getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控
Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + stringBuffer.toString());
} 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) {
try {
//added:2019.12.6
//设置5个app的开关
//时钟
int deskclock = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_deskclock", deskclock);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.deskclock");
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.soundrecorder");
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_music", music);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.music");
Log.e("SystemSetting", "qch_app_music" + music);
//图库
int gallery = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_gallery", gallery);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.gallery3d");
Log.e("SystemSetting", "qch_app_gallery" + gallery);
//壁纸
int wallpaper = 1;
Settings.System.putInt(mContext.getContentResolver(), "qch_app_wallpaper", wallpaper);
Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
//文件管理器
int filemanager = 1;
Settings.System.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);
} catch (Exception e) {
Log.e(TAG, "setIcon: " + e.getMessage());
}
}
private static void setIcon(Context mContext, JSONObject jsonObject) {
try {
//added:2019.12.6
//设置5个app的开关
//时钟
int deskclock = changeNum(jsonObject.getInteger("setting_clock"));
Settings.System.putInt(mContext.getContentResolver(), "qch_app_deskclock", deskclock);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.deskclock");
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = changeNum(jsonObject.getInteger("setting_recording"));
Settings.System.putInt(mContext.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.soundrecorder");
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = changeNum(jsonObject.getInteger("setting_music"));
Settings.System.putInt(mContext.getContentResolver(), "qch_app_music", music);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.music");
Log.e("SystemSetting", "qch_app_music" + music);
//图库
int gallery = changeNum(jsonObject.getInteger("setting_picture"));
Settings.System.putInt(mContext.getContentResolver(), "qch_app_gallery", gallery);
ApkUtils.hideSystemSettingAPP(mContext, "com.android.gallery3d");
Log.e("SystemSetting", "qch_app_gallery" + gallery);
//壁纸
int wallpaper = changeNum(jsonObject.getInteger("setting_wallpaper"));
Settings.System.putInt(mContext.getContentResolver(), "qch_app_wallpaper", wallpaper);
Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
//文件管理器
int filemanager = changeNum(jsonObject.getInteger("setting_file"));
Settings.System.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);
} catch (Exception e) {
Log.e(TAG, "setIcon: " + e.getMessage());
}
}
}