version:1.5

fix:
add:非法设备不进行自动下载
This commit is contained in:
2022-01-25 16:17:28 +08:00
parent f0307e9027
commit be3934c1bb
11 changed files with 96 additions and 42 deletions

View File

@@ -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.

View File

@@ -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<String, Long, Long> {
@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())) {

View File

@@ -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<UserInfo> 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 {

View File

@@ -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();
}
}

View File

@@ -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<BaseResponse<AppInfo>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e(TAG, "onSubscribe: ");
Log.e("checkUpdate", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<AppInfo> 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: ");
}
});

View File

@@ -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

View File

@@ -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())) {

View File

@@ -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);
}

View File

@@ -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);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 41 KiB