diff --git a/app/build.gradle b/app/build.gradle index 789823c..fc67e44 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,9 +41,9 @@ android { //新平台正式 newly { flavorDimensions "default" - versionCode 626 + versionCode 628 //versionCode 1037 - versionName "2.2.6" + versionName "2.2.8" /*********************************极光推送************************************/ manifestPlaceholders = [ JPUSH_PKGNAME: "com.jiaoguanyi.appstore", @@ -361,6 +361,8 @@ dependencies { implementation 'com.trello.rxlifecycle2:rxlifecycle:2.2.2' implementation 'com.trello.rxlifecycle2:rxlifecycle-android:2.2.2' implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.2' + + implementation 'com.tencent:mmkv-static:1.2.10' } preBuild { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8259288..6575eaf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -125,7 +125,7 @@ + android:exported="true"> diff --git a/app/src/main/java/com/mjsheng/myappstore/activity/MainPresenter.java b/app/src/main/java/com/mjsheng/myappstore/activity/MainPresenter.java index 7e3062b..f04d54d 100644 --- a/app/src/main/java/com/mjsheng/myappstore/activity/MainPresenter.java +++ b/app/src/main/java/com/mjsheng/myappstore/activity/MainPresenter.java @@ -253,7 +253,7 @@ public class MainPresenter implements MainContact.Presenter { @Override public void onNext(@NonNull BaseResponse response) { - Logutils.e(TAG + ":" + "getLockedState", "onNext: "); + Logutils.e(TAG + ":" + "getLockedState", "onNext: " + JSONObject.toJSONString(response)); if (response.code == OK) { JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject(); int locked = jsonObject.get("lock").getAsInt(); diff --git a/app/src/main/java/com/mjsheng/myappstore/base/BaseApplication.java b/app/src/main/java/com/mjsheng/myappstore/base/BaseApplication.java index 8aa152c..b122bf2 100644 --- a/app/src/main/java/com/mjsheng/myappstore/base/BaseApplication.java +++ b/app/src/main/java/com/mjsheng/myappstore/base/BaseApplication.java @@ -34,6 +34,7 @@ import com.mjsheng.myappstore.utils.SystemUtils; import com.mjsheng.myappstore.utils.ToastUtil; import com.mjsheng.myappstore.utils.Utils; import com.mjsheng.myappstore.utils.XAPKUtils; +import com.tencent.mmkv.MMKV; import org.jetbrains.annotations.NotNull; @@ -98,7 +99,8 @@ public class BaseApplication extends MultiDexApplication { AmapManager.init(this); AmapManager.getInstance().initAmap(); ToastUtil.init(this); - + String rootDir = MMKV.initialize(this); + System.out.println("mmkv root: " + rootDir); JGYUtils.getInstance().hookWebView(); // 设置开启日志,发布时请关闭日志 diff --git a/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java b/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java index a32b07e..4aeca18 100644 --- a/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java +++ b/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java @@ -433,6 +433,12 @@ public class MyJPushReceiver extends BroadcastReceiver { case UPDATE_BATCH: ToastUtil.betaShow("收到管控:更换批次不恢复出厂设置"); Aria.download(this).removeAllTask(true); + try { + new CacheUtils().cleanApplicationUserData(mContext, "com.android.browser"); + } catch (Exception e) { + e.printStackTrace(); + Logutils.e(TAG, "setHomepagtag: " + e.getMessage()); + } if (MainService.mPresenter != null) { MainService.mPresenter.getLockedState(); Logutils.e("getLockedState", "mPresenter: " + "getLockedState"); diff --git a/app/src/main/java/com/mjsheng/myappstore/service/MainService.java b/app/src/main/java/com/mjsheng/myappstore/service/MainService.java index e9d1fec..30b9536 100644 --- a/app/src/main/java/com/mjsheng/myappstore/service/MainService.java +++ b/app/src/main/java/com/mjsheng/myappstore/service/MainService.java @@ -3,6 +3,7 @@ package com.mjsheng.myappstore.service; import android.annotation.SuppressLint; import android.app.Service; import android.content.BroadcastReceiver; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; @@ -33,6 +34,7 @@ import com.mjsheng.myappstore.action.JGYActions; import com.mjsheng.myappstore.activity.MainActivity; import com.mjsheng.myappstore.activity.MainContact; import com.mjsheng.myappstore.activity.MainPresenter; +import com.mjsheng.myappstore.receiver.BootReceiver; import com.mjsheng.myappstore.utils.ApkUtils; import com.mjsheng.myappstore.utils.ForegroundAppUtil; import com.mjsheng.myappstore.utils.Logutils; @@ -150,7 +152,6 @@ public class MainService extends Service implements MainContact.MainView, Networ mPresenter = new MainPresenter(this); mPresenter.attachView(this); mPresenter.setProvider(this); - lifecycleSubject.onNext(ActivityEvent.CREATE); if ((int) SPUtils.get(this, "first_connect", 0) == 0) { // TODO: 2021/5/26 待底层修改,临时解决办法 Logutils.e(TAG, "onCreate: " + "Disable All Settings"); @@ -191,6 +192,9 @@ public class MainService extends Service implements MainContact.MainView, Networ @Override public int onStartCommand(Intent intent, int flags, int startId) { + Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); + bootIntent.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver")); + sendBroadcast(bootIntent); JPushInterface.init(this); if (MainActivity.isForeground) { Logutils.e(TAG, "onStartCommand: MainService: isForeground: " + MainActivity.isForeground); diff --git a/app/src/main/java/com/mjsheng/myappstore/service/StepService.java b/app/src/main/java/com/mjsheng/myappstore/service/StepService.java index f74d76b..0f86204 100644 --- a/app/src/main/java/com/mjsheng/myappstore/service/StepService.java +++ b/app/src/main/java/com/mjsheng/myappstore/service/StepService.java @@ -219,7 +219,7 @@ public class StepService extends Service implements NetworkUtils.OnNetworkStatus //connectBlocking多出一个等待操作,会先连接再发送,否则未连接发送会报错 Logutils.i("JWebSocketClientService", "websocket链接中"); client.connectBlocking(); - } catch (InterruptedException e) { + } catch (Exception e) { Logutils.i("JWebSocketClientService", e.getMessage()); // e.printStackTrace(); } @@ -251,11 +251,15 @@ public class StepService extends Service implements NetworkUtils.OnNetworkStatus JSONObject jsonObject = new JSONObject(); jsonObject.put("sn", Utils.getSerial()); jsonObject.put("online", state); - if (null != client) { - Logutils.i("JWebSocketClientService", "发送的消息:" + jsonObject.toJSONString()); - client.send(jsonObject.toJSONString()); - } else { - Logutils.i("JWebSocketClientService", "未连接"); + try { + if (null != client) { + Logutils.i("JWebSocketClientService", "发送的消息:" + jsonObject.toJSONString()); + client.send(jsonObject.toJSONString()); + } else { + Logutils.i("JWebSocketClientService", "未连接"); + } + } catch (Exception e) { + Log.e(TAG, "sendMsg: " + e.getMessage()); } } diff --git a/app/src/main/java/com/mjsheng/myappstore/utils/ApkUtils.java b/app/src/main/java/com/mjsheng/myappstore/utils/ApkUtils.java index ef34d29..12c5591 100644 --- a/app/src/main/java/com/mjsheng/myappstore/utils/ApkUtils.java +++ b/app/src/main/java/com/mjsheng/myappstore/utils/ApkUtils.java @@ -1178,7 +1178,9 @@ public class ApkUtils { uploadAppInfo.setPackage_name(packageInfo.packageName); Logutils.e("getAppInfo", "getAppInfo:" + packageInfo.packageName); // uploadAppInfo.setId(i); - String firstInstallTime = Utils.transferLongToDate(packageInfo.firstInstallTime); +// String firstInstallTime = Utils.transferLongToDate(packageInfo.firstInstallTime); +// String lastUpdateTime = Utils.transferLongToDate(packageInfo.lastUpdateTime); + String firstInstallTime = Utils.transferLongToDate(packageInfo.lastUpdateTime); uploadAppInfo.setInstall_time(firstInstallTime); uploadAppInfo.setVersionCode(String.valueOf(packageInfo.versionCode)); uploadAppInfo.setState(0); diff --git a/app/src/main/java/com/mjsheng/myappstore/utils/URLUtils.java b/app/src/main/java/com/mjsheng/myappstore/utils/URLUtils.java index bd3e943..180d1bf 100644 --- a/app/src/main/java/com/mjsheng/myappstore/utils/URLUtils.java +++ b/app/src/main/java/com/mjsheng/myappstore/utils/URLUtils.java @@ -51,6 +51,12 @@ public class URLUtils { } else { Logutils.e(TAG, "getBrowserWhiteList: " + "oldwhiteList is : " + oldwhiteList); HashSet URLList = new HashSet<>(Arrays.asList(oldwhiteList.trim().split(","))); + URLList.removeIf(TextUtils::isEmpty); + if (URLList.size() == 0) { + Log.e(TAG, "setBrowserWhiteList: URLList set is empty , set Invalid"); + Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", "Invalid"); + return; + } Log.e(TAG, "setBrowserWhiteList: " + URLList); Observable.create(new ObservableOnSubscribe() { @Override @@ -73,7 +79,9 @@ public class URLUtils { // } // }else { // } - nohttpURLList.add("m." + getDomain(url)); + if (haveDomain(url)){ + nohttpURLList.add("m." + getDomain(url)); + } // nohttpURLList.add(getDomain(url)); if (!url.startsWith("http")) { @@ -294,6 +302,13 @@ public class URLUtils { return domainVal; } + public boolean haveDomain(String url) { + String regexStr = "(?<=//|)((\\w)+(\\.cn|\\.com.cn|\\.org.cn|\\.com|\\.net|\\.org|\\.cc|\\.biz|\\.uk|\\.info|\\.in|\\.eu))+"; + Pattern p = Pattern.compile(regexStr); + Matcher m = p.matcher(url); + return m.find(); + } + /** * Gets ip. diff --git a/app/src/main/java/com/mjsheng/myappstore/utils/Utils.java b/app/src/main/java/com/mjsheng/myappstore/utils/Utils.java index c2437eb..7158345 100644 --- a/app/src/main/java/com/mjsheng/myappstore/utils/Utils.java +++ b/app/src/main/java/com/mjsheng/myappstore/utils/Utils.java @@ -162,9 +162,9 @@ public class Utils { } public static String getAndroid10MAC(Context context) { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1){ + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) { return getMacAddress(context); - }else { + } else { return getAndroid7MAC(); } } @@ -703,6 +703,9 @@ public class Utils { e.printStackTrace(); Logutils.e("e", "读取设备序列号异常:" + e.toString()); } + if (BuildConfig.DEBUG) { +// return "QNG2DKB00463"; + } return serial; }