From 8c948e62beb35c4ee7877694ec7e0c25dc421b3c Mon Sep 17 00:00:00 2001 From: Fanhuitong <981964879@qq.com> Date: Sat, 17 Jun 2023 09:38:37 +0800 Subject: [PATCH] =?UTF-8?q?version:6.4.0=20fix:=20update:=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 49 +- app/keystore/MTKP20S.keystore | Bin 0 -> 2361 bytes ...ndor.mediatek.hardware.nvram-V1.0-java.jar | Bin 0 -> 20915 bytes app/src/main/AndroidManifest.xml | 117 ++-- .../sn/activity/main/MainAPresenter.java | 2 +- .../sn/activity/main/MainActivity.java | 9 +- .../com/aoleyun/sn/base/BaseApplication.java | 64 ++- .../com/aoleyun/sn/comm/CommonConfig.java | 2 +- .../com/aoleyun/sn/comm/PackageNames.java | 2 + .../sn/network/NetInterfaceManager.java | 65 ++- .../PushManager.java} | 499 +++++------------- .../push/alipush/AliMessageIntentService.java | 99 ++++ .../push/alipush/AliyunMessageReceiver.java | 116 ++++ .../sn/{ => push}/tpush/Constants.java | 2 +- .../sn/push/tpush/MessageReceiver.java | 307 +++++++++++ .../{ => push}/tpush/common/DBOpenHelper.java | 2 +- .../tpush/common/NotificationService.java | 4 +- .../{ => push}/tpush/po/XGNotification.java | 2 +- .../com/aoleyun/sn/service/GuardService.java | 28 +- .../com/aoleyun/sn/service/RemoteService.java | 2 +- .../com/aoleyun/sn/service/StepService.java | 24 +- .../aoleyun/sn/service/main/MainService.java | 14 +- .../java/com/aoleyun/sn/utils/ApkUtils.java | 10 +- .../java/com/aoleyun/sn/utils/JGYUtils.java | 168 +++--- .../com/aoleyun/sn/utils/SysSettingUtils.java | 103 ++-- .../main/java/com/aoleyun/sn/utils/Utils.java | 163 ++++-- app/src/main/res/values/strings.xml | 1 + build.gradle | 9 +- 28 files changed, 1153 insertions(+), 710 deletions(-) create mode 100644 app/keystore/MTKP20S.keystore create mode 100644 app/libs/vendor.mediatek.hardware.nvram-V1.0-java.jar rename app/src/main/java/com/aoleyun/sn/{tpush/MessageReceiver.java => push/PushManager.java} (74%) create mode 100644 app/src/main/java/com/aoleyun/sn/push/alipush/AliMessageIntentService.java create mode 100644 app/src/main/java/com/aoleyun/sn/push/alipush/AliyunMessageReceiver.java rename app/src/main/java/com/aoleyun/sn/{ => push}/tpush/Constants.java (93%) create mode 100644 app/src/main/java/com/aoleyun/sn/push/tpush/MessageReceiver.java rename app/src/main/java/com/aoleyun/sn/{ => push}/tpush/common/DBOpenHelper.java (93%) rename app/src/main/java/com/aoleyun/sn/{ => push}/tpush/common/NotificationService.java (98%) rename app/src/main/java/com/aoleyun/sn/{ => push}/tpush/po/XGNotification.java (97%) diff --git a/app/build.gradle b/app/build.gradle index a015026..8666787 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -81,25 +81,32 @@ android { //酷比魔方 cube { flavorDimensions "default" - versionCode 79 - versionName "6.3.9" + versionCode 80 + versionName "6.4.0" buildConfigField "String", "platform", '"ZhanRuiCube"' } //MTK MTKnewly { flavorDimensions "default" - versionCode 54 - versionName "2.4.4" + versionCode 55 + versionName "2.4.5" buildConfigField "String", "platform", '"MTK"' } Huaruian { flavorDimensions "default" - versionCode 7 - versionName "1.0.6" + versionCode 8 + versionName "1.0.7" buildConfigField "String", "platform", '"MTK11"' } + + Teclast { + flavorDimensions "default" + versionCode 8 + versionName "1.0.7" + buildConfigField "String", "platform", '"P20S"' + } } sourceSets { @@ -108,7 +115,6 @@ android { // newly.res.srcDirs = ['src/beta/res'] } - //签名 signingConfigs { zhanRui { @@ -164,6 +170,14 @@ android { v1SigningEnabled true v2SigningEnabled true } + + P20S { + storeFile file("keystore/MTKP20S.keystore") + storePassword "123456" + keyAlias "MTKP20S" + keyPassword "123456" + v2SigningEnabled false + } } // Disable release builds for now @@ -227,6 +241,18 @@ android { signingConfig signingConfigs.G10PUserDebug } + TeclastP20SDebug.initWith(debug) + TeclastP20SDebug { + debuggable true + versionNameSuffix "-debug" + signingConfig signingConfigs.P20S + } + + TeclastP20SRelease.initWith(release) + TeclastP20SRelease { + signingConfig signingConfigs.P20S + } + zhanRuiDebug.initWith(debug) zhanRuiDebug { debuggable true @@ -304,6 +330,7 @@ dependencies { compileOnly files('libs/framework.jar') compileOnly files('libs/cube_mdm.jar') compileOnly files('libs/cube_sdk_v1.0.0.jar') + implementation files('libs/vendor.mediatek.hardware.nvram-V1.0-java.jar') implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.cardview:cardview:1.0.0' @@ -349,14 +376,16 @@ dependencies { debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1' //磁盘缓存 implementation 'com.jakewharton:disklrucache:2.0.2' - //fastjson - implementation 'com.alibaba:fastjson:1.2.83' + //阿里云推送 + implementation 'com.aliyun.ams:alicloud-android-push:3.8.0' +// //fastjson +// implementation 'com.alibaba:fastjson:1.2.83' //百度地图 implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.1.8' //MMKV implementation 'com.tencent:mmkv-static:1.2.13' //腾讯移动推送 TPNS - implementation 'com.tencent.tpns:tpns:1.3.2.0-release' + implementation 'com.tencent.tpns:tpns:1.4.0.1-release' //工具类 implementation 'com.blankj:utilcodex:1.31.0' //Aria diff --git a/app/keystore/MTKP20S.keystore b/app/keystore/MTKP20S.keystore new file mode 100644 index 0000000000000000000000000000000000000000..1156f88138f04646c9b36610fd9a684c23b9aae9 GIT binary patch literal 2361 zcmd5-={wX77oMLPYcnBZEqk)n_>G3iQYng%EhJ@YOpIj^W6L^~qDVu$NS36DQ7Dyt z&14%9QFSI>LB&-HwG|A6ly(2n52h3*awsdk1*> zs)PQ!{LaEBBMJn<2?5ElZE!CapDGss15`K!0e}+%Bg3Xtww}gQ3y$@t;O>Tu*z(TK z@!9u(&R1n1Ec>M5mr`O8=bModx~D7ABnlpBYSL3m?cQM71kx1PnXbZ$20`ksykdcs zDIQ~@B&ScNWjAuz*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69x3u*)7 z65`M|L+=9x{tzBGuOZ2W=w{$UbVCb*{C_lVIL`%lJTY_^X#U+gyAmIq>mr_L?Lt7q zLB2o29ys)(zQKR1K;gWec$_MPFz|MFEYU3grrV*EF-S zC@FBuvAvzzs(yJu>sV-jZg?1$ScOo5Xoi(dn%C(sbUNJ9ygg@<(I!*M>03fsjk8l7 z3}gye`(@1*abHs$-;rP8v~RKbs86`$Z15%6_AsU>*$ZKkdlXUMP_`vIRtI=NE%}4b z3B+0|>-5DQ5RQFxU%i%i1{P_AES^T4C5l4@p*=$5!8udD%b{|<6rYE};`&&ryLtGa zx$pUtF3!T$_nL4Sl4s2MQyfqL0z9<<%|OZB?U39H z6M-R{j;z!X(rYy{ThMf7*tA-ve<}=={u7pmiGdr|uds_W0!Dcqo!TPqR0&3a*Kl+Z0IE##2UtK9?~e)G$lfK%WbYUv)(`!TUN zLl0~n-xIvFeLiaBkXr?8NED7|vly3^EFEdl<(E4P7wS{_HTFSs%432XTe-}bZvG&d zfx}-ZxlmL6VGWs=SGgH0la&Q_w@t}OwTV1K#hBM9BU+TQ{Q56dZ`6?%tggO^5$baL zsAE=zY@P`{5i>oP&uZr`HYhD{Qts?wC#4HSjUf&Y(;!Z$_x4ozOPNVh@+mK@3Om9p WBLzOZn#xZ$*vGQNCovE8uKgQX@*^w& literal 0 HcmV?d00001 diff --git a/app/libs/vendor.mediatek.hardware.nvram-V1.0-java.jar b/app/libs/vendor.mediatek.hardware.nvram-V1.0-java.jar new file mode 100644 index 0000000000000000000000000000000000000000..86849f7430b2286c51fe2a9bcc23204fc675f159 GIT binary patch literal 20915 zcmb5V1ym%#mMsd6ySux)d*fcXTO)bcs9sIvgMNxpPl%$$Ev!axuvAvZ!(8ZNW6X@(>jmJnX&x$D5U=bWocz*`){D=|6izy zu?z6u;Bo#-ye69w>%W3v!TvGE|NQxJ{P#f;Kod6$S$lH_N>OK1ODk8PsjHhaklEDM z*u^C&@luswfnZ2Psdl8uIFIs8aTMi-Lj9S7aay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zx*=>HNB~?|G+;w!|4+pqJz2DVplu7A&y;~72^z2=der2@bpzZ+KWr??wMFp1R - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -388,18 +320,35 @@ - + + + + + + + + + + + + + + - - - - + android:name=".push.alipush.AliMessageIntentService" + android:exported="false"> + + + + + + + + + + + + + + \ No newline at end of file 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 91aafd4..ec30e72 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 @@ -85,7 +85,7 @@ public class MainAPresenter implements MainAContact.Presenter { @Override public void getQrCode(boolean loocked) { - String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getSerial()); + String encryptString = CXAESUtil.encrypt(CommonConfig.AES_KEY, Utils.getSerial(mContext)); Log.e("getQRCode", "setImageAndText: " + encryptString); Bitmap bitmap = Utils.createQRImage(encryptString, 400, 400); mView.setQrCode(bitmap); 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 d300c67..7e903b4 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 @@ -252,7 +252,12 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView, tv_model.setText(Build.MODEL); String sn = Utils.getSerial(this); Log.e(TAG, "getDevicesInfo: " + sn); - tv_serial.setText(sn); + Log.e(TAG, "getDevicesInfo: " + Utils.getMac()); + if (TextUtils.isEmpty(sn)) { + tv_serial.setText(getString(R.string.no_data)); + } else { + tv_serial.setText(sn); + } getIMEI(); setMac(); checkSnError(sn); @@ -264,7 +269,7 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView, } private void getIMEI() { - if (!Utils.NOSN.equalsIgnoreCase(Utils.getSerial())) { + if (!Utils.NOSN.equalsIgnoreCase(Utils.getSerial(this))) { tv_imei.setText(Utils.getIMEI(this, 1)); } else { if (!TextUtils.isEmpty(Utils.getIMEI(this, 1))) { 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 ee89b6f..9f74588 100644 --- a/app/src/main/java/com/aoleyun/sn/base/BaseApplication.java +++ b/app/src/main/java/com/aoleyun/sn/base/BaseApplication.java @@ -5,10 +5,14 @@ import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.Process; +import android.text.TextUtils; import android.util.Log; import androidx.multidex.MultiDexApplication; +import com.alibaba.sdk.android.push.CloudPushService; +import com.alibaba.sdk.android.push.CommonCallback; +import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.bean.BaseResponse; import com.aoleyun.sn.comm.CommonConfig; @@ -17,6 +21,7 @@ import com.aoleyun.sn.manager.ConnectManager; import com.aoleyun.sn.manager.FileManager; import com.aoleyun.sn.network.NetInterfaceManager; import com.aoleyun.sn.network.UrlAddress; +import com.aoleyun.sn.push.PushManager; import com.aoleyun.sn.rlog.LogDBManager; import com.aoleyun.sn.statistics.AppInformation; import com.aoleyun.sn.statistics.StatisticsInfo; @@ -73,7 +78,9 @@ public class BaseApplication extends MultiDexApplication { String rootDir = MMKV.initialize(this); Log.e(TAG, "mmkv root: " + rootDir); + PushManager.init(this); tPushInit(); + aliyunPushInit(); ToastUtil.init(this); NetInterfaceManager.init(this); JGYUtils.init(this); @@ -126,20 +133,22 @@ public class BaseApplication extends MultiDexApplication { Log.e("TPush", "注册成功,设备token为:" + data); MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE).encode("XGPushtoken", data.toString()); List accountInfoList = new ArrayList<>(); - accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial(getApplicationContext()))); - if (Utils.NOSN.equalsIgnoreCase(Utils.getSerial())) { + String sn = Utils.getSerial(getApplicationContext()); + Log.e("TPush", "onSuccess: " + sn); + accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), sn)); + if (Utils.NOSN.equalsIgnoreCase(sn)) { 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(getApplicationContext(), accountInfoList, new XGIOperateCallback() { @Override public void onSuccess(Object data, int flag) { - Log.e("TPush", "onSuccess, data:" + data + ", flag:" + flag); + Log.e("TPush upsertAccounts", "onSuccess, data:" + data + ", flag:" + flag); } @Override public void onFail(Object data, int errCode, String msg) { - Log.e("TPush", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg); + Log.e("TPush upsertAccounts", "onFail, data:" + data + ", code:" + errCode + ", msg:" + msg); } }); } @@ -150,4 +159,51 @@ public class BaseApplication extends MultiDexApplication { } }); } + + private void aliyunPushInit() { + PushServiceFactory.init(this); + final CloudPushService pushService = PushServiceFactory.getCloudPushService(); + pushService.setLogLevel(CloudPushService.LOG_DEBUG); + pushService.register(this, new CommonCallback() { + @Override + public void onSuccess(String response) { + Log.e("AliyunPush", "init cloudchannel success"); + Log.e("AliyunPush", "init cloudchannel success " + pushService.getDeviceId()); + String sn = Utils.getSerial(BaseApplication.this); + if (TextUtils.isEmpty(sn)) { + return; + } + pushService.bindAccount(sn, new CommonCallback() { + @Override + public void onSuccess(String s) { + Log.e("AliyunPush", "bind account " + sn + " success\n"); + } + + @Override + public void onFailed(String errorCode, String errorMsg) { + Log.e("AliyunPush", "bind account " + sn + " failed." + + "errorCode: " + errorCode + ", errorMsg:" + errorMsg); + } + }); + pushService.addAlias(sn, new CommonCallback() { + @Override + public void onSuccess(String s) { + Log.e("AliyunPush", "add alias " + sn + " success\n"); + } + + @Override + public void onFailed(String errorCode, String errorMsg) { + Log.e("AliyunPush", "add alias " + sn + " failed." + + "errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n"); + } + }); + } + + @Override + public void onFailed(String errorCode, String errorMessage) { + Log.e("AliyunPush", "init cloudchannel failed -- errorcode:" + errorCode + " -- errorMessage:" + errorMessage); + } + }); + } + } 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 cf13e1f..c779fc3 100644 --- a/app/src/main/java/com/aoleyun/sn/comm/CommonConfig.java +++ b/app/src/main/java/com/aoleyun/sn/comm/CommonConfig.java @@ -85,7 +85,7 @@ public class CommonConfig { public final static String AOLE_ACTION_APP_POWER_ON = "aole_app_power_on"; /*禁止联网应用*/ public final static String AOLE_ACTION_NETWORK_DISALLOW = "aole_network_disallow"; - /*允许联网应用*/ + /*允许联网应用 G10P*/ public final static String AOLE_ACTION_NETWORK_ALLOW = "aole_network_allow"; diff --git a/app/src/main/java/com/aoleyun/sn/comm/PackageNames.java b/app/src/main/java/com/aoleyun/sn/comm/PackageNames.java index bd52fd5..1122b78 100644 --- a/app/src/main/java/com/aoleyun/sn/comm/PackageNames.java +++ b/app/src/main/java/com/aoleyun/sn/comm/PackageNames.java @@ -19,4 +19,6 @@ public class PackageNames { public static final String BROWSER = "com.aoleyun.browser"; public static final String APP_STORE_BOOTRECEIVER = "com.aoleyun.appstore.receiver.BootReceiver"; public static final String LEARNING_DESKTOP = "com.aoleyunos.dop2"; + public static final String YIXUEPAI_DESKTOP = "com.ygyb.yischool"; + } 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 4a1a922..cc7cec1 100644 --- a/app/src/main/java/com/aoleyun/sn/network/NetInterfaceManager.java +++ b/app/src/main/java/com/aoleyun/sn/network/NetInterfaceManager.java @@ -3,6 +3,7 @@ package com.aoleyun.sn.network; import android.annotation.SuppressLint; import android.app.AlarmManager; import android.app.PendingIntent; +import android.app.StatusBarManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -13,9 +14,9 @@ import android.util.Log; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.sdk.android.push.CloudPushService; +import com.alibaba.sdk.android.push.CommonCallback; +import com.alibaba.sdk.android.push.noonesdk.PushServiceFactory; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.bean.AppAttr; import com.aoleyun.sn.bean.AppID; @@ -117,6 +118,7 @@ import com.aoleyun.sn.utils.WiFiUtils; import com.arialyy.aria.core.Aria; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; @@ -149,6 +151,7 @@ import io.reactivex.rxjava3.core.Observer; import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.functions.BiFunction; import io.reactivex.rxjava3.functions.Function5; +import io.reactivex.rxjava3.functions.Function6; import io.reactivex.rxjava3.schedulers.Schedulers; import io.reactivex.rxjava3.subjects.BehaviorSubject; import okhttp3.Cache; @@ -754,10 +757,13 @@ public class NetInterfaceManager { .getUpdateApi().getUpdate(PackageNames.BROWSER, JGYUtils.getInstance().checkAppPlatform()); Observable> learningDesktopObservable = NetInterfaceManager.getInstance() .getUpdateApi().getUpdate(PackageNames.LEARNING_DESKTOP, JGYUtils.getInstance().checkAppPlatform()); - Observable.zip(infoUpdateObservable, storeUpdateObservable, desktopUpdateObservable, notifyUpdateObservable, browserUpdateObservable, + Observable.zip(infoUpdateObservable, storeUpdateObservable, desktopUpdateObservable, + notifyUpdateObservable, browserUpdateObservable, new Function5, BaseResponse, BaseResponse, BaseResponse, BaseResponse, List>() { @Override - public List apply(BaseResponse appUpdateInfoBaseResponse, BaseResponse appUpdateInfoBaseResponse2, BaseResponse appUpdateInfoBaseResponse3, BaseResponse appUpdateInfoBaseResponse4, BaseResponse appUpdateInfoBaseResponse5) throws Throwable { + public List apply + (BaseResponse appUpdateInfoBaseResponse, BaseResponse appUpdateInfoBaseResponse2, BaseResponse appUpdateInfoBaseResponse3, + BaseResponse appUpdateInfoBaseResponse4, BaseResponse appUpdateInfoBaseResponse5) throws Throwable { List appUpdateInfos = new ArrayList<>(); if (appUpdateInfoBaseResponse.code == OK) { appUpdateInfos.add(appUpdateInfoBaseResponse.data); @@ -996,7 +1002,7 @@ public class NetInterfaceManager { if (jsonString == null) { getDefaultDesktop(lifecycle, callback); } else { - JSONObject data = JSON.parseObject(jsonString); + JsonObject data = GsonUtils.getJsonObject(jsonString); if (data != null) { JGYUtils.getInstance().installDesktop(data); } @@ -1034,7 +1040,7 @@ public class NetInterfaceManager { if (baseResponse.code == OK) { ForceDownloadData desktopInfo = baseResponse.data; String jsonString = GsonUtils.toJSONString(desktopInfo); - JSONObject data = JSON.parseObject(jsonString); + JsonObject data = GsonUtils.getJsonObject(jsonString); cacheHelper.put(UrlAddress.GET_DESKTOP, jsonString); JGYUtils.getInstance().installDesktop(data); setDefaultDesktop(desktopInfo.getApp_package()); @@ -1772,7 +1778,7 @@ public class NetInterfaceManager { @Override public void onNext(BaseResponse defaultAppBaseResponse) { - Log.e("getDefaultApp", "onNext: " + JSONObject.toJSONString(defaultAppBaseResponse.data)); + Log.e("getDefaultApp", "onNext: " + GsonUtils.toJSONString(defaultAppBaseResponse.data)); int code = defaultAppBaseResponse.code; if (code == OK) { DefaultApp defaultApp = defaultAppBaseResponse.data; @@ -1956,9 +1962,19 @@ public class NetInterfaceManager { // Log.e( "getLockedState", "onNext: " + "state changed , reset devices"); // Utils.doMasterClear(mContext); // } + if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform) { + JGYUtils.getInstance().showApp(PackageNames.YIXUEPAI_DESKTOP); + JGYUtils.getInstance().setYxpDefaultDesktop(); + } Settings.System.putInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED); } else if (locked == JGYActions.NET_CODE_UNLOCKED) { // SysSettingUtils.setEnableSetting(mContext); + if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform) { + JGYUtils.getInstance().hideApp(PackageNames.YIXUEPAI_DESKTOP); + JGYUtils.getInstance().setDefaultDesktop(); + StatusBarManager mStatusBarManager = (StatusBarManager) mContext.getSystemService(Context.STATUS_BAR_SERVICE); + mStatusBarManager.disable(StatusBarManager.DISABLE_NONE); + } Settings.System.putInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_UNLOCKED); } } else if (response.code == NOTFOUND) { @@ -2141,7 +2157,7 @@ public class NetInterfaceManager { }; } - public void clearAndAppendTags(Set tagSets) { + public void clearAndAppendTags(Set tagSets) { XGPushManager.clearAndAppendTags(mContext, "clearAndAppendTags :" + System.currentTimeMillis(), tagSets, new XGIOperateCallback() { @Override public void onSuccess(Object o, int i) { @@ -2153,6 +2169,20 @@ public class NetInterfaceManager { Log.e("setPushTags", "onFail: " + o); } }); + String[] tag = new ArrayList<>(tagSets).toArray(new String[tagSets.size()]); + CloudPushService pushService = PushServiceFactory.getCloudPushService(); + pushService.bindTag(CloudPushService.DEVICE_TARGET, tag, null, new CommonCallback() { + @Override + public void onSuccess(String s) { + Log.e("bindTag", "bind tag " + Arrays.toString(tag) + " success\n"); + } + + @Override + public void onFailed(String errorCode, String errorMsg) { + Log.e("bindTag", "bind tag " + Arrays.toString(tag) + " failed." + + "errorCode: " + errorCode + ", errorMsg:" + errorMsg + "\n"); + } + }); } @@ -2745,6 +2775,7 @@ public class NetInterfaceManager { JGYUtils.getInstance().writeAppPackageList(mContext, result); JGYUtils.getInstance().deleteOtherApp(); } else { + JGYUtils.getInstance().writeAppPackageList(); cacheHelper.put(UrlAddress.SET_WHITE_PACKAGE_LIST, ""); Log.e("getAppLimit", "onNext: " + baseResponse); } @@ -3411,18 +3442,18 @@ public class NetInterfaceManager { Log.e("fht", "获取信息失败"); } - JSONObject data = new JSONObject(); - JSONArray appinfo = new JSONArray(); + JsonObject data = new JsonObject(); + JsonArray appinfo = new JsonArray(); try { if (localAppList.size() > 0) { for (int i = 0; i < 5; i++) { AppInformation information = localAppList.get(i); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("package", information.getPackageName()); - jsonObject.put("use_time", (int) information.getUsedTimebyDay() / 1000); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("package", information.getPackageName()); + jsonObject.addProperty("use_time", (int) information.getUsedTimebyDay() / 1000); appinfo.add(jsonObject); } - data.put("data", appinfo); + data.add("data", appinfo); } } catch (Exception e) { Log.e("sendAppUsedTime", e.getMessage()); @@ -3430,7 +3461,7 @@ public class NetInterfaceManager { NetInterfaceManager.getInstance() .getAppLogApi() - .getAppLog(Utils.getSerial(mContext), random, data.toJSONString()) + .getAppLog(Utils.getSerial(mContext), random, data.toString()) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer() { @@ -3497,7 +3528,7 @@ public class NetInterfaceManager { return; } getBatteryInfoApi() - .sendBatteryInfo(Utils.getSerial(), HTTP_KEY, + .sendBatteryInfo(Utils.getSerial(mContext), HTTP_KEY, info.getBattery_quantity(), info.getBattery_temperature(), info.getBattery_voltage(), diff --git a/app/src/main/java/com/aoleyun/sn/tpush/MessageReceiver.java b/app/src/main/java/com/aoleyun/sn/push/PushManager.java similarity index 74% rename from app/src/main/java/com/aoleyun/sn/tpush/MessageReceiver.java rename to app/src/main/java/com/aoleyun/sn/push/PushManager.java index 34a2f05..c75d656 100644 --- a/app/src/main/java/com/aoleyun/sn/tpush/MessageReceiver.java +++ b/app/src/main/java/com/aoleyun/sn/push/PushManager.java @@ -1,4 +1,4 @@ -package com.aoleyun.sn.tpush; +package com.aoleyun.sn.push; import android.annotation.SuppressLint; import android.content.ContentResolver; @@ -17,10 +17,7 @@ import android.os.PowerManager; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; -import android.widget.Toast; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.aoleyun.sn.R; import com.aoleyun.sn.bean.BaseResponse; import com.aoleyun.sn.bean.BatteryInfo; @@ -37,8 +34,6 @@ import com.aoleyun.sn.network.NetInterfaceManager; import com.aoleyun.sn.network.RetryCallback; import com.aoleyun.sn.network.UrlAddress; import com.aoleyun.sn.service.main.MainService; -import com.aoleyun.sn.tpush.common.NotificationService; -import com.aoleyun.sn.tpush.po.XGNotification; import com.aoleyun.sn.utils.ApkUtils; import com.aoleyun.sn.utils.BatteryUtils; import com.aoleyun.sn.utils.CacheUtils; @@ -57,21 +52,12 @@ import com.baidu.location.LocationClient; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; -import com.tencent.android.tpush.NotificationAction; -import com.tencent.android.tpush.XGPushBaseReceiver; -import com.tencent.android.tpush.XGPushClickedResult; -import com.tencent.android.tpush.XGPushRegisterResult; -import com.tencent.android.tpush.XGPushShowedResult; -import com.tencent.android.tpush.XGPushTextMessage; import com.tencent.mmkv.MMKV; import java.io.File; import java.lang.reflect.Type; -import java.text.SimpleDateFormat; import java.util.Arrays; -import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -89,12 +75,40 @@ import okhttp3.RequestBody; import retrofit2.Call; import retrofit2.Response; -public class MessageReceiver extends XGPushBaseReceiver { - private static final String TAG = MessageReceiver.class.getSimpleName(); +public class PushManager { + private static final String TAG = PushManager.class.getSimpleName(); - public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW"; - public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION"; - public static final String LogTag = "xg.test"; + + @SuppressLint("StaticFieldLeak") + private static PushManager sInstance; + private Context mContext; + private PackageManager mPackageManager; + private ContentResolver mResolver; + private CacheHelper mCacheHelper; + private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE); + + private PushManager(Context context) { + if (context == null) { + throw new RuntimeException("Context is NULL"); + } + this.mContext = context; + this.mResolver = context.getContentResolver(); + this.mCacheHelper = new CacheHelper(context); + this.mPackageManager = mContext.getPackageManager(); + } + + public static void init(Context context) { + if (sInstance == null) { + sInstance = new PushManager(context); + } + } + + public static PushManager getInstance() { + if (sInstance == null) { + throw new IllegalStateException("You must be init PushManager first"); + } + return sInstance; + } /*删除应用*/ private static final String MSG_DELETE = "1"; @@ -189,289 +203,13 @@ public class MessageReceiver extends XGPushBaseReceiver { /*判断是否更新桌面*/ private static final String UPDATE_DESKTOP = "56"; - - private Context mContext; - private ContentResolver mResolver; - private PackageManager mPackageManager; - private CacheHelper cacheHelper; - - /** - * 消息透传处理 - * - * @param context - * @param message 解析自定义的 JSON - */ - @Override - public void onTextMessage(Context context, XGPushTextMessage message) { - this.mContext = context; - this.mResolver = context.getContentResolver(); - this.mPackageManager = context.getPackageManager(); - this.cacheHelper = new CacheHelper(context); - String text = "收到消息:" + message.toString(); - // 获取自定义key-value - String customContent = message.getCustomContent(); - if (customContent != null && customContent.length() != 0) { - JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject(); - // key1为前台配置的key - if (!TextUtils.isEmpty(obj.get("key").getAsString())) { - String value = obj.get("key").getAsString(); - Log.d(LogTag, "get custom value:" + value); - } - // ... - } - // APP自主处理消息的过程... - Log.e(LogTag, text); - show(context, text); - processCustomMessage(context, message); - } - - /** - * 通知展示 - * - * @param context - * @param notifiShowedRlt 包含通知的内容 - */ - @Override - public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) { - if (context == null || notifiShowedRlt == null) { - return; - } - XGNotification notific = new XGNotification(); - notific.setMsg_id(notifiShowedRlt.getMsgId()); - notific.setTitle(notifiShowedRlt.getTitle()); - notific.setContent(notifiShowedRlt.getContent()); - // notificationActionType==1为Activity,2为url,3为intent - notific.setNotificationActionType(notifiShowedRlt - .getNotificationActionType()); - // Activity,url,intent都可以通过getActivity()获得 - notific.setActivity(notifiShowedRlt.getActivity()); - notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") - .format(Calendar.getInstance().getTime())); - NotificationService.getInstance(context).save(notific); - - Intent testIntent = new Intent(TEST_ACTION); - if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) { - testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION); - } else { - testIntent.putExtra("step", Constants.TEST_NOTIFICATION); - } - context.sendBroadcast(testIntent); - - Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION); - context.sendBroadcast(viewIntent); - show(context, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString()); - Log.d(LogTag, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel()); - } - - /** - * 注册回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - */ - @Override - public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) { - if (context == null || message == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - // 在这里拿token - String token = message.getToken(); - text = "注册成功1. token:" + token; - } else { - text = message + "注册失败,错误码:" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - } - - /** - * 反注册回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - */ - @Override - public void onUnregisterResult(Context context, int errorCode) { - if (context == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - text = "反注册成功"; - } else { - text = "反注册失败" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - - } - - /** - * 设置标签回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param tagName 设置的 TAG - */ - @Override - public void onSetTagResult(Context context, int errorCode, String tagName) { - if (context == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - text = "\"" + tagName + "\"设置成功"; - } else { - text = "\"" + tagName + "\"设置失败,错误码:" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_SET_TAG); - context.sendBroadcast(testIntent); - } - - /** - * 删除标签的回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param tagName 设置的 TAG - */ - @Override - public void onDeleteTagResult(Context context, int errorCode, String tagName) { - if (context == null) { - return; - } - String text = ""; - if (errorCode == XGPushBaseReceiver.SUCCESS) { - text = "\"" + tagName + "\"删除成功"; - } else { - text = "\"" + tagName + "\"删除失败,错误码:" + errorCode; - } - Log.d(LogTag, text); - show(context, text); - - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_DEL_TAG); - context.sendBroadcast(testIntent); - } - - /** - * 设置账号回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param account 设置的账号 - */ - @Override - public void onSetAccountResult(Context context, int errorCode, String account) { - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT); - context.sendBroadcast(testIntent); - } - - - /** - * 删除账号回调 - * - * @param context - * @param errorCode 0 为成功,其它为错误码 - * @param account 设置的账号 - */ - @Override - public void onDeleteAccountResult(Context context, int errorCode, String account) { - Intent testIntent = new Intent(TEST_ACTION); - testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT); - context.sendBroadcast(testIntent); - } - - @Override - public void onSetAttributeResult(Context context, int i, String s) { - - } - - @Override - public void onDeleteAttributeResult(Context context, int i, String s) { - - } - - @Override - public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) { - Log.i(LogTag, "action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data); - } - - /** - * 通知点击回调 actionType=1为该消息被清除,actionType=0为该消息被点击 - * - * @param context - * @param message 包含被点击通知的内容 - */ - @Override - public void onNotificationClickedResult(Context context, XGPushClickedResult message) { - if (context == null || message == null) { - return; - } - String text = ""; - if (message.getActionType() == NotificationAction.clicked.getType()) { - // 通知在通知栏被点击啦。。。。。 - // APP自己处理点击的相关动作 - // 这个动作可以在activity的onResume也能监听,请看第3点相关内容 - text = "通知被打开 :" + message; - } else if (message.getActionType() == NotificationAction.delete.getType()) { - // 通知被清除啦。。。。 - // APP自己处理通知被清除后的相关动作 - text = "通知被清除 :" + message; - } - Toast.makeText(context, "广播接收到通知被点击:" + message.toString(), - Toast.LENGTH_SHORT).show(); - // 获取自定义key-value - String customContent = message.getCustomContent(); - if (customContent != null && customContent.length() != 0) { - JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject(); - // key1为前台配置的key - if (!TextUtils.isEmpty(obj.get("key").getAsString())) { - String value = obj.get("key").getAsString(); - Log.d(LogTag, "get custom value:" + value); - } - // ... - } - // APP自主处理的过程。。。 - Log.d(LogTag, text); - show(context, text); - } - - private void show(Context context, String text) { -// Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); - } - - private int changeNum(int paramInt) { - return paramInt == 0 ? 1 : 0; - } - - private void processCustomMessage(Context context, XGPushTextMessage message) { - if (context == null || message == null) { - return; - } - - String title = message.getTitle(); - String content = message.getContent(); - JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject(); - - String extras = ""; - if (extrasJson.get("extras") != null) { - extras = extrasJson.get("extras").toString(); - } - + public void setPushContent(String title, String extras) { switch (title) { case MSG_DELETE: ToastUtil.betaShow("收到管控:应用删除"); if (!TextUtils.isEmpty(extras)) { - JSONObject jsonObject = JSON.parseObject(extras); - String pkg = jsonObject.getString("package_name"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String pkg = jsonObject.get("package_name").getAsString(); if (TextUtils.isEmpty(pkg)) return; ApkUtils.UninstallAPP(mContext, pkg); } @@ -511,11 +249,11 @@ public class MessageReceiver extends XGPushBaseReceiver { ToastUtil.betaShow("收到管控:设备重置"); JGYUtils.getInstance().cleanAoleLauncher3Cache(); Utils.doMasterClear(mContext); - MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE).clearAll(); + mMMKV.clearAll(); JGYUtils.getInstance().cleanAoleAppCache(); JGYUtils.getInstance().wakeUpAoleyunAPP(); NetInterfaceManager.getInstance().setPushTags(); - sendRefreshBroadcast(context); + sendRefreshBroadcast(mContext); break; case MSG_INSTALL: ToastUtil.betaShow("收到管控:应用安装"); @@ -543,9 +281,9 @@ public class MessageReceiver extends XGPushBaseReceiver { break; case GET_APP_USEDTIME: ToastUtil.betaShow("收到管控:获取应用使用时间"); - JSONObject usedTimeJson = JSON.parseObject(extras); - String random = usedTimeJson.getString("random"); - String sendType = usedTimeJson.getString("type"); + JsonObject usedTimeJson = GsonUtils.getJsonObject(extras); + String random = usedTimeJson.get("random").getAsString(); + String sendType = usedTimeJson.get("type").getAsString(); NetInterfaceManager.getInstance().sendAppUsedTime(random, sendType); break; case GET_FORCEDOWNLOADURL: @@ -558,16 +296,16 @@ public class MessageReceiver extends XGPushBaseReceiver { Log.e(TAG, "settingNetControl extras is null"); return; } - JSONObject extra = JSON.parseObject(extras); - String app_name = extra.getString("app_name"); - String app_package = extra.getString("package"); - String url = extra.getString("url"); - int versionCode = extra.getInteger("version_code"); - String app_id = extra.getString("app_id"); - JSONObject packageObj = new JSONObject(); - packageObj.put("app_name", app_name); - packageObj.put("app_package", app_package); - packageObj.put("app_id", app_id); + JsonObject extra = GsonUtils.getJsonObject(extras); + String app_name = extra.get("app_name").getAsString(); + String app_package = extra.get("package").getAsString(); + String url = extra.get("url").getAsString(); + int versionCode = extra.get("version_code").getAsInt(); + String app_id = extra.get("app_id").getAsString(); + JsonObject packageObj = new JsonObject(); + packageObj.addProperty("app_name", app_name); + packageObj.addProperty("app_package", app_package); + packageObj.addProperty("app_id", app_id); Utils.ariaDownload(mContext, url, packageObj); break; case SET_HOMEPAG_TAG: @@ -620,8 +358,8 @@ public class MessageReceiver extends XGPushBaseReceiver { break; case GET_DEVICES_INFO: ToastUtil.betaShow("收到管控:获取设备信息"); - getBatteryInfo(context); - sendRefreshBroadcast(context); + getBatteryInfo(mContext); + sendRefreshBroadcast(mContext); LocationClient locationClient = MapManager.getInstance().getLocationClient(); locationClient.stop(); locationClient.start(); @@ -708,8 +446,8 @@ public class MessageReceiver extends XGPushBaseReceiver { break; case LOCK_SCREEN: ToastUtil.betaShow("收到管控:屏幕锁定"); - JSONObject lockJSONObject = JSON.parseObject(extras); - String name = lockJSONObject.getString("name"); + JsonObject lockJSONObject = GsonUtils.getJsonObject(extras); + String name = lockJSONObject.get("name").getAsString(); setLock_screen(1, name); break; case UNLOCK_SCREEN: @@ -718,8 +456,8 @@ public class MessageReceiver extends XGPushBaseReceiver { break; case KILL_SERVER: ToastUtil.betaShow("收到管控:停止应用"); - JSONObject killJSONObject = JSON.parseObject(extras); - String packages = killJSONObject.getString("package_name"); + JsonObject killJSONObject = GsonUtils.getJsonObject(extras); + String packages = killJSONObject.get("package_name").getAsString(); JGYUtils.getInstance().killBackgroundProcesses(packages); break; case TIME_CONTROL: @@ -775,7 +513,7 @@ public class MessageReceiver extends XGPushBaseReceiver { e.printStackTrace(); Log.e(TAG, "setHomepagtag: " + e.getMessage()); } - sendRefreshBroadcast(context); + sendRefreshBroadcast(mContext); break; case UPDATE_WIFI_PW: NetInterfaceManager.getInstance().getWiFiPasswd(); @@ -799,10 +537,10 @@ public class MessageReceiver extends XGPushBaseReceiver { senSNLogFile(extras); break; case DISABLE_APP_USAGE: - disableApp(content, extras); + disableApp(extras); break; case INFO_BATTERY_INFO: - getBatteryInfo(context); + getBatteryInfo(mContext); break; case UPDATE_DESKTOP: @@ -811,7 +549,11 @@ public class MessageReceiver extends XGPushBaseReceiver { } } - private void disableApp(String content, String extras) { + private int changeNum(int paramInt) { + return paramInt == 0 ? 1 : 0; + } + + private void disableApp(String extras) { JsonObject jsonObject = GsonUtils.getJsonObject(extras); try { String packages = jsonObject.get("package").getAsString(); @@ -832,7 +574,7 @@ public class MessageReceiver extends XGPushBaseReceiver { ScreenLockState screenLockState = new ScreenLockState(); screenLockState.setIs_screen_lock(state); screenLockState.setName(name); - cacheHelper.put(UrlAddress.GET_LOCK_SCREEN_STATE, GsonUtils.toJSONString(screenLockState)); + mCacheHelper.put(UrlAddress.GET_LOCK_SCREEN_STATE, GsonUtils.toJSONString(screenLockState)); Intent intent = new Intent(); intent.putExtra("name", name); if (state == 1) { @@ -872,11 +614,11 @@ public class MessageReceiver extends XGPushBaseReceiver { mContext.sendBroadcast(intent); } - JSONObject packageObj = new JSONObject(); - packageObj.put("app_name", app_name); - packageObj.put("app_package", app_package); - packageObj.put("app_id", app_id); - packageObj.put("MD5", MD5); + JsonObject packageObj = new JsonObject(); + packageObj.addProperty("app_name", app_name); + packageObj.addProperty("app_package", app_package); + packageObj.addProperty("app_id", app_id); + packageObj.addProperty("MD5", MD5); Log.e(TAG, "doDownloadAndInstall: app_package:" + app_package); Log.e(TAG, "doDownloadAndInstall: app_url:" + app_url); PackageInfo packageInfo = null; @@ -921,10 +663,10 @@ public class MessageReceiver extends XGPushBaseReceiver { } private void setDisableSlideList(String jsonString) { - JSONObject jSONObject = JSON.parseObject(jsonString); + JsonObject jSONObject = GsonUtils.getJsonObject(jsonString); Log.e("setDisableSlideList", "jSONObject::" + jSONObject.toString()); - String strban = jSONObject.getString("ban"); - String strnot = jSONObject.getString("not"); + String strban = jSONObject.get("ban").getAsString(); + String strnot = jSONObject.get("not").getAsString(); String aole_disable_slide = Settings.System.getString(mResolver, CommonConfig.AOLE_ACTION_DISABLE_SLIDE); Log.e("fht", "aole_disable_slide: " + aole_disable_slide); @@ -939,9 +681,9 @@ public class MessageReceiver extends XGPushBaseReceiver { private void setDisableUpdateList(String jsonString) { Log.e("setDisableUpdateList", jsonString); - JSONObject jsonObject = JSON.parseObject(jsonString); - String ban = jsonObject.getString("ban"); - String not = jsonObject.getString("not"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + String ban = jsonObject.get("ban").getAsString(); + String not = jsonObject.get("not").getAsString(); String[] banList = ban.split(","); String[] notList = not.split(","); boolean b = Utils.writeDisableUpdateList(mContext, banList, notList); @@ -955,8 +697,8 @@ public class MessageReceiver extends XGPushBaseReceiver { Log.e(TAG, "settingNetControl extras is null"); return; } - JSONObject jSONObject = JSON.parseObject(s); - String s1 = jSONObject.getString("ban"); + JsonObject jSONObject = GsonUtils.getJsonObject(s); + String s1 = jSONObject.get("ban").getAsString(); // String str = jSONObject.optString("not"); Log.e("settingCamera", "ban::" + s1); // Log.e("settingCamera", "not::" + str); @@ -976,21 +718,21 @@ public class MessageReceiver extends XGPushBaseReceiver { Log.e(TAG, "settingNetControl extras is null"); // return; } - JSONObject jSONObject = JSON.parseObject(s); + JsonObject jSONObject = GsonUtils.getJsonObject(s); Log.e("settingOneNet", "jSONObject::" + jSONObject.toString()); - String packages = jSONObject.getString("package"); - String status = jSONObject.getString("status"); + String packages = jSONObject.get("package").getAsString(); + String status = jSONObject.get("status").getAsString(); } private void settingNetControl(String s) { if (TextUtils.isEmpty(s)) { Log.e(TAG, "settingNetControl extras is null"); } - JSONObject jSONObject = JSON.parseObject(s); + JsonObject jSONObject = GsonUtils.getJsonObject(s); Log.e("settingNetControl", "jSONObject::" + jSONObject.toString()); - String disallow = jSONObject.getString("ban"); - String allow = jSONObject.getString("not"); + String disallow = jSONObject.get("ban").getAsString(); + String allow = jSONObject.get("not").getAsString(); HashSet disallowApp = new HashSet<>(Arrays.asList(disallow.split(","))); HashSet allowApp = new HashSet<>(Arrays.asList(allow.split(","))); JGYUtils.setAppNetwork(mContext, disallowApp, allowApp); @@ -1001,9 +743,9 @@ public class MessageReceiver extends XGPushBaseReceiver { Log.e(TAG, "settingPowerOn extras is null"); return; } - JSONObject jSONObject = JSON.parseObject(s); - String ban = jSONObject.getString("ban"); - String not = jSONObject.getString("not"); + JsonObject jSONObject = GsonUtils.getJsonObject(s); + String ban = jSONObject.get("ban").getAsString(); + String not = jSONObject.get("not").getAsString(); Log.e(TAG, "settingPowerOn: aole_app_power_on = " + not); if (TextUtils.isEmpty(not)) { //当 qch_app_power_on 的值为空时,会造成系统所有应用断网 @@ -1044,9 +786,8 @@ public class MessageReceiver extends XGPushBaseReceiver { Log.e(TAG, "settingLock extras is null"); return; } - JSONObject jSONObject = JSON.parseObject(s); - - int i = changeNum(jSONObject.getIntValue("lock")); + JsonObject jSONObject = GsonUtils.getJsonObject(s); + int i = changeNum(jSONObject.get("lock").getAsInt()); Settings.System.putInt(mResolver, JGYActions.ACTION_QCH_UNLOCK_IPAD, i); Log.e("SystemSetting", "qch_unlock_ipad---------" + i); @@ -1058,7 +799,7 @@ public class MessageReceiver extends XGPushBaseReceiver { } public void screenshot(String s) { -// JSONObject jSONObject = JSON.parseObject(s); +// JsonObject jSONObject = GsonUtils.getJsonObject(s); // long createTime = jSONObject.getLong("createTime"); long createTime = System.currentTimeMillis() / 1000; PowerManager.WakeLock mWakeLock = JGYUtils.acquireWakeLock(mContext, 60 * 1000); @@ -1181,27 +922,27 @@ public class MessageReceiver extends XGPushBaseReceiver { } private void getTopApp(String extras) { - JSONObject jsonObject = JSON.parseObject(extras); - cacheHelper.put(UrlAddress.GET_TOP_APP_CONTROL, extras); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + mCacheHelper.put(UrlAddress.GET_TOP_APP_CONTROL, extras); - String packageName = jsonObject.getString("app_package"); + String packageName = jsonObject.get("app_package").getAsString(); if (TextUtils.isEmpty(packageName)) { - Settings.Global.putString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY, ""); + Settings.Global.putString(mResolver, ForegroundAppUtil.TOPAPP_KEY, ""); ForegroundAppUtil.setTopAppClass(mContext, ""); } else { - Settings.Global.putString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY, packageName); + Settings.Global.putString(mResolver, ForegroundAppUtil.TOPAPP_KEY, packageName); ForegroundAppUtil.setTopAppClass(mContext, packageName); ForegroundAppUtil.openTopApp(mContext); } - Log.e(TAG, "getTopApp: " + Settings.Global.getString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY)); + Log.e(TAG, "getTopApp: " + Settings.Global.getString(mResolver, ForegroundAppUtil.TOPAPP_KEY)); } private void setBootanimation(String extras) { - JSONObject jsonObject = JSONObject.parseObject(extras); - int type = jsonObject.getInteger("type"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + int type = jsonObject.get("type").getAsInt(); if (type == 1) { - String file_url = jsonObject.getString("file_url"); - String file_md5 = jsonObject.getString("file_md5"); + String file_url = jsonObject.get("file_url").getAsString(); + String file_md5 = jsonObject.get("file_md5").getAsString(); JGYUtils.getInstance().checkBootFile(file_url, file_md5); } else { JGYUtils.getInstance().removeBootanimation(); @@ -1212,8 +953,8 @@ public class MessageReceiver extends XGPushBaseReceiver { if (TextUtils.isEmpty(extras)) { JGYUtils.getInstance().setDefaultDesktop(""); } else { - JSONObject jsonObject = JSON.parseObject(extras); - String default_launcher = jsonObject.getString("default_launcher"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String default_launcher = jsonObject.get("default_launcher").getAsString(); if (TextUtils.isEmpty(default_launcher)) { JGYUtils.getInstance().setDefaultDesktop(""); SPUtils.put(mContext, "default_launcher", ""); @@ -1225,7 +966,7 @@ public class MessageReceiver extends XGPushBaseReceiver { } private void playSound(String extras) { - JSONObject jsonObject = JSONObject.parseObject(extras); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); defaultCallMediaPlayer(mContext); } @@ -1295,8 +1036,8 @@ public class MessageReceiver extends XGPushBaseReceiver { } private void cleanCache(String extras) { - JSONObject jsonObject = JSONObject.parseObject(extras); - String packageName = jsonObject.getString("app_package"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String packageName = jsonObject.get("app_package").getAsString(); if (TextUtils.isEmpty(packageName)) { Log.e(TAG, "cleanCache: " + "package is empty"); } else { @@ -1314,8 +1055,8 @@ public class MessageReceiver extends XGPushBaseReceiver { } private void setDeveloperoptions(String extras) { - JSONObject jsonObject = JSONObject.parseObject(extras); - int is_developer = jsonObject.getInteger("is_developer"); + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + int is_developer = jsonObject.get("is_developer").getAsInt(); Log.e(TAG + ":" + "getDeveloper", "onNext: " + is_developer); Log.e(TAG, "setDeveloperoptions: " + is_developer); JGYUtils.getInstance().setDeveloperOptions(is_developer == 0 ? 1 : 0); @@ -1325,8 +1066,8 @@ public class MessageReceiver extends XGPushBaseReceiver { if (TextUtils.isEmpty(jsonString)) { throw new RuntimeException(); } - JSONObject jsonObject = JSON.parseObject(jsonString); - String platform = jsonObject.getString("platform"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + String platform = jsonObject.get("platform").getAsString(); if (JGYUtils.getInstance().isSamePlatform(platform)) { checkAPPInstall(jsonObject); } else { @@ -1335,11 +1076,11 @@ public class MessageReceiver extends XGPushBaseReceiver { } @SuppressLint("NewApi") - private void checkAPPInstall(JSONObject jsonObject) { - long version_code = jsonObject.getLong("app_version_code"); + private void checkAPPInstall(JsonObject jsonObject) { + long version_code = jsonObject.get("app_version_code").getAsLong(); PackageInfo packageInfo = null; try { - packageInfo = mPackageManager.getPackageInfo(jsonObject.getString("app_package"), 0); + packageInfo = mPackageManager.getPackageInfo(jsonObject.get("app_package").getAsString(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } @@ -1351,15 +1092,15 @@ public class MessageReceiver extends XGPushBaseReceiver { } if (packageInfo == null || appVersionCode < version_code) { - Utils.ariaDownload(mContext, jsonObject.getString("app_url"), jsonObject); + Utils.ariaDownload(mContext, jsonObject.get("app_url").getAsString(), jsonObject); } else { Log.e(TAG, "checkAPPInstall: " + "已经是最新版"); } } private void setEbagCode(String jsonString) { - JSONObject jsonObject = JSON.parseObject(jsonString); - String ebagCode = jsonObject.getString("ebagCode"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + String ebagCode = jsonObject.get("ebagCode").getAsString(); if (TextUtils.isEmpty(ebagCode)) { Log.e(TAG, "setEbagCode: " + "ebagCode is empty"); } else { @@ -1407,9 +1148,9 @@ public class MessageReceiver extends XGPushBaseReceiver { * "is_log_type": 1 //获取运行日志类型 0即时 1定时 */ private void senSNLogFile(String jsonString) { - JSONObject jsonObject = JSON.parseObject(jsonString); - int is_log = jsonObject.getInteger("is_log"); - int is_log_type = jsonObject.getInteger("is_log_type"); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + int is_log = jsonObject.get("is_log").getAsInt(); + int is_log_type = jsonObject.get("is_log_type").getAsInt(); if (is_log == 0) { return; } diff --git a/app/src/main/java/com/aoleyun/sn/push/alipush/AliMessageIntentService.java b/app/src/main/java/com/aoleyun/sn/push/alipush/AliMessageIntentService.java new file mode 100644 index 0000000..7d22924 --- /dev/null +++ b/app/src/main/java/com/aoleyun/sn/push/alipush/AliMessageIntentService.java @@ -0,0 +1,99 @@ +package com.aoleyun.sn.push.alipush; + +import android.content.Context; +import android.util.Log; + +import com.alibaba.sdk.android.push.AliyunMessageIntentService; +import com.alibaba.sdk.android.push.notification.CPushMessage; + +import java.util.Map; + +/** + * Created by liyazhou on 17/8/22. + * 为避免推送广播被系统拦截的小概率事件,我们推荐用户通过IntentService处理消息互调,接入步骤: + * 1. 创建IntentService并继承AliyunMessageIntentService + * 2. 覆写相关方法,并在Manifest的注册该Service + * 3. 调用接口CloudPushService.setPushIntentService + * 详细用户可参考:https://help.aliyun.com/document_detail/30066.html#h2-2-messagereceiver-aliyunmessageintentservice + */ + +public class AliMessageIntentService extends AliyunMessageIntentService { + private static final String TAG = AliyunMessageIntentService.class.getSimpleName(); + + /** + * 推送通知的回调方法 + * + * @param context + * @param title + * @param summary + * @param extraMap + */ + @Override + protected void onNotification(Context context, String title, String summary, Map extraMap) { + Log.i(TAG, "收到一条推送通知 : " + title + ", summary:" + summary); + } + + /** + * 推送消息的回调方法 + * + * @param context + * @param cPushMessage + */ + @Override + protected void onMessage(Context context, CPushMessage cPushMessage) { + Log.i(TAG, "收到一条推送消息 : " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent()); + } + + /** + * 从通知栏打开通知的扩展处理 + * + * @param context + * @param title + * @param summary + * @param extraMap + */ + @Override + protected void onNotificationOpened(Context context, String title, String summary, String extraMap) { + Log.i(TAG, "onNotificationOpened : " + " : " + title + " : " + summary + " : " + extraMap); + } + + /** + * 无动作通知点击回调。当在后台或阿里云控制台指定的通知动作为无逻辑跳转时,通知点击回调为onNotificationClickedWithNoAction而不是onNotificationOpened + * + * @param context + * @param title + * @param summary + * @param extraMap + */ + @Override + protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) { + Log.i(TAG, "onNotificationClickedWithNoAction : " + " : " + title + " : " + summary + " : " + extraMap); + } + + /** + * 通知删除回调 + * + * @param context + * @param messageId + */ + @Override + protected void onNotificationRemoved(Context context, String messageId) { + Log.i(TAG, "onNotificationRemoved : " + messageId); + } + + /** + * 应用处于前台时通知到达回调。注意:该方法仅对自定义样式通知有效,相关详情请参考https://help.aliyun.com/document_detail/30066.html#h3-3-4-basiccustompushnotification-api + * + * @param context + * @param title + * @param summary + * @param extraMap + * @param openType + * @param openActivity + * @param openUrl + */ + @Override + protected void onNotificationReceivedInApp(Context context, String title, String summary, Map extraMap, int openType, String openActivity, String openUrl) { + Log.i(TAG, "onNotificationReceivedInApp : " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl); + } +} diff --git a/app/src/main/java/com/aoleyun/sn/push/alipush/AliyunMessageReceiver.java b/app/src/main/java/com/aoleyun/sn/push/alipush/AliyunMessageReceiver.java new file mode 100644 index 0000000..3ced65b --- /dev/null +++ b/app/src/main/java/com/aoleyun/sn/push/alipush/AliyunMessageReceiver.java @@ -0,0 +1,116 @@ +package com.aoleyun.sn.push.alipush; + +import android.content.Context; +import android.util.Log; + +import com.alibaba.sdk.android.push.MessageReceiver; +import com.alibaba.sdk.android.push.notification.CPushMessage; +import com.aoleyun.sn.push.PushManager; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + +import java.util.Map; + +/** + * @author: 正纬 + * @since: 15/4/9 + * @version: 1.1 + * @feature: 用于接收推送的通知和消息 + */ +public class AliyunMessageReceiver extends MessageReceiver { + // 消息接收部分的LOG_TAG + public static final String TAG = AliyunMessageReceiver.class.getSimpleName(); + + /** + * 推送通知的回调方法 + * + * @param context + * @param title + * @param summary + * @param extraMap + */ + @Override + public void onNotification(Context context, String title, String summary, Map extraMap) { + // TODO 处理推送通知 + if (null != extraMap) { + for (Map.Entry entry : extraMap.entrySet()) { + Log.i(TAG, "@Get diy param : Key=" + entry.getKey() + " , Value=" + entry.getValue()); + } + } else { + Log.i(TAG, "@收到通知 && 自定义消息为空"); + } + Log.i(TAG, "收到一条推送通知 : " + title + ", summary:" + summary); + } + + /** + * 应用处于前台时通知到达回调。注意:该方法仅对自定义样式通知有效,相关详情请参考https://help.aliyun.com/document_detail/30066.html?spm=5176.product30047.6.620.wjcC87#h3-3-4-basiccustompushnotification-api + * + * @param context + * @param title + * @param summary + * @param extraMap + * @param openType + * @param openActivity + * @param openUrl + */ + @Override + protected void onNotificationReceivedInApp(Context context, String title, String summary, Map extraMap, int openType, String openActivity, String openUrl) { + Log.i(TAG, "onNotificationReceivedInApp : " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl); + } + + /** + * 推送消息的回调方法 + * + * @param context + * @param cPushMessage + */ + @Override + public void onMessage(Context context, CPushMessage cPushMessage) { + Log.e(TAG, "收到一条推送消息 : " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent()); + String title = cPushMessage.getTitle(); + String content = cPushMessage.getContent(); + JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject(); + String extras = ""; + if (extrasJson.get("extras") != null) { + extras = extrasJson.get("extras").toString(); + } + PushManager.getInstance().setPushContent(title, extras); + } + + /** + * 从通知栏打开通知的扩展处理 + * + * @param context + * @param title + * @param summary + * @param extraMap + */ + @Override + public void onNotificationOpened(Context context, String title, String summary, String extraMap) { + Log.i(TAG, "onNotificationOpened : " + " : " + title + " : " + summary + " : " + extraMap); + } + + /** + * 通知删除回调 + * + * @param context + * @param messageId + */ + @Override + public void onNotificationRemoved(Context context, String messageId) { + Log.i(TAG, "onNotificationRemoved : " + messageId); + } + + /** + * 无动作通知点击回调。当在后台或阿里云控制台指定的通知动作为无逻辑跳转时,通知点击回调为onNotificationClickedWithNoAction而不是onNotificationOpened + * + * @param context + * @param title + * @param summary + * @param extraMap + */ + @Override + protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) { + Log.i(TAG, "onNotificationClickedWithNoAction : " + " : " + title + " : " + summary + " : " + extraMap); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/aoleyun/sn/tpush/Constants.java b/app/src/main/java/com/aoleyun/sn/push/tpush/Constants.java similarity index 93% rename from app/src/main/java/com/aoleyun/sn/tpush/Constants.java rename to app/src/main/java/com/aoleyun/sn/push/tpush/Constants.java index 6e5d21b..6975260 100644 --- a/app/src/main/java/com/aoleyun/sn/tpush/Constants.java +++ b/app/src/main/java/com/aoleyun/sn/push/tpush/Constants.java @@ -1,4 +1,4 @@ -package com.aoleyun.sn.tpush; +package com.aoleyun.sn.push.tpush; /** * Created by chacewang on 2019/7/5. diff --git a/app/src/main/java/com/aoleyun/sn/push/tpush/MessageReceiver.java b/app/src/main/java/com/aoleyun/sn/push/tpush/MessageReceiver.java new file mode 100644 index 0000000..efef39b --- /dev/null +++ b/app/src/main/java/com/aoleyun/sn/push/tpush/MessageReceiver.java @@ -0,0 +1,307 @@ +package com.aoleyun.sn.push.tpush; + +import android.content.ContentResolver; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.text.TextUtils; +import android.util.Log; +import android.widget.Toast; + +import com.aoleyun.sn.disklrucache.CacheHelper; +import com.aoleyun.sn.push.PushManager; +import com.aoleyun.sn.push.tpush.common.NotificationService; +import com.aoleyun.sn.push.tpush.po.XGNotification; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.tencent.android.tpush.NotificationAction; +import com.tencent.android.tpush.XGPushBaseReceiver; +import com.tencent.android.tpush.XGPushClickedResult; +import com.tencent.android.tpush.XGPushRegisterResult; +import com.tencent.android.tpush.XGPushShowedResult; +import com.tencent.android.tpush.XGPushTextMessage; + +import java.text.SimpleDateFormat; +import java.util.Calendar; + +public class MessageReceiver extends XGPushBaseReceiver { + private static final String TAG = MessageReceiver.class.getSimpleName(); + + public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW"; + public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION"; + public static final String LogTag = "xg.test"; + + private Context mContext; + private ContentResolver mResolver; + private PackageManager mPackageManager; + private CacheHelper cacheHelper; + + /** + * 消息透传处理 + * + * @param context + * @param message 解析自定义的 JSON + */ + @Override + public void onTextMessage(Context context, XGPushTextMessage message) { + this.mContext = context; + this.mResolver = context.getContentResolver(); + this.mPackageManager = context.getPackageManager(); + this.cacheHelper = new CacheHelper(context); + String text = "收到消息:" + message.toString(); + // 获取自定义key-value + String customContent = message.getCustomContent(); + if (customContent != null && customContent.length() != 0) { + JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject(); + // key1为前台配置的key + if (!TextUtils.isEmpty(obj.get("key").getAsString())) { + String value = obj.get("key").getAsString(); + Log.d(LogTag, "get custom value:" + value); + } + // ... + } + // APP自主处理消息的过程... + Log.e(LogTag, text); + show(context, text); + processCustomMessage(context, message); + } + + /** + * 通知展示 + * + * @param context + * @param notifiShowedRlt 包含通知的内容 + */ + @Override + public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) { + if (context == null || notifiShowedRlt == null) { + return; + } + XGNotification notific = new XGNotification(); + notific.setMsg_id(notifiShowedRlt.getMsgId()); + notific.setTitle(notifiShowedRlt.getTitle()); + notific.setContent(notifiShowedRlt.getContent()); + // notificationActionType==1为Activity,2为url,3为intent + notific.setNotificationActionType(notifiShowedRlt + .getNotificationActionType()); + // Activity,url,intent都可以通过getActivity()获得 + notific.setActivity(notifiShowedRlt.getActivity()); + notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") + .format(Calendar.getInstance().getTime())); + NotificationService.getInstance(context).save(notific); + + Intent testIntent = new Intent(TEST_ACTION); + if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) { + testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION); + } else { + testIntent.putExtra("step", Constants.TEST_NOTIFICATION); + } + context.sendBroadcast(testIntent); + + Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION); + context.sendBroadcast(viewIntent); + show(context, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString()); + Log.d(LogTag, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel()); + } + + /** + * 注册回调 + * + * @param context + * @param errorCode 0 为成功,其它为错误码 + */ + @Override + public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) { + if (context == null || message == null) { + return; + } + String text = ""; + if (errorCode == XGPushBaseReceiver.SUCCESS) { + // 在这里拿token + String token = message.getToken(); + text = "注册成功1. token:" + token; + } else { + text = message + "注册失败,错误码:" + errorCode; + } + Log.d(LogTag, text); + show(context, text); + } + + /** + * 反注册回调 + * + * @param context + * @param errorCode 0 为成功,其它为错误码 + */ + @Override + public void onUnregisterResult(Context context, int errorCode) { + if (context == null) { + return; + } + String text = ""; + if (errorCode == XGPushBaseReceiver.SUCCESS) { + text = "反注册成功"; + } else { + text = "反注册失败" + errorCode; + } + Log.d(LogTag, text); + show(context, text); + + } + + /** + * 设置标签回调 + * + * @param context + * @param errorCode 0 为成功,其它为错误码 + * @param tagName 设置的 TAG + */ + @Override + public void onSetTagResult(Context context, int errorCode, String tagName) { + if (context == null) { + return; + } + String text = ""; + if (errorCode == XGPushBaseReceiver.SUCCESS) { + text = "\"" + tagName + "\"设置成功"; + } else { + text = "\"" + tagName + "\"设置失败,错误码:" + errorCode; + } + Log.d(LogTag, text); + show(context, text); + + Intent testIntent = new Intent(TEST_ACTION); + testIntent.putExtra("step", Constants.TEST_SET_TAG); + context.sendBroadcast(testIntent); + } + + /** + * 删除标签的回调 + * + * @param context + * @param errorCode 0 为成功,其它为错误码 + * @param tagName 设置的 TAG + */ + @Override + public void onDeleteTagResult(Context context, int errorCode, String tagName) { + if (context == null) { + return; + } + String text = ""; + if (errorCode == XGPushBaseReceiver.SUCCESS) { + text = "\"" + tagName + "\"删除成功"; + } else { + text = "\"" + tagName + "\"删除失败,错误码:" + errorCode; + } + Log.d(LogTag, text); + show(context, text); + + Intent testIntent = new Intent(TEST_ACTION); + testIntent.putExtra("step", Constants.TEST_DEL_TAG); + context.sendBroadcast(testIntent); + } + + /** + * 设置账号回调 + * + * @param context + * @param errorCode 0 为成功,其它为错误码 + * @param account 设置的账号 + */ + @Override + public void onSetAccountResult(Context context, int errorCode, String account) { + Intent testIntent = new Intent(TEST_ACTION); + testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT); + context.sendBroadcast(testIntent); + } + + + /** + * 删除账号回调 + * + * @param context + * @param errorCode 0 为成功,其它为错误码 + * @param account 设置的账号 + */ + @Override + public void onDeleteAccountResult(Context context, int errorCode, String account) { + Intent testIntent = new Intent(TEST_ACTION); + testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT); + context.sendBroadcast(testIntent); + } + + @Override + public void onSetAttributeResult(Context context, int i, String s) { + + } + + @Override + public void onDeleteAttributeResult(Context context, int i, String s) { + + } + + @Override + public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) { + Log.i(LogTag, "action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data); + } + + /** + * 通知点击回调 actionType=1为该消息被清除,actionType=0为该消息被点击 + * + * @param context + * @param message 包含被点击通知的内容 + */ + @Override + public void onNotificationClickedResult(Context context, XGPushClickedResult message) { + if (context == null || message == null) { + return; + } + String text = ""; + if (message.getActionType() == NotificationAction.clicked.getType()) { + // 通知在通知栏被点击啦。。。。。 + // APP自己处理点击的相关动作 + // 这个动作可以在activity的onResume也能监听,请看第3点相关内容 + text = "通知被打开 :" + message; + } else if (message.getActionType() == NotificationAction.delete.getType()) { + // 通知被清除啦。。。。 + // APP自己处理通知被清除后的相关动作 + text = "通知被清除 :" + message; + } + Toast.makeText(context, "广播接收到通知被点击:" + message.toString(), + Toast.LENGTH_SHORT).show(); + // 获取自定义key-value + String customContent = message.getCustomContent(); + if (customContent != null && customContent.length() != 0) { + JsonObject obj = JsonParser.parseString(customContent).getAsJsonObject(); + // key1为前台配置的key + if (!TextUtils.isEmpty(obj.get("key").getAsString())) { + String value = obj.get("key").getAsString(); + Log.d(LogTag, "get custom value:" + value); + } + // ... + } + // APP自主处理的过程。。。 + Log.d(LogTag, text); + show(context, text); + } + + private void show(Context context, String text) { +// Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); + } + + private void processCustomMessage(Context context, XGPushTextMessage message) { + if (context == null || message == null) { + return; + } + + String title = message.getTitle(); + String content = message.getContent(); + JsonObject extrasJson = JsonParser.parseString(content).getAsJsonObject(); + + String extras = ""; + if (extrasJson.get("extras") != null) { + extras = extrasJson.get("extras").toString(); + } + PushManager.getInstance().setPushContent(title, extras); + } +} diff --git a/app/src/main/java/com/aoleyun/sn/tpush/common/DBOpenHelper.java b/app/src/main/java/com/aoleyun/sn/push/tpush/common/DBOpenHelper.java similarity index 93% rename from app/src/main/java/com/aoleyun/sn/tpush/common/DBOpenHelper.java rename to app/src/main/java/com/aoleyun/sn/push/tpush/common/DBOpenHelper.java index a72a305..e292f93 100644 --- a/app/src/main/java/com/aoleyun/sn/tpush/common/DBOpenHelper.java +++ b/app/src/main/java/com/aoleyun/sn/push/tpush/common/DBOpenHelper.java @@ -1,4 +1,4 @@ -package com.aoleyun.sn.tpush.common; +package com.aoleyun.sn.push.tpush.common; import android.content.Context; import android.database.sqlite.SQLiteDatabase; diff --git a/app/src/main/java/com/aoleyun/sn/tpush/common/NotificationService.java b/app/src/main/java/com/aoleyun/sn/push/tpush/common/NotificationService.java similarity index 98% rename from app/src/main/java/com/aoleyun/sn/tpush/common/NotificationService.java rename to app/src/main/java/com/aoleyun/sn/push/tpush/common/NotificationService.java index 484d97f..29c3d0d 100644 --- a/app/src/main/java/com/aoleyun/sn/tpush/common/NotificationService.java +++ b/app/src/main/java/com/aoleyun/sn/push/tpush/common/NotificationService.java @@ -1,11 +1,11 @@ -package com.aoleyun.sn.tpush.common; +package com.aoleyun.sn.push.tpush.common; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; -import com.aoleyun.sn.tpush.po.XGNotification; +import com.aoleyun.sn.push.tpush.po.XGNotification; import java.util.ArrayList; import java.util.List; diff --git a/app/src/main/java/com/aoleyun/sn/tpush/po/XGNotification.java b/app/src/main/java/com/aoleyun/sn/push/tpush/po/XGNotification.java similarity index 97% rename from app/src/main/java/com/aoleyun/sn/tpush/po/XGNotification.java rename to app/src/main/java/com/aoleyun/sn/push/tpush/po/XGNotification.java index e62d20c..c009d9f 100644 --- a/app/src/main/java/com/aoleyun/sn/tpush/po/XGNotification.java +++ b/app/src/main/java/com/aoleyun/sn/push/tpush/po/XGNotification.java @@ -1,4 +1,4 @@ -package com.aoleyun.sn.tpush.po; +package com.aoleyun.sn.push.tpush.po; public class XGNotification { private Integer id; 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 547a9d4..e0b8cab 100644 --- a/app/src/main/java/com/aoleyun/sn/service/GuardService.java +++ b/app/src/main/java/com/aoleyun/sn/service/GuardService.java @@ -19,14 +19,13 @@ import android.util.Log; import androidx.annotation.Nullable; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.KeepAliveConnection; import com.aoleyun.sn.R; import com.aoleyun.sn.bean.BaseResponse; import com.aoleyun.sn.comm.CommonConfig; import com.aoleyun.sn.comm.PackageNames; +import com.aoleyun.sn.gson.GsonUtils; import com.aoleyun.sn.manager.MapManager; import com.aoleyun.sn.network.NetInterfaceManager; import com.aoleyun.sn.network.api.post.SendScreenStatusApi; @@ -47,6 +46,7 @@ import com.arialyy.annotations.Download; import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.task.DownloadTask; import com.baidu.location.LocationClient; +import com.google.gson.JsonObject; import java.io.BufferedReader; import java.io.File; @@ -432,9 +432,9 @@ public class GuardService extends Service { @Override public void onNext(ResponseBody responseBody) { try { - com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(responseBody.string()); + JsonObject jsonObject = GsonUtils.getJsonObject(responseBody.string()); Log.e("getLockState", "onNext: " + jsonObject); - int code = jsonObject.getInteger("code"); + int code = jsonObject.get("code").getAsInt(); Log.e("getLockState", "onNext: code: " + code); } catch (IOException e) { e.printStackTrace(); @@ -843,9 +843,9 @@ public class GuardService extends Service { //在这里处理任务执行中的状态,如进度进度条的刷新 @Download.onTaskRunning protected void running(DownloadTask task) { - JSONObject jsonObject = JSON.parseObject(task.getExtendField()); - String app_name = jsonObject.getString("app_name"); - String app_package = jsonObject.getString("app_package"); + JsonObject jsonObject = GsonUtils.getJsonObject(task.getExtendField()); + String app_name = jsonObject.get("app_name").getAsString(); + String app_package = jsonObject.get("app_package").getAsString(); Log.e("aria", "正在下载:" + task.getPercent() + ":" + task.getExtendField()); ToastUtil.show("正在下载:" + app_name + "-" + task.getPercent() + "%" + "\t" + Formatter.formatFileSize(GuardService.this, task.getSpeed()) + "/s"); } @@ -859,10 +859,10 @@ public class GuardService extends Service { Log.e("taskComplete", "extendField::" + extendField); if (filepath.endsWith("apk")) { - JSONObject jsonObject = JSON.parseObject(extendField); - String app_name = jsonObject.getString("app_name"); - String app_package = jsonObject.getString("app_package"); - String app_id = jsonObject.getString("app_id"); + JsonObject jsonObject = GsonUtils.getJsonObject(extendField); + String app_name = jsonObject.get("app_name").getAsString(); + String app_package = jsonObject.get("app_package").getAsString(); + String app_id = jsonObject.get("app_id").getAsString(); ToastUtil.show(app_name + "\t:下载完成"); if (filepath.endsWith(".xapk")) { XAPKUtils.getInstance().installXAPK(filepath); @@ -936,9 +936,9 @@ public class GuardService extends Service { Aria.download(this).resumeAllTask(); final String filepath = task.getFilePath(); final String packageName = task.getExtendField(); - JSONObject jsonObject = JSON.parseObject(task.getExtendField()); - String app_name = jsonObject.getString("app_name"); - String app_package = jsonObject.getString("app_package"); + JsonObject jsonObject = GsonUtils.getJsonObject(task.getExtendField()); + String app_name = jsonObject.get("app_name").getAsString(); + String app_package = jsonObject.get("app_package").getAsString(); Log.e("aria", "taskFail: " + packageName + "filepath: " + filepath + "Exception: " + e.getMessage()); // ToastUtil.show(app_name + "\t:下载失败"); } catch (Exception e1) { diff --git a/app/src/main/java/com/aoleyun/sn/service/RemoteService.java b/app/src/main/java/com/aoleyun/sn/service/RemoteService.java index c94ca3f..e67f080 100644 --- a/app/src/main/java/com/aoleyun/sn/service/RemoteService.java +++ b/app/src/main/java/com/aoleyun/sn/service/RemoteService.java @@ -46,7 +46,7 @@ public class RemoteService extends Service { @Override public String getSerial() throws RemoteException { - return Utils.getSerial(); + return Utils.getSerial(RemoteService.this); } @Override diff --git a/app/src/main/java/com/aoleyun/sn/service/StepService.java b/app/src/main/java/com/aoleyun/sn/service/StepService.java index 53794e8..9159080 100644 --- a/app/src/main/java/com/aoleyun/sn/service/StepService.java +++ b/app/src/main/java/com/aoleyun/sn/service/StepService.java @@ -16,13 +16,13 @@ import android.util.Log; import androidx.annotation.Nullable; -import com.alibaba.fastjson.JSONObject; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.utils.JGYUtils; import com.blankj.utilcode.util.NetworkUtils; import com.aoleyun.sn.KeepAliveConnection; import com.aoleyun.sn.utils.ServiceAliveUtils; import com.aoleyun.sn.utils.Utils; +import com.google.gson.JsonObject; import org.java_websocket.handshake.ServerHandshake; @@ -231,29 +231,29 @@ public class StepService extends Service implements NetworkUtils.OnNetworkStatus * 发送消息 */ public void sendMsg() { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("sn", Utils.getSerial(this)); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("sn", Utils.getSerial(this)); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if (!pm.isScreenOn()) { - jsonObject.put("online", 2); + jsonObject.addProperty("online", 2); //熄屏状态 } else { - jsonObject.put("online", 1); + jsonObject.addProperty("online", 1); } if (null != client) { - Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toJSONString()); - client.send(jsonObject.toJSONString()); + Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toString()); + client.send(jsonObject.toString()); } } public void sendMsg(int state) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("sn", Utils.getSerial(this)); - jsonObject.put("online", state); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("sn", Utils.getSerial(this)); + jsonObject.addProperty("online", state); try { if (null != client) { - Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toJSONString()); - client.send(jsonObject.toJSONString()); + Log.i("JWebSocketClientService", "发送的消息:" + jsonObject.toString()); + client.send(jsonObject.toString()); } else { Log.i("JWebSocketClientService", "未连接"); } diff --git a/app/src/main/java/com/aoleyun/sn/service/main/MainService.java b/app/src/main/java/com/aoleyun/sn/service/main/MainService.java index 9b2e39b..fa9a431 100644 --- a/app/src/main/java/com/aoleyun/sn/service/main/MainService.java +++ b/app/src/main/java/com/aoleyun/sn/service/main/MainService.java @@ -5,6 +5,7 @@ import android.app.AlarmManager; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.Service; +import android.app.StatusBarManager; import android.app.role.OnRoleHoldersChangedListener; import android.app.role.RoleManager; import android.content.BroadcastReceiver; @@ -37,8 +38,6 @@ import android.widget.TextView; import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationManagerCompat; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.R; import com.aoleyun.sn.activity.main.MainActivity; @@ -46,6 +45,7 @@ import com.aoleyun.sn.bean.PoweroffBean; import com.aoleyun.sn.comm.CommonConfig; import com.aoleyun.sn.comm.JGYActions; import com.aoleyun.sn.comm.PackageNames; +import com.aoleyun.sn.gson.GsonUtils; import com.aoleyun.sn.network.NetInterfaceManager; import com.aoleyun.sn.rlog.LogDBManager; import com.aoleyun.sn.utils.ApkUtils; @@ -60,6 +60,7 @@ import com.aoleyun.sn.utils.Utils; import com.arialyy.aria.core.Aria; import com.blankj.utilcode.util.NetworkUtils; import com.google.gson.Gson; +import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import com.tencent.android.tpush.XGIOperateCallback; import com.tencent.android.tpush.XGPushConfig; @@ -181,9 +182,12 @@ public class MainService extends Service implements MainSContact.MainView, Netwo tagSets.add(JGYUtils.CubeTag); } else if (platform == JGYUtils.MTK11Platform) { tagSets.add(JGYUtils.MTK11Tag); + } else if (platform == JGYUtils.TeclastP20sPlatform) { + tagSets.add(JGYUtils.TeclastP20sTag); } } }); + Log.e(TAG, "setPushTag: " + tagSets); NetInterfaceManager.getInstance().clearAndAppendTags(tagSets); } }); @@ -429,6 +433,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo timeChangedStart.onstar(System.currentTimeMillis()); setStatusbar(); setFloatingWindow(); + JGYUtils.getInstance().writeAppPackageList(); // notificationManager = NotificationManagerCompat.from(this); // createNotificationChannel(); } @@ -506,13 +511,15 @@ public class MainService extends Service implements MainSContact.MainView, Netwo } private void setStatusbar() { +// StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE); +// mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME); String status = (String) SPUtils.get(this, JGYActions.ACTION_STATUSBAR_STATUS, ""); Log.e(TAG, "setStatusbar: String: " + status); if (TextUtils.isEmpty(status)) { Log.e(TAG, "setStatusbar: " + "status is NULL"); return; } - JSONObject jsonObject = JSON.parseObject(status); + JsonObject jsonObject = GsonUtils.getJsonObject(status); SysSettingUtils.setStatusBar(this, jsonObject); } @@ -929,6 +936,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo } else { ToastUtil.betaShow("设备已解锁"); // notificationManager.cancel(NotificationID); + JGYUtils.getInstance().writeAppPackageList(); SysSettingUtils.setEnableSetting(this); } 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 b246a7e..f2cab20 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/ApkUtils.java @@ -23,15 +23,15 @@ import android.util.Log; import androidx.annotation.RequiresApi; import androidx.core.content.FileProvider; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.bean.UploadAppInfo; import com.aoleyun.sn.comm.JGYActions; import com.aoleyun.sn.comm.PackageNames; +import com.aoleyun.sn.gson.GsonUtils; import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.download.DownloadEntity; import com.google.gson.Gson; +import com.google.gson.JsonObject; import java.io.BufferedReader; import java.io.DataOutputStream; @@ -977,6 +977,8 @@ public class ApkUtils { this.add("com.wyt.wangkexueximvvm1"); this.add("com.android.stk"); this.add("com.shoufei.aole"); + + this.add("com.ygyb.yischool"); }}; public static void showAllAPP(Context context) { @@ -1266,8 +1268,8 @@ public class ApkUtils { for (DownloadEntity entity : list) { long id = entity.getId(); String extendField = Aria.download(this).load(id).getExtendField(); - JSONObject jsonObject = JSON.parseObject(extendField); - if (packageName.equals(jsonObject.getString("app_package"))) { + JsonObject jsonObject = GsonUtils.getJsonObject(extendField); + if (packageName.equals(jsonObject.get("app_package").getAsString())) { Log.e("RemoveTask", "subscribe: " + "删除文件:" + entity.getFilePath()); Aria.download(this).load(id).cancel(true); } 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 3327d0c..9d2c0a4 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/JGYUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/JGYUtils.java @@ -37,8 +37,6 @@ import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.core.content.ContextCompat; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.bean.AppListInfo; import com.aoleyun.sn.bean.Appground; @@ -95,7 +93,6 @@ import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.Executor; import java.util.function.Consumer; import java.util.function.Predicate; @@ -118,12 +115,14 @@ public class JGYUtils { public static final int CubePlatform = 2; public static final int ZhanruiPlatform = 3; public static final int MTK11Platform = 5; + public static final int TeclastP20sPlatform = 6; public static final String Other = "其他"; public static final String MTKTag = "MTK"; public static final String CubeTag = "展锐cube"; public static final String ZhanruiTag = "展锐"; public static final String MTK11Tag = "MTK11"; + public static final String TeclastP20sTag = "P20S"; private CacheHelper cacheHelper; @@ -158,6 +157,7 @@ public class JGYUtils { public static native String getAuthorization(); public int checkSNPlatform(String sn) { + if (TextUtils.isEmpty(sn)) return UnknowPlatform; String secondChars = sn.substring(1, 2); if ("N".equalsIgnoreCase(secondChars)) {//MTK平台 return MTKPlatform; @@ -180,9 +180,12 @@ public class JGYUtils { } else if ("ZhanRuiCube".equalsIgnoreCase(platform)) { Log.i(TAG, "checkAppPlatform: " + "ZhanRuiCube"); return CubePlatform; - } else if ("MTK11".equalsIgnoreCase(platform)) { + } else if (MTK11Tag.equalsIgnoreCase(platform)) { Log.i(TAG, "checkAppPlatform: " + "MTK11"); return MTK11Platform; + } else if (TeclastP20sTag.equalsIgnoreCase(platform)) { + Log.i(TAG, "checkAppPlatform: " + "P20S"); + return TeclastP20sPlatform; } else { Log.i(TAG, "checkAppPlatform: " + "没有数据"); return UnknowPlatform; @@ -212,6 +215,8 @@ public class JGYUtils { getAppPlatformCallback.AppPlatform(CubePlatform); } else if ("MTK11".equalsIgnoreCase(platform)) { getAppPlatformCallback.AppPlatform(MTK11Platform); + } else if (TeclastP20sTag.equalsIgnoreCase(platform)) { + getAppPlatformCallback.AppPlatform(TeclastP20sPlatform); } else { getAppPlatformCallback.AppPlatform(UnknowPlatform); } @@ -227,6 +232,8 @@ public class JGYUtils { return CubeTag; } else if ("MTK11".equalsIgnoreCase(platform)) { return MTK11Tag; + } else if ("P20S".equalsIgnoreCase(platform)) { + return TeclastP20sTag; } else { return Other; } @@ -490,11 +497,11 @@ public class JGYUtils { Log.e(TAG, "checkPackageAndVersion: appVersionCode: " + appVersionCode + " getApp_version_code: " + info.getApp_version_code()); Log.e(TAG, "checkPackageAndVersion: " + pkg + " 卸载"); ApkUtils.UninstallAPP(mContext, pkg); - JSONObject packageObj = new JSONObject(); - packageObj.put("app_name", info.getApp_name()); - packageObj.put("app_package", info.getApp_package()); - packageObj.put("app_id", info.getApp_id()); - packageObj.put("MD5", info.getApp_md5()); + JsonObject packageObj = new JsonObject(); + packageObj.addProperty("app_name", info.getApp_name()); + packageObj.addProperty("app_package", info.getApp_package()); + packageObj.addProperty("app_id", info.getApp_id()); + packageObj.addProperty("MD5", info.getApp_md5()); Utils.ariaDownload(mContext, info.getApp_url(), packageObj); } else { Log.e(TAG, "checkPackageAndVersion: " + pkg + " 版本正常"); @@ -762,8 +769,11 @@ public class JGYUtils { synchronized public void setNewAppinsideWeb(BaseResponse response) { Log.e(TAG, "setNewAppinsideWeb: " + "应用内部联网管控: " + response); if (response.code == 200) { - String jsonString = JSONArray.toJSONString(response.data); - List appgrounds = JSONObject.parseArray(jsonString, TTAppground.class); + String jsonString = GsonUtils.toJSONString(response.data); + Gson gson = new Gson(); + Type type = new TypeToken>() { + }.getType(); + List appgrounds = gson.fromJson(jsonString, type); List whiteApp = new ArrayList<>(); List blackApp = new ArrayList<>(); if (appgrounds != null && appgrounds.size() > 0) { @@ -1070,39 +1080,42 @@ public class JGYUtils { if (TextUtils.isEmpty(data)) { Log.e(TAG, "SettingSysData: " + "data is empty"); SysSettingUtils.setDisableSetting(mContext); + SPUtils.put(mContext, JGYActions.ACTION_STATUSBAR_STATUS, ""); } else { SysSettingUtils.setSystemSetting(mContext, data); } } + HashSet defaultPackages = new HashSet() {{ + this.add(BuildConfig.APPLICATION_ID); + this.add(PackageNames.OLD_DEVICE_INFO);//设备信息 + this.add(PackageNames.OLD_APPSTORE);//教管壹 + this.add(PackageNames.DEVICE_INFO); + this.add(PackageNames.APPSTORE); + this.add("com.info.sn"); + this.add("com.uiuios.jgy1"); + this.add("com.uiuios.jgy2"); + this.add("com.tt.ttutils"); + this.add("com.aoleyun.browser"); + this.add("com.uiui.browser"); + this.add("com.android.uiuios"); + this.add("com.aoleyun.os"); + this.add("com.aoleyunos.dop1"); + this.add("com.aoleyunos.dop2"); + this.add("com.aoleyun.info"); + this.add("com.calculator.uiui"); + this.add("com.notepad.uiui"); + this.add("com.calendar.uiui"); + this.add("com.alarmclock.uiui"); + this.add("com.uiui.videoplayer"); + this.add("com.ygyb.yischool"); + }}; + @SuppressLint("NewApi") public void writeAppPackageList(Context context, String packageList) { ApkUtils.addShortcut(context); - HashSet packages = new HashSet() {{ - this.add(BuildConfig.APPLICATION_ID); - this.add(PackageNames.OLD_DEVICE_INFO);//设备信息 - this.add(PackageNames.OLD_APPSTORE);//教管壹 - this.add(PackageNames.DEVICE_INFO); - this.add(PackageNames.APPSTORE); - this.add("com.info.sn"); - this.add("com.uiuios.jgy1"); - this.add("com.uiuios.jgy2"); - this.add("com.tt.ttutils"); - this.add("com.aoleyun.browser"); - this.add("com.uiui.browser"); - this.add("com.android.uiuios"); - this.add("com.aoleyun.os"); - this.add("com.aoleyunos.dop1"); - this.add("com.aoleyunos.dop2"); - this.add("com.aoleyun.info"); - this.add("com.calculator.uiui"); - this.add("com.notepad.uiui"); - this.add("com.calendar.uiui"); - this.add("com.alarmclock.uiui"); - this.add("com.uiui.videoplayer"); - }}; HashSet pkgSet = new HashSet<>(Arrays.asList(packageList.split(","))); - pkgSet.addAll(packages); + pkgSet.addAll(defaultPackages); pkgSet.addAll(ApkUtils.desktopAPP); pkgSet.addAll(ApkUtils.aoleyunAPP); pkgSet.addAll(ApkUtils.aihuaApp); @@ -1113,6 +1126,12 @@ public class JGYUtils { Log.e("writeAppPackageList: ", "aole_app_forbid: " + b + " " + Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID)); } + public void writeAppPackageList() { + String aole_app_forbid = String.join(",", defaultPackages); + Log.e(TAG, "writeAppPackageList: " + aole_app_forbid); + Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid); + } + public void checkForceDownload() { String jsonString = cacheHelper.getAsString(UrlAddress.GET_FORCE_INSTALL_LIST); //为 "" 是已经请求成功的 @@ -1142,11 +1161,11 @@ public class JGYUtils { String app_url = forceDownloadData.getApp_url(); String app_id = forceDownloadData.getApp_id(); String app_md5 = forceDownloadData.getApp_md5(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("app_name", app_name); - jsonObject.put("app_package", app_package); - jsonObject.put("app_id", app_id); - jsonObject.put("MD5", app_md5); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("app_name", app_name); + jsonObject.addProperty("app_package", app_package); + jsonObject.addProperty("app_id", app_id); + jsonObject.addProperty("MD5", app_md5); long app_version_code = forceDownloadData.getApp_version_code(); Log.e("fht ", "packageName=" + app_package + ",URL= " + app_url + ",app_version_code=" + app_version_code); if (BuildConfig.APPLICATION_ID.equals(data.get(i).getApp_package())) { @@ -1191,10 +1210,10 @@ public class JGYUtils { String app_name = jsonObject.get("app_name").getAsString(); String app_md5 = jsonObject.get("app_md5").getAsString(); // String app_id = jsonObject.get("app_id").getAsString(); - JSONObject object = new JSONObject(); - object.put("app_name", app_name); - object.put("app_package", packageName); - object.put("MD5", app_md5); + JsonObject object = new JsonObject(); + object.addProperty("app_name", app_name); + object.addProperty("app_package", packageName); + object.addProperty("MD5", app_md5); // object.put("app_id", app_id); PackageManager pm = mContext.getPackageManager(); PackageInfo packageInfo = null; @@ -1219,9 +1238,9 @@ public class JGYUtils { String packageName = jsonObject.get("app_package").getAsString(); String app_name = jsonObject.get("app_name").getAsString(); // String app_id = jsonObject.get("app_id").getAsString(); - JSONObject object = new JSONObject(); - object.put("app_name", app_name); - object.put("app_package", packageName); + JsonObject object = new JsonObject(); + object.addProperty("app_name", app_name); + object.addProperty("app_package", packageName); // object.put("app_id", app_id); PackageManager pm = mContext.getPackageManager(); PackageInfo packageInfo = null; @@ -1251,10 +1270,10 @@ public class JGYUtils { String app_name = data.getApp_name(); String app_md5 = data.getApp_md5(); // String app_id = jsonObject.get("app_id").getAsString(); - JSONObject object = new JSONObject(); - object.put("app_name", app_name); - object.put("app_package", packageName); - object.put("MD5", app_md5); + JsonObject object = new JsonObject(); + object.addProperty("app_name", app_name); + object.addProperty("app_package", packageName); + object.addProperty("MD5", app_md5); // object.put("app_id", app_id); PackageManager pm = mContext.getPackageManager(); PackageInfo packageInfo = null; @@ -1271,11 +1290,11 @@ public class JGYUtils { } } - public void installDesktop(JSONObject jsonObject) { - String app_name = jsonObject.getString("app_name"); - String app_url = jsonObject.getString("app_url"); - String app_package = jsonObject.getString("app_package"); - int app_version_code = jsonObject.getInteger("app_version_code"); + public void installDesktop(JsonObject jsonObject) { + String app_name = jsonObject.get("app_name").getAsString(); + String app_url = jsonObject.get("app_url").getAsString(); + String app_package = jsonObject.get("app_package").getAsString(); + int app_version_code = jsonObject.get("app_version_code").getAsInt(); if (ApkUtils.desktopAPP.get(0).equals(app_package)) { ApkUtils.UninstallAPP(mContext, ApkUtils.desktopAPP.get(1)); } else { @@ -1311,9 +1330,9 @@ public class JGYUtils { public void deleteOtherApp() { Log.e(TAG, "deleteOtherApp: " + Build.MODEL); if ("K106".equalsIgnoreCase(Build.MODEL) - ||"G10".equalsIgnoreCase(Build.MODEL) - ||"G10P".equalsIgnoreCase(Build.MODEL) - ||"G10R".equalsIgnoreCase(Build.MODEL) + || "G10".equalsIgnoreCase(Build.MODEL) + || "G10P".equalsIgnoreCase(Build.MODEL) + || "G10R".equalsIgnoreCase(Build.MODEL) ) { return; } @@ -1442,6 +1461,24 @@ public class JGYUtils { } } + public void hideApp(String pkg) { + PackageManager pm = mContext.getPackageManager(); + try { + pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); + } catch (Exception e) { + Log.e(TAG, "hideApp: " + e.getMessage()); + } + } + + public void showApp(String pkg) { + PackageManager pm = mContext.getPackageManager(); + try { + pm.setApplicationEnabledSetting(pkg, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0); + } catch (Exception e) { + Log.e(TAG, "hideApp: " + e.getMessage()); + } + } + /** * 从Manifest中获取meta-data值 @@ -1471,15 +1508,15 @@ public class JGYUtils { Log.e(TAG, "checkBootFile: Bootanimation file exists"); setBootanimation(bootFile.getAbsolutePath()); } else { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("MD5", MD5); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("MD5", MD5); Utils.ariaDownload(mContext, url, jsonObject); Log.e(TAG, "checkBootFile: " + "download file"); } } else { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("MD5", MD5); - jsonObject.put("app_name", urlFileName); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("MD5", MD5); + jsonObject.addProperty("app_name", urlFileName); Utils.ariaDownload(mContext, url, jsonObject); } } @@ -2037,6 +2074,9 @@ public class JGYUtils { setDefaultDesktop(PackageNames.DESKTOP); } + public void setYxpDefaultDesktop() { + setDefaultDesktop(PackageNames.YIXUEPAI_DESKTOP); + } /** * 设置默认桌面 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 d72707f..59adac7 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/SysSettingUtils.java @@ -11,12 +11,12 @@ import android.provider.Settings; import android.text.TextUtils; import android.util.Log; -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 com.aoleyun.sn.gson.GsonUtils; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; import java.util.ArrayList; import java.util.List; @@ -41,7 +41,7 @@ public class SysSettingUtils { if (null == context) { throw new RuntimeException("Context it's null"); } - JSONObject jsonObject = JSON.parseObject(jsonObj); + JsonObject jsonObject = GsonUtils.getJsonObject(jsonObj); setPhoneList(context, jsonObject); setBluetooth(context, jsonObject); setHotspot(context, jsonObject); @@ -51,8 +51,8 @@ public class SysSettingUtils { setIcon(context, jsonObject); setCanReset(context, jsonObject); setAutoTime(context, jsonObject); - JSONObject navJson = jsonObject.getJSONObject("setting_nav"); - SPUtils.put(context, JGYActions.ACTION_STATUSBAR_STATUS, jsonObject.getJSONObject("setting_nav").toJSONString()); + JsonObject navJson = jsonObject.get("setting_nav").getAsJsonObject(); + SPUtils.put(context, JGYActions.ACTION_STATUSBAR_STATUS, jsonObject.get("setting_nav").toString()); setStatusBar(context, navJson); setBrowserInput(context, jsonObject); // TODO: 2022/4/11 不是酷比定制的会报错,无法抛出异常 @@ -123,15 +123,15 @@ public class SysSettingUtils { } } - private static void setPhoneList(Context context, JSONObject jsonObject) { + private static void setPhoneList(Context context, JsonObject jsonObject) { try { //设置电话功能,电话白名单 //电话通话开关 - int setting_call = changeNum(jsonObject.getInteger("setting_call")); + int setting_call = changeNum(jsonObject.get("setting_call").getAsInt()); boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", setting_call); Log.e(TAG, "qch_call_forbid:" + qch_call_forbid); //电话白名单开关 - int setting_phone = changeNum(jsonObject.getInteger("setting_phone")); + int setting_phone = changeNum(jsonObject.get("setting_phone").getAsInt()); 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); //白名单列表 @@ -140,13 +140,13 @@ public class SysSettingUtils { // ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+aole_white_list_Array+"---"+qch_call_forbid); Log.e(TAG, "aole_white_list_Array:" + aole_white_list_Array); } else { - String setting_phones = jsonObject.getString("setting_phones"); + String setting_phones = jsonObject.get("setting_phones").getAsString(); 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")); + int setting_memory = changeNum(jsonObject.get("setting_memory").getAsInt()); 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) { @@ -174,12 +174,12 @@ public class SysSettingUtils { } } - private static void setUSBstate(Context context, JSONObject jsonObject) { + private static void setUSBstate(Context context, JsonObject jsonObject) { //USB数据功能管控 //仅充电:usb_charge //MTP模式:usb_mtp //Midi模式:usb_midi - String setting_usb = jsonObject.getString("setting_usb"); + String setting_usb = jsonObject.get("setting_usb").getAsString(); if (!BuildConfig.DEBUG) { if (JGYUtils.isCubeDevice()) { SuperPower mService = (SuperPower) context.getSystemService("mdm"); @@ -237,14 +237,14 @@ public class SysSettingUtils { } } - private static void setBluetooth(Context context, JSONObject jsonObject) { + private static void setBluetooth(Context context, JsonObject jsonObject) { try { //蓝牙开关 - int setting_bht = changeNum(jsonObject.getInteger("setting_bht")); + int setting_bht = changeNum(jsonObject.get("setting_bht").getAsInt()); //总开关 - int setting_bhtvideo = changeNum(jsonObject.getInteger("setting_bhtvideo")); + int setting_bhtvideo = changeNum(jsonObject.get("setting_bhtvideo").getAsInt()); //蓝牙音频开关 - int setting_bluetooth = changeNum(jsonObject.getInteger("setting_bluetooth")); + int setting_bluetooth = changeNum(jsonObject.get("setting_bluetooth").getAsInt()); //蓝牙传输开关 boolean aole_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_BHT_FORBID_ON, setting_bht); @@ -258,7 +258,7 @@ public class SysSettingUtils { } if (setting_bht == 0) { //蓝牙总开关开启 - String setting_context = jsonObject.getString("setting_context"); + String setting_context = jsonObject.get("setting_context").getAsString(); 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); @@ -293,9 +293,9 @@ public class SysSettingUtils { } } - private static void setHotspot(Context context, JSONObject jsonObject) { + private static void setHotspot(Context context, JsonObject jsonObject) { try { - int setting_hotspot = changeNum(jsonObject.getInteger("setting_hotspot"));//热点 + int setting_hotspot = changeNum(jsonObject.get("setting_hotspot").getAsInt());//热点 if (setting_hotspot == 1) { Intent intent = new Intent(); intent.setAction("qch_hotspot_close"); @@ -355,9 +355,9 @@ public class SysSettingUtils { } } - private static void setBar(Context context, JSONObject jsonObject) { + private static void setBar(Context context, JsonObject jsonObject) { //系统导航条显示开关 - int setting_navigation = changeNum(jsonObject.getInteger("setting_navigation")); + int setting_navigation = changeNum(jsonObject.get("setting_navigation").getAsInt()); //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 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); @@ -378,7 +378,7 @@ public class SysSettingUtils { //状态栏显示开关 - int setting_statusbar = changeNum(jsonObject.getInteger("setting_statusbar")); + int setting_statusbar = changeNum(jsonObject.get("setting_statusbar").getAsInt()); int oldNum = Settings.System.getInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HIDE_STATUS_BAR, 0); if (oldNum != setting_statusbar) { //写入到系统不涉及任何管控,因为之前调用会频繁隐藏显示 @@ -423,10 +423,10 @@ public class SysSettingUtils { } } - private static void setCamera(Context context, JSONObject jsonObject) { + private static void setCamera(Context context, JsonObject jsonObject) { try { //摄像头开关 - int setting_camera = changeNum(jsonObject.getInteger("setting_camera")); + int setting_camera = changeNum(jsonObject.get("setting_camera").getAsInt()); Settings.System.putInt(context.getContentResolver(), "qch_app_camera", setting_camera); Log.e(TAG, "qch_app_camera2:" + setting_camera); // ApkUtils.hideSystemSettingAPP(context, "com.mediatek.camera"); @@ -479,9 +479,9 @@ public class SysSettingUtils { * @param context * @param jsonObject tfmedia开关 */ - private static void setTF(Context context, JSONObject jsonObject) { + private static void setTF(Context context, JsonObject jsonObject) { try { - int setting_tfmedia = jsonObject.getInteger("setting_tfmedia"); + int setting_tfmedia = jsonObject.get("setting_tfmedia").getAsInt(); // if (JGYUtils.isOfficialVersion() ) { // setting_tfmedia = changeNum(setting_tfmedia); // } @@ -502,12 +502,11 @@ public class SysSettingUtils { Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings"); context.sendBroadcast(tfmediaIntent); if (setting_tfmedia == 1) { - JSONArray jSONArray = null; - jSONArray = jsonObject.getJSONArray("setting_tfmedia_format"); + JsonArray jSONArray = jsonObject.get("setting_tfmedia_format").getAsJsonArray(); StringBuffer stringBuffer = new StringBuffer(); for (int i = 0; i < jSONArray.size(); i++) { - stringBuffer.append(jSONArray.getString(i)); + stringBuffer.append(jSONArray.get(i).toString()); stringBuffer.append(","); } stringBuffer.deleteCharAt(stringBuffer.length() - 1); @@ -561,35 +560,35 @@ public class SysSettingUtils { } } - private static void setIcon(Context context, JSONObject jsonObject) { + private static void setIcon(Context context, JsonObject jsonObject) { try { //added:2019.12.6 //设置5个app的开关 //时钟 - int deskclock = changeNum(jsonObject.getInteger("setting_clock")); + int deskclock = changeNum(jsonObject.get("setting_clock").getAsInt()); Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", deskclock); ApkUtils.hideSystemSettingAPP(context, "com.android.deskclock"); Log.e(TAG, "qch_app_deskclock" + deskclock); //录音机 - int soundrecorder = changeNum(jsonObject.getInteger("setting_recording")); + int soundrecorder = changeNum(jsonObject.get("setting_recording").getAsInt()); Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", soundrecorder); ApkUtils.hideSystemSettingAPP(context, "com.android.soundrecorder"); Log.e(TAG, "qch_app_soundrecorder" + soundrecorder); //音乐 - int music = changeNum(jsonObject.getInteger("setting_music")); + int music = changeNum(jsonObject.get("setting_music").getAsInt()); Settings.System.putInt(context.getContentResolver(), "qch_app_music", music); ApkUtils.hideSystemSettingAPP(context, "com.android.music"); Log.e(TAG, "qch_app_music" + music); //图库 - int gallery = changeNum(jsonObject.getInteger("setting_picture")); + int gallery = changeNum(jsonObject.get("setting_picture").getAsInt()); Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", gallery); ApkUtils.hideSystemSettingAPP(context, "com.android.gallery3d"); Log.e(TAG, "qch_app_gallery" + gallery); //壁纸 - int wallpaper = changeNum(jsonObject.getInteger("setting_wallpaper")); + int wallpaper = changeNum(jsonObject.get("setting_wallpaper").getAsInt()); setWallpaper(context, wallpaper); //文件管理器 - int filemanager = changeNum(jsonObject.getInteger("setting_file")); + int filemanager = changeNum(jsonObject.get("setting_file").getAsInt()); Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", filemanager); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { ApkUtils.hideSystemSettingAPP(context, "com.mediatek.filemanager"); @@ -598,11 +597,11 @@ public class SysSettingUtils { } Log.e(TAG, "qch_app_filemanager" + filemanager); //浏览器 - int browser = changeNum(jsonObject.getInteger("setting_browser")); + int browser = changeNum(jsonObject.get("setting_browser").getAsInt()); Settings.System.putInt(context.getContentResolver(), "qch_app_browser", browser); Log.e(TAG, "qch_app_browser" + browser); //短信 - int setting_sms = changeNum(jsonObject.getInteger("setting_sms")); + int setting_sms = changeNum(jsonObject.get("setting_sms").getAsInt()); Settings.System.putInt(context.getContentResolver(), "qch_app_sms", setting_sms); Log.e(TAG, "qch_app_sms" + setting_sms); } catch (Exception e) { @@ -625,8 +624,8 @@ public class SysSettingUtils { //aole_restore_forbid_on=1,禁止恢复出厂设置 //aole_restore_forbid_on=0,允许恢复出厂设置 - private static void setCanReset(Context context, JSONObject jsonObject) { - int mode = jsonObject.getInteger("qch_restore"); + private static void setCanReset(Context context, JsonObject jsonObject) { + int mode = jsonObject.get("qch_restore").getAsInt(); if (mode == 1) { 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); @@ -653,8 +652,8 @@ public class SysSettingUtils { //intent34.setPackage("com.android.settings"); //sendBroadcast(intent34); - private static void setAutoTime(Context context, JSONObject jsonObject) { - String autoTime = jsonObject.getString("setting_autotime"); + private static void setAutoTime(Context context, JsonObject jsonObject) { + String autoTime = jsonObject.get("setting_autotime").getAsString(); String action = "qch_autotime_network"; if (TextUtils.isEmpty(autoTime)) { action = "qch_autotime_network"; @@ -690,23 +689,23 @@ public class SysSettingUtils { } @SuppressLint("NewApi") - public static void setStatusBar(Context context, JSONObject jsonObject) { - Log.e(TAG, "setStatusBar: " + jsonObject.toJSONString()); + public static void setStatusBar(Context context, JsonObject jsonObject) { + Log.e(TAG, "setStatusBar: " + jsonObject.toString()); if (null != jsonObject) { - int whole = jsonObject.getInteger("whole"); + int whole = jsonObject.get("whole").getAsInt(); if (whole == 1) { setStatusBar(context, 0); } else { List disableWhat = new ArrayList<>(); - int home = jsonObject.getInteger("home"); + int home = jsonObject.get("home").getAsInt(); if (home == 0) { disableWhat.add(StatusBarManager.DISABLE_HOME); } - int returnKey = jsonObject.getInteger("returnKey"); + int returnKey = jsonObject.get("returnKey").getAsInt(); if (returnKey == 0) { disableWhat.add(StatusBarManager.DISABLE_BACK); } - int taskbar = jsonObject.getInteger("taskbar"); + int taskbar = jsonObject.get("taskbar").getAsInt(); if (taskbar == 0) { disableWhat.add(StatusBarManager.DISABLE_RECENT); } @@ -737,12 +736,12 @@ public class SysSettingUtils { * @param context * @param jsonObject */ - private static void setBrowserInput(Context context, JSONObject jsonObject) { + private static void setBrowserInput(Context context, JsonObject jsonObject) { int state = 1; try { - state = jsonObject.getInteger("setting_browserInput"); + state = jsonObject.get("setting_browserInput").getAsInt(); Log.e(TAG, "setBrowserInput: " + state); - String json = jsonObject.getString("setting_browserInput"); + String json = jsonObject.get("setting_browserInput").getAsString(); if (TextUtils.isEmpty(json)) { state = 1; } 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 7fe3f5f..ac71b50 100644 --- a/app/src/main/java/com/aoleyun/sn/utils/Utils.java +++ b/app/src/main/java/com/aoleyun/sn/utils/Utils.java @@ -48,7 +48,6 @@ import android.widget.Toast; import androidx.annotation.RequiresApi; import androidx.annotation.VisibleForTesting; -import com.alibaba.fastjson.JSONObject; import com.aoleyun.sn.BuildConfig; import com.aoleyun.sn.R; import com.aoleyun.sn.base.BaseApplication; @@ -63,6 +62,7 @@ import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import com.squareup.moshi.Json; import com.tencent.mmkv.MMKV; import java.io.BufferedReader; @@ -107,6 +107,7 @@ import io.reactivex.rxjava3.core.ObservableOnSubscribe; import io.reactivex.rxjava3.core.Observer; import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.schedulers.Schedulers; +import vendor.mediatek.hardware.nvram.V1_0.INvram; import static android.content.Context.WIFI_SERVICE; @@ -177,6 +178,7 @@ public class Utils { // } else { // return getAndroid7MAC(); // } + return getAllMacAddress(context); } @@ -375,6 +377,13 @@ public class Utils { return "未获取到设备Mac地址"; } + private static String getMacAddrApiS(Context context) { + WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + WifiInfo wifiInfo = wifiManager.getConnectionInfo(); + String mac = wifiInfo.getMacAddress(); + return mac; + } + // MD5 设备地址标识 public static String getMD5(Context context) { String WLANMAC = getMAC(context); @@ -781,42 +790,86 @@ public class Utils { return t1; } - public static String NOSN = "012345679ABCDEF"; + public static final String NOSN = "012345679ABCDEF"; + public static final String TECLAST_BRAND = "Teclast"; /** * 获取设备序列号 * * @return */ - @SuppressLint({"MissingPermission", "HardwareIds"}) public static String getSerial(Context context) { - String serial = "unknow"; - try { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+ - serial = Build.getSerial(); - } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+ - serial = Build.SERIAL; - } else {//8.0- - Class c = Class.forName("android.os.SystemProperties"); - Method get = c.getMethod("get", String.class); - serial = (String) get.invoke(c, "ro.serialno"); + if (TECLAST_BRAND.equalsIgnoreCase(Build.BRAND)) { + return getPushMac(context); + } else { + if (NOSN.equalsIgnoreCase(getSn())) { + return getIMEI(context); + } else { + return getSn(); } - } catch (Exception e) { - e.printStackTrace(); - Log.e("getSerial", "读取设备序列号异常:" + e.toString()); } - if (BuildConfig.DEBUG) { -// return "LTPKD22110000051"; -// serial = "012345679ABCDEF"; - } - if (NOSN.equalsIgnoreCase(serial)) { - return getIMEI(context); - } - return serial; } + public static String getPushMac(Context context) { + String macaddr = Utils.getMacAddrFromNvram(); + return macaddr.replace(":", "").toUpperCase().trim(); + } + + //mh add start---- + private static final int MAC_ADDRESS_ID = 30; + private static final int MAC_ADDRESS_OFFSET = 4; + private static final int MAC_ADDRESS_DIGITS = 6; + private static final int MAX_ADDRESS_VALUE = 0xff; + private static final int INVALID_RSSI = -200; + + private static final String MAC_ADDRESS_FILENAME = "/mnt/vendor/nvdata/APCFG/APRDEB/WIFI"; + + private static String getMacAddrFromNvram() { + StringBuffer nvramBuf = new StringBuffer(); + try { + int i = 0; + String buff = null; + INvram agent = INvram.getService(); + if (agent == null) { + // mToast.setText("No support MAC address writing due to NVRAM"); + // mToast.show(); + Log.e("mh_mac", "NvRAMAgent is null"); + return ""; + } + try { + buff = agent.readFileByName( + MAC_ADDRESS_FILENAME, MAC_ADDRESS_OFFSET + MAC_ADDRESS_DIGITS); + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + Log.i("mh_mac", "Raw data:" + buff); + if (buff.length() < 2 * (MAC_ADDRESS_OFFSET + MAC_ADDRESS_DIGITS)) { + // mToast.setText("The foramt of NVRAM is not correct"); + // mToast.show(); + return ""; + } + // Remove the \0 special character. + int macLen = buff.length() - 1; + for (i = MAC_ADDRESS_OFFSET * 2; i < macLen; i += 2) { + if ((i + 2) < macLen) { + nvramBuf.append(buff.substring(i, i + 2)); + nvramBuf.append(":"); + } else { + nvramBuf.append(buff.substring(i)); + } + } + Log.d("mh_mac", "buff:" + nvramBuf.toString()); + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + return nvramBuf.toString(); + } + //mh add end------ + @SuppressLint({"MissingPermission", "HardwareIds"}) - public static String getSerial() { + public static String getSn() { String serial = "unknow"; try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+ @@ -832,9 +885,6 @@ public class Utils { e.printStackTrace(); Log.e("getSerial", "读取设备序列号异常:" + e.toString()); } - if (BuildConfig.DEBUG) { -// return "QNG2DKB00463"; - } return serial; } @@ -1138,9 +1188,9 @@ public class Utils { * @param url * @param jsonObject */ - public static void ariaDownload(Context context, String url, JSONObject jsonObject) { + public static void ariaDownload(Context context, String url, JsonObject jsonObject) { String fileName = getFileNamefromURL(url); - String urlMD5 = jsonObject.getString("MD5"); + String urlMD5 = jsonObject.get("MD5").getAsString(); Log.e("ariaDownload", "urlMD5=" + urlMD5); String p = JGYUtils.getInstance().getDownLoadPath(); File file = new File(JGYUtils.getInstance().getDownLoadPath() + fileName); @@ -1158,7 +1208,7 @@ public class Utils { .load(url) //读取下载地址 .setFilePath(JGYUtils.getInstance().getDownLoadPath() + fileName) .ignoreFilePathOccupy() - .setExtendField(jsonObject.toJSONString()) + .setExtendField(jsonObject.toString()) .create(); //启动下载} // } } @@ -1167,7 +1217,7 @@ public class Utils { .load(url) //读取下载地址 .setFilePath(JGYUtils.getInstance().getDownLoadPath() + fileName) .ignoreFilePathOccupy() - .setExtendField(jsonObject.toJSONString()) + .setExtendField(jsonObject.toString()) .create(); //启动下载} } } @@ -1317,7 +1367,7 @@ public class Utils { imei = tm.getDeviceId(slotIndex); } if (TextUtils.isEmpty(imei)) { - return "暂无数据"; + return context.getString(R.string.no_data); } return imei; } @@ -1330,7 +1380,7 @@ public class Utils { //8.0及以后版本获取 if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { IMEI = TelephonyMgr.getDeviceId(); -// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // try { // Method method = TelephonyMgr.getClass().getMethod("getImei"); // IMEI = (String) method.invoke(TelephonyMgr); @@ -1341,11 +1391,11 @@ public class Utils { // IMEI = TelephonyMgr.getDeviceId(); // } else {//9.0到10.0获取 -// IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); + IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); } Log.e("IMEI:", "IMEI: " + IMEI); if (null == IMEI) { - return "-"; + return ""; } else { return IMEI.toUpperCase(); } @@ -1390,18 +1440,18 @@ public class Utils { String firmware_version = getRomVersion(); String rom = Utils.getCustomVersion(); String screen_rate = getAndroiodScreenProperty(context); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("device", device); - jsonObject.put("imei", imei); - jsonObject.put("system_version", system_version); - jsonObject.put("firmware_version", firmware_version); - jsonObject.put("rom", rom); - jsonObject.put("screen_rate", screen_rate); - jsonObject.put("working_time", SystemClock.elapsedRealtime() / 1000); - jsonObject.put("restart_count", SPUtils.get(context, "restart_count", 0)); - jsonObject.put("storage_usable", getRemnantSize(context)); - jsonObject.put("storage_total", getDataTotalSize(context)); - String jsonString = jsonObject.toJSONString(); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("device", device); + jsonObject.addProperty("imei", imei); + jsonObject.addProperty("system_version", system_version); + jsonObject.addProperty("firmware_version", firmware_version); + jsonObject.addProperty("rom", rom); + jsonObject.addProperty("screen_rate", screen_rate); + jsonObject.addProperty("working_time", SystemClock.elapsedRealtime() / 1000); + jsonObject.addProperty("restart_count", (int) SPUtils.get(context, "restart_count", 0)); + jsonObject.addProperty("storage_usable", getRemnantSize(context)); + jsonObject.addProperty("storage_total", getDataTotalSize(context)); + String jsonString = jsonObject.toString(); Log.e(TAG, "getMachine: " + jsonString); return jsonString; } @@ -1414,14 +1464,14 @@ public class Utils { Log.e("getHardware", "Memory: " + memory); String storage = getRemnantSize(context) + "/" + getDataTotalSize(context); int CPU = getNumCores(); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("electric", electric); - jsonObject.put("charging", charging); - jsonObject.put("memory", memory); - jsonObject.put("storage", storage); - jsonObject.put("battery_capacity", Utils.getBatterymAh(context)); - jsonObject.put("CPU", CPU + "核"); - String jsonString = jsonObject.toJSONString(); + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("electric", electric); + jsonObject.addProperty("charging", charging); + jsonObject.addProperty("memory", memory); + jsonObject.addProperty("storage", storage); + jsonObject.addProperty("battery_capacity", Utils.getBatterymAh(context)); + jsonObject.addProperty("CPU", CPU + "核"); + String jsonString = jsonObject.toString(); Log.e(TAG, "getHardware: " + jsonString); return jsonString; } @@ -1704,6 +1754,7 @@ public class Utils { || JGYUtils.getInstance().checkAppPlatform() == JGYUtils.CubePlatform || JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTKPlatform || JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTK11Platform + || JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform ) { return Utils.getProperty("ro.build.display.id", "获取失败"); } else { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8f75bd8..be8f4cc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -113,6 +113,7 @@ 最大充电电压: 发送命令: adb shell dumpsys battery \n 新版本%s已经发布,请更新应用 + 暂无数据 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 52d43b4..88df504 100644 --- a/build.gradle +++ b/build.gradle @@ -4,10 +4,10 @@ buildscript { repositories { google() mavenCentral() - maven {url 'http://developer.huawei.com/repo/'} maven { url "https://jitpack.io" } + maven {url 'http://developer.huawei.com/repo/'} maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' } - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url 'http://maven.aliyun.com/nexus/content/repositories/releases/' } } dependencies { classpath 'com.android.tools.build:gradle:3.6.4' @@ -20,13 +20,12 @@ buildscript { allprojects { repositories { - //jcenter即将关闭 google() mavenCentral() - maven {url 'http://developer.huawei.com/repo/'} maven { url "https://jitpack.io" } + maven {url 'http://developer.huawei.com/repo/'} maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' } - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url 'http://maven.aliyun.com/nexus/content/repositories/releases/' } } gradle.projectsEvaluated { tasks.withType(JavaCompile) {