diff --git a/app/build.gradle b/app/build.gradle index df5949b..3b1aa0b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -60,8 +60,8 @@ android { productFlavors { beta { flavorDimensions "default" - versionCode 4 - versionName "1.3" + versionCode 6 + versionName "1.5" manifestPlaceholders = [ JPUSH_PKGNAME: "com.uiui.sn", JPUSH_APPKEY : "1a1e405ca5a1a5cd50e9f734", //JPush 上注册的包名对应的 Appkey. diff --git a/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java b/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java index 1aeb9b6..663dccf 100644 --- a/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java +++ b/app/src/main/java/com/uiui/sn/activity/main/MainActivity.java @@ -87,12 +87,6 @@ import static com.uiui.sn.jpush.TagAliasOperatorHelper.ACTION_SET; public class MainActivity extends BaseActivity implements MainContact.MainView, NetworkUtils.OnNetworkStatusChangedListener { private final String TAG = MainActivity.class.getSimpleName(); - private MainPresenter mPresenter = new MainPresenter(this); - - private long time0; - private long timeMillis; - public static boolean isForeground = false; - @BindView(R.id.tv_exit) TextView tv_exit; @BindView(R.id.tv_title) @@ -112,6 +106,11 @@ public class MainActivity extends BaseActivity implements MainContact.MainView, @BindView(R.id.iv_exit) ImageView iv_exit; + private MainPresenter mPresenter = new MainPresenter(this); + private long time0; + private long timeMillis; + public static boolean isForeground = false; + @Override public void onDisconnected() { @@ -153,14 +152,11 @@ public class MainActivity extends BaseActivity implements MainContact.MainView, // JGYUtils.getInstance().killBackgroundProcesses(this, "com.gankao.gkwxhd"); SPUtils.put(this, "versionCode", BuildConfig.VERSION_CODE); } - //启动应用市场 - Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); - bootIntent.setComponent(new ComponentName("com.uiui.appstore", "com.uiui.appstore.receiver.BootReceiver")); - sendBroadcast(bootIntent); + JGYUtils.getInstance().wakeUpAppstore(); + JGYUtils.getInstance().wakeUpUpdateTools(); } private class TimeTask extends AsyncTask { - @Override protected Long doInBackground(String... strings) { return TimeUtils.getTimeFromNtpServer(strings[0]); @@ -716,7 +712,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView, UserInfo userInfo = response.data; boolean username = Settings.System.putString(getContentResolver(), "UserInfo_username", userInfo.getSn_name()); boolean gread = Settings.System.putString(getContentResolver(), "UserInfo_grade", userInfo.getGrade()); - SPUtils.put(this, Configs.isLogined, 1); SPUtils.put(this, "member_id", userInfo.getMember_id()); SPUtils.put(this, "sn_id", userInfo.getId()); if (!TextUtils.isEmpty(userInfo.getSn_name())) { diff --git a/app/src/main/java/com/uiui/sn/activity/main/MainPresenter.java b/app/src/main/java/com/uiui/sn/activity/main/MainPresenter.java index a64304d..22594d7 100644 --- a/app/src/main/java/com/uiui/sn/activity/main/MainPresenter.java +++ b/app/src/main/java/com/uiui/sn/activity/main/MainPresenter.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.os.Build; +import android.os.Handler; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; @@ -227,14 +228,14 @@ public class MainPresenter implements MainContact.Presenter { @Override public void onNext(BaseResponse userInfoBaseResponse) { - Log.e(TAG + "getInfo", "onNext: "); + Log.e(TAG + "getInfo", "onNext: " + userInfoBaseResponse); mView.setSnInfo(userInfoBaseResponse); int code = userInfoBaseResponse.code; if (code == 200) { + SPUtils.put(mContext, Configs.isLogined, 1); UserInfo userInfo = userInfoBaseResponse.data; Settings.System.putString(mContext.getContentResolver(), "UserInfo_username", userInfo.getSn_name()); Settings.System.putString(mContext.getContentResolver(), "UserInfo_grade", userInfo.getGrade()); - SPUtils.put(mContext, Configs.isLogined, 1); SPUtils.put(mContext, "member_id", userInfo.getMember_id()); SPUtils.put(mContext, "sn_id", userInfo.getId()); if (!TextUtils.isEmpty(userInfo.getSn_name())) { @@ -262,6 +263,10 @@ public class MainPresenter implements MainContact.Presenter { intent.setPackage("com.jiaoguanyi.os"); intent.setPackage("com.tt.ttutils"); mContext.sendBroadcast(intent); + } else if (code == 300) { + SPUtils.put(mContext, Configs.isLogined, 0); + } else if (code == 400) { + SPUtils.put(mContext, Configs.isLogined, 2); } } @@ -275,6 +280,13 @@ public class MainPresenter implements MainContact.Presenter { @Override public void onComplete() { Log.e(TAG + "getInfo", "onComplete: "); + int isLogined = (int) SPUtils.get(mContext, Configs.isLogined, 2); + if (isLogined == 2) return; + Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(mContext), 1234); + Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_APPSTORE), 2345); + Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_BROWSER), 3456); + Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_OS), 5678); + Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_VIDEOPLAYER), 6789); } }); } @@ -536,7 +548,7 @@ public class MainPresenter implements MainContact.Presenter { SPUtils.put(mContext, "is_first_connection", 0); int code = systemSettingsBaseResponse.code; if (code == 200) { - String data = new Gson().toJson(systemSettingsBaseResponse.data); + String data = new Gson().toJson(systemSettingsBaseResponse.data); Log.e("getSystemSettings", "onNext: " + data); ControlManager.getInstance().setSystemSetting(data); } else { diff --git a/app/src/main/java/com/uiui/sn/bean/zuoye/UserInfo.java b/app/src/main/java/com/uiui/sn/bean/zuoye/UserInfo.java index cb7aef2..f151e84 100644 --- a/app/src/main/java/com/uiui/sn/bean/zuoye/UserInfo.java +++ b/app/src/main/java/com/uiui/sn/bean/zuoye/UserInfo.java @@ -1,5 +1,10 @@ package com.uiui.sn.bean.zuoye; +import androidx.annotation.NonNull; + +import com.google.gson.Gson; +import com.google.gson.JsonParser; + import java.io.Serializable; public class UserInfo implements Serializable { @@ -123,4 +128,10 @@ public class UserInfo implements Serializable { public void setSchool(String school) { this.school = school; } + + @NonNull + @Override + public String toString() { + return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString(); + } } diff --git a/app/src/main/java/com/uiui/sn/network/HTTPInterface.java b/app/src/main/java/com/uiui/sn/network/HTTPInterface.java index bf26950..22e0827 100644 --- a/app/src/main/java/com/uiui/sn/network/HTTPInterface.java +++ b/app/src/main/java/com/uiui/sn/network/HTTPInterface.java @@ -673,8 +673,8 @@ public class HTTPInterface { jsonObject.put("longitude", longitude); jsonObject.put("latitude", latitude); JSONObject softwareJson = new JSONObject(); - softwareJson.put("appstore_version", ApkUtils.getAPPVersionName(context, "com.uiui.appstore")); - softwareJson.put("updatetools_version", ApkUtils.getAPPVersionName(context, "com.uiuios.updatetools")); + softwareJson.put("appstore_version", ApkUtils.getAPPVersionName(context, JGYUtils.PACKAGE_APPSTORE)); + softwareJson.put("updatetools_version", ApkUtils.getAPPVersionName(context, JGYUtils.PACKAGE_UPDATETOOLS)); softwareJson.put("info_version", ApkUtils.getAPPVersionName(context, "com.uiui.sn")); softwareJson.put("jiaoguanyi_version", ApkUtils.getAPPVersionName(context, "com.jiaoguanyi.os")); softwareJson.put("gankao_version", ApkUtils.getAPPVersionName(context, "com.gankao.gkwxhd")); @@ -840,6 +840,7 @@ public class HTTPInterface { } public static void checkUpdate(final Context context, String packageName, String versionCode) { + Log.e("checkUpdate", "packageName: " + packageName); NewestAppUpdate newestAppUpdate = NetInterfaceManager.getInstance().getNewestAppUpdateControl(); newestAppUpdate.getAppUpdate(packageName, versionCode, JGYUtils.getInstance().checkAppPlatform()) .subscribeOn(Schedulers.io()) @@ -847,12 +848,12 @@ public class HTTPInterface { .subscribe(new Observer>() { @Override public void onSubscribe(@NonNull Disposable d) { - Log.e(TAG, "onSubscribe: "); + Log.e("checkUpdate", "onSubscribe: "); } @Override public void onNext(@NonNull BaseResponse appInfoBaseResponse) { - Log.e(TAG, "onNext: " + appInfoBaseResponse); + Log.e("checkUpdate", "onNext: " + appInfoBaseResponse); int code = appInfoBaseResponse.code; if (code == 200) { AppInfo appInfo = appInfoBaseResponse.data; @@ -873,7 +874,7 @@ public class HTTPInterface { @Override public void onComplete() { - Log.e(TAG, "onComplete: "); + Log.e("checkUpdate", "onComplete: "); } }); diff --git a/app/src/main/java/com/uiui/sn/receiver/APKinstallReceiver.java b/app/src/main/java/com/uiui/sn/receiver/APKinstallReceiver.java index 37be757..d764962 100644 --- a/app/src/main/java/com/uiui/sn/receiver/APKinstallReceiver.java +++ b/app/src/main/java/com/uiui/sn/receiver/APKinstallReceiver.java @@ -8,11 +8,13 @@ import android.content.Intent; import android.text.TextUtils; import android.util.Log; +import com.uiui.sn.config.Configs; import com.uiui.sn.network.HTTPInterface; import com.uiui.sn.service.ManagerService; import com.uiui.sn.utils.ApkUtils; import com.uiui.sn.utils.CacheUtils; import com.uiui.sn.utils.JGYUtils; +import com.uiui.sn.utils.SPUtils; import java.util.concurrent.TimeUnit; @@ -62,21 +64,14 @@ public class APKinstallReceiver extends BroadcastReceiver { } Log.e(TAG, "sendAppInfo: " + state + packageName); newAppListener.setNewAppListener(packageName); - //启动应用市场 - if ("com.uiui.appstore".equals(packageName)) { - Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); - bootIntent.setComponent(new ComponentName("com.uiui.appstore", "com.uiui.appstore.receiver.BootReceiver")); - context.sendBroadcast(bootIntent); - } else if ("com.uiuios.updatetools".equals(packageName)) { + if (JGYUtils.PACKAGE_APPSTORE.equals(packageName)) { + //启动应用市场 + JGYUtils.getInstance().wakeUpDeviceInfo(); + } else if (JGYUtils.PACKAGE_UPDATETOOLS.equals(packageName)) { //启动升级组件 - Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); - bootIntent.setComponent(new ComponentName("com.uiuios.updatetools", "com.uiuios.updatetools.receiver.BootReceiver")); - context.sendBroadcast(bootIntent); + JGYUtils.getInstance().wakeUpUpdateTools(); } - Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); - bootIntent.setComponent(new ComponentName("com.appstore.uiui", "com.appstore.uiui.receiver.BootReceiver")); - context.sendBroadcast(bootIntent); - newAppListener.setNewAppListener(packageName); + } private void cleanLauncher3Cache() { @@ -103,12 +98,15 @@ public class APKinstallReceiver extends BroadcastReceiver { @Override public void onNext(String s) { + int isLogined = (int) SPUtils.get(mContext, Configs.isLogined, 2); + if (isLogined == 2) return; HTTPInterface.getAPPinfo(mContext); HTTPInterface.getForceInstall(mContext); HTTPInterface.getAllappPackage(mContext); HTTPInterface.getAppInside(mContext); - HTTPInterface.checkUpdate(mContext, "com.uiui.appstore"); - HTTPInterface.checkUpdate(mContext, "com.uiui.browser"); + HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_APPSTORE); + HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_BROWSER); + HTTPInterface.checkUpdate(mContext, JGYUtils.PACKAGE_OS); } @Override diff --git a/app/src/main/java/com/uiui/sn/service/MainService.java b/app/src/main/java/com/uiui/sn/service/MainService.java index 695f86e..8ea4389 100644 --- a/app/src/main/java/com/uiui/sn/service/MainService.java +++ b/app/src/main/java/com/uiui/sn/service/MainService.java @@ -283,7 +283,6 @@ public class MainService extends Service implements MainContact.MainView, Networ UserInfo userInfo = response.data; boolean username = Settings.System.putString(getContentResolver(), "UserInfo_username", userInfo.getSn_name()); boolean gread = Settings.System.putString(getContentResolver(), "UserInfo_grade", userInfo.getGrade()); - SPUtils.put(this, Configs.isLogined, 1); SPUtils.put(this, "member_id", userInfo.getMember_id()); SPUtils.put(this, "sn_id", userInfo.getId()); if (!TextUtils.isEmpty(userInfo.getSn_name())) { diff --git a/app/src/main/java/com/uiui/sn/service/ManagerService.java b/app/src/main/java/com/uiui/sn/service/ManagerService.java index 88f7422..05b0083 100644 --- a/app/src/main/java/com/uiui/sn/service/ManagerService.java +++ b/app/src/main/java/com/uiui/sn/service/ManagerService.java @@ -25,11 +25,13 @@ import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.NetworkUtils; import com.uiui.sn.R; import com.uiui.sn.bean.zuoye.BaseResponse; +import com.uiui.sn.config.Configs; import com.uiui.sn.manager.ControlManager; import com.uiui.sn.manager.NetInterfaceManager; import com.uiui.sn.network.HTTPInterface; import com.uiui.sn.receiver.APKinstallReceiver; import com.uiui.sn.receiver.BootReceiver; +import com.uiui.sn.utils.JGYUtils; import com.uiui.sn.utils.SPUtils; import com.uiui.sn.utils.TimeUtils; import com.uiui.sn.utils.Utils; @@ -97,11 +99,13 @@ public class ManagerService extends Service implements NetworkUtils.OnNetworkSta @Override public void onNext(Long aLong) { Log.e("TimeObserver", "onNext: " + aLong); + int isLogined = (int) SPUtils.get(ManagerService.this, Configs.isLogined, 2); + if (isLogined == 2) return; Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this), 1234); - Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, "com.uiui.appstore"), 2345); - Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, "com.uiui.browser"), 3456); - Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, "com.uiui.os"), 5678); - Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, "com.uiui.videoplayer"), 6789); + Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, JGYUtils.PACKAGE_APPSTORE), 2345); + Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, JGYUtils.PACKAGE_BROWSER), 3456); + Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, JGYUtils.PACKAGE_OS), 5678); + Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, JGYUtils.PACKAGE_VIDEOPLAYER), 6789); } diff --git a/app/src/main/java/com/uiui/sn/utils/JGYUtils.java b/app/src/main/java/com/uiui/sn/utils/JGYUtils.java index 6f53cee..522b669 100644 --- a/app/src/main/java/com/uiui/sn/utils/JGYUtils.java +++ b/app/src/main/java/com/uiui/sn/utils/JGYUtils.java @@ -35,6 +35,7 @@ import com.alibaba.fastjson.JSONObject; import com.android.internal.view.RotationPolicy; import com.uiui.sn.BuildConfig; import com.uiui.sn.R; +import com.uiui.sn.receiver.BootReceiver; import java.io.File; import java.lang.reflect.Constructor; @@ -924,4 +925,37 @@ public class JGYUtils { } + public static final String PACKAGE_BROWSER = "com.uiui.browser"; + public static final String PACKAGE_VIDEOPLAYER = "com.uiui.videoplayer"; + public static final String PACKAGE_OS = "com.uiui.os"; + + public static final String PACKAGE_DEVICEINFO = "com.uiui.sn"; + public static final String PACKAGE_APPSTORE = "com.uiui.appstore"; + public static final String PACKAGE_UPDATETOOLS = "com.uiui.updatetools"; + + public static final String CLASS_DEVICEINFO = "com.uiui.sn.receiver.BootReceiver"; + public static final String CLASS_APPSTORE = "com.uiui.appstore.receiver.BootReceiver"; + public static final String CLASS_UPDATETOOLS = "com.uiui.updatetools.receiver.BootReceiver"; + + public void wakeUpDeviceInfo() { + //启动设备信息 + Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); + bootIntent.setComponent(new ComponentName(PACKAGE_DEVICEINFO, CLASS_DEVICEINFO)); + mContext.sendBroadcast(bootIntent); + } + + public void wakeUpAppstore() { + //启动应用市场 + Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); + bootIntent.setComponent(new ComponentName(PACKAGE_APPSTORE, CLASS_APPSTORE)); + mContext.sendBroadcast(bootIntent); + } + + public void wakeUpUpdateTools() { + //启动升级组件 + Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED); + bootIntent.setComponent(new ComponentName(PACKAGE_UPDATETOOLS, CLASS_UPDATETOOLS)); + mContext.sendBroadcast(bootIntent); + } + } diff --git a/app/src/main/res/drawable-hdpi/applet_qrcode.png b/app/src/main/res/drawable-hdpi/applet_qrcode.png index b9cebba..57b3c3f 100644 Binary files a/app/src/main/res/drawable-hdpi/applet_qrcode.png and b/app/src/main/res/drawable-hdpi/applet_qrcode.png differ diff --git a/app/src/main/res/drawable-hdpi/bind_applet.png b/app/src/main/res/drawable-hdpi/bind_applet.png index d9c1730..f42729a 100644 Binary files a/app/src/main/res/drawable-hdpi/bind_applet.png and b/app/src/main/res/drawable-hdpi/bind_applet.png differ