diff --git a/app/build.gradle b/app/build.gradle index 3f63e63..df5949b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -60,8 +60,8 @@ android { productFlavors { beta { flavorDimensions "default" - versionCode 3 - versionName "1.2" + versionCode 4 + versionName "1.3" manifestPlaceholders = [ JPUSH_PKGNAME: "com.uiui.sn", JPUSH_APPKEY : "1a1e405ca5a1a5cd50e9f734", //JPush 上注册的包名对应的 Appkey. @@ -232,7 +232,8 @@ dependencies { annotationProcessor 'com.arialyy.aria:compiler:3.8.15' implementation "org.java-websocket:Java-WebSocket:1.4.1" - + //MMKV + implementation 'com.tencent:mmkv-static:1.2.10' //高德地图定位 implementation 'com.amap.api:location:5.1.0' //屏幕适配方案 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 37a5dd9..3eff373 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -52,7 +52,7 @@ + + @@ -100,13 +105,13 @@ - - + + @@ -120,7 +125,7 @@ - + @@ -133,11 +138,11 @@ @@ -156,7 +161,7 @@ @@ -169,7 +174,7 @@ @@ -270,14 +275,14 @@ @@ -289,7 +294,7 @@ - + diff --git a/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java b/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java index 1c98526..1aeb9b6 100644 --- a/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java +++ b/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java @@ -53,6 +53,7 @@ import com.uiui.sn.jpush.TagAliasOperatorHelper; import com.uiui.sn.manager.NetInterfaceManager; import com.uiui.sn.network.HTTPInterface; import com.uiui.sn.receiver.BootReceiver; +import com.uiui.sn.service.ControlPanelService; import com.uiui.sn.service.DownloadService; import com.uiui.sn.service.GuardService; import com.uiui.sn.service.MainService; @@ -640,6 +641,8 @@ public class MainActivity extends BaseActivity implements MainContact.MainView, startService(new Intent(this, StepService.class)); startService(new Intent(this, DownloadService.class)); startService(new Intent(this, ManagerService.class)); + startService(new Intent(this, ControlPanelService.class)); + } private void registerReceiver() { diff --git a/app/src/main/java/com/uiui/sn/base/BaseApplication.java b/app/src/main/java/com/uiui/sn/base/BaseApplication.java index e0144c4..cbc5566 100644 --- a/app/src/main/java/com/uiui/sn/base/BaseApplication.java +++ b/app/src/main/java/com/uiui/sn/base/BaseApplication.java @@ -8,9 +8,11 @@ import android.os.Looper; import android.util.Log; import com.arialyy.aria.core.Aria; +import com.tencent.mmkv.MMKV; import com.uiui.sn.BuildConfig; import com.uiui.sn.jpush.TagAliasOperatorHelper; import com.uiui.sn.manager.AmapManager; +import com.uiui.sn.manager.ControlPanelManager; import com.uiui.sn.manager.NetInterfaceManager; import com.uiui.sn.manager.ControlManager; import com.uiui.sn.manager.DeviceManager; @@ -79,11 +81,13 @@ public class BaseApplication extends Application { // 设置开启日志,发布时请关闭日志 JPushInterface.setDebugMode(true); JPushInterface.requestPermission(this); - + String rootDir = MMKV.initialize(this); + Log.i(TAG, "mmkv root: " + rootDir); Aria.init(this); Aria.download(this).resumeAllTask(); JGYUtils.init(this); ControlManager.init(this); + ControlPanelManager.init(this); DeviceManager.init(this); AmapManager.init(this); AmapManager.getInstance().initAmap(); diff --git a/app/src/main/java/com/uiui/sn/bean/zuoye/SystemSettings.java b/app/src/main/java/com/uiui/sn/bean/zuoye/SystemSettings.java index 5f7d942..ebcd8a2 100644 --- a/app/src/main/java/com/uiui/sn/bean/zuoye/SystemSettings.java +++ b/app/src/main/java/com/uiui/sn/bean/zuoye/SystemSettings.java @@ -39,7 +39,7 @@ public class SystemSettings implements Serializable { int setting_volume; int setting_luminance; String setting_typeface; - + int setting_admin_app; public int getQch_restore() { return qch_restore; @@ -274,6 +274,13 @@ public class SystemSettings implements Serializable { this.setting_typeface = setting_typeface; } + public int getSetting_admin_app() { + return setting_admin_app; + } + + public void setSetting_admin_app(int setting_admin_app) { + this.setting_admin_app = setting_admin_app; + } @Override public String toString() { diff --git a/app/src/main/java/com/uiui/sn/manager/AmapManager.java b/app/src/main/java/com/uiui/sn/manager/AmapManager.java index 1a42503..76acb3e 100644 --- a/app/src/main/java/com/uiui/sn/manager/AmapManager.java +++ b/app/src/main/java/com/uiui/sn/manager/AmapManager.java @@ -1,5 +1,6 @@ package com.uiui.sn.manager; +import android.annotation.SuppressLint; import android.content.Context; import android.util.Log; @@ -10,16 +11,21 @@ import com.amap.api.location.AMapLocationListener; import com.uiui.sn.utils.SPUtils; public class AmapManager { + private static final String TAG = AmapManager.class.getSimpleName(); + @SuppressLint("StaticFieldLeak") private static AmapManager sInstance; private Context mContext; + @SuppressLint("StaticFieldLeak") public static AMapLocationClient locationClient = null; - private String TAG = AmapManager.class.getSimpleName(); private AmapManager(Context context) { this.mContext = context; } public static void init(Context context) { + if (context == null) { + throw new RuntimeException("Context is NULL"); + } if (sInstance == null) { sInstance = new AmapManager(context); } diff --git a/app/src/main/java/com/uiui/sn/manager/ControlManager.java b/app/src/main/java/com/uiui/sn/manager/ControlManager.java index 53d490c..df34d0a 100644 --- a/app/src/main/java/com/uiui/sn/manager/ControlManager.java +++ b/app/src/main/java/com/uiui/sn/manager/ControlManager.java @@ -35,25 +35,25 @@ public class ControlManager { @SuppressLint("StaticFieldLeak") private static ControlManager sInstance; private Context mContext; - private ContentResolver resolver; + private ContentResolver mResolver; - private ControlManager(Context mContext) { - if (mContext == null) { + private ControlManager(Context context) { + if (context == null) { throw new RuntimeException("Context is NULL"); } - this.mContext = mContext; - this.resolver = mContext.getContentResolver(); + this.mContext = context; + this.mResolver = context.getContentResolver(); } - public static void init(Context mContext) { + public static void init(Context context) { if (sInstance == null) { - sInstance = new ControlManager(mContext); + sInstance = new ControlManager(context); } } public static ControlManager getInstance() { if (sInstance == null) { - throw new IllegalStateException("You must be init ControlUtils first"); + throw new IllegalStateException("You must be init ControlManager first"); } return sInstance; } @@ -80,11 +80,16 @@ public class ControlManager { setDeveloperOptions(jsonString); setSearchTopic(jsonString); setSOSNumber(settings); - + setAppstoreAdmin(settings); JGYUtils.getInstance().updateForbidList(); } } + private void setAppstoreAdmin(SystemSettings settings) { + int setting_admin_app = settings.getSetting_admin_app(); + Settings.System.putInt(mResolver, "setting_admin_app", setting_admin_app); + } + /** * 关闭所有功能 */ @@ -120,7 +125,7 @@ public class ControlManager { Log.e("SystemSetting", "setting_usb:" + setting_usb); if (!DeviceManager.isDebugMode()) { try { - boolean qch_usb_choose = JGYUtils.putString(resolver, "qch_usb_choose", setting_usb); + boolean qch_usb_choose = JGYUtils.putString(mResolver, "qch_usb_choose", setting_usb); Log.e("SystemSetting", "qch_usb_choose:" + qch_usb_choose); String usbStatus = ""; switch (setting_usb) { @@ -157,7 +162,7 @@ public class ControlManager { //Midi模式:usb_midi if (!DeviceManager.isDebugMode()) { try { - boolean qch_usb_choose = Settings.System.putString(resolver, "qch_usb_choose", "usb_charge"); + boolean qch_usb_choose = Settings.System.putString(mResolver, "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"); @@ -171,36 +176,36 @@ public class ControlManager { private void setPhoneList(SystemSettings settings) { //设置电话功能,电话白名单 int setting_call = changeNum(settings.getSetting_call()); - boolean qch_call_forbid = JGYUtils.putInt(resolver, "qch_call_forbid", setting_call); + boolean qch_call_forbid = JGYUtils.putInt(mResolver, "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(resolver, "qch_white_list_on", setting_phone); + boolean qch_white_list_on = JGYUtils.putInt(mResolver, "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(resolver, "qch_white_list_Array", setting_phones); + boolean qch_white_list_Array = JGYUtils.putString(mResolver, "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(resolver, "qch_sdcard_forbid_on", setting_memory); + boolean qch_sdcard_forbid_on = JGYUtils.putInt(mResolver, "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(resolver, "qch_call_forbid", state); + boolean qch_call_forbid = Settings.System.putInt(mResolver, "qch_call_forbid", state); Log.e(TAG, "qch_call_forbid:" + qch_call_forbid); - boolean qch_white_list_on = Settings.System.putInt(resolver, "qch_white_list_on", state); + boolean qch_white_list_on = Settings.System.putInt(mResolver, "qch_white_list_on", state); Log.e(TAG, "qch_white_list_on:" + qch_white_list_on); - boolean qch_white_list_Array = Settings.System.putString(resolver, "qch_white_list_Array", ""); + boolean qch_white_list_Array = Settings.System.putString(mResolver, "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(resolver, "qch_sdcard_forbid_on", state); + boolean qch_sdcard_forbid_on = Settings.System.putInt(mResolver, "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()); @@ -216,7 +221,7 @@ public class ControlManager { //蓝牙音频开关 int setting_bluetooth = changeNum(settings.getSetting_bluetooth()); //蓝牙传输开关 - boolean qch_bht_forbid_on = JGYUtils.putInt(resolver, "qch_bht_forbid_on", setting_bht); + boolean qch_bht_forbid_on = JGYUtils.putInt(mResolver, "qch_bht_forbid_on", setting_bht); //写入系统数据库 Log.e("SystemSetting", "qch_bht_forbid_on:" + qch_bht_forbid_on); BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); @@ -232,14 +237,14 @@ public class ControlManager { 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(resolver, "qch_bhtvideo_forbid_on", setting_context); + JGYUtils.putString(mResolver, "qch_bhtvideo_forbid_on", setting_context); } else { - JGYUtils.putString(resolver, "qch_bhtvideo_forbid_on", "Empty"); + JGYUtils.putString(mResolver, "qch_bhtvideo_forbid_on", "Empty"); } } else if (setting_bhtvideo == 1) { - JGYUtils.putString(resolver, "qch_bhtvideo_forbid_on", "Empty"); + JGYUtils.putString(mResolver, "qch_bhtvideo_forbid_on", "Empty"); } - JGYUtils.putInt(resolver, "qch_bt_forbid_on", setting_bluetooth); + JGYUtils.putInt(mResolver, "qch_bt_forbid_on", setting_bluetooth); } else { mBluetoothAdapter.disable(); //设置关闭时关闭蓝牙 @@ -252,7 +257,7 @@ public class ControlManager { private void setBluetooth(int state) { try { - boolean qch_bht_forbid_on = Settings.System.putInt(resolver, "qch_bht_forbid_on", state); + boolean qch_bht_forbid_on = Settings.System.putInt(mResolver, "qch_bht_forbid_on", state); //写入系统数据库 Log.e(TAG, "qch_bht_forbid_on:" + qch_bht_forbid_on); BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); @@ -263,8 +268,8 @@ public class ControlManager { //获取默认蓝牙适配器 } //蓝牙总开关开启 - Settings.System.putString(resolver, "qch_bhtvideo_forbid_on", "Empty"); - Settings.System.putInt(resolver, "qch_bt_forbid_on", state); + Settings.System.putString(mResolver, "qch_bhtvideo_forbid_on", "Empty"); + Settings.System.putInt(mResolver, "qch_bt_forbid_on", state); mBluetoothAdapter.disable(); //设置关闭时关闭蓝牙 } @@ -282,7 +287,7 @@ public class ControlManager { intent.setPackage("com.android.settings"); mContext.sendStickyBroadcast(intent); } - boolean qch_hotspot_forbid_on = JGYUtils.putInt(resolver, "qch_hotspot_forbid_on", setting_hotspot);//写入系统数据库 + boolean qch_hotspot_forbid_on = JGYUtils.putInt(mResolver, "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) { @@ -296,7 +301,7 @@ public class ControlManager { intent.setAction("qch_hotspot_close"); intent.setPackage("com.android.settings"); mContext.sendStickyBroadcast(intent); - boolean qch_hotspot_forbid_on = Settings.System.putInt(resolver, "qch_hotspot_forbid_on", state); + boolean qch_hotspot_forbid_on = Settings.System.putInt(mResolver, "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()); @@ -306,7 +311,7 @@ public class ControlManager { private void setBar(SystemSettings settings) { //系统导航条显示开关 int setting_navigation = changeNum(settings.getSetting_navigation()); - boolean qch_hide_navigationBar = JGYUtils.putInt(resolver, "qch_hide_NavigationBar", setting_navigation); + boolean qch_hide_navigationBar = JGYUtils.putInt(mResolver, "qch_hide_NavigationBar", setting_navigation); Log.e("SystemSetting", "qch_hide_navigationBar:" + qch_hide_navigationBar); String navigationStatus = ""; @@ -324,9 +329,9 @@ public class ControlManager { //状态栏显示开关 int setting_statusbar = changeNum(settings.getSetting_statusbar()); - int oldNum = JGYUtils.getInt(resolver, "qch_hide_statusBar", 0); + int oldNum = JGYUtils.getInt(mResolver, "qch_hide_statusBar", 0); if (oldNum != setting_statusbar) { - boolean qch_hide_statusBar = JGYUtils.putInt(resolver, "qch_hide_statusBar", setting_statusbar); + boolean qch_hide_statusBar = JGYUtils.putInt(mResolver, "qch_hide_statusBar", setting_statusbar); Log.e("SystemSetting", "qch_hide_statusBar:" + qch_hide_statusBar); String statusbarStatus = ""; switch (setting_statusbar) { @@ -346,7 +351,7 @@ public class ControlManager { try { //摄像头开关 int setting_camera = changeNum(settings.getSetting_camera()); - JGYUtils.putInt(resolver, "qch_app_camera", setting_camera); + JGYUtils.putInt(mResolver, "qch_app_camera", setting_camera); // ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.camera"); Log.e("SystemSetting", "setting_camera:" + setting_camera); String cameraStatus = ""; @@ -368,7 +373,7 @@ public class ControlManager { private void setCamera(int state) { try { //摄像头开关 - boolean qch_app_camera = Settings.System.putInt(resolver, "qch_app_camera", state); + boolean qch_app_camera = Settings.System.putInt(mResolver, "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); @@ -392,7 +397,7 @@ public class ControlManager { private void setTF(SystemSettings settings) { //tfmedia开关 int setting_tfmedia = changeNum(settings.getSetting_tfmedia()); - boolean qch_tfmedia_forbid = JGYUtils.putInt(resolver, "qch_tfmedia_forbid", setting_tfmedia); + boolean qch_tfmedia_forbid = JGYUtils.putInt(mResolver, "qch_tfmedia_forbid", setting_tfmedia); Log.e("SystemSetting", "setting_tfmedia:" + qch_tfmedia_forbid); String tfmediaStatus = ""; switch (setting_tfmedia) { @@ -410,7 +415,7 @@ public class ControlManager { if (setting_tfmedia == 1) { String qch_tfmedia_filetypes = settings.getSetting_tfmedia_format(); if (TextUtils.isEmpty(qch_tfmedia_filetypes)) { - JGYUtils.putString(resolver, "qch_tfmedia_filetypes", "");//影音管控 + JGYUtils.putString(mResolver, "qch_tfmedia_filetypes", "");//影音管控 } else { HashSet types = new HashSet<>(Arrays.asList(qch_tfmedia_filetypes.split(","))); types.removeIf(new Predicate() { @@ -420,11 +425,11 @@ public class ControlManager { } }); String typesString = String.join(",", types); - JGYUtils.putString(resolver, "qch_tfmedia_filetypes", typesString);//影音管控 + JGYUtils.putString(mResolver, "qch_tfmedia_filetypes", typesString);//影音管控 Log.e("SystemSetting", "qch_tfmedia_filetypes :" + typesString); } } else { - JGYUtils.putInt(resolver, "qch_tfmedia_forbid", 0); + JGYUtils.putInt(mResolver, "qch_tfmedia_forbid", 0); } } @@ -432,7 +437,7 @@ public class ControlManager { try { //tfmedia开关 // int setting_tfmedia = 1; - boolean qch_tfmedia_forbid = Settings.System.putInt(resolver, "qch_tfmedia_forbid", state); + boolean qch_tfmedia_forbid = Settings.System.putInt(mResolver, "qch_tfmedia_forbid", state); Log.e(TAG, "setting_tfmedia---------" + qch_tfmedia_forbid); String tfmediaStatus = ""; switch (state) { @@ -446,10 +451,10 @@ public class ControlManager { Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings"); mContext.sendBroadcast(tfmediaIntent); if (state == 1) { - boolean qch_tfmedia_filetypes = Settings.System.putString(resolver, "qch_tfmedia_filetypes", "Empty");//影音管控 + boolean qch_tfmedia_filetypes = Settings.System.putString(mResolver, "qch_tfmedia_filetypes", "Empty");//影音管控 Log.e(TAG, "qch_tfmedia_filetypes:" + qch_tfmedia_filetypes); } else { - Settings.System.putInt(resolver, "qch_tfmedia_forbid", 0); + Settings.System.putInt(mResolver, "qch_tfmedia_forbid", 0); } } catch (Exception e) { Log.e(TAG, "setTF: " + e.getMessage()); @@ -462,31 +467,31 @@ public class ControlManager { //设置5个app的开关 //时钟 int deskclock = changeNum(settings.getSetting_clock()); - JGYUtils.putInt(resolver, "qch_app_deskclock", deskclock); + JGYUtils.putInt(mResolver, "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(resolver, "qch_app_soundrecorder", soundrecorder); + JGYUtils.putInt(mResolver, "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(resolver, "qch_app_music", music); + JGYUtils.putInt(mResolver, "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(resolver, "qch_app_gallery", gallery); + JGYUtils.putInt(mResolver, "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(resolver, "qch_app_wallpaper", wallpaper); + JGYUtils.putInt(mResolver, "qch_app_wallpaper", wallpaper); Log.e("SystemSetting", "qch_app_wallpaper:" + wallpaper); //文件管理器 int filemanager = changeNum(settings.getSetting_file()); - JGYUtils.putInt(resolver, "qch_app_filemanager", filemanager); + JGYUtils.putInt(mResolver, "qch_app_filemanager", filemanager); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.filemanager"); } else { @@ -495,7 +500,7 @@ public class ControlManager { Log.e("SystemSetting", "qch_app_filemanager:" + filemanager); //浏览器 int browser = changeNum(settings.getSetting_browser()); - JGYUtils.putInt(resolver, "qch_app_browser", browser); + JGYUtils.putInt(mResolver, "qch_app_browser", browser); Log.e(TAG, "qch_app_browser" + browser); } catch (Exception e) { Log.e(TAG, "setIcon: " + e.getMessage()); @@ -508,27 +513,27 @@ public class ControlManager { //设置5个app的开关 //时钟 // int deskclock = 1; - Settings.System.putInt(resolver, "qch_app_deskclock", state); + Settings.System.putInt(mResolver, "qch_app_deskclock", state); ApkUtils.hideSystemSettingAPP(mContext, "com.android.deskclock"); Log.e(TAG, "qch_app_deskclock" + state); //录音机 // int soundrecorder = 1; - Settings.System.putInt(resolver, "qch_app_soundrecorder", state); + Settings.System.putInt(mResolver, "qch_app_soundrecorder", state); ApkUtils.hideSystemSettingAPP(mContext, "com.android.soundrecorder"); Log.e(TAG, "qch_app_soundrecorder" + state); //音乐 // int music = 1; - Settings.System.putInt(resolver, "qch_app_music", state); + Settings.System.putInt(mResolver, "qch_app_music", state); ApkUtils.hideSystemSettingAPP(mContext, "com.android.music"); Log.e(TAG, "qch_app_music" + state); //图库 // int gallery = 1; - Settings.System.putInt(resolver, "qch_app_gallery", state); + Settings.System.putInt(mResolver, "qch_app_gallery", state); ApkUtils.hideSystemSettingAPP(mContext, "com.android.gallery3d"); Log.e(TAG, "qch_app_gallery" + state); //文件管理器 // int filemanager = 1; - Settings.System.putInt(resolver, "qch_app_filemanager", state); + Settings.System.putInt(mResolver, "qch_app_filemanager", state); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.filemanager"); } else { @@ -536,7 +541,7 @@ public class ControlManager { } Log.e(TAG, "qch_app_filemanager" + state); //浏览器 - Settings.System.putInt(resolver, "qch_app_browser", state); + Settings.System.putInt(mResolver, "qch_app_browser", state); Log.e(TAG, "qch_app_browser" + state); } catch (Exception e) { Log.e(TAG, "setIcon: " + e.getMessage()); @@ -546,22 +551,22 @@ public class ControlManager { private void setWallpaper(int state) { //壁纸 // int wallpaper = 1; - Settings.System.putInt(resolver, "qch_app_wallpaper", state); + Settings.System.putInt(mResolver, "qch_app_wallpaper", state); Log.e(TAG, "qch_app_wallpaper" + state); } private void setCanReset(SystemSettings settings) { int mode = settings.getQch_restore(); if (mode == 1) { - Settings.System.putInt(resolver, "qch_restore_forbid_on", 0); + Settings.System.putInt(mResolver, "qch_restore_forbid_on", 0); } else { - Settings.System.putInt(resolver, "qch_restore_forbid_on", 1); + Settings.System.putInt(mResolver, "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(resolver, "qch_restore_forbid_on", 0); + boolean qch_restore_forbid_on = Settings.System.putInt(mResolver, "qch_restore_forbid_on", 0); Log.e(TAG, "qch_restore_forbid_on:" + qch_restore_forbid_on); //默认打开 } @@ -572,7 +577,7 @@ public class ControlManager { * @param state */ private void setBrowserInput(int state) { - Settings.System.putInt(resolver, "qch_Browser_input", 0); + Settings.System.putInt(mResolver, "qch_Browser_input", 0); } public void setDeveloperOptions(String jsonString) { @@ -580,7 +585,7 @@ public class ControlManager { int dev_mode = changeNum(jsonObject.getIntValue("dev_mode")); Log.e(TAG, "getDeveloper: " + dev_mode); if (!DeviceManager.isDebugMode()) { - JGYUtils.putInt(resolver, "qch_Developeroptions", dev_mode); + JGYUtils.putInt(mResolver, "qch_Developeroptions", dev_mode); if (dev_mode == 1) { Intent intent = new Intent(); intent.setAction("qch_developeroptions_close"); @@ -598,7 +603,7 @@ public class ControlManager { public void setDeveloperOptions(int state) { Log.e(TAG, "getDeveloper: " + state); if (!DeviceManager.isDebugMode()) { - Settings.System.putInt(resolver, "qch_Developeroptions", state); + Settings.System.putInt(mResolver, "qch_Developeroptions", state); if (state == 1) { Intent intent = new Intent(); intent.setAction("qch_developeroptions_close"); @@ -632,7 +637,7 @@ public class ControlManager { //仅充电:usb_charge //MTP模式:usb_mtp //Midi模式:usb_midi - String setting_usb = JGYUtils.getString(resolver, "qch_usb_choose"); + String setting_usb = JGYUtils.getString(mResolver, "qch_usb_choose"); Log.e("SystemSetting", "setting_usb:" + setting_usb); String usbStatus = ""; if (TextUtils.isEmpty(setting_usb)) { @@ -661,7 +666,7 @@ public class ControlManager { private void setSOSNumber(SystemSettings settings) { String setting_sos = settings.getSetting_sos(); - Settings.System.putString(resolver, "setting_sos", setting_sos); + Settings.System.putString(mResolver, "setting_sos", setting_sos); Intent intent = new Intent("setting_sos"); intent.putExtra("setting_sos", setting_sos); intent.setPackage("com.uiui.os"); @@ -672,7 +677,6 @@ public class ControlManager { int setting_volume = settings.getSetting_volume(); int setting_luminance = settings.getSetting_luminance(); String setting_typeface = settings.getSetting_typeface(); - } } diff --git a/app/src/main/java/com/uiui/sn/manager/ControlPanelManager.java b/app/src/main/java/com/uiui/sn/manager/ControlPanelManager.java new file mode 100644 index 0000000..cd7f9f0 --- /dev/null +++ b/app/src/main/java/com/uiui/sn/manager/ControlPanelManager.java @@ -0,0 +1,77 @@ +package com.uiui.sn.manager; + +import android.annotation.SuppressLint; +import android.content.ContentResolver; +import android.content.Context; +import android.hardware.usb.UsbManager; +import android.util.Log; + +import com.tencent.mmkv.MMKV; + +/** + * 控制面板管理类 + */ +public class ControlPanelManager { + private static final String TAG = ControlPanelManager.class.getSimpleName(); + + @SuppressLint("StaticFieldLeak") + private static ControlPanelManager sInstance; + private Context mContext; + private ContentResolver mResolver; + private MMKV mmkv; + private UsbManager mUsbManager; + + public static final String KEY_USB_STATUS = "KEY_USB_STATUS"; + public static final String USB_STATUS_CHARGE = "usb_charge"; + public static final String USB_STATUS_MTP = "usb_mtp"; + public static final String USB_STATUS_MIDI = "usb_midi"; + + private ControlPanelManager(Context context) { + if (context == null) { + throw new RuntimeException("Context is NULL"); + } + this.mContext = context; + this.mResolver = context.getContentResolver(); + mUsbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE); + mmkv = MMKV.defaultMMKV(); + } + + public static void init(Context context) { + if (sInstance == null) { + sInstance = new ControlPanelManager(context); + } + } + + public static ControlPanelManager getInstance() { + if (sInstance == null) { + throw new IllegalStateException("You must be init ControlPanelManager first"); + } + return sInstance; + } + + + public boolean setUsbStatus(String action) { + String functions = UsbManager.USB_FUNCTION_NONE; + switch (action) { + case USB_STATUS_CHARGE: + functions = UsbManager.USB_FUNCTION_NONE; + break; + case USB_STATUS_MTP: + functions = UsbManager.USB_FUNCTION_MTP; + break; + case USB_STATUS_MIDI: + functions = UsbManager.USB_FUNCTION_MIDI; + break; + default: + } + mmkv.encode(KEY_USB_STATUS, action); + try { + mUsbManager.setCurrentFunction(functions, true); + } catch (Exception e) { + Log.e(TAG, "setUsbStatus: " + e.getLocalizedMessage()); + } + return true; + } + + +} diff --git a/app/src/main/java/com/uiui/sn/receiver/BootReceiver.java b/app/src/main/java/com/uiui/sn/receiver/BootReceiver.java index ee78638..0128ecf 100644 --- a/app/src/main/java/com/uiui/sn/receiver/BootReceiver.java +++ b/app/src/main/java/com/uiui/sn/receiver/BootReceiver.java @@ -5,10 +5,12 @@ import android.content.Context; import android.content.Intent; import android.util.Log; +import com.uiui.sn.service.ControlPanelService; import com.uiui.sn.service.GuardService; import com.uiui.sn.service.MainService; import com.uiui.sn.service.ManagerService; import com.uiui.sn.service.DownloadService; +import com.uiui.sn.service.RemoteService; import com.uiui.sn.service.StepService; @@ -40,6 +42,7 @@ public class BootReceiver extends BroadcastReceiver { context.startService(new Intent(context, StepService.class)); context.startService(new Intent(context, DownloadService.class)); context.startService(new Intent(context, ManagerService.class)); + context.startService(new Intent(context, ControlPanelService.class)); } } } diff --git a/app/src/main/java/com/uiui/sn/receiver/MyJPushReceiver.java b/app/src/main/java/com/uiui/sn/receiver/MyJPushReceiver.java index 3a5179d..5c24957 100644 --- a/app/src/main/java/com/uiui/sn/receiver/MyJPushReceiver.java +++ b/app/src/main/java/com/uiui/sn/receiver/MyJPushReceiver.java @@ -1,7 +1,6 @@ package com.uiui.sn.receiver; import android.annotation.SuppressLint; -import android.app.NotificationManager; import android.bluetooth.BluetoothAdapter; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -10,8 +9,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.media.AudioManager; import android.os.Bundle; import android.os.CountDownTimer; @@ -28,19 +25,15 @@ import com.alibaba.fastjson.JSONObject; import com.android.internal.view.RotationPolicy; import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.download.DownloadEntity; -import com.blankj.utilcode.util.ImageUtils; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import com.uiui.sn.R; import com.uiui.sn.bean.zuoye.BaseResponse; import com.uiui.sn.dialog.CustomDialog; import com.uiui.sn.jpush.Logger; import com.uiui.sn.manager.ControlManager; +import com.uiui.sn.manager.ControlPanelManager; import com.uiui.sn.manager.DeviceManager; import com.uiui.sn.manager.NetInterfaceManager; import com.uiui.sn.network.HTTPInterface; -import com.uiui.sn.network.api.UploadScreenshot; import com.uiui.sn.service.MainService; import com.uiui.sn.service.ManagerService; import com.uiui.sn.utils.ApkUtils; @@ -52,12 +45,8 @@ import com.uiui.sn.utils.ServiceAliveUtils; import com.uiui.sn.utils.ToastUtil; import com.uiui.sn.utils.Utils; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -201,7 +190,8 @@ public class MyJPushReceiver extends BroadcastReceiver { private static final String JIGUANG_SOS_PHONENUM = "61"; //重新安装应用 private static final String JIGUANG_REINSTALL_APP = "62"; - + //显示所有的admin应用 + private static final String JIGUANG_ADMIN_APP = "63"; @Override public void onReceive(Context context, Intent intent) { @@ -257,7 +247,7 @@ public class MyJPushReceiver extends BroadcastReceiver { break; case JIGUANG_USB_STATE: ToastUtil.debugShow("收到推送消息: USB连接模式管控"); - setUsbState(context, extras); + setUsbStatus(context, extras); break; case JIGUANG_TFCARD_STATE: ToastUtil.debugShow("收到推送消息: TF卡管控"); @@ -494,9 +484,18 @@ public class MyJPushReceiver extends BroadcastReceiver { case JIGUANG_REINSTALL_APP: reinstallApp(context, extras); break; + case JIGUANG_ADMIN_APP: + setAdminApp(context, extras); + break; } } + private void setAdminApp(Context context, String extras) { + JSONObject jsonObject = JSON.parseObject(extras); + int setting_admin_app = jsonObject.getInteger("setting_admin_app"); + Settings.System.putInt(context.getContentResolver(), "setting_admin_app", setting_admin_app); + } + private void setZenMode(Context context, String extras) { JSONObject jsonObject = JSON.parseObject(extras); @@ -571,29 +570,30 @@ public class MyJPushReceiver extends BroadcastReceiver { } } - synchronized private void setUsbState(Context context, String jsonString) { + synchronized private void setUsbStatus(Context context, String jsonString) { if (!TextUtils.isEmpty(jsonString)) { JSONObject jsonObject = JSON.parseObject(jsonString); String setting_usb = jsonObject.getString("setting_usb"); - boolean qch_usb_choose = JGYUtils.putString(context.getContentResolver(), "qch_usb_choose", setting_usb); - Log.e("setUsbState:", JGYUtils.getString(context.getContentResolver(), "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"); - context.sendBroadcast(usbIntent); + ControlPanelManager.getInstance().setUsbStatus(setting_usb); +// boolean qch_usb_choose = JGYUtils.putString(context.getContentResolver(), "qch_usb_choose", setting_usb); +// Log.e("setUsbState:", JGYUtils.getString(context.getContentResolver(), "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"); +// context.sendBroadcast(usbIntent); } else { ToastUtil.debugShow("setUsbState jsonString is NULL"); } diff --git a/app/src/main/java/com/uiui/sn/service/ControlPanelService.java b/app/src/main/java/com/uiui/sn/service/ControlPanelService.java new file mode 100644 index 0000000..8d2b575 --- /dev/null +++ b/app/src/main/java/com/uiui/sn/service/ControlPanelService.java @@ -0,0 +1,104 @@ +package com.uiui.sn.service; + +import android.app.Service; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.hardware.usb.UsbManager; +import android.hardware.usb.UsbPortStatus; +import android.os.Bundle; +import android.os.IBinder; +import android.util.Log; + +public class ControlPanelService extends Service { + private static final String TAG = ControlPanelService.class.getSimpleName(); + + public ControlPanelService() { + } + + @Override + public IBinder onBind(Intent intent) { + return null; + } + + @Override + public void onCreate() { + super.onCreate(); + registerUsbConnectionReceiver(); + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + return super.onStartCommand(intent, flags, startId); + } + + @Override + public void onDestroy() { + super.onDestroy(); + + } + + + private void registerUsbConnectionReceiver() { + if (mUsbConnectionReceiver == null) { + mUsbConnectionReceiver = new UsbConnectionReceiver(); + } + IntentFilter filter = new IntentFilter(); + filter.addAction(UsbManager.ACTION_USB_STATE); + filter.addAction(UsbManager.ACTION_USB_PORT_CHANGED); + registerReceiver(mUsbConnectionReceiver, filter); + } + + UsbConnectionReceiver mUsbConnectionReceiver; + + private boolean mConnected; + private long mFunctions; +// private int mDataRole; +// private int mPowerRole; + + public class UsbConnectionReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + Log.e(TAG, "onReceive: " + intent.getAction()); + Bundle bundle = intent.getExtras(); + if (UsbManager.ACTION_USB_STATE.equals(intent.getAction())) { + mConnected = intent.getExtras().getBoolean(UsbManager.USB_CONNECTED) + || intent.getExtras().getBoolean(UsbManager.USB_HOST_CONNECTED); + long functions = UsbManager.FUNCTION_NONE; + if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_MTP) + && intent.getExtras().getBoolean(UsbManager.USB_DATA_UNLOCKED, false)) { + functions |= UsbManager.FUNCTION_MTP; + } + if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_PTP) + && intent.getExtras().getBoolean(UsbManager.USB_DATA_UNLOCKED, false)) { + functions |= UsbManager.FUNCTION_PTP; + } + if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_MIDI)) { + functions |= UsbManager.FUNCTION_MIDI; + } + if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_RNDIS)) { + functions |= UsbManager.FUNCTION_RNDIS; + } + if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_ACCESSORY)) { + functions |= UsbManager.FUNCTION_ACCESSORY; + } + mFunctions = functions; + +// mDataRole = mUsbBackend.getDataRole(); +// mPowerRole = mUsbBackend.getPowerRole(); + } else if (UsbManager.ACTION_USB_PORT_CHANGED.equals(intent.getAction())) { + UsbPortStatus portStatus = intent.getExtras() + .getParcelable(UsbManager.EXTRA_PORT_STATUS); + if (portStatus != null) { +// mDataRole = portStatus.getCurrentDataRole(); +// mPowerRole = portStatus.getCurrentPowerRole(); + } + } +// if (mUsbConnectionListener != null) { +// mUsbConnectionListener.onUsbConnectionChanged(mConnected, mFunctions, mPowerRole, +// mDataRole); +// } + } + } +} diff --git a/app/src/main/java/com/uiui/sn/service/DownloadService.java b/app/src/main/java/com/uiui/sn/service/DownloadService.java index aacdeec..4608200 100644 --- a/app/src/main/java/com/uiui/sn/service/DownloadService.java +++ b/app/src/main/java/com/uiui/sn/service/DownloadService.java @@ -35,6 +35,7 @@ public class DownloadService extends Service { startService(new Intent(this, GuardService.class)); startService(new Intent(this, MainService.class)); startService(new Intent(this, ManagerService.class)); + startService(new Intent(this, ControlPanelService.class)); Aria.download(this).register(); //恢复所有未完成的下载任务 Aria.download(this).resumeAllTask(); diff --git a/app/src/main/java/com/uiui/sn/service/ManagerService.java b/app/src/main/java/com/uiui/sn/service/ManagerService.java index cf3b8b2..88f7422 100644 --- a/app/src/main/java/com/uiui/sn/service/ManagerService.java +++ b/app/src/main/java/com/uiui/sn/service/ManagerService.java @@ -345,6 +345,7 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta setFloatingWindow(); } + // String packages = ForegroundAppUtil.getForegroundPackageName(context); // if (!packages.equals("com.estrongs.android.pop")) { // ApkUtils.openApp(context, "com.estrongs.android.pop"); diff --git a/app/src/main/java/com/uiui/sn/utils/JGYUtils.java b/app/src/main/java/com/uiui/sn/utils/JGYUtils.java index 949d11f..6f53cee 100644 --- a/app/src/main/java/com/uiui/sn/utils/JGYUtils.java +++ b/app/src/main/java/com/uiui/sn/utils/JGYUtils.java @@ -82,6 +82,8 @@ public class JGYUtils { this.add("com.uiuios.jgy2"); this.add("com.info.chat"); this.add("com.info.learning"); + this.add("com.uiui.multios"); + }}; public HashSet getOwnApp() { @@ -236,14 +238,14 @@ public class JGYUtils { } - private void sendAllweb() { + private void sendAllweb() { Intent intent = new Intent("qch_app_website") .setPackage("com.android.settings"); intent.putExtra("package_name", "Invalid"); mContext.sendBroadcast(intent); } - private void sendwebUrl() { + private void sendwebUrl() { Intent intent = new Intent("qch_app_inside_website") .setPackage("com.android.settings"); intent.putExtra("websitelist", "Invalid"); @@ -563,7 +565,7 @@ public class JGYUtils { } } - public int isWifiConnect() { + public int isWifiConnect() { // 网络管理对象 ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE); // 获取所有类型的链接管理对象 @@ -603,7 +605,7 @@ public class JGYUtils { /** * 获取当前进程名 */ - public String getCurrentProcessName() { + public String getCurrentProcessName() { int pid = android.os.Process.myPid(); String processName = ""; ActivityManager manager = (ActivityManager) mContext.getSystemService