From cdaaaaed91bbbfd8ee62684ce5dd60a7425a741a Mon Sep 17 00:00:00 2001 From: tongtongstudio Date: Sat, 11 Jun 2022 17:58:04 +0800 Subject: [PATCH] =?UTF-8?q?version:=20cude=205.1=20fix:=20update:=E9=80=82?= =?UTF-8?q?=E9=85=8D=E5=8F=B0=E7=94=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 8 +- .../aoleyun/sn/activity/SplashActivity.java | 8 +- .../sn/activity/main/MainAPresenter.java | 1 + .../sn/activity/main/MainActivity.java | 21 +- .../com/aoleyun/sn/base/BaseApplication.java | 12 +- .../com/aoleyun/sn/comm/CommonConfig.java | 50 ++++ .../sn/network/NetInterfaceManager.java | 17 +- .../aoleyun/sn/receiver/NewAppReceiver.java | 1 + .../com/aoleyun/sn/service/GuardService.java | 14 +- .../com/aoleyun/sn/tpush/MessageReceiver.java | 17 +- .../java/com/aoleyun/sn/utils/ApkUtils.java | 6 +- .../java/com/aoleyun/sn/utils/JGYUtils.java | 277 ++++++++++-------- .../com/aoleyun/sn/utils/SysSettingUtils.java | 125 ++++---- .../main/java/com/aoleyun/sn/utils/Utils.java | 6 +- 14 files changed, 323 insertions(+), 240 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4120be8..177e2d9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -83,8 +83,8 @@ android { //酷比魔方 cube { flavorDimensions "default" - versionCode 40 - versionName "4.9" + versionCode 42 + versionName "5.1" buildConfigField "String", "platform", '"ZhanRuiCube"' manifestPlaceholders = [ AMAP_KEY: "6e339305206eeb43f2b4cc1f31751f89" @@ -94,8 +94,8 @@ android { //MTK MTKnewly { flavorDimensions "default" - versionCode 18 - versionName "2.7" + versionCode 20 + versionName "2.9" buildConfigField "String", "platform", '"MTK"' manifestPlaceholders = [ AMAP_KEY: "1af68e0a7edcaac82678b1cbb7643408" diff --git a/app/src/main/java/com/aoleyun/sn/activity/SplashActivity.java b/app/src/main/java/com/aoleyun/sn/activity/SplashActivity.java index 225903d..fa4b805 100644 --- a/app/src/main/java/com/aoleyun/sn/activity/SplashActivity.java +++ b/app/src/main/java/com/aoleyun/sn/activity/SplashActivity.java @@ -150,12 +150,12 @@ public class SplashActivity extends AppCompatActivity { // hideStatusBar(); // boolean qch_force_app = Settings.System.putString(getContentResolver(), "qch_launcher_icon_app", ""); Log.i(TAG, "DebugTest: qch_launcher_icon_app:" + Settings.System.getString(getContentResolver(), "qch_launcher_icon_app")); - Log.i(TAG, "DebugTest: qch_hide_NavigationBar: " + Settings.System.getString(getContentResolver(), "qch_hide_NavigationBar")); + Log.i(TAG, "DebugTest: aole_hide_NavigationBar: " + Settings.System.getString(getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR)); String only_jgy_shortcut_list = Settings.System.getString(getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST); Log.i(TAG, "debugTest: only_jgy_shortcut_list:" + only_jgy_shortcut_list); - String qch_app_forbid = Settings.System.getString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID); - Settings.System.putString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, qch_app_forbid + ",com.aoleyun.browser"); - Log.e(TAG, "debugTest: qch_app_forbid:" + qch_app_forbid); + String aole_app_forbid = Settings.System.getString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID); + Settings.System.putString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid + ",com.aoleyun.browser"); + Log.e(TAG, "debugTest: aole_app_forbid:" + aole_app_forbid); Log.i(TAG, "debugTest: ip = " + JGYUtils.getInstance().getIPAddress()); Log.i(TAG, "debugTest: getPackage = " + Utils.getPackage()); Log.i(TAG, "debugTest: getMacAddress = " + Utils.getAndroid10MAC(this)); diff --git a/app/src/main/java/com/aoleyun/sn/activity/main/MainAPresenter.java b/app/src/main/java/com/aoleyun/sn/activity/main/MainAPresenter.java index d5a62ec..669568c 100644 --- a/app/src/main/java/com/aoleyun/sn/activity/main/MainAPresenter.java +++ b/app/src/main/java/com/aoleyun/sn/activity/main/MainAPresenter.java @@ -62,6 +62,7 @@ public class MainAPresenter implements MainAContact.Presenter { @Override public void detachView() { this.mView = null; + this.mContext = null; } @Override diff --git a/app/src/main/java/com/aoleyun/sn/activity/main/MainActivity.java b/app/src/main/java/com/aoleyun/sn/activity/main/MainActivity.java index 6c6b77b..5ba9344 100644 --- a/app/src/main/java/com/aoleyun/sn/activity/main/MainActivity.java +++ b/app/src/main/java/com/aoleyun/sn/activity/main/MainActivity.java @@ -153,8 +153,6 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView, mMainAPresenter = new MainAPresenter(this); mMainAPresenter.attachView(this); mMainAPresenter.setLifecycle(lifecycleSubject); - NetworkUtils.registerNetworkStatusChangedListener(this); - registerUpdateReceiver(); JGYUtils.startServices(MainActivity.this); getDevicesInfo(); setStoreUpdateListener(bt_checkupdate); @@ -272,7 +270,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView, } MainService.MainBinder mMainBinder; - ServiceConnect serviceConnect = new ServiceConnect(); + private ServiceConnect serviceConnect = new ServiceConnect(); private class ServiceConnect implements ServiceConnection { @Override @@ -321,6 +319,8 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView, String batch = studesInfo.getBatch(); String head_img = studesInfo.getHead_img(); + + settradeType(trade_type); if (TextUtils.isEmpty(sno)) { setNumberText("", View.GONE); @@ -433,23 +433,24 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView, @Override protected void onPause() { super.onPause(); + NetworkUtils.unregisterNetworkStatusChangedListener(this); + if (mUpdateReceiver != null) { + unregisterReceiver(mUpdateReceiver); + } } @Override protected void onResume() { super.onResume(); + NetworkUtils.registerNetworkStatusChangedListener(this); + registerUpdateReceiver(); } @Override protected void onDestroy() { super.onDestroy(); - NetworkUtils.unregisterNetworkStatusChangedListener(this); mMainAPresenter.detachView(); mMainAPresenter = null; - if (mUpdateReceiver != null) { - unregisterReceiver(mUpdateReceiver); - mUpdateReceiver = null; - } JGYUtils.startServices(MainActivity.this); } @@ -473,7 +474,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView, } } - UpdateReceiver mUpdateReceiver; + private UpdateReceiver mUpdateReceiver; private void registerUpdateReceiver() { if (mUpdateReceiver == null) { @@ -484,7 +485,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView, registerReceiver(mUpdateReceiver, filter); } - class UpdateReceiver extends BroadcastReceiver { + private class UpdateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (UPDATE_LOCKED_STATUS.equals(intent.getAction())) { diff --git a/app/src/main/java/com/aoleyun/sn/base/BaseApplication.java b/app/src/main/java/com/aoleyun/sn/base/BaseApplication.java index 4a2047d..1495aee 100644 --- a/app/src/main/java/com/aoleyun/sn/base/BaseApplication.java +++ b/app/src/main/java/com/aoleyun/sn/base/BaseApplication.java @@ -69,7 +69,7 @@ public class BaseApplication extends MultiDexApplication { @Override public void onCreate() { super.onCreate(); - context = this; + context = this.getApplicationContext(); // if (SystemUtils.isMainProcessName(this, Process.myPid())) { //非主进程不初始化 init(); @@ -157,10 +157,10 @@ public class BaseApplication extends MultiDexApplication { List accountInfoList = new ArrayList<>(); accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial(getApplicationContext()))); if (Utils.NOSN.equalsIgnoreCase(Utils.getSerial())) { - accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getAppContext(), 0))); - accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getAppContext(), 1))); + accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getApplicationContext(), 0))); + accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getApplicationContext(), 1))); } - XGPushManager.upsertAccounts(getAppContext(), accountInfoList, new XGIOperateCallback() { + XGPushManager.upsertAccounts(getApplicationContext(), accountInfoList, new XGIOperateCallback() { @Override public void onSuccess(Object data, int flag) { Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag); @@ -272,7 +272,7 @@ public class BaseApplication extends MultiDexApplication { public static void setJpushAlias() { Log.e("jiguangInterface", "30s后重新设置alias"); -// JPushInterface.setAlias(context, TagAliasOperatorHelper.sequence++, Utils.getSerial()); +// JPushInterface.setAlias(getAppContext(), TagAliasOperatorHelper.sequence++, Utils.getSerial()); } private static void initTagObservable() { @@ -518,7 +518,7 @@ public class BaseApplication extends MultiDexApplication { totalTimes = statisticsInfo.getTotalTimes();//全部次数 } - synchronized public static void setAPPUsage(List lists) { + synchronized public static void setAPPUsage( List lists) { StatisticsInfo statisticsInfo = new StatisticsInfo(getAppContext()); List list = null; List localAppList = new ArrayList<>(); diff --git a/app/src/main/java/com/aoleyun/sn/comm/CommonConfig.java b/app/src/main/java/com/aoleyun/sn/comm/CommonConfig.java index c25da02..1186589 100644 --- a/app/src/main/java/com/aoleyun/sn/comm/CommonConfig.java +++ b/app/src/main/java/com/aoleyun/sn/comm/CommonConfig.java @@ -52,8 +52,58 @@ public class CommonConfig { * 管控系统指令 */ + /*USB模式-充电*/ public final static String AOLE_ACTION_USB_USB_CHARGE = "aole_action_usb_usb_charge"; + /*USB模式-MTP*/ + public final static String AOLE_ACTION_USB_USB_MTP = "aole_action_usb_usb_mtp"; + /*USB模式-MIDI*/ + public final static String AOLE_ACTION_USB_USB_MIDI = "aole_action_usb_usb_midi"; + + /*应用安装白名单*/ public final static String AOLE_ACTION_APP_FORBID = "aole_app_forbid"; + /*强制安装应用,禁止卸载*/ + public final static String AOLE_ACTION_FORCE_APP = "aole_force_app"; + + /*应用ID管控*/ + public final static String AOLE_ACTION_APP_FORBID_ID = "aole_app_forbid_id"; + + /*禁止应用滑动*/ + public final static String AOLE_ACTION_DISABLE_SLIDE = "aole_disable_slide"; + /*开机自启应用*/ + public final static String AOLE_ACTION_APP_POWER_ON = "aole_app_power_on"; + /*禁止联网应用*/ + public final static String AOLE_ACTION_NETWORK_DISALLOW = "aole_network_disallow"; + /*允许联网应用*/ + public final static String AOLE_ACTION_NETWORK_ALLOW = "aole_network_allow"; + + + /*存储卡管控*/ + public final static String AOLE_ACTION_SDCARD_FORBID_ON = "aole_sdcard_forbid_on"; + /*开发者选项管控*/ + public final static String AOLE_ACTION_DEVELOPER_OPTIONS = "aole_Developeroptions"; + /*显示导航栏*/ + public final static String AOLE_ACTION_SHOW_NAVIGATION_BAR = "aole_show_NavigationBar"; + /*隐藏导航栏*/ + public final static String AOLE_ACTION_HIDE_NAVIGATION_BAR = "aole_hide_NavigationBar"; + /*显示状态栏*/ + public final static String AOLE_ACTION_SHOW_STATUS_BAR = "aole_show_statusBar"; + /*隐藏状态栏*/ + public final static String AOLE_ACTION_HIDE_STATUS_BAR = "aole_hide_statusBar"; + /*热点*/ + public final static String AOLE_ACTION_HOTSPOT_FORBID_ON = "aole_hotspot_forbid_on"; + /*蓝牙总开关*/ + public final static String AOLE_ACTION_BHT_FORBID_ON = "aole_bht_forbid_on"; + /*蓝牙传输开关*/ + public final static String AOLE_ACTION_BT_FORBID_ON = "aole_bt_forbid_on"; + /*蓝牙音频开关*/ + public final static String AOLE_ACTION_BHTVIDEO_FORBID_ON = "aole_bhtvideo_forbid_on"; + /*电话白名单开关*/ + public final static String AOLE_ACTION_WHITE_LIST_ON = "aole_white_list_on"; + /*电话白名单列表*/ + public final static String AOLE_ACTION_WHITE_LIST_ARRAY = "aole_white_list_Array"; + /*恢复出厂设置开关*/ + public final static String AOLE_ACTION_RESTORE_FORBID_ON = "aole_restore_forbid_on"; + } 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 492b651..b50136c 100644 --- a/app/src/main/java/com/aoleyun/sn/network/NetInterfaceManager.java +++ b/app/src/main/java/com/aoleyun/sn/network/NetInterfaceManager.java @@ -857,8 +857,8 @@ public class NetInterfaceManager { JGYUtils.getInstance().forceDownload(forceDownloadData); } else if (forceDownloadBean.code == -200) { cacheHelper.put(UrlAddress.GET_FORCE_INSTALL_LIST, ""); - boolean qch_force_app = Settings.System.putString(mContext.getContentResolver(), "qch_force_app", "invalid"); - Log.e("getForceDownload", "qch_force_app:" + qch_force_app); + boolean aole_force_app = Settings.System.putString(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_FORCE_APP, "invalid"); + Log.e("getForceDownload", "aole_force_app:" + aole_force_app); } else { cacheHelper.put(UrlAddress.GET_FORCE_INSTALL_LIST, ""); Log.e("getForceDownload", forceDownloadBean.msg); @@ -941,13 +941,18 @@ public class NetInterfaceManager { cacheHelper.put(UrlAddress.GET_DESKTOP, ""); String whiteList = Settings.System.getString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST); Log.e("getDefaultDesktop", "onNext: " + whiteList); + if (!TextUtils.isEmpty(whiteList)) { if (!whiteList.contains(ApkUtils.desktopAPP.get(0))) { - ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(0)); + if (!BuildConfig.DEBUG) { + ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(0)); + } Log.e("getDefaultDesktop", "skip: " + ApkUtils.desktopAPP.get(0)); } if (!whiteList.contains(ApkUtils.desktopAPP.get(1))) { - ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(1)); + if (!BuildConfig.DEBUG) { + ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(1)); + } Log.e("getDefaultDesktop", "skip: " + ApkUtils.desktopAPP.get(1)); } } else { @@ -1097,7 +1102,7 @@ public class NetInterfaceManager { public void onError(Throwable e) { Log.e("getDeveloper", "onError: " + e.getMessage()); if (!BuildConfig.DEBUG) { - int oldStatus = Settings.System.getInt(mContext.getContentResolver(), "qch_Developeroptions", 1); + int oldStatus = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, 1); Log.e("getDeveloper", "oldStatus: " + oldStatus); JGYUtils.getInstance().setDeveloperOptions(oldStatus); } @@ -1487,7 +1492,7 @@ public class NetInterfaceManager { cacheHelper.put(UrlAddress.GET_FIRMWARE, ""); //获取系统管控先不要关闭开发人员选项 if (!BuildConfig.DEBUG) { - Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", 1); + Settings.System.putInt(mContext.getContentResolver(), CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, 1); } } } diff --git a/app/src/main/java/com/aoleyun/sn/receiver/NewAppReceiver.java b/app/src/main/java/com/aoleyun/sn/receiver/NewAppReceiver.java index 9765a43..ca24ea6 100644 --- a/app/src/main/java/com/aoleyun/sn/receiver/NewAppReceiver.java +++ b/app/src/main/java/com/aoleyun/sn/receiver/NewAppReceiver.java @@ -66,6 +66,7 @@ public class NewAppReceiver extends BroadcastReceiver { JGYUtils.getInstance().checkDefaultDesktop(packageName); JGYUtils.getInstance().checkForceDownload(); NetInterfaceManager.getInstance().checkUpdate(); + NetInterfaceManager.getInstance().getDefaultDesktop(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (!PackageNames.APPSTORE.equals(packageName) || !PackageNames.DEVICE_INFO.equals(packageName)) { ApkUtils.addShortcut(context); diff --git a/app/src/main/java/com/aoleyun/sn/service/GuardService.java b/app/src/main/java/com/aoleyun/sn/service/GuardService.java index e7643ed..084220b 100644 --- a/app/src/main/java/com/aoleyun/sn/service/GuardService.java +++ b/app/src/main/java/com/aoleyun/sn/service/GuardService.java @@ -227,12 +227,12 @@ public class GuardService extends Service { sendBroadcast(intent1); JGYUtils.startServices(GuardService.this); if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) { - int setting_statusbar = Settings.System.getInt(context.getContentResolver(), "qch_hide_statusBar", 0); + int setting_statusbar = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0); String statusbarStatus = ""; if (setting_statusbar == 0) { - statusbarStatus = "qch_show_statusBar"; + statusbarStatus = CommonConfig.AOLE_ACTION_SHOW_STATUS_BAR; } else if (setting_statusbar == 1) { - statusbarStatus = "qch_hide_statusBar"; + statusbarStatus = CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR; } Intent navIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); context.sendBroadcast(navIntent); @@ -442,17 +442,17 @@ public class GuardService extends Service { Log.e("setDefaultUSBStatus", "setting_usb---------" + setting_usb); String usbStatus = ""; if (TextUtils.isEmpty(setting_usb)) { - usbStatus = "aole_action_usb_usb_charge"; + usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; } else { switch (setting_usb) { case "usb_charge": - usbStatus = "aole_action_usb_usb_charge"; + usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; break; case "usb_mtp": - usbStatus = "aole_action_usb_usb_mtp"; + usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP; break; case "usb_midi": - usbStatus = "aole_action_usb_usb_midi"; + usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MIDI; break; default: break; diff --git a/app/src/main/java/com/aoleyun/sn/tpush/MessageReceiver.java b/app/src/main/java/com/aoleyun/sn/tpush/MessageReceiver.java index cf4571d..c7b1228 100644 --- a/app/src/main/java/com/aoleyun/sn/tpush/MessageReceiver.java +++ b/app/src/main/java/com/aoleyun/sn/tpush/MessageReceiver.java @@ -504,6 +504,7 @@ public class MessageReceiver extends XGPushBaseReceiver { ToastUtil.betaShow("收到管控:设备重置"); JGYUtils.getInstance().cleanAoleLauncher3Cache(); Utils.doMasterClear(mContext); + MMKV.defaultMMKV().clearAll(); JGYUtils.getInstance().cleanAoleAppCache(); JGYUtils.getInstance().wakeUpAoleyunAPP(); MainService.mPresenter.getLockedState("MSG_PUSH_RESET"); @@ -846,16 +847,16 @@ public class MessageReceiver extends XGPushBaseReceiver { Log.e("setDisableSlideList", "jSONObject::" + jSONObject.toString()); String strban = jSONObject.getString("ban"); String strnot = jSONObject.getString("not"); - String qch_disable_slide = Settings.System.getString(mResolver, "qch_disable_slide"); - Log.e("fht", "qch_disable_slide::" + qch_disable_slide); + String aole_disable_slide = Settings.System.getString(mResolver, CommonConfig.AOLE_ACTION_DISABLE_SLIDE); + Log.e("fht", "aole_disable_slide: " + aole_disable_slide); if (!TextUtils.isEmpty(strban)) { - Settings.System.putString(mResolver, "qch_disable_slide", strban); + Settings.System.putString(mResolver, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, strban); Log.e("fht", "sendban::" + strban); } else { - Settings.System.putString(mResolver, "qch_disable_slide", "Invalid"); + Settings.System.putString(mResolver, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, "Invalid"); } - Log.e("fht", "qch_disable_slide::" + Settings.System.getString(mResolver, "qch_disable_slide")); + Log.e("fht", "aole_disable_slide::" + Settings.System.getString(mResolver, CommonConfig.AOLE_ACTION_DISABLE_SLIDE)); } private void setDisableUpdateList(String jsonString) { @@ -924,12 +925,12 @@ public class MessageReceiver extends XGPushBaseReceiver { JSONObject jSONObject = JSON.parseObject(s); String ban = jSONObject.getString("ban"); String not = jSONObject.getString("not"); - Log.e(TAG, "settingPowerOn: qch_app_power_on = " + not); + Log.e(TAG, "settingPowerOn: aole_app_power_on = " + not); if (TextUtils.isEmpty(not)) { //当 qch_app_power_on 的值为空时,会造成系统所有应用断网 - Settings.System.putString(mResolver, "qch_app_power_on", "Invalid"); + Settings.System.putString(mResolver, CommonConfig.AOLE_ACTION_APP_POWER_ON, "Invalid"); } else { - Settings.System.putString(mResolver, "qch_app_power_on", not); + Settings.System.putString(mResolver, CommonConfig.AOLE_ACTION_APP_POWER_ON, not); } } diff --git a/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java b/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java index 0a2c117..e70a7ee 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java @@ -558,7 +558,7 @@ public class ApkUtils { Observable.create(new ObservableOnSubscribe() { @Override public void subscribe(ObservableEmitter emitter) throws Exception { - Log.e("UninstallAPP", "call: " + Thread.currentThread().getName()); +// Log.e("UninstallAPP", "call: " + Thread.currentThread().getName()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { ApkUtils.uninstall(context, pkg); } else { @@ -1146,11 +1146,11 @@ public class ApkUtils { Log.i("addShortcut", "packages: " + s); } String installedList = installedListBuilder.toString(); - boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", installedList); + boolean aole_force_app = Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", installedList); // String old = Settings.System.getString(context.getContentResolver(), "qch_launcher_icon_app"); // Log.e("addShortcut", old); Log.e("addShortcut", "installedList:" + installedList); - Log.e("addShortcut", "putstring:" + qch_force_app); + Log.e("addShortcut", "putstring:" + aole_force_app); } private static Set AoleyunOSApp = new HashSet() {{ 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 dcab5f4..67bddd4 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/JGYUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/JGYUtils.java @@ -26,6 +26,7 @@ import android.os.Environment; import android.os.PowerManager; import android.os.Process; import android.os.RemoteException; +import android.os.SystemProperties; import android.os.UserHandle; import android.provider.Settings; import android.text.TextUtils; @@ -406,12 +407,12 @@ public class JGYUtils { if (disallowSlide.size() != 0) { String slide_not = String.join(",", disallowSlide); - boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", slide_not); - Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not); + boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, slide_not); + Log.e("fht", "aole_disable_slide=" + writeSucceed + ":" + slide_not); } else { String slide_ok = String.join(",", allowSlide); - boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", "Invalid"); - Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok); + boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, "Invalid"); + Log.e("fht", "aole_disable_slide ok=" + writeSucceed + ":" + slide_ok); } String[] upgrade_ok = new String[allowUpgrade.size()]; @@ -420,19 +421,19 @@ public class JGYUtils { String[] upgrade_not = new String[disallowUpgrade.size()]; disallowUpgrade.toArray(upgrade_not); Utils.writeDisableUpdateList(mContext, upgrade_not, upgrade_ok); - String qch_app_power_on = String.join(",", autoLaunchApp); - Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on); - if (TextUtils.isEmpty(qch_app_power_on)) { - //当 qch_app_power_on 的值为空时,会造成系统所有应用断网 - Settings.System.putString(crv, "qch_app_power_on", "Invalid"); - Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid"); + String aole_app_power_on = String.join(",", autoLaunchApp); + Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + aole_app_power_on); + if (TextUtils.isEmpty(aole_app_power_on)) { + //当 aole_app_power_on 的值为空时,会造成系统所有应用断网 + Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_POWER_ON, "Invalid"); + Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + "Invalid"); } else { - Settings.System.putString(crv, "qch_app_power_on", qch_app_power_on); - Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on); + Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_POWER_ON, aole_app_power_on); + Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + aole_app_power_on); } // if (BuildConfig.DEBUG) { // TODO: 2021/7/2 测试写入为空是否断网 -// boolean w = Settings.System.putString(crv, "qch_app_power_on", ""); +// boolean w = Settings.System.putString(crv, "aole_app_power_on", ""); // Log.e(TAG, "setNetAndlaunch: 测试写入: " + w); // } setAppNetwork(mContext, disallowNetApp); @@ -498,26 +499,34 @@ public class JGYUtils { int is_upgrade = netAndLaunchData.getIs_upgrade(); int is_slide = netAndLaunchData.getIs_slide(); - if (is_auto == 1) autoLaunchApp.add(app_package); - - if (is_network == 1) allowNetApp.add(app_package); - else disallowNetApp.add(app_package); - - if (is_upgrade == 1) allowUpgrade.add(app_package); - else disallowUpgrade.add(app_package); - - if (is_slide == 1) allowSlide.add(app_package); - else disallowSlide.add(app_package); + if (is_auto == 0) { + autoLaunchApp.add(app_package); + } + if (is_network == 0) { + allowNetApp.add(app_package); + } else { + disallowNetApp.add(app_package); + } + if (is_upgrade == 0) { + allowUpgrade.add(app_package); + } else { + disallowUpgrade.add(app_package); + } + if (is_slide == 0) { + allowSlide.add(app_package); + } else { + disallowSlide.add(app_package); + } } if (disallowSlide.size() != 0) { String slide_not = String.join(",", disallowSlide); - boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", slide_not); - Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not); + boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, slide_not); + Log.e("fht", "aole_disable_slide=" + writeSucceed + ":" + slide_not); } else { String slide_ok = String.join(",", allowSlide); - boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", "Invalid"); - Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok); + boolean writeSucceed = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_DISABLE_SLIDE, "Invalid"); + Log.e("fht", "aole_disable_slide ok=" + writeSucceed + ":" + slide_ok); } String[] upgrade_ok = new String[allowUpgrade.size()]; @@ -525,19 +534,19 @@ public class JGYUtils { String[] upgrade_not = new String[disallowUpgrade.size()]; disallowUpgrade.toArray(upgrade_not); Utils.writeDisableUpdateList(mContext, upgrade_not, upgrade_ok); - String qch_app_power_on = String.join(",", autoLaunchApp); - Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on); - if (TextUtils.isEmpty(qch_app_power_on)) { + String aole_app_power_on = String.join(",", autoLaunchApp); + Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + aole_app_power_on); + if (TextUtils.isEmpty(aole_app_power_on)) { //当 qch_app_power_on 的值为空时,会造成系统所有应用断网 - Settings.System.putString(crv, "qch_app_power_on", "Invalid"); - Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid"); + Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_POWER_ON, "Invalid"); + Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + "Invalid"); } else { - Settings.System.putString(crv, "qch_app_power_on", qch_app_power_on); - Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on); + Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_POWER_ON, aole_app_power_on); + Log.e(TAG, "setNetAndlaunch: aole_app_power_on: " + aole_app_power_on); } // if (BuildConfig.DEBUG) { // TODO: 2021/7/2 测试写入为空是否断网 -// boolean w = Settings.System.putString(crv, "qch_app_power_on", ""); +// boolean w = Settings.System.putString(crv, "aole_app_power_on", ""); // Log.e(TAG, "setNetAndlaunch: 测试写入: " + w); // } setAppNetwork(mContext, disallowNetApp); @@ -545,84 +554,86 @@ public class JGYUtils { @SuppressLint("NewApi") synchronized public static void setAppNetwork(Context context, HashSet blackList) { + ContentResolver contentResolver = context.getContentResolver(); Log.e(TAG, "setAppNetwork: " + "设置应用联网管控" + blackList); - String dis = Settings.System.getString(context.getContentResolver(), JGYActions.ACTION_HRRECEIVER_JGY_DIS); - String not = Settings.System.getString(context.getContentResolver(), JGYActions.ACTION_HRRECEIVER_JGY); - //清除旧数据 - if (!TextUtils.isEmpty(dis)) { - Log.e(TAG, "setAppNetwork: dis = " + dis); - Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HRRECEIVER_JGY_DIS, "Invalid"); - } - if (!TextUtils.isEmpty(not)) { - Log.e(TAG, "setAppNetwork: not = " + not); - Settings.System.putString(context.getContentResolver(), JGYActions.ACTION_HRRECEIVER_JGY, "Invalid"); - } +// String dis = Settings.System.getString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW); +// String not = Settings.System.getString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_ALLOW); +// //清除旧数据 +// if (!TextUtils.isEmpty(dis)) { +// Log.e(TAG, "setAppNetwork: dis = " + dis); +// Settings.System.putString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, "Invalid"); +// } +// if (!TextUtils.isEmpty(not)) { +// Log.e(TAG, "setAppNetwork: not = " + not); +// Settings.System.putString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, "Invalid"); +// } - String oldBlackList = (String) SPUtils.get(context, JGYActions.ACTION_HRRECEIVER_JGY_DIS, ""); - HashSet oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackList.split(","))); - oldBlackListSet.removeIf(s -> TextUtils.isEmpty(s.trim())); - //之前禁止上网得列表 - Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet); - if (oldBlackListSet.size() == 0) { - Log.e(TAG, "setAppNetwork: blackList: " + blackList); - for (String pkg : new HashSet<>(blackList)) { - if (TextUtils.isEmpty(pkg)) continue; - //发送没有安装的 - if (!ApkUtils.isAvailable(context, pkg)) { - Log.e(TAG, "setAppNetwork: skip: " + pkg); - blackList.remove(pkg); - continue; - } else { - Log.e(TAG, "setAppNetwork: " + pkg + " 已安装"); - } - Intent netControlNotIntent = new Intent(JGYActions.ACTION_HRRECEIVER_JGY_DIS); - netControlNotIntent.putExtra("package_name", pkg); - netControlNotIntent.setPackage("com.android.settings"); - context.sendBroadcast(netControlNotIntent); - } - } else { - //减少的 - Set removedNet = oldBlackListSet; - //增加的 - Set addedNet = new HashSet<>(); - for (String pkg : blackList) { - if (TextUtils.isEmpty(pkg)) continue; - if (removedNet.contains(pkg)) { - removedNet.remove(pkg); - } else { - addedNet.add(pkg); - } - } - - Log.e(TAG, "setAppNetwork: removedNet: " + removedNet); - Log.e(TAG, "setAppNetwork: addedNet: " + addedNet); - for (String pkg : removedNet) { - if (TextUtils.isEmpty(pkg)) continue; - Intent netControlNotIntent = new Intent(JGYActions.ACTION_HRRECEIVER_JGY); - netControlNotIntent.putExtra("package_name", pkg); - netControlNotIntent.setPackage("com.android.settings"); - context.sendBroadcast(netControlNotIntent); - } - for (String pkg : addedNet) { - if (TextUtils.isEmpty(pkg)) continue; - if (!ApkUtils.isAvailable(context, pkg)) { - Log.e(TAG, "setAppNetwork: skip: " + pkg); - blackList.remove(pkg); - continue; - } else { - Log.e(TAG, "setAppNetwork: " + pkg + " 已安装"); - } - Intent netControlNotIntent = new Intent(JGYActions.ACTION_HRRECEIVER_JGY_DIS); - netControlNotIntent.putExtra("package_name", pkg); - netControlNotIntent.setPackage("com.android.settings"); - context.sendBroadcast(netControlNotIntent); - } - } +// String oldBlackList = Settings.System.getString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW); +// HashSet oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackList.split(","))); +// oldBlackListSet.removeIf(s -> TextUtils.isEmpty(s.trim())); +// //之前禁止上网得列表 +// Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet); +// if (oldBlackListSet.size() == 0) { +// Log.e(TAG, "setAppNetwork: blackList: " + blackList); +// for (String pkg : new HashSet<>(blackList)) { +// if (TextUtils.isEmpty(pkg)) continue; +// //发送没有安装的 +// if (!ApkUtils.isAvailable(context, pkg)) { +// Log.e(TAG, "setAppNetwork: skip: " + pkg); +// blackList.remove(pkg); +// continue; +// } else { +// Log.e(TAG, "setAppNetwork: " + pkg + " 已安装"); +// } +// Intent netControlNotIntent = new Intent(CommonConfig.AOLE_ACTION_NETWORK_DISALLOW); +// netControlNotIntent.putExtra("package_name", pkg); +// netControlNotIntent.setPackage("com.android.settings"); +// context.sendBroadcast(netControlNotIntent); +// } +// } else { +// //减少的 +// Set removedNet = oldBlackListSet; +// //增加的 +// Set addedNet = new HashSet<>(); +// for (String pkg : blackList) { +// if (TextUtils.isEmpty(pkg)) continue; +// if (removedNet.contains(pkg)) { +// removedNet.remove(pkg); +// } else { +// addedNet.add(pkg); +// } +// } +// +// Log.e(TAG, "setAppNetwork: removedNet: " + removedNet); +// Log.e(TAG, "setAppNetwork: addedNet: " + addedNet); +// for (String pkg : removedNet) { +// if (TextUtils.isEmpty(pkg)) continue; +// Settings.System.putString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_ALLOW, pkg); +// Intent netControlNotIntent = new Intent(CommonConfig.AOLE_ACTION_NETWORK_ALLOW); +// netControlNotIntent.putExtra("package_name", pkg); +// netControlNotIntent.setPackage("com.android.settings"); +// context.sendBroadcast(netControlNotIntent); +// } +// for (String pkg : addedNet) { +// if (TextUtils.isEmpty(pkg)) continue; +// if (!ApkUtils.isAvailable(context, pkg)) { +// Log.e(TAG, "setAppNetwork: skip: " + pkg); +// blackList.remove(pkg); +// continue; +// } else { +// Log.e(TAG, "setAppNetwork: " + pkg + " 已安装"); +// } +// Intent netControlNotIntent = new Intent(CommonConfig.AOLE_ACTION_NETWORK_DISALLOW); +// netControlNotIntent.putExtra("package_name", pkg); +// netControlNotIntent.setPackage("com.android.settings"); +// context.sendBroadcast(netControlNotIntent); +// } +// } String net_not = String.join(",", blackList); - SPUtils.put(context, JGYActions.ACTION_HRRECEIVER_JGY_DIS, net_not); - //Settings.System.putString(crv, JGYActions.ACTION_HrReceiver_JGY_DIS, net_not); - Log.e("fht", "not::" + net_not); + SPUtils.put(context, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, net_not); + Settings.System.putString(contentResolver, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, net_not); + Log.e(TAG, "setAppNetwork: " + net_not); //Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS); //netControlIntent.putExtra("package_name", net_not); @@ -635,7 +646,7 @@ public class JGYUtils { @SuppressLint("NewApi") synchronized public void onBootSendNetwork() { - String oldBlackListString = (String) SPUtils.get(mContext, JGYActions.ACTION_HRRECEIVER_JGY_DIS, ""); + String oldBlackListString = (String) SPUtils.get(mContext, CommonConfig.AOLE_ACTION_NETWORK_DISALLOW, ""); HashSet oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackListString.split(","))); Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet); oldBlackListSet.removeIf(new Predicate() { @@ -650,7 +661,7 @@ public class JGYUtils { Log.e(TAG, "setAppNetwork: skip: " + pkg); continue; } - Intent netControlNotIntent = new Intent(JGYActions.ACTION_HRRECEIVER_JGY_DIS); + Intent netControlNotIntent = new Intent(CommonConfig.AOLE_ACTION_NETWORK_DISALLOW); netControlNotIntent.putExtra("package_name", pkg); netControlNotIntent.setPackage("com.android.settings"); mContext.sendBroadcast(netControlNotIntent); @@ -684,22 +695,20 @@ public class JGYUtils { packageStringBuilder.append(pkg); } - - String olddeselectViewArray = Settings.System.getString(crv, "qch_app_forbid_id"); + String olddeselectViewArray = Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID_ID); Log.e("writeDeselectIDtoSystem", "olddeselectViewArray: " + olddeselectViewArray); - Settings.System.putString(crv, "qch_app_forbid_id", packageStringBuilder.toString()); + Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID_ID, packageStringBuilder.toString()); Settings.System.putString(crv, "DeselectViewArray", idStringBuilder.toString()); - Log.e("writeDeselectIDtoSystem", "qch_app_forbid_id: " + packageStringBuilder.toString()); + Log.e("writeDeselectIDtoSystem", "aole_app_forbid_id: " + packageStringBuilder.toString()); Log.e("writeDeselectIDtoSystem", "deselectViewArray: " + idStringBuilder.toString()); } else { Log.e("writeDeselectIDtoSystem", "writeDeselectIDtoSystem is null:"); - Settings.System.putString(crv, "qch_app_forbid_id", ""); + Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID_ID, ""); Settings.System.putString(crv, "DeselectViewArray", ""); } } - synchronized public void setAppinsideWeb(BaseResponse> response) { if (response.code == 200) { List appgrounds = response.data; @@ -1100,10 +1109,10 @@ public class JGYUtils { HashSet pkgSet = new HashSet<>(Arrays.asList(packageList.split(","))); pkgSet.addAll(packages); pkgSet.removeIf(TextUtils::isEmpty); - String qch_app_forbid = String.join(",", pkgSet); - Log.e(TAG, "writeAppPackageList: " + qch_app_forbid); - boolean b = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, qch_app_forbid); - Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID)); + String aole_app_forbid = String.join(",", pkgSet); + Log.e(TAG, "writeAppPackageList: " + aole_app_forbid); + boolean b = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid); + Log.e("writeAppPackageList: ", "aole_app_forbid: " + b + " " + Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID)); } public void checkForceDownload() { @@ -1122,6 +1131,7 @@ public class JGYUtils { } } + public void forceDownload(List data) { if (data == null || data.size() <= 0) { return; @@ -1314,12 +1324,12 @@ public class JGYUtils { result_white = only_jgy_shortcut_list.split(","); } //获取可以被安装的包名 - String qch_app_forbid = Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID); - if (!TextUtils.isEmpty(qch_app_forbid)) { - result_forbid = qch_app_forbid.split(","); + String aole_app_forbid = Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID); + if (!TextUtils.isEmpty(aole_app_forbid)) { + result_forbid = aole_app_forbid.split(","); } Log.e("deleteOtherApp", "only_jgy_shortcut_list:" + only_jgy_shortcut_list); - Log.e("deleteOtherApp", "qch_app_forbid:" + qch_app_forbid); + Log.e("deleteOtherApp", "aole_app_forbid:" + aole_app_forbid); List resulWhitetList = new ArrayList<>(Arrays.asList(result_white)); List resulForbidtList = new ArrayList<>(Arrays.asList(result_forbid)); @@ -1409,6 +1419,8 @@ public class JGYUtils { Log.e(TAG, "hideSystemAPP: " + pkg); if (ApkUtils.isSystemApp(mContext, pkg)) { pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0); + } else { + continue; } if (!showAppList.contains(pkg) && !ApkUtils.aihuaApp.contains(pkg)) { pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); @@ -1550,7 +1562,7 @@ public class JGYUtils { public void setDeveloperOptions(int state) { Log.e(TAG, "getDeveloper: " + state); if (!BuildConfig.DEBUG) { - Settings.System.putInt(crv, "qch_Developeroptions", state); + Settings.System.putInt(crv, CommonConfig.AOLE_ACTION_DEVELOPER_OPTIONS, state); if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) { Settings.Global.putInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, state == 1 ? 0 : 1); Settings.Global.putInt(crv, Settings.Global.ADB_ENABLED, state == 1 ? 0 : 1); @@ -1948,6 +1960,7 @@ public class JGYUtils { } } catch (java.lang.SecurityException e) { e.printStackTrace(); + Log.e(TAG, "setDefaultLauncher: " + e.getMessage()); } } @@ -2044,8 +2057,11 @@ public class JGYUtils { public void setDefaultDesktop(String pkg, String className) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { setRoleHolderAsUser(mContext, pkg); + Log.e(TAG, "setDefaultDesktop: setRoleHolderAsUser"); } else { - setDefaultLauncher(mContext, pkg, className); + //爱华设置,暂时屏蔽 +// setDefaultLauncher(mContext, pkg, className); + Log.e(TAG, "setDefaultDesktop: setDefaultLauncher"); } String oldDesktop = (String) SPUtils.get(mContext, "default_launcher", ""); if (Objects.equals(oldDesktop, pkg)) { @@ -2055,10 +2071,17 @@ public class JGYUtils { Intent intent = new Intent("setDefaultLauncher"); intent.putExtra("package", pkg); intent.putExtra("className", className); + if (JGYUtils.getInstance().checkAppPlatform() == MTKPlatform) { + //爱华定制 + intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.AoleReceiver")); + setDefaultLauncher(mContext, "com.android.transfer", "com.android.transfer.MainActivity"); + } intent.setPackage("com.android.settings"); mContext.sendBroadcast(intent); ApkUtils.openPackage(mContext, pkg); Log.e(TAG, "setDefaultDesktop: " + pkg + ":" + className); + Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.pkgname = " + SystemProperties.get("persist.sys.launcher.pkgname")); + Log.e(TAG, "setDefaultDesktop: " + "persist.sys.launcher.classname = " + SystemProperties.get("persist.sys.launcher.classname")); } public String getMacJson(Context context) { 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 a16196a..2eae2ee 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java @@ -15,6 +15,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.aoleyun.sn.BuildConfig; +import com.aoleyun.sn.comm.CommonConfig; import com.aoleyun.sn.comm.JGYActions; import java.util.ArrayList; @@ -108,14 +109,14 @@ public class SysSettingUtils { boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", state); Log.e(TAG, "qch_call_forbid:" + qch_call_forbid); - boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", state); - Log.e(TAG, "qch_white_list_on:" + qch_white_list_on); + boolean aole_white_list_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ON, state); + Log.e(TAG, "aole_white_list_on:" + aole_white_list_on); - boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", ""); - // ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid); - Log.e(TAG, "qch_white_list_Array:" + qch_white_list_Array + "---" + qch_white_list_Array); + boolean aole_white_list_Array = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ARRAY, ""); + // 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); - boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_sdcard_forbid_on", state); + boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_SDCARD_FORBID_ON, state); Log.e(TAG, "aole_sdcard_forbid_on:" + aole_sdcard_forbid_on); } catch (Exception e) { Log.e(TAG, "setPhoneList: " + e.getMessage()); @@ -131,22 +132,22 @@ public class SysSettingUtils { Log.e(TAG, "qch_call_forbid:" + qch_call_forbid); //电话白名单开关 int setting_phone = changeNum(jsonObject.getInteger("setting_phone")); - boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", setting_phone); - Log.e(TAG, "qch_white_list_on:" + qch_white_list_on); + boolean aole_white_list_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ON, setting_phone); + Log.e(TAG, "aole_white_list_on:" + aole_white_list_on); //白名单列表 if (setting_phone == 1) { - boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", "empty"); - // 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); + boolean aole_white_list_Array = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ARRAY, "empty"); + // 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); } else { String setting_phones = jsonObject.getString("setting_phones"); - boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", setting_phones); - // ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid); - Log.e(TAG, "qch_white_list_Array:" + qch_white_list_Array + "---" + setting_phones); + boolean aole_white_list_Array = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_WHITE_LIST_ARRAY, setting_phones); + // 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.getInteger("setting_memory")); - boolean aole_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_sdcard_forbid_on", setting_memory); + 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()); @@ -164,7 +165,7 @@ public class SysSettingUtils { mService.setUSBDataDisabled(true); 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 = "aole_action_usb_usb_charge"; + String usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings"); context.sendBroadcast(usbIntent); } catch (NoClassDefFoundError | Exception e) { @@ -193,17 +194,17 @@ public class SysSettingUtils { } } else { boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", setting_usb); - Log.e("setUSBstate", "aole_usb_choose---------" + aole_usb_choose); - String usbStatus = "aole_action_usb_usb_charge"; + Log.e("setUSBstate", "aole_usb_choose: " + aole_usb_choose); + String usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; switch (setting_usb) { case "usb_charge": - usbStatus = "aole_action_usb_usb_charge"; + usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE; break; case "usb_mtp": - usbStatus = "aole_action_usb_usb_mtp"; + usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP; break; case "usb_midi": - usbStatus = "aole_action_usb_usb_midi"; + usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MIDI; break; default: } @@ -215,19 +216,19 @@ public class SysSettingUtils { private static void setBluetooth(Context context, int state) { try { - boolean qch_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bht_forbid_on", state); + boolean aole_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, state); //写入系统数据库 - Log.e(TAG, "qch_bht_forbid_on:" + qch_bht_forbid_on); + Log.e(TAG, "aole_bht_forbid_on:" + aole_bht_forbid_on); BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - if (qch_bht_forbid_on) { + if (aole_bht_forbid_on) { //成功 if (null == mBluetoothAdapter) { mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); //获取默认蓝牙适配器 } //蓝牙总开关开启 - Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty"); - Settings.System.putInt(context.getContentResolver(), "qch_bt_forbid_on", state); + Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, "Empty"); + Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, state); mBluetoothAdapter.disable(); //设置关闭时关闭蓝牙 } @@ -245,11 +246,11 @@ public class SysSettingUtils { //蓝牙音频开关 int setting_bluetooth = changeNum(jsonObject.getInteger("setting_bluetooth")); //蓝牙传输开关 - boolean qch_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bht_forbid_on", setting_bht); + boolean aole_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, setting_bht); - Log.e(TAG, "qch_bht_forbid_on:" + qch_bht_forbid_on); + Log.e(TAG, "aole_bht_forbid_on:" + aole_bht_forbid_on); BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); - if (qch_bht_forbid_on) { + if (aole_bht_forbid_on) { //成功 if (null == mBluetoothAdapter) { mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); @@ -261,14 +262,14 @@ public class SysSettingUtils { if (setting_bhtvideo == 0) { if (null != setting_context && !"".equals(setting_context) && !" ".equals(setting_context) && !"null".equals(setting_context)) { Log.e(TAG, "setting_context:" + setting_context); - Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", setting_context); + Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, setting_context); } else { - Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty"); + Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, "Empty"); } } else if (setting_bhtvideo == 1) { - Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty"); + Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHTVIDEO_FORBID_ON, "Empty"); } - Settings.System.putInt(context.getContentResolver(), "qch_bt_forbid_on", setting_bluetooth); + Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BT_FORBID_ON, setting_bluetooth); } else { mBluetoothAdapter.disable(); //设置关闭时关闭蓝牙 @@ -285,8 +286,8 @@ public class SysSettingUtils { intent.setAction("qch_hotspot_close"); intent.setPackage("com.android.settings"); context.sendStickyBroadcast(intent); - boolean qch_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_hotspot_forbid_on", state); - Log.e(TAG, "qch_hotspot_forbid_on:" + qch_hotspot_forbid_on); + 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); } catch (Exception e) { Log.e(TAG, "setHotspot: " + e.getMessage()); } @@ -301,9 +302,9 @@ public class SysSettingUtils { intent.setPackage("com.android.settings"); context.sendStickyBroadcast(intent); } - boolean qch_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_hotspot_forbid_on", setting_hotspot); - Log.e(TAG, "qch_hotspot_forbid_on---------" + setting_hotspot); - Log.e(TAG, "qch_hotspot_forbid_on---------" + qch_hotspot_forbid_on); + 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); } catch (Exception e) { Log.e(TAG, "setHotspot: " + e.getMessage()); } @@ -313,16 +314,16 @@ public class SysSettingUtils { //系统导航条显示开关 int setting_navigation = 0; //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 - boolean qch_hide_navigationBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_NavigationBar", setting_navigation); - Log.e(TAG, "qch_hide_navigationBar---------" + qch_hide_navigationBar); + 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); String navigationStatus = ""; switch (setting_navigation) { case 0: - navigationStatus = "qch_show_NavigationBar"; + navigationStatus = CommonConfig.AOLE_ACTION_SHOW_NAVIGATION_BAR; break; case 1: - navigationStatus = "qch_hide_NavigationBar"; + navigationStatus = CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR; break; } @@ -332,18 +333,18 @@ public class SysSettingUtils { //状态栏显示开关 int setting_statusbar = 0; - int oldNum = Settings.System.getInt(context.getContentResolver(), "qch_hide_statusBar", 0); + int oldNum = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0); if (oldNum != setting_statusbar) { //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 - boolean qch_hide_statusBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_statusBar", setting_statusbar); - Log.e(TAG, "qch_hide_statusBar---------" + qch_hide_statusBar); + boolean aole_hide_statusBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, setting_statusbar); + Log.e(TAG, "aole_hide_statusBar: " + aole_hide_statusBar); String statusbarStatus = ""; switch (setting_statusbar) { case 0: - statusbarStatus = "qch_show_statusBar"; + statusbarStatus = CommonConfig.AOLE_ACTION_SHOW_STATUS_BAR; break; case 1: - statusbarStatus = "qch_hide_statusBar"; + statusbarStatus = CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR; break; } Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); @@ -355,16 +356,16 @@ public class SysSettingUtils { //系统导航条显示开关 int setting_navigation = changeNum(jsonObject.getInteger("setting_navigation")); //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 - boolean qch_hide_navigationBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_NavigationBar", setting_navigation); - Log.e(TAG, "qch_hide_navigationBar---------" + qch_hide_navigationBar); + 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); String navigationStatus = ""; switch (setting_navigation) { case 0: - navigationStatus = "qch_show_NavigationBar"; + navigationStatus = CommonConfig.AOLE_ACTION_SHOW_NAVIGATION_BAR; break; case 1: - navigationStatus = "qch_hide_NavigationBar"; + navigationStatus = CommonConfig.AOLE_ACTION_HIDE_NAVIGATION_BAR; break; } Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui"); @@ -373,18 +374,18 @@ public class SysSettingUtils { //状态栏显示开关 int setting_statusbar = changeNum(jsonObject.getInteger("setting_statusbar")); - int oldNum = Settings.System.getInt(context.getContentResolver(), "qch_hide_statusBar", 0); + int oldNum = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0); if (oldNum != setting_statusbar) { //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 - boolean qch_hide_statusBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_statusBar", setting_statusbar); - Log.e(TAG, "qch_hide_statusBar---------" + qch_hide_statusBar); + boolean aole_hide_statusBar = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, setting_statusbar); + Log.e(TAG, "aole_hide_statusBar: " + aole_hide_statusBar); String statusbarStatus = ""; switch (setting_statusbar) { case 0: - statusbarStatus = "qch_show_statusBar"; + statusbarStatus = CommonConfig.AOLE_ACTION_SHOW_STATUS_BAR; break; case 1: - statusbarStatus = "qch_hide_statusBar"; + statusbarStatus = CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR; break; } Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui"); @@ -607,8 +608,8 @@ public class SysSettingUtils { } private static void setCanReset(Context context, int state) { - boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_restore_forbid_on", 0); - Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on); + boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0); + Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on); //默认打开 } @@ -617,11 +618,11 @@ public class SysSettingUtils { private static void setCanReset(Context context, JSONObject jsonObject) { int mode = jsonObject.getInteger("qch_restore"); if (mode == 1) { - boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_restore_forbid_on", 0); - Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on); + boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 0); + Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on); } else { - boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "aole_restore_forbid_on", 1); - Log.e(TAG, "aole_restore_forbid_on:" + aole_restore_forbid_on); + boolean aole_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_RESTORE_FORBID_ON, 1); + Log.e(TAG, "aole_restore_forbid_on: " + aole_restore_forbid_on); } } diff --git a/app/src/main/java/com/aoleyun/sn/utils/Utils.java b/app/src/main/java/com/aoleyun/sn/utils/Utils.java index cd596af..d33a177 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/Utils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/Utils.java @@ -519,14 +519,14 @@ public class Utils { public static void unInstallAPP(Context context, String packageName) { if (!TextUtils.isEmpty(packageName) && !ApkUtils.isSystemApp(context, packageName)) { if (ApkUtils.isSystemApp(context, packageName)) { - Toast.makeText(BaseApplication.getAppContext(), R.string.system_unistall_error, Toast.LENGTH_SHORT).show(); + Toast.makeText(context, R.string.system_unistall_error, Toast.LENGTH_SHORT).show(); } else { Uri packageURI = Uri.parse("package:" + packageName); Intent intent = new Intent(Intent.ACTION_DELETE, packageURI); context.startActivity(intent); } } else { - Toast.makeText(BaseApplication.getAppContext(), R.string.unistall_error, Toast.LENGTH_SHORT).show(); + Toast.makeText(context, R.string.unistall_error, Toast.LENGTH_SHORT).show(); } } @@ -1097,7 +1097,7 @@ public class Utils { list = list.substring(0, list.length() - 1); Log.e("fht", list); writeSucceed = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, list); - Log.e("fht", "qch_app_forbid:" + list); + Log.e("fht", "aole_app_forbid:" + list); } else { writeSucceed = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, "Invalid"); }