修改升级接口

This commit is contained in:
lixiaopeng
2022-09-14 19:46:06 +08:00
parent 78bf858c2a
commit 055d186b6d
7 changed files with 130 additions and 165 deletions

View File

@@ -11,7 +11,7 @@ import retrofit2.http.Query;
/**
* @author lixiaopeng
* @description 绑定车辆
* @description 升级
* @since: 6/20/22
*/
public interface UpgradeApiService {
@@ -21,7 +21,8 @@ public interface UpgradeApiService {
* @return {@link UpgradeAppInfo}
*/
@Headers("Content-Type:application/json;charset=UTF-8")
@POST("unify/selectResources")
Observable<UpgradeAppInfo> getUpgradeInfo(@Query("resources") String res, @Body RequestBody requestBody);
@POST("/eagleEye-mis/config/versionInfo")
// Observable<UpgradeAppInfo> getUpgradeInfo(@Query("resources") String res, @Body RequestBody requestBody);
Observable<UpgradeAppInfo> getUpgradeInfo(@Body RequestBody requestBody);
}

View File

@@ -35,7 +35,7 @@ import okhttp3.RequestBody;
public class UpgradeAppNetWorkManager {
private static volatile UpgradeAppNetWorkManager requestNoticeManager;
private final UpgradeApiService mUpgradeApiService;
private static final String TAG = "UpgradeAppNetWorkManager";
private static final String TAG = "Upgrade";
private UpgradeAppNetWorkManager() {
@@ -58,18 +58,16 @@ public class UpgradeAppNetWorkManager {
/**
* 获取app升级信息
*/
public void getAppUpgradeInfo(Context context, String screenType, String carType) {
public void getAppUpgradeInfo(Context context, String mac, String screenType) {
String sn = "X20202203105S688HZ";
// int versionCode = 2070000;
// String versionName = "2.7.0";
// String mac = "48:b0:2d:3a:bc:78";
// String sn = MoGoAiCloudClientConfig.getInstance().getSn();
int versionCode = AppUtils.getAppVersionCode();
String versionName = AppUtils.getAppVersionName();
UpgradeAppRequest request = new UpgradeAppRequest(sn, versionCode, versionName, screenType, carType);
//TODO 不能写死
UpgradeAppRequest request = new UpgradeAppRequest(sn, mac, screenType);
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
mUpgradeApiService.getUpgradeInfo("apps_control", requestBody)
mUpgradeApiService.getUpgradeInfo(requestBody)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<UpgradeAppInfo>() {
@@ -79,18 +77,20 @@ public class UpgradeAppNetWorkManager {
@Override
public void onNext(@NonNull UpgradeAppInfo info) {
if (info != null && info.getData() != null && info.getData().size() > 0) {
CallerLogger.INSTANCE.d(TAG, "UpgradeAppInfo url = " + info.getData().get(0).getApp_url() + "----code = " + info.getData().get(0).getVersion_code());
// if (info.getData().get(0).getVersion_code() > versionCode) {
CallerHmiManager.INSTANCE.showUpgradeDialog(info.getData().get(0).getApp_url().substring(info.getData().get(0).getApp_url().lastIndexOf("/")+1), info.getData().get(0).getApp_url());
// }
if (info != null) {
CallerLogger.INSTANCE.d(TAG, "UpgradeAppInfo url = " + info.result.getAppUrl() + "----code = " + info.result.getVersionCode());
Log.d(TAG, "UpgradeAppInfo url = " + info.result.getAppUrl() + "----code = " + info.result.getVersionCode() + "--versionCode =" + versionCode + "--info.result = " + info.result);
if (info.result.getVersionCode() > versionCode) {
CallerHmiManager.INSTANCE.showUpgradeDialog(info.result.getAppUrl().substring(info.result.getAppUrl().lastIndexOf("/")+1), info.result.getAppUrl());
}
} else {
Log.e(TAG, "onNext info == null");
}
}
@Override
public void onError(@NonNull Throwable e) {
CallerLogger.INSTANCE.e(TAG, "UpgradeAppInfo onError e = " + e.toString() + "---e.getMessage = " + e.getMessage());
public void onError(Throwable e) {
}
@Override

View File

@@ -6,18 +6,15 @@ package com.mogo.eagle.core.function.appupgrade.network;
* @since: 11/15/21
*/
public class UpgradeAppRequest {
private String mac;
private String sn;
private int version_code;
private String version_name;
private String screen_type;
private String car_type;
private String screenType;
public UpgradeAppRequest( String sn, int versionCode, String versionName, String type, String carType) {
public UpgradeAppRequest( String sn, String mac, String screenType) {
this.sn = sn;
this.version_code = versionCode;
this.version_name = versionName;
this.screen_type = type;
this.car_type = carType;
this.mac = mac;
this.screenType = screenType;
}
public String getSn() {
@@ -28,46 +25,20 @@ public class UpgradeAppRequest {
this.sn = sn;
}
public int getVersion_code() {
return version_code;
public String getMac() {
return mac;
}
public void setVersion_code(int version_code) {
this.version_code = version_code;
public void setMac(String mac) {
this.mac = mac;
}
public String getVersion_name() {
return version_name;
public String getScreenType() {
return screenType;
}
public void setVersion_name(String version_name) {
this.version_name = version_name;
public void setScreenType(String screenType) {
this.screenType = screenType;
}
public String getScreen_type() {
return screen_type;
}
public void setScreen_type(String screen_type) {
this.screen_type = screen_type;
}
public String getCar_type() {
return car_type;
}
public void setCar_type(String car_type) {
this.car_type = car_type;
}
@Override
public String toString() {
return "UpgradeAppRequest{" +
"sn='" + sn + '\'' +
", version_code=" + version_code +
", version_name='" + version_name + '\'' +
", screen_type='" + screen_type + '\'' +
", car_type='" + car_type + '\'' +
'}';
}
}

View File

@@ -116,6 +116,10 @@ public class BindingcarProvider implements IMoGoBindingcarProvider {
}
}
/**
* 以后可能废弃
* @return
*/
private int getScreenType() {
int screenType = -1;
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
@@ -142,12 +146,34 @@ public class BindingcarProvider implements IMoGoBindingcarProvider {
}
private String getCarScreenType() {
String screenType = "";
if(AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
screenType = "1"; //taxi乘客端
}
if(AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
screenType = "2"; //taxi司机端
}
if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
screenType = "3"; //bus 乘客端
}
if(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
screenType = "4"; //bus 司机端
}
return screenType;
}
/**
* 查询app是否需要升级
*/
@Override
public void queryAppUpgrade() {
UpgradeAppNetWorkManager.getInstance().getAppUpgradeInfo(mContext, String.valueOf(getScreenType()), String.valueOf(getCarType()));
Log.d("Upgrade", "mac = " + mAddress + "---type = " + getCarScreenType() );
UpgradeAppNetWorkManager.getInstance().getAppUpgradeInfo(mContext, mAddress, getCarScreenType());
}
}