diff --git a/app/src/main/java/com/fuying/sn/push/PushManager.java b/app/src/main/java/com/fuying/sn/push/PushManager.java index 416256f..2abebba 100644 --- a/app/src/main/java/com/fuying/sn/push/PushManager.java +++ b/app/src/main/java/com/fuying/sn/push/PushManager.java @@ -308,245 +308,169 @@ public class PushManager { public void setPushContent(String title, String extras) { switch (title) { case PUSH_GET_DRIVELINE: - ToastUtil.debugShow("收到推送消息: 获取在线信息"); + showDeviceOnlinePush(); break; case PUSH_GET_STARTTIME: - ToastUtil.debugShow("收到推送消息: 获取运行应用"); - updateUserSettings(); - sendStartTime(extras); + handleStartTimePush(extras); break; case PUSH_USB_STATE: - ToastUtil.debugShow("收到推送消息: USB连接模式管控"); setUsbStatus(extras); break; case PUSH_TFCARD_STATE: - ToastUtil.debugShow("收到推送消息: TF卡管控"); setTfcardState(extras); break; case PUSH_BLUETOOTH_STATE: - ToastUtil.debugShow("收到推送消息: 蓝牙管控"); setBluetoothState(extras); break; case PUSH_BROWSER_URLPATH: - ToastUtil.debugShow("收到推送消息: 浏览器上网管控"); - try { - new CacheUtils().cleanApplicationUserData(mContext, "com.android.browser"); - } catch (Exception e) { - e.printStackTrace(); - } - new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { - @Override - public void run() { - BrowserPolicySync.getInstance().setBrowserWhiteList(); - } - }, 2000); + setBrowserUrlPath(); break; case PUSH_APP_NETWORKSTATE: - ToastUtil.debugShow("收到推送消息: 应用联网管控"); - new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { - @Override - public void run() { - AppInventorySync.getInstance().getAppInside(); - } - }, 2000); + setAppNetworkState(); break; case PUSH_APP_LOCKEDSTATE: - ToastUtil.debugShow("收到推送消息: 应用锁管控"); setAppLockedstate(extras); break; case PUSH_FORCE_INSTALLAPK: - ToastUtil.debugShow("收到推送消息: 强制安装应用"); -// AppInventorySync.getInstance().getAllappPackage(); -// AppUpdateCoordinator.getInstance().getOverallApp(); - intallApk(extras); + handleForceInstallapkPush(extras); break; case PUSH_FORCE_UNINSTALLAPK: - ToastUtil.debugShow("收到推送消息: 强制卸载应用"); unintallApk(extras); break; case PUSH_BIND_DEVIVES: - ToastUtil.debugShow("收到推送消息: 绑定设备"); bindService(extras); break; case PUSH_TFMEDIA: - ToastUtil.debugShow("收到推送消息: 影音格式管控"); + setTfMedia(); break; case PUSH_CAMRERA: - ToastUtil.debugShow("收到推送消息: 摄像头管控"); - setCameta(extras); - JgyUtils.getInstance().updateForbidList(); + handleCameraPush(extras); break; case PUSH_PHONE: - ToastUtil.debugShow("收到推送消息: 电话管控"); - setPhone(extras); + handlePhonePush(extras); break; case PUSH_DISABLE_UPDATAE: - ToastUtil.debugShow("收到推送消息: 禁止升级"); setAppUpdate(extras); break; case PUSH_APP_WEBSITE: - ToastUtil.debugShow("收到推送消息: app内部网址管控"); setAppInsideNetwork(extras); break; - case PUSH_REBOOT_DEVICES: - ToastUtil.debugShow("收到推送消息: 重启"); - DeviceManager.rebootDevices(); - break; - case PUSH_APP_NET_AUTO: - ToastUtil.debugShow("收到推送消息: APP联网自启管控"); - new Handler(Looper.getMainLooper()).postDelayed(() -> AppInventorySync.getInstance().getAllappPackage(), 2000); + case PUSH_RESET_DEVICES: + resetDevices(); break; case PUSH_BROWSER_LABEL: - ToastUtil.debugShow("收到推送消息: 浏览器书签"); - try { - new CacheUtils().cleanApplicationUserData(mContext, "com.android.browser"); - } catch (Exception e) { - e.printStackTrace(); - } - //延时2秒执行,以防收到推送数据库还没有生效 - new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { - @Override - public void run() { - BrowserPolicySync.getInstance().getBrowserWhiteList(); - BrowserPolicySync.getInstance().getBrowserLabel(); - } - }, 2000); + setBrowserLabel(); + break; + case PUSH_APP_NET_AUTO: + setAppNetworkAuto(); break; case PUSH_SYSTEM_SETTING: - ToastUtil.debugShow("收到推送消息: 系统管控"); - updateUserSettings(); + handleSystemSettingsPush(); break; - case PUSH_RESET_DEVICES: - ToastUtil.debugShow("收到推送消息: 设备恢复出厂设置"); - try { - mCacheHelper.delete(); - } catch (IOException e) { - e.printStackTrace(); - } - DeviceManager.doMasterClear(); + case PUSH_REBOOT_DEVICES: + rebootDevices(); break; case PUSH_APP_SETTING: - ToastUtil.debugShow("收到推送消息: 获取app管控设置"); - new Handler(Looper.getMainLooper()).postDelayed(() -> AppInventorySync.getInstance().getAllappPackage(), 2000); + setAppSettings(); break; case PUSH_FORCE_KILL: - ToastUtil.debugShow("收到推送消息: 强制停止应用"); - JsonObject killJSONObject = GsonUtils.getJsonObject(extras); - String packages = killJSONObject.get("app_package").getAsString(); - JgyUtils.getInstance().killPackage(packages); - JgyUtils.getInstance().gotoLauncher(); - Log.e(TAG, extras); + forceKillApp(extras); break; case PUSH_LOCK_SCREEN: - ToastUtil.debugShow("收到推送消息: 锁屏"); - setLock_screen(extras); - Log.e(TAG, extras); + handleLockScreenPush(extras); break; case PUSH_SNAPSHOT: - ToastUtil.debugShow("收到推送消息: 截图"); - doscreenshot(mContext); - Log.e(TAG, extras); + handleSnapshotPush(extras); break; case PUSH_TIME_CONTROL: - ToastUtil.debugShow("收到推送消息: 时间管控"); + setTimeControl(); break; case PUSH_HOTSPOT_CONTROL: - ToastUtil.debugShow("收到推送消息: 热点管控"); setHotspot(extras); break; case PUSH_RESTORE_CONTROL: - ToastUtil.debugShow("收到推送消息: 恢复出厂设置管控"); setRestore(extras); break; case PUSH_BROWSER_CONTROL: - ToastUtil.debugShow("收到推送消息: 浏览器禁止输入"); setBrowserInput(extras); break; case PUSH_DEVELOPER_CONTROL: - ToastUtil.debugShow("收到推送消息: 开发人员选项"); - ControlManager.getInstance().setDeveloperOptions(extras); + setDeveloperControl(extras); break; case PUSH_CLEAN_APP_CACHE: - ToastUtil.debugShow("收到推送消息: 清除应用缓存"); cleanAppCache(extras); break; case PUSH_APP_RECORDER: + handleSystemAppPush(); + break; case PUSH_APP_FILE_MANAGER: + handleSystemAppPush(); + break; case PUSH_APP_GALLERY: + handleSystemAppPush(); + break; case PUSH_APP_MUSIC: - ToastUtil.debugShow("收到推送消息: 系统APP管控"); - hideDesktopIcon(); + handleSystemAppPush(); break; case PUSH_SEARCH_TOPIC: - ToastUtil.debugShow("收到推送消息: 搜题开关"); searchTopic(extras); break; case PUSH_PHONE_LIST: - ToastUtil.debugShow("收到推送消息: 电话白名单管控"); - setPhone(extras); + handlePhoneListPush(extras); break; case PUSH_CHANGE_COMBO: - ToastUtil.debugShow("更换套餐"); + changeCombo(); break; case PUSH_CANCEL_COMBO: - ToastUtil.debugShow("取消套餐"); + cancelCombo(); + break; + case PUSH_APP_BROWSER: + handleBrowserAppPush(extras); break; case PUSH_UPGRADE_COMBO: - ToastUtil.debugShow("升级套餐"); - case PUSH_APP_BROWSER: - ToastUtil.debugShow("收到推送消息: 系统APP管控"); - Log.e(TAG, "processCustomMessage: " + extras); - hideDesktopIcon(); + upgradeCombo(extras); break; case PUSH_BIND_UNBIND: - ToastUtil.debugShow("老师授权/取消授权"); - AppPolicySync.getInstance().getAppAndWhite(); - AppPolicySync.getInstance().getForceInstall(); - try { - mCacheHelper.delete(); - } catch (IOException e) { - e.printStackTrace(); - } - DeviceManager.doMasterClear(); + handleBindUnbindPush(); break; case PUSH_FLIGHT_MODE: + setFlightMode(); break; case PUSH_NOTDISTURB_MODE: - ToastUtil.debugShow("收到推送消息: 设置勿扰模式"); setZenMode(extras); break; case PUSH_LOCATION: - ToastUtil.debugShow("收到推送消息: 定位设置"); + setLocation(); break; case PUSH_CHARGING_REMINDER: + setChargingReminder(); break; case PUSH_VOLUME: - ToastUtil.debugShow("收到推送消息: 设置音量"); + setVolume(); break; case PUSH_LUMINANCE: - ToastUtil.debugShow("收到推送消息: 设置屏幕亮度"); setScreenBrightness(extras); break; case PUSH_TYPEFACE: - ToastUtil.debugShow("收到推送消息: 设置字体大小"); setFontSize(extras); break; case PUSH_SCREEN_ROTATION: - ToastUtil.debugShow("收到推送消息: 设置自动旋转"); setRotationLock(extras); break; case PUSH_WIFI_SET: + setWifi(); break; case PUSH_ALARM_CLOCK: setAlarmCLock(extras); break; case PUSH_APP_WHITELIST: + setAppWhitelist(); break; case PUSH_HIDE_APPICON: + handleHideAppIconPush(); break; case PUSH_KILL_APP: - ToastUtil.debugShow("收到推送消息: 内存优化"); - Utils.killBackgroundApp(mContext); + killBackgroundApps(); break; case PUSH_SOS_PHONENUM: setSOSPhoneNumber(extras); @@ -558,11 +482,9 @@ public class PushManager { setAdminApp(extras); break; case PUSH_SCREEN_SHARED: - ToastUtil.debugShow("收到推送消息: 投屏开关"); setScreenShared(extras); break; case PUSH_HOT_SPOT: - ToastUtil.debugShow("收到推送消息: 热点开关"); setHotPoint(extras); break; case PUSH_DEFAULT_DESKTOP: @@ -575,26 +497,21 @@ public class PushManager { setDefaultInputMethod(extras); break; case PUSH_PARENTAL_CONTROL: - ToastUtil.debugShow("收到推送消息: 家长管控"); - updateUserSettings(); + setParentalControl(); break; case PUSH_WHOLE_MACHINE_QUOTA: - ToastUtil.debugShow("收到推送消息: 整机管控"); - - updateUserSettings(); + setWholeMachineQuota(); break; case PUSH_APP_CONTROL: - ToastUtil.debugShow("收到推送消息: APP管控"); - updateUserSettings(); + setAppControl(); break; case PUSH_UPDATE_WHITE_LIST: - AppInventorySync.getInstance().getAllappPackage(); + updateWhiteList(); break; case PUSH_SN_RUN_LOG: recordLog(extras); break; case PUSH_DISABLE_NETWORK: - ToastUtil.debugShow("收到推送消息: 一键断网"); oneKeyNetwork(extras); break; case PUSH_SN_ADD_TAG: @@ -613,6 +530,652 @@ public class PushManager { } + private void showDeviceOnlinePush() { + ToastUtil.debugShow("收到推送消息: 获取在线信息"); + } + + private void handleStartTimePush(String extras) { + ToastUtil.debugShow("收到推送消息: 获取运行应用"); + updateUserSettings(); + sendStartTime(extras); + } + + private void setUsbStatus(String jsonString) { + ToastUtil.debugShow("收到推送消息: USB连接模式管控"); + if (!TextUtils.isEmpty(jsonString)) { + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + String setting_usb = jsonObject.get("setting_usb").getAsString(); + ControlManager.getInstance().setUSBstate(setting_usb); + } else { + ToastUtil.debugShow("setUsbState jsonString is NULL"); + } + } + + private void setTfcardState(String jsonString) { + ToastUtil.debugShow("收到推送消息: TF卡管控"); + if (!TextUtils.isEmpty(jsonString)) { + JsonObject extra = GsonUtils.getJsonObject(jsonString); + int is_tf = extra.get("setting_memory").getAsInt(); + boolean aole_sdcard_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, changeNum(is_tf)); + if (aole_sdcard_forbid_on) { + Log.e("setTfcardState:", Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON)); + } else { + ToastUtil.debugShow("setTfcardState failed,state:" + is_tf); + } + } else { + ToastUtil.debugShow("setTfcardState jsonString is NULL"); + } + } + + private void setBluetoothState(String jsonString) { + ToastUtil.debugShow("收到推送消息: 蓝牙管控"); + if (!TextUtils.isEmpty(jsonString)) { + if (null == mBluetoothAdapter) { + mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();//获取默认蓝牙适配器 + } + JsonObject extra = GsonUtils.getJsonObject(jsonString); + int is_bluetooth = changeNum(extra.get("setting_bht").getAsInt()); + Log.e(TAG, "aole_bht_forbid_on: " + is_bluetooth); + try { + //写入系统数据库 + boolean aole_bht_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, is_bluetooth); + Log.e(TAG, "aole_bht_forbid_on: " + aole_bht_forbid_on); + BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); + if (aole_bht_forbid_on) { + //成功 + if (null == mBluetoothAdapter) { + mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); + //获取默认蓝牙适配器 + } + //设置关闭时关闭蓝牙 + mBluetoothAdapter.disable(); + } + } catch (Exception e) { + Log.e(TAG, "setBluetooth: " + e.getMessage()); + } + } else { + ToastUtil.debugShow("setBluetoothState jsonString is NULL"); + } + } + + private void setBrowserUrlPath() { + ToastUtil.debugShow("收到推送消息: 浏览器上网管控"); + try { + new CacheUtils().cleanApplicationUserData(mContext, "com.android.browser"); + } catch (Exception e) { + e.printStackTrace(); + } + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + BrowserPolicySync.getInstance().setBrowserWhiteList(); + } + }, 2000); + } + + private void setAppNetworkState() { + ToastUtil.debugShow("收到推送消息: 应用联网管控"); + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + AppInventorySync.getInstance().getAppInside(); + } + }, 2000); + } + + private void setAppLockedstate(String jsonString) { + ToastUtil.debugShow("收到推送消息: 应用锁管控"); + if (!TextUtils.isEmpty(jsonString)) { + JsonObject extra = GsonUtils.getJsonObject(jsonString); + String packageName = extra.get("package").getAsString(); + int is_lock = extra.get("is_lock").getAsInt(); + ToastUtil.debugShow("收到应用锁管控消息:包名" + packageName + "is_lock_state:" + is_lock); + PackageManager pm = mContext.getPackageManager(); + //后台为0可能传过来null + if (is_lock == 1) { + pm.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); + } else { + pm.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0); + } + } else { + ToastUtil.debugShow("setAppLockedstate jsonString is NULL"); + } + } + + private void handleForceInstallapkPush(String extras) { + ToastUtil.debugShow("收到推送消息: 强制安装应用"); +// AppInventorySync.getInstance().getAllappPackage(); +// AppUpdateCoordinator.getInstance().getOverallApp(); + intallApk(extras); + } + + private void unintallApk(String jsonString) { + ToastUtil.debugShow("收到推送消息: 强制卸载应用"); + JsonObject object = GsonUtils.getJsonObject(jsonString); + String packageName = object.get("app_package").getAsString(); + // 台电设备不删除无法静默卸载 + removeForceSettings(packageName); + ToastUtil.debugShow("收到应用卸载消息:包名" + packageName); + if (!"".equals(packageName) && !packageName.equals(mContext.getApplicationContext().getPackageName())) { + if (!ApkUtils.isAvailable(mContext.getApplicationContext(), packageName)) { + + } else { + ApkUtils.uninstallApp(mContext, packageName); + } + } + } + + void bindService(final String jsonString) { + ToastUtil.debugShow("收到推送消息: 绑定设备"); + ToastUtil.debugShow("收到绑定设备请求"); + JsonObject object = GsonUtils.getJsonObject(jsonString); + String userName = object.get("member_name").getAsString(); + final String id = object.get("id").getAsString(); + String phoneNum = object.get("member_phone").getAsString(); + dialog = new CustomDialog(mContext); + subscribe = Observable.interval(1, TimeUnit.SECONDS) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer() { + @Override + public void accept(Long aLong) throws Exception { +// Log.e("TAG", "倒计时:" + aLong); + if (aLong < cutdownTime && !subscribe.isDisposed()) { + dialog.setNegtiveText("拒绝" + "(" + (cutdownTime - aLong) + ")"); + } else { + bind(id, 0); + dialog.dismiss(); + subscribe.dispose(); + subscribe = null; + } + } + }); + dialog.setMessage(phoneNum + "的用户请求绑定你的平板") + .setTitle("绑定请求") + .setPositive("允许") + .setNegtive("拒绝") + .setOnClickBottomListener(new CustomDialog.OnClickBottomListener() { + @Override + public void onPositiveClick() { + bind(id, 1); + dialog.dismiss(); + subscribe.dispose(); + subscribe = null; + } + + @Override + public void onNegtiveClick() { + bind(id, 0); + ToastUtil.show("设备取消绑定"); + dialog.dismiss(); + subscribe.dispose(); + subscribe = null; + } + }); + dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); + dialog.show(); + dialog.getWindow().setGravity(Gravity.CENTER); + dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); + dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); + } + + private void setTfMedia() { + ToastUtil.debugShow("收到推送消息: 影音格式管控"); + } + + private void handleCameraPush(String extras) { + ToastUtil.debugShow("收到推送消息: 摄像头管控"); + setCameta(extras); + JgyUtils.getInstance().updateForbidList(); + } + + private void handlePhonePush(String extras) { + ToastUtil.debugShow("收到推送消息: 电话管控"); + setPhone(extras); + } + + private void setAppUpdate(String jsonString) { + ToastUtil.debugShow("收到推送消息: 禁止升级"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + String is_upgrade = jsonObject.get("is_upgrade").getAsString(); + String packageName = jsonObject.get("package").getAsString(); + String nowApplist = Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID); + List applist = new ArrayList<>(Arrays.asList(nowApplist.split(","))); + if ("0".equals(is_upgrade)) { + if (applist.contains(packageName)) { + applist.remove(packageName); + } else { + Log.e("setAppUpdate", "app已经存在"); + } + } else if ("1".equals(is_upgrade)) { + if (!applist.contains(packageName)) { + applist.add(packageName); + } + } + Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, String.join(",", applist)); + Log.e("setAppUpdate", Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID)); + } + + private void setAppInsideNetwork(String extras) { + ToastUtil.debugShow("收到推送消息: app内部网址管控"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + int is_ground = jsonObject.get("is_ground").getAsInt(); + if (is_ground == 0) { + boolean putString = Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_APP_WEB_BLACK_LIST, ""); + Log.e(TAG, "setAppInsideNetwork: " + putString); + } else if (is_ground == 1) { + AppPolicySync.getInstance().getAppJump(); + } + } + + private void resetDevices() { + ToastUtil.debugShow("收到推送消息: 设备恢复出厂设置"); + try { + mCacheHelper.delete(); + } catch (IOException e) { + e.printStackTrace(); + } + DeviceManager.doMasterClear(); + } + + private void setBrowserLabel() { + ToastUtil.debugShow("收到推送消息: 浏览器书签"); + try { + new CacheUtils().cleanApplicationUserData(mContext, "com.android.browser"); + } catch (Exception e) { + e.printStackTrace(); + } + //延时2秒执行,以防收到推送数据库还没有生效 + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + BrowserPolicySync.getInstance().getBrowserWhiteList(); + BrowserPolicySync.getInstance().getBrowserLabel(); + } + }, 2000); + } + + private void setAppNetworkAuto() { + ToastUtil.debugShow("收到推送消息: APP联网自启管控"); + new Handler(Looper.getMainLooper()).postDelayed(() -> AppInventorySync.getInstance().getAllappPackage(), 2000); + } + + private void handleSystemSettingsPush() { + ToastUtil.debugShow("收到推送消息: 系统管控"); + updateUserSettings(); + } + + private void rebootDevices() { + ToastUtil.debugShow("收到推送消息: 重启"); + DeviceManager.rebootDevices(); + } + + private void setAppSettings() { + ToastUtil.debugShow("收到推送消息: 获取app管控设置"); + new Handler(Looper.getMainLooper()).postDelayed(() -> AppInventorySync.getInstance().getAllappPackage(), 2000); + } + + private void forceKillApp(String extras) { + ToastUtil.debugShow("收到推送消息: 强制停止应用"); + JsonObject killJSONObject = GsonUtils.getJsonObject(extras); + String packages = killJSONObject.get("app_package").getAsString(); + JgyUtils.getInstance().killPackage(packages); + JgyUtils.getInstance().gotoLauncher(); + Log.e(TAG, extras); + } + + private void handleLockScreenPush(String extras) { + ToastUtil.debugShow("收到推送消息: 锁屏"); + setLock_screen(extras); + Log.e(TAG, extras); + } + + private void handleSnapshotPush(String extras) { + ToastUtil.debugShow("收到推送消息: 截图"); + doscreenshot(mContext); + Log.e(TAG, extras); + } + + private void setTimeControl() { + ToastUtil.debugShow("收到推送消息: 时间管控"); + } + + /** + * @param jsonString 设置热点开关 + */ + private void setHotspot(String jsonString) { + ToastUtil.debugShow("收到推送消息: 热点管控"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + int setting_hotspot = changeNum(jsonObject.get("setting_hotspot").getAsInt());//热点 + try { + if (setting_hotspot == 1) { + Intent intent = new Intent(); + intent.setAction("qch_hotspot_close"); + intent.setPackage("com.android.settings"); + mContext.sendStickyBroadcast(intent); + } + boolean aole_hotspot_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_HOTSPOT_FORBID_ON, setting_hotspot); + Log.e("SystemSetting", "aole_hotspot_forbid_on---------" + setting_hotspot); + Log.e("SystemSetting", "aole_hotspot_forbid_on---------" + aole_hotspot_forbid_on); + } catch (Exception e) { + Log.e(TAG, "setHotspot: " + e.getMessage()); + } + } + + private void setRestore(String jsonString) { + ToastUtil.debugShow("收到推送消息: 恢复出厂设置管控"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + int mode = jsonObject.get("qch_restore").getAsInt(); + boolean aole_restore_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, changeNum(mode)); + Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on); + } + + private void setBrowserInput(String jsonString) { + ToastUtil.debugShow("收到推送消息: 浏览器禁止输入"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + int setting_browserInput = changeNum(jsonObject.get("setting_browserInput").getAsInt()); + Settings.System.putInt(mContext.getContentResolver(), "qch_Browser_input", setting_browserInput); + } + + private void setDeveloperControl(String extras) { + ToastUtil.debugShow("收到推送消息: 开发人员选项"); + ControlManager.getInstance().setDeveloperOptions(extras); + } + + private void cleanAppCache(String jsonString) { + ToastUtil.debugShow("收到推送消息: 清除应用缓存"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + String pkg = jsonObject.get("package").getAsString(); + if (TextUtils.isEmpty(pkg)) { + Log.e(TAG, "cleanAppCache: pkg is null"); + return; + } + try { + new CacheUtils().cleanApplicationUserData(mContext, pkg); + } catch (Exception e) { + e.printStackTrace(); + Log.e(TAG, "cleanAppCache: " + e.getMessage()); + } + } + + private void handleSystemAppPush() { + ToastUtil.debugShow("收到推送消息: 系统APP管控"); + hideDesktopIcon(); + } + + private void searchTopic(String jsonString) { + ToastUtil.debugShow("收到推送消息: 搜题开关"); + Log.e(TAG, "searchTopic: " + jsonString); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + int search_topic = jsonObject.get("search_topic").getAsInt(); + Log.e(TAG, "searchTopic: put = " + SPUtils.put(mContext, "search_topic", search_topic)); + JgyUtils.getInstance().updateForbidList(); + } + + private void handlePhoneListPush(String extras) { + ToastUtil.debugShow("收到推送消息: 电话白名单管控"); + setPhone(extras); + } + + private void changeCombo() { + ToastUtil.debugShow("更换套餐"); + } + + private void cancelCombo() { + ToastUtil.debugShow("取消套餐"); + } + + private void handleBrowserAppPush(String extras) { + ToastUtil.debugShow("收到推送消息: 系统APP管控"); + Log.e(TAG, "processCustomMessage: " + extras); + hideDesktopIcon(); + } + + private void upgradeCombo(String extras) { + ToastUtil.debugShow("升级套餐"); + } + + private void handleBindUnbindPush() { + ToastUtil.debugShow("老师授权/取消授权"); + AppPolicySync.getInstance().getAppAndWhite(); + AppPolicySync.getInstance().getForceInstall(); + try { + mCacheHelper.delete(); + } catch (IOException e) { + e.printStackTrace(); + } + DeviceManager.doMasterClear(); + } + + private void setFlightMode() { + } + + private void setZenMode(String extras) { + ToastUtil.debugShow("收到推送消息: 设置勿扰模式"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + int setting_disturbance = jsonObject.get("setting_disturbance").getAsInt(); + } + + private void setLocation() { + ToastUtil.debugShow("收到推送消息: 定位设置"); + } + + private void setChargingReminder() { + } + + private void setVolume() { + ToastUtil.debugShow("收到推送消息: 设置音量"); + } + + private void setScreenBrightness(String extras) { + ToastUtil.debugShow("收到推送消息: 设置屏幕亮度"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + int setting_luminance = jsonObject.get("setting_luminance").getAsInt(); + Settings.System.putInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); + int Scrern_brightness = (int) ((1.0 * 255 / 100) * setting_luminance); + Settings.System.putInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, Scrern_brightness); + } + + private void setFontSize(String extras) { + ToastUtil.debugShow("收到推送消息: 设置字体大小"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String setting_typeface = jsonObject.get("setting_typeface").getAsString(); + final Resources res = mContext.getResources(); + mEntries = Arrays.asList(res.getStringArray(R.array.entries_font_size)); + final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size); + mValues = new float[strEntryValues.length]; + for (int i = 0; i < strEntryValues.length; ++i) { + mValues[i] = Float.parseFloat(strEntryValues[i]); + } + mCurrentIndex = mEntries.indexOf(setting_typeface); + if (mCurrentIndex == -1) { + return; + } + Settings.System.putFloat(mContext.getContentResolver(), Settings.System.FONT_SCALE, mValues[mCurrentIndex]); + } + + private void setRotationLock(String extras) { + ToastUtil.debugShow("收到推送消息: 设置自动旋转"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + int setting_rotation = jsonObject.get("setting_rotation").getAsInt(); + RotationPolicy.setRotationLock(mContext, setting_rotation == 0); + } + + private void setWifi() { + } + + private void setAlarmCLock(String ex) { + Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); + bootIntent.setComponent(new ComponentName("com.uiui.os", "com.uiui.os.receiver.BootReceiver")); + mContext.sendBroadcast(bootIntent); + } + + private void setAppWhitelist() { + } + + private void handleHideAppIconPush() { + } + + private void killBackgroundApps() { + ToastUtil.debugShow("收到推送消息: 内存优化"); + Utils.killBackgroundApp(mContext); + } + + private void setSOSPhoneNumber(String extras) { + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String setting_sos = jsonObject.get("setting_sos").getAsString(); + Settings.System.putString(mContext.getContentResolver(), "setting_sos", setting_sos); + Intent intent = new Intent("setting_sos"); + intent.putExtra("setting_sos", setting_sos); + intent.setPackage("com.uiui.os"); + mContext.sendBroadcast(intent); + } + + private void reinstallApp(String extras) { + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String packages = jsonObject.get("package").getAsString(); + String app_url = jsonObject.get("app_url").getAsString(); + } + + private void setAdminApp(String extras) { + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + int setting_admin_app = jsonObject.get("setting_admin_app").getAsInt(); + Settings.System.putInt(mContext.getContentResolver(), "setting_admin_app", setting_admin_app); + } + + private void setScreenShared(String extras) { + ToastUtil.debugShow("收到推送消息: 投屏开关"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + int projection_screen = jsonObject.get("projection_screen").getAsInt(); + ControlManager.getInstance().setScreenShared(changeNum(projection_screen)); + } + + /** + * @param jsonString 设置热点开关 + */ + private void setHotPoint(String jsonString) { + ToastUtil.debugShow("收到推送消息: 热点开关"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + int setting_hotspot = changeNum(jsonObject.get("hot_point").getAsInt());//热点 + try { + if (setting_hotspot == 1) { + Intent intent = new Intent(); + intent.setAction("aole_hotspot_close"); + intent.setPackage("com.android.settings"); + mContext.sendStickyBroadcast(intent); + stopTethering(mContext); + + } + boolean aole_hotspot_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_HOTSPOT_FORBID_ON, setting_hotspot); + Log.e("setHotPoint", "aole_hotspot_forbid_on: " + setting_hotspot); + Log.e("setHotPoint", "aole_hotspot_forbid_on: " + aole_hotspot_forbid_on); + } catch (Exception e) { + Log.e(TAG, "setHotPoint: " + e.getMessage()); + } + } + + private void setDefaultDesktop(String extras) { + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + JsonElement jsonElement = jsonObject.get("desktop_app"); + if (jsonElement != null) { + String packeges = jsonElement.getAsString(); + JgyUtils.getInstance().setDefaultDesktop(packeges); + } else { + + } + } + + private void setDefaultBrowser(String extras) { + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + JsonElement jsonElement = jsonObject.get("browser_app"); + if (jsonElement != null) { + String packeges = jsonElement.getAsString(); + JgyUtils.getInstance().setDefaultBrowser(packeges); + } else { + Log.e(TAG, "setDefaultBrowser: packeges is NULL"); + } + } + + private void setDefaultInputMethod(String extras) { + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String packeges = jsonObject.get("typewriting_app").getAsString(); + JgyUtils.getInstance().setDefaultInputMethod(packeges); + } + + private void setParentalControl() { + ToastUtil.debugShow("收到推送消息: 家长管控"); + updateUserSettings(); + } + + private void setWholeMachineQuota() { + ToastUtil.debugShow("收到推送消息: 整机管控"); + + updateUserSettings(); + } + + private void setAppControl() { + ToastUtil.debugShow("收到推送消息: APP管控"); + updateUserSettings(); + } + + private void updateWhiteList() { + AppInventorySync.getInstance().getAllappPackage(); + } + + private void recordLog(String jsonString) { + if (!ServiceAliveUtils.isServiceAlive(mContext, LogcatService.class.getName())) { + mContext.startService(new Intent(mContext, LogcatService.class)); + } + RemoteDiagnostics.getInstance().getRunLog(); + } + + private void oneKeyNetwork(String extras) { + ToastUtil.debugShow("收到推送消息: 一键断网"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + int is_network = jsonObject.get("is_network").getAsInt(); + if (is_network == 1) { + JgyUtils.getInstance().oneKeyDisconnection(); + } else { + JgyUtils.getInstance().restorrNetwork(); + } + } + + private void addTag(String extras) { + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + try { + String tag_name = jsonObject.get("tag_name").getAsString(); + Log.e(TAG, "addTag: " + tag_name); + if (!TextUtils.isEmpty(tag_name)) { + PushTagSync.getInstance().setPushTags(tag_name); + } + } catch (Exception e) { + Log.e(TAG, "addTag: " + e.getMessage()); + } + } + + private void deleteTag(String extras) { + PushTagSync.getInstance().setPushTags(); + } + + private void addApkToWhiteList(String extras) { + Random random = new Random(); + //避免同时请求 + int number = random.nextInt(10000); + Log.e(TAG, "addApkToWhiteList: Random " + number); + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + AppInventorySync.getInstance().getAppWhiteList(new AppInventorySync.WhiteListCallback() { + @Override + public void onComplet() { + Log.e("getAppWhiteList", "onComplet: "); + } + }); + } + }, number); + + } + private void updateUserSettings() { updateUserSettings(true); } @@ -678,67 +1241,6 @@ public class PushManager { }); } - private void addApkToWhiteList(String extras) { - Random random = new Random(); - //避免同时请求 - int number = random.nextInt(10000); - Log.e(TAG, "addApkToWhiteList: Random " + number); - new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { - @Override - public void run() { - AppInventorySync.getInstance().getAppWhiteList(new AppInventorySync.WhiteListCallback() { - @Override - public void onComplet() { - Log.e("getAppWhiteList", "onComplet: "); - } - }); - } - }, number); - - } - - private void deleteTag(String extras) { - PushTagSync.getInstance().setPushTags(); - } - - private void addTag(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - try { - String tag_name = jsonObject.get("tag_name").getAsString(); - Log.e(TAG, "addTag: " + tag_name); - if (!TextUtils.isEmpty(tag_name)) { - PushTagSync.getInstance().setPushTags(tag_name); - } - } catch (Exception e) { - Log.e(TAG, "addTag: " + e.getMessage()); - } - } - - private void setAdminApp(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - int setting_admin_app = jsonObject.get("setting_admin_app").getAsInt(); - Settings.System.putInt(mContext.getContentResolver(), "setting_admin_app", setting_admin_app); - } - - private void setZenMode(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - int setting_disturbance = jsonObject.get("setting_disturbance").getAsInt(); - } - - private void setRotationLock(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - int setting_rotation = jsonObject.get("setting_rotation").getAsInt(); - RotationPolicy.setRotationLock(mContext, setting_rotation == 0); - } - - private void setScreenBrightness(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - int setting_luminance = jsonObject.get("setting_luminance").getAsInt(); - Settings.System.putInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL); - int Scrern_brightness = (int) ((1.0 * 255 / 100) * setting_luminance); - Settings.System.putInt(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, Scrern_brightness); - } - private float[] mValues; /** * 当前设置值在候选列表中的索引。 @@ -749,23 +1251,6 @@ public class PushManager { */ protected List mEntries; - private void setFontSize(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - String setting_typeface = jsonObject.get("setting_typeface").getAsString(); - final Resources res = mContext.getResources(); - mEntries = Arrays.asList(res.getStringArray(R.array.entries_font_size)); - final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size); - mValues = new float[strEntryValues.length]; - for (int i = 0; i < strEntryValues.length; ++i) { - mValues[i] = Float.parseFloat(strEntryValues[i]); - } - mCurrentIndex = mEntries.indexOf(setting_typeface); - if (mCurrentIndex == -1) { - return; - } - Settings.System.putFloat(mContext.getContentResolver(), Settings.System.FONT_SCALE, mValues[mCurrentIndex]); - } - private int changeNum(int paramInt) { return paramInt == 1 ? 0 : 1; } @@ -779,81 +1264,8 @@ public class PushManager { } } - private void setUsbStatus(String jsonString) { - if (!TextUtils.isEmpty(jsonString)) { - JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); - String setting_usb = jsonObject.get("setting_usb").getAsString(); - ControlManager.getInstance().setUSBstate(setting_usb); - } else { - ToastUtil.debugShow("setUsbState jsonString is NULL"); - } - } - - private void setTfcardState(String jsonString) { - if (!TextUtils.isEmpty(jsonString)) { - JsonObject extra = GsonUtils.getJsonObject(jsonString); - int is_tf = extra.get("setting_memory").getAsInt(); - boolean aole_sdcard_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, changeNum(is_tf)); - if (aole_sdcard_forbid_on) { - Log.e("setTfcardState:", Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON)); - } else { - ToastUtil.debugShow("setTfcardState failed,state:" + is_tf); - } - } else { - ToastUtil.debugShow("setTfcardState jsonString is NULL"); - } - } - private BluetoothAdapter mBluetoothAdapter; - private void setBluetoothState(String jsonString) { - if (!TextUtils.isEmpty(jsonString)) { - if (null == mBluetoothAdapter) { - mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();//获取默认蓝牙适配器 - } - JsonObject extra = GsonUtils.getJsonObject(jsonString); - int is_bluetooth = changeNum(extra.get("setting_bht").getAsInt()); - Log.e(TAG, "aole_bht_forbid_on: " + is_bluetooth); - try { - //写入系统数据库 - boolean aole_bht_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, is_bluetooth); - Log.e(TAG, "aole_bht_forbid_on: " + aole_bht_forbid_on); - BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - if (aole_bht_forbid_on) { - //成功 - if (null == mBluetoothAdapter) { - mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - //获取默认蓝牙适配器 - } - //设置关闭时关闭蓝牙 - mBluetoothAdapter.disable(); - } - } catch (Exception e) { - Log.e(TAG, "setBluetooth: " + e.getMessage()); - } - } else { - ToastUtil.debugShow("setBluetoothState jsonString is NULL"); - } - } - - private void setAppLockedstate(String jsonString) { - if (!TextUtils.isEmpty(jsonString)) { - JsonObject extra = GsonUtils.getJsonObject(jsonString); - String packageName = extra.get("package").getAsString(); - int is_lock = extra.get("is_lock").getAsInt(); - ToastUtil.debugShow("收到应用锁管控消息:包名" + packageName + "is_lock_state:" + is_lock); - PackageManager pm = mContext.getPackageManager(); - //后台为0可能传过来null - if (is_lock == 1) { - pm.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); - } else { - pm.setApplicationEnabledSetting(packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0); - } - } else { - ToastUtil.debugShow("setAppLockedstate jsonString is NULL"); - } - } - private void intallApk(String jsonString) { if (TextUtils.isEmpty(jsonString)) { return; @@ -1026,21 +1438,6 @@ public class PushManager { } } - private void unintallApk(String jsonString) { - JsonObject object = GsonUtils.getJsonObject(jsonString); - String packageName = object.get("app_package").getAsString(); - // 台电设备不删除无法静默卸载 - removeForceSettings(packageName); - ToastUtil.debugShow("收到应用卸载消息:包名" + packageName); - if (!"".equals(packageName) && !packageName.equals(mContext.getApplicationContext().getPackageName())) { - if (!ApkUtils.isAvailable(mContext.getApplicationContext(), packageName)) { - - } else { - ApkUtils.uninstallApp(mContext, packageName); - } - } - } - private boolean removeForceSettings(String pkg) { String force_app = Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP); if (!TextUtils.isEmpty(force_app)) { @@ -1055,59 +1452,6 @@ public class PushManager { private long cutdownTime = 30; private CustomDialog dialog; - void bindService(final String jsonString) { - ToastUtil.debugShow("收到绑定设备请求"); - JsonObject object = GsonUtils.getJsonObject(jsonString); - String userName = object.get("member_name").getAsString(); - final String id = object.get("id").getAsString(); - String phoneNum = object.get("member_phone").getAsString(); - dialog = new CustomDialog(mContext); - subscribe = Observable.interval(1, TimeUnit.SECONDS) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Consumer() { - @Override - public void accept(Long aLong) throws Exception { -// Log.e("TAG", "倒计时:" + aLong); - if (aLong < cutdownTime && !subscribe.isDisposed()) { - dialog.setNegtiveText("拒绝" + "(" + (cutdownTime - aLong) + ")"); - } else { - bind(id, 0); - dialog.dismiss(); - subscribe.dispose(); - subscribe = null; - } - } - }); - dialog.setMessage(phoneNum + "的用户请求绑定你的平板") - .setTitle("绑定请求") - .setPositive("允许") - .setNegtive("拒绝") - .setOnClickBottomListener(new CustomDialog.OnClickBottomListener() { - @Override - public void onPositiveClick() { - bind(id, 1); - dialog.dismiss(); - subscribe.dispose(); - subscribe = null; - } - - @Override - public void onNegtiveClick() { - bind(id, 0); - ToastUtil.show("设备取消绑定"); - dialog.dismiss(); - subscribe.dispose(); - subscribe = null; - } - }); - dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); - dialog.show(); - dialog.getWindow().setGravity(Gravity.CENTER); - dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); - dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); - } - private void bind(final String id, int type) { DeviceRepository.getInstance().bindDevice(id, type) .to(BackgroundRequests.submit(new Observer() { @@ -1173,38 +1517,6 @@ public class PushManager { DeviceSettingsSync.getInstance().getSystemSettings(); } - private void setAppUpdate(String jsonString) { - JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); - String is_upgrade = jsonObject.get("is_upgrade").getAsString(); - String packageName = jsonObject.get("package").getAsString(); - String nowApplist = Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID); - List applist = new ArrayList<>(Arrays.asList(nowApplist.split(","))); - if ("0".equals(is_upgrade)) { - if (applist.contains(packageName)) { - applist.remove(packageName); - } else { - Log.e("setAppUpdate", "app已经存在"); - } - } else if ("1".equals(is_upgrade)) { - if (!applist.contains(packageName)) { - applist.add(packageName); - } - } - Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, String.join(",", applist)); - Log.e("setAppUpdate", Settings.System.getString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID)); - } - - private void setAppInsideNetwork(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - int is_ground = jsonObject.get("is_ground").getAsInt(); - if (is_ground == 0) { - boolean putString = Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_APP_WEB_BLACK_LIST, ""); - Log.e(TAG, "setAppInsideNetwork: " + putString); - } else if (is_ground == 1) { - AppPolicySync.getInstance().getAppJump(); - } - } - private void setLock_screen(String jsonString) { int type = 0; JsonObject jSONObject = GsonUtils.getJsonObject(jsonString); @@ -1287,119 +1599,11 @@ public class PushManager { } - /** - * @param jsonString 设置热点开关 - */ - private void setHotspot(String jsonString) { - JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); - int setting_hotspot = changeNum(jsonObject.get("setting_hotspot").getAsInt());//热点 - try { - if (setting_hotspot == 1) { - Intent intent = new Intent(); - intent.setAction("qch_hotspot_close"); - intent.setPackage("com.android.settings"); - mContext.sendStickyBroadcast(intent); - } - boolean aole_hotspot_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_HOTSPOT_FORBID_ON, setting_hotspot); - Log.e("SystemSetting", "aole_hotspot_forbid_on---------" + setting_hotspot); - Log.e("SystemSetting", "aole_hotspot_forbid_on---------" + aole_hotspot_forbid_on); - } catch (Exception e) { - Log.e(TAG, "setHotspot: " + e.getMessage()); - } - } - - private void setRestore(String jsonString) { - JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); - int mode = jsonObject.get("qch_restore").getAsInt(); - boolean aole_restore_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, changeNum(mode)); - Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on); - } - - private void setBrowserInput(String jsonString) { - JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); - int setting_browserInput = changeNum(jsonObject.get("setting_browserInput").getAsInt()); - Settings.System.putInt(mContext.getContentResolver(), "qch_Browser_input", setting_browserInput); - } - - private void cleanAppCache(String jsonString) { - JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); - String pkg = jsonObject.get("package").getAsString(); - if (TextUtils.isEmpty(pkg)) { - Log.e(TAG, "cleanAppCache: pkg is null"); - return; - } - try { - new CacheUtils().cleanApplicationUserData(mContext, pkg); - } catch (Exception e) { - e.printStackTrace(); - Log.e(TAG, "cleanAppCache: " + e.getMessage()); - } - } - private void hideDesktopIcon() { DeviceRepository.removeCache(UrlAddress.GET_SETTINGS); DeviceSettingsSync.getInstance().getSystemSettings(); } - private void searchTopic(String jsonString) { - Log.e(TAG, "searchTopic: " + jsonString); - JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); - int search_topic = jsonObject.get("search_topic").getAsInt(); - Log.e(TAG, "searchTopic: put = " + SPUtils.put(mContext, "search_topic", search_topic)); - JgyUtils.getInstance().updateForbidList(); - } - - private void setAlarmCLock(String ex) { - Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); - bootIntent.setComponent(new ComponentName("com.uiui.os", "com.uiui.os.receiver.BootReceiver")); - mContext.sendBroadcast(bootIntent); - } - - private void setSOSPhoneNumber(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - String setting_sos = jsonObject.get("setting_sos").getAsString(); - Settings.System.putString(mContext.getContentResolver(), "setting_sos", setting_sos); - Intent intent = new Intent("setting_sos"); - intent.putExtra("setting_sos", setting_sos); - intent.setPackage("com.uiui.os"); - mContext.sendBroadcast(intent); - } - - private void reinstallApp(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - String packages = jsonObject.get("package").getAsString(); - String app_url = jsonObject.get("app_url").getAsString(); - } - - private void setScreenShared(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - int projection_screen = jsonObject.get("projection_screen").getAsInt(); - ControlManager.getInstance().setScreenShared(changeNum(projection_screen)); - } - - /** - * @param jsonString 设置热点开关 - */ - private void setHotPoint(String jsonString) { - JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); - int setting_hotspot = changeNum(jsonObject.get("hot_point").getAsInt());//热点 - try { - if (setting_hotspot == 1) { - Intent intent = new Intent(); - intent.setAction("aole_hotspot_close"); - intent.setPackage("com.android.settings"); - mContext.sendStickyBroadcast(intent); - stopTethering(mContext); - - } - boolean aole_hotspot_forbid_on = Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_HOTSPOT_FORBID_ON, setting_hotspot); - Log.e("setHotPoint", "aole_hotspot_forbid_on: " + setting_hotspot); - Log.e("setHotPoint", "aole_hotspot_forbid_on: " + aole_hotspot_forbid_on); - } catch (Exception e) { - Log.e(TAG, "setHotPoint: " + e.getMessage()); - } - } - /** * android8.0以上关闭手机热点 */ @@ -1414,48 +1618,4 @@ public class PushManager { } } - private void setDefaultDesktop(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - JsonElement jsonElement = jsonObject.get("desktop_app"); - if (jsonElement != null) { - String packeges = jsonElement.getAsString(); - JgyUtils.getInstance().setDefaultDesktop(packeges); - } else { - - } - } - - private void setDefaultBrowser(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - JsonElement jsonElement = jsonObject.get("browser_app"); - if (jsonElement != null) { - String packeges = jsonElement.getAsString(); - JgyUtils.getInstance().setDefaultBrowser(packeges); - } else { - Log.e(TAG, "setDefaultBrowser: packeges is NULL"); - } - } - - private void setDefaultInputMethod(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - String packeges = jsonObject.get("typewriting_app").getAsString(); - JgyUtils.getInstance().setDefaultInputMethod(packeges); - } - - private void oneKeyNetwork(String extras) { - JsonObject jsonObject = GsonUtils.getJsonObject(extras); - int is_network = jsonObject.get("is_network").getAsInt(); - if (is_network == 1) { - JgyUtils.getInstance().oneKeyDisconnection(); - } else { - JgyUtils.getInstance().restorrNetwork(); - } - } - - private void recordLog(String jsonString) { - if (!ServiceAliveUtils.isServiceAlive(mContext, LogcatService.class.getName())) { - mContext.startService(new Intent(mContext, LogcatService.class)); - } - RemoteDiagnostics.getInstance().getRunLog(); - } }