update:2020.12.30
fix:发版 add:
This commit is contained in:
@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.info.sn.BuildConfig;
|
||||
import com.info.sn.bean.AppInfo;
|
||||
import com.info.sn.bean.AppJump;
|
||||
import com.info.sn.bean.AppStart;
|
||||
@@ -23,6 +24,7 @@ import com.info.sn.network.api.AddAppInstall;
|
||||
import com.info.sn.network.api.Browser;
|
||||
import com.info.sn.network.api.ForceInstall;
|
||||
import com.info.sn.network.api.Label;
|
||||
import com.info.sn.network.api.NewestAppUpdate;
|
||||
import com.info.sn.network.api.QueryAllApp;
|
||||
import com.info.sn.network.api.QuerySnAppStart;
|
||||
import com.info.sn.network.api.UpdateAdminSn;
|
||||
@@ -31,6 +33,7 @@ import com.info.sn.utils.FileUtils;
|
||||
import com.info.sn.utils.SPUtils;
|
||||
import com.info.sn.utils.Utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
@@ -526,7 +529,7 @@ public class HTTPInterface {
|
||||
if (null != appInfos && appInfos.size() != 0) {
|
||||
getForceInstallState(context, appInfos);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_force_app", "invalid");
|
||||
Log.e("fht", "qch_force_app:" + qch_force_app + ":" + "invalid");
|
||||
}
|
||||
@@ -583,6 +586,71 @@ public class HTTPInterface {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkUpdate(final Context context, String packageName, String versionCode) {
|
||||
NewestAppUpdate newestAppUpdate = NetWorkManager.getNewestAppUpdateControl();
|
||||
newestAppUpdate.getAppUpdate(packageName, versionCode)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse<AppInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<AppInfo> appInfoBaseResponse) {
|
||||
int code = appInfoBaseResponse.code;
|
||||
if (code == 200) {
|
||||
AppInfo appInfo = appInfoBaseResponse.data;
|
||||
if (null != appInfo) {
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(appInfo);
|
||||
FileUtils.ariaDownload(context, appInfo.getApp_url(), jsonObject);
|
||||
}
|
||||
Log.e("checkUpdate", "update now");
|
||||
} else {
|
||||
Log.e("checkUpdate", "not find update");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("checkUpdate", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void checkUpdate(Context context) {
|
||||
String packageName = BuildConfig.APPLICATION_ID;
|
||||
String versionCode = String.valueOf(BuildConfig.VERSION_CODE);
|
||||
checkUpdate(context, packageName, versionCode);
|
||||
}
|
||||
|
||||
public static void checkUpdate(Context context, String packageName) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
PackageInfo info = null;
|
||||
try {
|
||||
info = pm.getPackageInfo(packageName, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (null != info) {
|
||||
long appVersionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
appVersionCode = info.getLongVersionCode();
|
||||
} else {
|
||||
appVersionCode = info.versionCode;
|
||||
}
|
||||
checkUpdate(context, packageName, String.valueOf(appVersionCode));
|
||||
} else {
|
||||
checkUpdate(context, packageName, "0");
|
||||
}
|
||||
}
|
||||
|
||||
//获取设备信息接口
|
||||
// public static synchronized void checkDevicesInfo(final Handler handler) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.info.sn.network.api.BindDevices;
|
||||
import com.info.sn.network.api.Browser;
|
||||
import com.info.sn.network.api.ForceInstall;
|
||||
import com.info.sn.network.api.Label;
|
||||
import com.info.sn.network.api.NewestAppUpdate;
|
||||
import com.info.sn.network.api.QueryAllApp;
|
||||
import com.info.sn.network.api.QuerySnAppStart;
|
||||
import com.info.sn.network.api.SNInfo;
|
||||
@@ -61,7 +62,7 @@ public class NetWorkManager {
|
||||
private static APPJump appJumpControl;
|
||||
private static UpdateAdminSn updateAdminSnControl;
|
||||
private static QueryAllApp queryAllAppControl;
|
||||
|
||||
private static NewestAppUpdate newestAppUpdateControl;
|
||||
|
||||
public static SNInfo getsnInfoControl() {
|
||||
if (null == snInfoControl) {
|
||||
@@ -206,4 +207,18 @@ public class NetWorkManager {
|
||||
return queryAllAppControl;
|
||||
}
|
||||
|
||||
public static NewestAppUpdate getNewestAppUpdateControl() {
|
||||
if (null == newestAppUpdateControl) {
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.client(client)
|
||||
.baseUrl(ROOT_URL)
|
||||
.addConverterFactory(gsonConverterFactory)
|
||||
.addCallAdapterFactory(rxJavaCallAdapterFactory)
|
||||
.build();
|
||||
newestAppUpdateControl = retrofit.create(NewestAppUpdate.class);
|
||||
}
|
||||
return newestAppUpdateControl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -33,5 +33,6 @@ public class UrlAddress {
|
||||
//发送卸载或者安装信息
|
||||
public final static String UPDATE_SNINFO = ROOT_URL + "sn/updateAdminSn";
|
||||
//发送卸载或者安装信息
|
||||
|
||||
public final static String GET_NEWESTAPPUPDATE = ROOT_URL + "app/newestAppUpdate";
|
||||
//根据包名获取更新
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.info.sn.network.api;
|
||||
|
||||
|
||||
import com.info.sn.bean.AppInfo;
|
||||
import com.info.sn.bean.BaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.Response;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface NewestAppUpdate {
|
||||
@GET(UrlAddress.GET_NEWESTAPPUPDATE)
|
||||
Observable<BaseResponse<AppInfo>> getAppUpdate(
|
||||
@Query("packageName") String packageName,
|
||||
@Query("versionCode") String versionCode
|
||||
);
|
||||
}
|
||||
@@ -12,8 +12,6 @@ import com.info.sn.service.StepService;
|
||||
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
|
||||
@@ -47,6 +47,8 @@ public class InitJpushServer extends Service {
|
||||
// HTTPInterface.checkDevicesInfo(InitJpushServer.this);
|
||||
HTTPInterface.getAllappPackage(InitJpushServer.this);
|
||||
HTTPInterface.getForceInstall(InitJpushServer.this);
|
||||
HTTPInterface.checkUpdate(InitJpushServer.this);
|
||||
HTTPInterface.checkUpdate(InitJpushServer.this,"com.appstore.uiui");
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user