diff --git a/app/build.gradle b/app/build.gradle index 0a5a093..0d11462 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -637,6 +637,8 @@ dependencies { compileOnly files('libs/framework.jar') compileOnly files('libs/cube_mdm.jar') compileOnly files('libs/cube_sdk_v1.0.0.jar') + //版本高了idea plugin 下载VisualClassBytes修改version jclasslib最好用 + compileOnly files('libs/qz_cubemdm_sdk_v1.0.0_1.8.jar') implementation files('libs/ebf_tools_v1.0.jar') implementation files('libs/vendor.mediatek.hardware.nvram-V1.0-java.jar') @@ -645,7 +647,7 @@ dependencies { implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0' + implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' implementation 'androidx.appcompat:appcompat:1.3.1' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' diff --git a/app/libs/qz_cubemdm_sdk_v1.0.0_1.8.jar b/app/libs/qz_cubemdm_sdk_v1.0.0_1.8.jar new file mode 100644 index 0000000..58c1322 Binary files /dev/null and b/app/libs/qz_cubemdm_sdk_v1.0.0_1.8.jar differ diff --git a/app/src/main/java/com/aoleyun/sn/network/NetInterfaceManager.java b/app/src/main/java/com/aoleyun/sn/network/NetInterfaceManager.java index 494bf2a..583efc1 100644 --- a/app/src/main/java/com/aoleyun/sn/network/NetInterfaceManager.java +++ b/app/src/main/java/com/aoleyun/sn/network/NetInterfaceManager.java @@ -10,6 +10,7 @@ import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.cubemdm.cubemdmmanager.CubeMdmManager; import android.graphics.drawable.Drawable; import android.os.Build; import android.provider.Settings; @@ -1222,6 +1223,10 @@ public class NetInterfaceManager { boolean aole_force_app = Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, String.join(",", forceApp)); Log.e("getForceDownload", "aole_force_app:" + aole_force_app); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm"); + cubeMdmManager.setForbidUnInstallPackageList(forceApp); + } } callback.onComplete(); } @@ -1264,10 +1269,18 @@ public class NetInterfaceManager { boolean aole_force_app = Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, String.join(",", forceApp)); Log.e("getForceDownload", "aole_force_app:" + aole_force_app); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm"); + cubeMdmManager.setForbidUnInstallPackageList(forceApp); + } } else if (forceDownloadBean.code == -200) { cacheHelper.put(UrlAddress.GET_FORCE_INSTALL_LIST, ""); boolean aole_force_app = Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, "invalid"); Log.e("getForceDownload", "aole_force_app:" + aole_force_app); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm"); + cubeMdmManager.setForbidUnInstallPackageList(new ArrayList<>()); + } } else { cacheHelper.put(UrlAddress.GET_FORCE_INSTALL_LIST, ""); Log.e("getForceDownload", forceDownloadBean.msg); diff --git a/app/src/main/java/com/aoleyun/sn/push/PushManager.java b/app/src/main/java/com/aoleyun/sn/push/PushManager.java index 00672d3..075d6fd 100644 --- a/app/src/main/java/com/aoleyun/sn/push/PushManager.java +++ b/app/src/main/java/com/aoleyun/sn/push/PushManager.java @@ -9,6 +9,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.cubemdm.cubemdmmanager.CubeMdmManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.media.AudioManager; @@ -715,9 +716,17 @@ public class PushManager { List forceAppList = new ArrayList<>(Arrays.asList(forceApp.split(","))); forceAppList.remove(pkg); if (forceAppList.size() != 0) { + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm"); + cubeMdmManager.setForbidUnInstallPackageList(forceAppList); + } Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, String.join(",", forceAppList)); } else { Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, ""); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm"); + cubeMdmManager.setForbidUnInstallPackageList(new ArrayList<>()); + } } } ApkUtils.UninstallAPP(mContext, pkg); diff --git a/app/src/main/java/com/aoleyun/sn/service/StepService.java b/app/src/main/java/com/aoleyun/sn/service/StepService.java index a23730d..79ab427 100644 --- a/app/src/main/java/com/aoleyun/sn/service/StepService.java +++ b/app/src/main/java/com/aoleyun/sn/service/StepService.java @@ -242,7 +242,12 @@ public class StepService extends Service implements NetworkUtils.OnNetworkStatus } if (null != client) { Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toString()); - client.send(jsonObject.toString()); + try { + client.send(jsonObject.toString()); + } catch (Exception e) { + Log.e(TAG, "sendMsg: " + e.getMessage()); + } + } } diff --git a/app/src/main/java/com/aoleyun/sn/utils/JgyUtils.java b/app/src/main/java/com/aoleyun/sn/utils/JgyUtils.java index 3cf19dc..3603bb4 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/JgyUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/JgyUtils.java @@ -18,6 +18,7 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.UserInfo; +import android.cubemdm.cubemdmmanager.CubeMdmManager; import android.graphics.Bitmap; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -2067,6 +2068,10 @@ public class JgyUtils { if (Settings.Global.getInt(crv, Settings.Global.ADB_ENABLED, 0) != state) { Settings.Global.putInt(crv, Settings.Global.ADB_ENABLED, state); } + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm"); + cubeMdmManager.setDeveloperEnable(state == 1); + } } } @@ -2735,6 +2740,11 @@ public class JgyUtils { // } intent.setPackage("com.android.settings"); mContext.sendBroadcast(intent); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) mContext.getSystemService("cube_mdm"); + cubeMdmManager.setDefaultLauncher(pkg); + } + // ApkUtils.openPackage(mContext, pkg); Log.e(TAG, "setDefaultDesktop: " + pkg + ":" + className); Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.pkgname = " + SystemProperties.get("persist.sys.launcher.pkgname")); @@ -3053,6 +3063,11 @@ public class JgyUtils { return getHardware().startsWith(UNISOC_HARDWARE) && Build.BRAND.equalsIgnoreCase(CUBE_BRAND); } + public static boolean isAllWinnerDevice() { + return JgyUtils.getInstance().checkAppPlatform() == U1302Platform; + } + + public boolean isScreenOn() { PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); //true为打开,false为关闭 diff --git a/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java b/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java index e8e81e2..07b3f48 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java @@ -6,6 +6,7 @@ import android.bluetooth.BluetoothAdapter; import android.content.Context; import android.content.Intent; import android.cube.SuperPower; +import android.cubemdm.cubemdmmanager.CubeMdmManager; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; @@ -183,11 +184,6 @@ public class SysSettingUtils { // ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+aole_white_list_Array+"---"+qch_call_forbid); Log.e(TAG, "aole_white_list_Array:" + aole_white_list_Array + "---" + setting_phones); } - //存储卡 - int setting_memory = changeNum(jsonObject.get("setting_memory").getAsInt()); - JgyUtils.getInstance().setSDOTGEnable(setting_memory == 0); - boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, setting_memory); - Log.e(TAG, "aole_sdcard_forbid_on:" + aole_sdcard_forbid_on); } catch (Exception e) { Log.e(TAG, "setPhoneList: " + e.getMessage()); } @@ -199,15 +195,35 @@ public class SysSettingUtils { //MTP模式:usb_mtp //Midi模式:usb_midi if (!BuildConfig.DEBUG) { - try { + if (JgyUtils.isCubeDevice()) { + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setUsbStatus(state); + Log.e(TAG, "setUSBstate: state = " + state); + } else { + SuperPower mService = (SuperPower) context.getSystemService("mdm"); + mService.setUsbDataDisabled(true); + } + } else { String oldUsb = Settings.System.getString(context.getContentResolver(), "aole_usb_choose"); if ("usb_charge".equals(oldUsb)) { Log.e(TAG, "setUSBstate: oldUsb = " + oldUsb + " no changed , skip"); return; } boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", "usb_charge"); - Log.e(TAG, "aole_usb_choose:" + aole_usb_choose); - String usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; + Log.e("setUSBstate", "aole_usb_choose: " + aole_usb_choose); + String usbStatus; + switch (state) { + default: + case 0: + usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; + JgyUtils.getInstance().setMtpEnable(false); + break; + case 1: + usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP; + JgyUtils.getInstance().setMtpEnable(true); + break; + } if (JgyUtils.getInstance().checkAppPlatform() == JgyUtils.AH6016Platform) { usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP; } @@ -218,11 +234,6 @@ public class SysSettingUtils { usbIntent.setPackage("com.android.settings"); } context.sendBroadcast(usbIntent); - - SuperPower mService = (SuperPower) context.getSystemService("mdm"); - mService.setUsbDataDisabled(true); - } catch (NoClassDefFoundError | Exception e) { - Log.e(TAG, "setUSBstate: " + e.getMessage()); } } } @@ -240,15 +251,33 @@ public class SysSettingUtils { } if (!BuildConfig.DEBUG) { if (JgyUtils.isCubeDevice()) { - SuperPower mService = (SuperPower) context.getSystemService("mdm"); - switch (setting_usb) { - case "usb_charge": - mService.setUsbDataDisabled(true); - break; - case "usb_mtp": - mService.setUsbDataDisabled(false); - break; - default: + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + switch (setting_usb) { + case "usb_charge": + cubeMdmManager.setUsbStatus(0); + break; + case "usb_mtp": + cubeMdmManager.setUsbStatus(1); + break; + case "usb_midi": + cubeMdmManager.setUsbStatus(2); + break; + default: + } + Log.e(TAG, "setUSBstate: setting_usb = " + setting_usb); + } else { + SuperPower mService = (SuperPower) context.getSystemService("mdm"); + switch (setting_usb) { + case "usb_mtp": + mService.setUsbDataDisabled(false); + break; + default: + case "usb_midi": + case "usb_charge": + mService.setUsbDataDisabled(true); + break; + } } } else { boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb); @@ -333,6 +362,10 @@ public class SysSettingUtils { } JgyUtils.getInstance().setBluetoothEnable(state == 0); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setBluetoothEnable(state == 0); + } } /** @@ -391,7 +424,6 @@ public class SysSettingUtils { } } - int old_setting_bht = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, 1); Log.e(TAG, "setBluetooth: old_setting_bht = " + old_setting_bht); int old_setting_bluetooth = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, 1); @@ -436,6 +468,11 @@ public class SysSettingUtils { } JgyUtils.getInstance().setBluetoothEnable(setting_bht == 0); + + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setBluetoothEnable(setting_bht == 0); + } } private static void setHotspot(Context context, int state) { @@ -446,6 +483,11 @@ public class SysSettingUtils { context.sendStickyBroadcast(intent); boolean aole_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HOTSPOT_FORBID_ON, state); Log.e(TAG, "aole_hotspot_forbid_on:" + aole_hotspot_forbid_on); + + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setWifiHotSpotStatus(state); + } } catch (Exception e) { Log.e(TAG, "setHotspot: " + e.getMessage()); } @@ -463,6 +505,11 @@ public class SysSettingUtils { boolean aole_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HOTSPOT_FORBID_ON, setting_hotspot); Log.e(TAG, "aole_hotspot_forbid_on---------" + setting_hotspot); Log.e(TAG, "aole_hotspot_forbid_on---------" + aole_hotspot_forbid_on); + + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setWifiHotSpotStatus(setting_hotspot); + } } catch (Exception e) { Log.e(TAG, "setHotspot: " + e.getMessage()); } @@ -516,6 +563,7 @@ public class SysSettingUtils { private static void setBar(Context context, JsonObject jsonObject) { //系统导航条显示开关 int setting_navigation = changeNum(jsonObject.get("setting_navigation").getAsInt()); + Log.e(TAG, "setBar: setting_navigation = " + setting_navigation); //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 boolean aole_hide_NavigationBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR, setting_navigation); Log.e(TAG, "aole_hide_NavigationBar---------" + aole_hide_NavigationBar); @@ -534,6 +582,11 @@ public class SysSettingUtils { Intent navIntent = new Intent(navigationStatus); context.sendBroadcast(navIntent); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setNavigationStatus(setting_navigation == 0); + Log.e(TAG, "setBar: setNavigationStatus = " + (setting_navigation == 0)); + } //状态栏显示开关 int setting_statusbar = changeNum(jsonObject.get("setting_statusbar").getAsInt()); @@ -558,6 +611,12 @@ public class SysSettingUtils { // Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); context.sendBroadcast(statusIntent); // } + + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setStatusBarEnable(setting_statusbar == 0); + Log.e(TAG, "setBar: setStatusBarEnable = " + (setting_statusbar == 0)); + } } private static void setCamera(Context context, int state) { @@ -609,6 +668,15 @@ public class SysSettingUtils { } private static void setTF(Context context, int state) { + //存储卡 + JgyUtils.getInstance().setSDOTGEnable(state == 0); + boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, state); + Log.e(TAG, "setTF: aole_sdcard_forbid_on = " + aole_sdcard_forbid_on); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setSDEnable(state == 0); + } + try { //tfmedia开关 // int setting_tfmedia = 1; @@ -634,6 +702,8 @@ public class SysSettingUtils { } catch (Exception e) { Log.e(TAG, "setTF: " + e.getMessage()); } + + } /** @@ -641,13 +711,23 @@ public class SysSettingUtils { * @param jsonObject tfmedia开关 */ private static void setTF(Context context, JsonObject jsonObject) { + //存储卡 + int setting_memory = changeNum(jsonObject.get("setting_memory").getAsInt()); + Log.e(TAG, "setTF: setting_memory = " + setting_memory); + JgyUtils.getInstance().setSDOTGEnable(setting_memory == 0); + boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, setting_memory); + Log.e(TAG, "setTF: aole_sdcard_forbid_on = " + aole_sdcard_forbid_on); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setSDEnable(setting_memory == 0); + } + try { int setting_tfmedia = jsonObject.get("setting_tfmedia").getAsInt(); // if (JgyUtils.isOfficialVersion() ) { // setting_tfmedia = changeNum(setting_tfmedia); // } - boolean qch_tfmedia_forbid = Settings.System.putInt(context.getContentResolver(), - "qch_tfmedia_forbid", setting_tfmedia); + boolean qch_tfmedia_forbid = Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", setting_tfmedia); Log.e(TAG, "setting_tfmedia---------" + qch_tfmedia_forbid); String tfmediaStatus = ""; switch (setting_tfmedia) { @@ -700,6 +780,11 @@ public class SysSettingUtils { Log.e(TAG, "setCanReset: state = " + state); Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, state); //默认打开 + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setResetFactoryEnable(state == 0); + Log.e(TAG, "setCanReset: setResetFactoryEnable = " + (state == 0)); + } } //aole_restore_forbid_on=1,禁止恢复出厂设置 @@ -712,6 +797,12 @@ public class SysSettingUtils { } else { Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 1); } + + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setResetFactoryEnable(mode == 1); + Log.e(TAG, "setCanReset: setResetFactoryEnable = " + (mode == 1)); + } } //系统默认“使用网络提供时间”且不可点击 @@ -866,10 +957,15 @@ public class SysSettingUtils { int is_app_install = appInstall.getAsInt(); Log.e(TAG, "setAdminApp: is_app_install = " + is_app_install); Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, is_app_install); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setInstallPackageEnable(is_app_install == 1); + } } else { Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, 0); } + JsonElement adminApp = jsonObject.get("is_admin_app"); if (adminApp != null) { int is_admin_app = adminApp.getAsInt(); @@ -890,6 +986,10 @@ public class SysSettingUtils { private static void setAdminApp(Context context, int state) { Log.e(TAG, "setAdminApp: state = " + state); + if (JgyUtils.isAllWinnerDevice()) { + CubeMdmManager cubeMdmManager = (CubeMdmManager) context.getSystemService("cube_mdm"); + cubeMdmManager.setInstallPackageEnable(state == 0); + } Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_APP_ALLOW_INSTALL, changeNum(state)); Settings.Global.putInt(context.getContentResolver(), "is_admin_app", changeNum(state)); }