[2.13.0-arch-opt] move binding car to deva tools
This commit is contained in:
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,80 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.alibaba.arouter'
|
||||
}
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
//ARouter apt 参数
|
||||
kapt {
|
||||
useBuildCache = false
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
|
||||
javaCompileOptions{
|
||||
annotationProcessorOptions{
|
||||
arguments = ["room.schemaLocation":"$projectDir/schemas".toString()]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.androidxroomruntime
|
||||
implementation rootProject.ext.dependencies.androidxroomktx
|
||||
implementation rootProject.ext.dependencies.litezxing
|
||||
kapt rootProject.ext.dependencies.androidxroomcompiler
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
|
||||
implementation rootProject.ext.dependencies.mogo_core_data
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
implementation rootProject.ext.dependencies.mogo_core_network
|
||||
implementation rootProject.ext.dependencies.mogo_core_function_call
|
||||
} else {
|
||||
implementation project(":foudations:mogo-commons")
|
||||
|
||||
implementation project(':core:mogo-core-data')
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':core:mogo-core-network')
|
||||
implementation project(':core:mogo-core-function-call')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -1,3 +0,0 @@
|
||||
GROUP=com.mogo.eagle.core.function.impl
|
||||
POM_ARTIFACT_ID=notice
|
||||
VERSION_CODE=1
|
||||
@@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.eagle.core.function.bindingcar">
|
||||
|
||||
<application>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.mogo.eagle.core.function.appupgrade.network;
|
||||
|
||||
import com.mogo.eagle.core.data.bindingcar.UpgradeAppInfo;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 升级
|
||||
* @since: 6/20/22
|
||||
*/
|
||||
public interface UpgradeApiService {
|
||||
/**
|
||||
* 获取升级信息
|
||||
* , @Query("resources") String i
|
||||
* @return {@link UpgradeAppInfo}
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("eagleEye-mis/config/versionInfo")
|
||||
// Observable<UpgradeAppInfo> getUpgradeInfo(@Query("resources") String res, @Body RequestBody requestBody);
|
||||
Observable<UpgradeAppInfo> getUpgradeInfo(@Body RequestBody requestBody);
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.mogo.eagle.core.function.appupgrade.network;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BINDING;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.constants.HostConst;
|
||||
import com.mogo.eagle.core.data.bindingcar.UpgradeAppInfo;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 获取升级信息
|
||||
* @since: 3/25/22
|
||||
*/
|
||||
public class UpgradeAppNetWorkManager {
|
||||
private static volatile UpgradeAppNetWorkManager requestNoticeManager;
|
||||
private final UpgradeApiService mUpgradeApiService;
|
||||
private static final String TAG = "Upgrade";
|
||||
|
||||
|
||||
private UpgradeAppNetWorkManager() {
|
||||
mUpgradeApiService = MoGoRetrofitFactory.getInstance(HostConst.getHost())
|
||||
.create(UpgradeApiService.class);
|
||||
}
|
||||
|
||||
public static UpgradeAppNetWorkManager getInstance() {
|
||||
if (requestNoticeManager == null) {
|
||||
synchronized (UpgradeAppNetWorkManager.class) {
|
||||
if (requestNoticeManager == null) {
|
||||
requestNoticeManager = new UpgradeAppNetWorkManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return requestNoticeManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取app升级信息
|
||||
*/
|
||||
public void getAppUpgradeInfo(Context context, String mac, String screenType) {
|
||||
// String sn = "X20202203105S688HZ";
|
||||
// String mac = "48:b0:2d:3a:bc:78";
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
int versionCode = AppUtils.getAppVersionCode();
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "getAppUpgradeInfo mac = " + mac + "---type = " + screenType + "---sn = " + sn + "---versionCode =" + versionCode);
|
||||
UpgradeAppRequest request = new UpgradeAppRequest(sn, mac, screenType);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
|
||||
mUpgradeApiService.getUpgradeInfo(requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<UpgradeAppInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull UpgradeAppInfo info) {
|
||||
if (info != null && info.result != null) {
|
||||
CallerLogger.INSTANCE.d(M_BINDING + 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(), info.result.getInstallTitle(), info.result.getInstallContent(), info.result.getInstallType());
|
||||
}
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "UpgradeAppInfo onNext info == null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.mogo.eagle.core.function.appupgrade.network;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 获取app升级信息
|
||||
* @since: 11/15/21
|
||||
*/
|
||||
public class UpgradeAppRequest {
|
||||
private String mac;
|
||||
private String sn;
|
||||
private String screenType;
|
||||
|
||||
|
||||
public UpgradeAppRequest( String sn, String mac, String screenType) {
|
||||
this.sn = sn;
|
||||
this.mac = mac;
|
||||
this.screenType = screenType;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setMac(String mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public String getScreenType() {
|
||||
return screenType;
|
||||
}
|
||||
|
||||
public void setScreenType(String screenType) {
|
||||
this.screenType = screenType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,182 +0,0 @@
|
||||
package com.mogo.eagle.core.function.bindingcar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.bindingcar.BindingcarCallBack;
|
||||
import com.mogo.eagle.core.function.api.bindingcar.IMoGoBindingcarProvider;
|
||||
import com.mogo.eagle.core.function.appupgrade.network.UpgradeAppNetWorkManager;
|
||||
import com.mogo.eagle.core.function.bindingcar.network.BindingcarNetWorkManager;
|
||||
import com.mogo.eagle.core.function.ipcupgrade.IPCUpgradeManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 绑定sn
|
||||
* @since: 3/26/22
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_BINDING_CAR)
|
||||
public class BindingcarProvider implements IMoGoBindingcarProvider {
|
||||
|
||||
private Context mContext;
|
||||
private volatile String mAddress;
|
||||
private volatile String mWidevineIDWithMd5; //google 数字版权
|
||||
private volatile int mScreenType = -1;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFunctionName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
IPCUpgradeManager.Companion.getINSTANCE().destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
mContext = context;
|
||||
IPCUpgradeManager.Companion.getINSTANCE().initServer(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取macaddress,每次连接请求一次
|
||||
*
|
||||
* @param macAddress
|
||||
*/
|
||||
@Override
|
||||
public void getBindingcarInfo(String macAddress, String widevineIDWithMd5) {
|
||||
Log.d("Upgrade", "getBindingcarInfo macAddress = " + macAddress + "--widevineIDWithMd5 = " + widevineIDWithMd5);
|
||||
mAddress = macAddress;
|
||||
mWidevineIDWithMd5 = widevineIDWithMd5;
|
||||
if (getScreenType() == 1) { //司机屏
|
||||
driverScreen(macAddress, widevineIDWithMd5);
|
||||
} else if (getScreenType() == 2) { //乘客屏
|
||||
passengerScreen(macAddress, widevineIDWithMd5);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认升级工控机docker版本
|
||||
*
|
||||
* @param images docker列表
|
||||
* @param padSn SN
|
||||
* @param releaseId 任务ID
|
||||
*/
|
||||
@Override
|
||||
public void upgradeConfirm(List<String> images, String padSn, String releaseId) {
|
||||
IPCUpgradeManager.Companion.getINSTANCE().upgradeConfirm(images, padSn, releaseId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新工控机docker版本
|
||||
*
|
||||
* @param padSn SN
|
||||
* @param dockerVersion 当前工控机版本
|
||||
*/
|
||||
@Override
|
||||
public void queryContainers(String padSn, String dockerVersion) {
|
||||
IPCUpgradeManager.Companion.getINSTANCE().queryContainers(padSn, dockerVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyCarInfo(BindingcarCallBack callBack) {
|
||||
BindingcarNetWorkManager.getInstance().modifyBindingcar(mAddress, mWidevineIDWithMd5, callBack, getScreenType());
|
||||
}
|
||||
|
||||
private void driverScreen(String macAddress, String widevineIDWithMd5) {
|
||||
long currentHour = System.currentTimeMillis() / (1000 * 60);
|
||||
long oldHour = SharedPrefsMgr.getInstance(mContext).getLong("typeDriver", 0);
|
||||
//如果2分钟内频繁调,需要拦截,业务导致的会多次请求工控机信息
|
||||
if (HmiBuildConfig.isShowSnBindingView) {
|
||||
if (currentHour - oldHour > 1) {
|
||||
SharedPrefsMgr.getInstance(mContext).putLong("typeDriver", System.currentTimeMillis() / (1000 * 60));
|
||||
BindingcarNetWorkManager.getInstance().getBindingcarInfo(mContext, macAddress, widevineIDWithMd5, getScreenType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void passengerScreen(String macAddress, String widevineIDWithMd5) {
|
||||
long currentHour = System.currentTimeMillis() / (1000 * 60);
|
||||
long oldHour = SharedPrefsMgr.getInstance(mContext).getLong("typePassenger", 0);
|
||||
//如果2分钟内频繁调,需要拦截,业务导致的会多次请求工控机信息
|
||||
if (HmiBuildConfig.isShowSnBindingView) {
|
||||
if (currentHour - oldHour > 1) {
|
||||
SharedPrefsMgr.getInstance(mContext).putLong("typePassenger", System.currentTimeMillis() / (1000 * 60));
|
||||
BindingcarNetWorkManager.getInstance().getBindingcarInfo(mContext, macAddress, widevineIDWithMd5, getScreenType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 以后可能废弃
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getScreenType() {
|
||||
int screenType = -1;
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
screenType = 1; //司机屏
|
||||
}
|
||||
|
||||
if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
screenType = 2; //乘客屏
|
||||
}
|
||||
return screenType;
|
||||
}
|
||||
|
||||
private int getCarType() {
|
||||
int carType = -1;
|
||||
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
carType = 1; //bus
|
||||
}
|
||||
|
||||
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
|
||||
carType = 2; //taxi
|
||||
}
|
||||
|
||||
return carType;
|
||||
|
||||
}
|
||||
|
||||
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, mAddress, getCarScreenType());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.mogo.eagle.core.function.bindingcar.network;
|
||||
|
||||
import com.mogo.eagle.core.data.bindingcar.BindingcarInfo;
|
||||
import com.mogo.eagle.core.data.bindingcar.ModifyBindingcarInfo;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.Header;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 绑定车辆
|
||||
* @since: 10/28/21
|
||||
*/
|
||||
public interface BindingcarApiService {
|
||||
/**
|
||||
* 获取绑定车辆的信息
|
||||
*
|
||||
* @return {@link BindingcarInfo}
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("eagleEye-mis/cmdbapi/pad/selectPadByMac")
|
||||
Observable<BindingcarInfo> getBindingcarInfo(/*@Header("access_token") String access_token,*/ @Body RequestBody requestBody);
|
||||
|
||||
/**
|
||||
* 绑定和修改绑定车机
|
||||
*
|
||||
* @return {@link ModifyBindingcarInfo}
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("eagleEye-mis/cmdbapi/pad/v2/updatePadByMac")
|
||||
Observable<ModifyBindingcarInfo> modifyBindingcarInfo(/*@Header("access_token") String access_token,*/ @Body RequestBody requestBody);
|
||||
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
package com.mogo.eagle.core.function.bindingcar.network;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_BINDING;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.commons.constants.HostConst;
|
||||
import com.mogo.commons.constants.SharedPrefsConstants;
|
||||
import com.mogo.eagle.core.data.bindingcar.BindingcarInfo;
|
||||
import com.mogo.eagle.core.data.bindingcar.ModifyBindingcarInfo;
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
|
||||
import com.mogo.eagle.core.function.api.bindingcar.BindingcarCallBack;
|
||||
import com.mogo.eagle.core.function.bindingcar.R;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerHDMapManager;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 绑定车机网络请求
|
||||
* @since: 3/25/22
|
||||
*/
|
||||
public class BindingcarNetWorkManager {
|
||||
private static volatile BindingcarNetWorkManager requestNoticeManager;
|
||||
private final BindingcarApiService mBindingcarApiService;
|
||||
private static final String TAG = "BindingcarNetManager";
|
||||
|
||||
private BindingcarNetWorkManager() {
|
||||
mBindingcarApiService = MoGoRetrofitFactory.getInstance(HostConst.getHost())
|
||||
.create(BindingcarApiService.class);
|
||||
}
|
||||
|
||||
public static BindingcarNetWorkManager getInstance() {
|
||||
if (requestNoticeManager == null) {
|
||||
synchronized (BindingcarNetWorkManager.class) {
|
||||
if (requestNoticeManager == null) {
|
||||
requestNoticeManager = new BindingcarNetWorkManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return requestNoticeManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取绑定的车辆信息
|
||||
*
|
||||
* @param macAddress mac地址
|
||||
*/
|
||||
public void getBindingcarInfo(Context context, String macAddress, String widevineIDWithMd5, int screenType) {
|
||||
// String macAddress1 = "48:b0:2d:4d:33:40";
|
||||
// String sn = "X2020220417KA94QIN";
|
||||
|
||||
BindingcarRequest request = new BindingcarRequest(macAddress, widevineIDWithMd5, screenType);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
|
||||
mBindingcarApiService.getBindingcarInfo(requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BindingcarInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BindingcarInfo info) {
|
||||
if (info != null && info.getData() != null) {
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "getBindingcarInfo onNext info.getData() =" + info.getData().toString());
|
||||
//根据车辆类型切换不同的车辆模型,只针对红旗做处理
|
||||
updateCarVrIconRes(info.getData().getBrandId());
|
||||
switch (info.getData().getCompare()) {
|
||||
case "0":
|
||||
CallerHmiManager.INSTANCE.showBindingcarDialog();
|
||||
break;
|
||||
case "3":
|
||||
CallerHmiManager.INSTANCE.showModifyBindingcarDialog();
|
||||
break;
|
||||
case "null":
|
||||
TipToast.shortTip("当前工控机没有入库");
|
||||
break;
|
||||
}
|
||||
SharedPrefsMgr.getInstance(context).putString(SharedPrefsConstants.CAR_INFO, GsonUtils.toJson(info.getData()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
CallerLogger.INSTANCE.e(M_BINDING + TAG, "getBindingcarInfo onError e = " + e.toString() + "---e.getMessage = " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定和修改绑定车辆
|
||||
* mac: 48:b0:2d:3a:9c:19
|
||||
*/
|
||||
public void modifyBindingcar(String macAddress, String widevineIDWithMd5, BindingcarCallBack callBack, int screenType) {
|
||||
// String macAddress1 = "48:b0:2d:4d:33:40";
|
||||
// String sn = "X2020220417KA94QIN";
|
||||
BindingcarRequest request = new BindingcarRequest(macAddress, widevineIDWithMd5, screenType);
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
|
||||
mBindingcarApiService.modifyBindingcarInfo(requestBody)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<ModifyBindingcarInfo>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull ModifyBindingcarInfo info) {
|
||||
if (info != null) {
|
||||
callBack.callBackResult(info);
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "modifyBindingcar onNext code = " + info.code + "---msg = " + info.msg + "--info.toString() = " + info.toString());
|
||||
updateCarVrIconRes(info.getData().getBrandId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
CallerLogger.INSTANCE.e(M_BINDING + TAG, "modifyBindingcar onError e = " + e.toString() + "---e.getMessage = " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void updateCarVrIconRes(String brandId){
|
||||
if(brandId == null || brandId.isEmpty()){
|
||||
return;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG,"updateCarVrIconRes : " + brandId);
|
||||
switch (brandId){
|
||||
case "1":
|
||||
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.chuzuche);
|
||||
HdMapBuildConfig.currentCarVrIconRes =R.raw.chuzuche;
|
||||
break;
|
||||
case "2":
|
||||
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.hq_h9);
|
||||
HdMapBuildConfig.currentCarVrIconRes =R.raw.hq_h9;
|
||||
break;
|
||||
case "3":
|
||||
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.xiaobache);
|
||||
HdMapBuildConfig.currentCarVrIconRes =R.raw.xiaobache;
|
||||
break;
|
||||
default:
|
||||
CallerHDMapManager.INSTANCE.changeCurrentIcon(R.raw.chuzuche);
|
||||
HdMapBuildConfig.currentCarVrIconRes =R.raw.chuzuche;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.mogo.eagle.core.function.bindingcar.network;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description
|
||||
* @since: 11/15/21
|
||||
*/
|
||||
public class BindingcarRequest {
|
||||
private String mac;
|
||||
private String sn;
|
||||
private int type;
|
||||
|
||||
public BindingcarRequest(String mac, String sn, int type) {
|
||||
this.mac = mac;
|
||||
this.sn = sn;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public void setMac(String mac) {
|
||||
this.mac = mac;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BindingcarRequest{" +
|
||||
"mac='" + mac + '\'' +
|
||||
", sn='" + sn + '\'' +
|
||||
", type=" + type +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
package com.mogo.eagle.core.function.ipcupgrade
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingCarListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.ipcupgrade.network.IPCUpgradeNetWorkModel
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* @author XuXinChao
|
||||
* @description 工控机镜像版本升级管理
|
||||
* @since: 2022/5/12
|
||||
*/
|
||||
class IPCUpgradeManager: IMogoOnMessageListener<IPCUpgradeStateInfo> ,
|
||||
IMoGoAutopilotStatusListener {
|
||||
|
||||
companion object{
|
||||
const val TAG ="IPCUpgradeManager"
|
||||
const val IPC_UPGRADE_MSG_TYPE = 50000
|
||||
val INSTANCE: IPCUpgradeManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED){
|
||||
IPCUpgradeManager()
|
||||
}
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
private val ipcUpgradeNetWorkModel = IPCUpgradeNetWorkModel()
|
||||
private var autopilotStatus: Int? = null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中
|
||||
|
||||
private var hasIPCUpgradeTask = false //是否有工控机升级任务,默认没有该任务
|
||||
private var ipcUpgradeStateInfoTask: IPCUpgradeStateInfo?=null
|
||||
|
||||
fun initServer(context: Context){
|
||||
mContext = context
|
||||
//添加长链接监听
|
||||
MogoAiCloudSocketManager.getInstance(context)
|
||||
.registerOnMessageListener(IPC_UPGRADE_MSG_TYPE, this)
|
||||
// 添加 ADAS状态 监听
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun target(): Class<IPCUpgradeStateInfo> {
|
||||
return IPCUpgradeStateInfo::class.java
|
||||
}
|
||||
|
||||
override fun onMsgReceived(ipcUpgradeStateInfo: IPCUpgradeStateInfo?) {
|
||||
CallerLogger.i(TAG,"IPCUpgradeManager received msg${ipcUpgradeStateInfo}")
|
||||
ipcUpgradeStateInfo?.let {
|
||||
if(it.status.isEmpty() || it.status == "0"){
|
||||
if(autopilotStatus == 2){
|
||||
//当前处于自动驾驶状态时,不弹窗提示,结束自动驾驶时弹窗
|
||||
hasIPCUpgradeTask = true
|
||||
ipcUpgradeStateInfoTask=it
|
||||
}else{
|
||||
var releaseId=""
|
||||
if(it.releaseId!=null){
|
||||
releaseId = it.releaseId.toString()
|
||||
}
|
||||
//弹窗提示,确认是否进行工控机升级
|
||||
CallerHmiManager.showAdUpgradeDialog(
|
||||
it.images,
|
||||
MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn,
|
||||
releaseId)
|
||||
}
|
||||
}else{
|
||||
//更新下载or升级状态
|
||||
CallerHmiManager.showAdUpgradeStatus(it)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶状态信息
|
||||
* @param autoPilotStatusInfo 状态信息
|
||||
*/
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
autopilotStatus = autoPilotStatusInfo.state
|
||||
//有升级任务,且不处于自动驾驶状态,进行升级提示
|
||||
if(hasIPCUpgradeTask && autopilotStatus!=2){
|
||||
ipcUpgradeStateInfoTask?.let {
|
||||
var releaseId=""
|
||||
if(it.releaseId!=null){
|
||||
releaseId = it.releaseId.toString()
|
||||
}
|
||||
CallerHmiManager.showAdUpgradeDialog(
|
||||
it.images,
|
||||
MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn,
|
||||
releaseId)
|
||||
//将升级任务置为false
|
||||
hasIPCUpgradeTask = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认升级工控机docker版本
|
||||
* @param images docker列表
|
||||
* @param padSn SN
|
||||
* @param releaseId 任务ID
|
||||
*/
|
||||
fun upgradeConfirm(images: List<String>,padSn: String,releaseId: String){
|
||||
ipcUpgradeNetWorkModel.upgradeConfirm(images,padSn,releaseId,
|
||||
onSuccess = {
|
||||
CallerBindingCarListenerManager.invokePushServerConfirm()
|
||||
},
|
||||
onError = {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新工控机docker版本
|
||||
* @param padSn SN
|
||||
* @param dockerVersion 当前工控机版本
|
||||
*/
|
||||
fun queryContainers(padSn: String,dockerVersion: String){
|
||||
ipcUpgradeNetWorkModel.queryContainers(padSn,
|
||||
onSuccess = {
|
||||
val jsonObject = JSONObject(it)
|
||||
val images = jsonObject.getJSONArray("images")
|
||||
val dockerList = ArrayList<String>()
|
||||
for(i in 0 until images.length()){
|
||||
if(!images[i].toString().contains(dockerVersion)){
|
||||
dockerList.add(images[i].toString())
|
||||
}
|
||||
|
||||
}
|
||||
//将数组结果回调
|
||||
CallerBindingCarListenerManager.invokeQueryContainersResponse(dockerList)
|
||||
},
|
||||
onError = {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun destroy(){
|
||||
//注销长链接监听
|
||||
MogoAiCloudSocketManager.getInstance(mContext)
|
||||
.unregisterLifecycleListener(IPC_UPGRADE_MSG_TYPE)
|
||||
// 移除 ADAS状态 监听
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
mContext = null
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.mogo.eagle.core.function.ipcupgrade.network
|
||||
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.Response
|
||||
import okhttp3.RequestBody
|
||||
import retrofit2.http.*
|
||||
|
||||
/**
|
||||
* @author XuXinChao
|
||||
* @description 工控机升级网络请求接口
|
||||
* @since: 2022/5/17
|
||||
*/
|
||||
interface IPCUpgradeApiService {
|
||||
|
||||
/**
|
||||
* 确认升级工控机docker版本
|
||||
* @param imageName docker域名
|
||||
* @param imageVersion docker版本
|
||||
* @param padSn SN
|
||||
* @param releaseId 任务ID
|
||||
*/
|
||||
@Headers(
|
||||
"Content-Type:application/json",
|
||||
"Accept: application/json"
|
||||
)
|
||||
@POST("/api/pushServer/confirm")
|
||||
suspend fun upgradeConfirm(@Body requestBody: RequestBody): BaseResponse<Any>
|
||||
|
||||
/**
|
||||
* 获取新工控机docker版本
|
||||
* @param padSn SN
|
||||
*/
|
||||
@GET("/api/pushServer/queryContainers")
|
||||
suspend fun queryContainers(@Query("padSn") padSn: String): Response<Any>
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.mogo.eagle.core.function.ipcupgrade.network
|
||||
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.Response
|
||||
import com.mogo.eagle.core.function.ipcupgrade.network.UpgradeHostConst.Companion.getBaseUrl
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.apiCall
|
||||
import com.mogo.eagle.core.network.apiResponseCall
|
||||
import com.mogo.eagle.core.network.request
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.RequestBody
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* @author XuXinChao
|
||||
* @description 工控机升级网络请求
|
||||
* @since: 2022/5/17
|
||||
*/
|
||||
class IPCUpgradeNetWorkModel {
|
||||
|
||||
private fun getNetWorkApi(baseUrl: String =getBaseUrl()): IPCUpgradeApiService{
|
||||
return MoGoRetrofitFactory.getInstanceNoCallAdapter(baseUrl)
|
||||
.create(IPCUpgradeApiService::class.java)
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认升级工控机docker版本
|
||||
* @param images docker列表
|
||||
* @param padSn SN
|
||||
* @param releaseId 任务ID
|
||||
*/
|
||||
fun upgradeConfirm(images: List<String>,padSn: String,releaseId: String,
|
||||
onSuccess: ((String) -> Unit),onError: ((String) -> Unit)){
|
||||
request<BaseResponse<Any?>> {
|
||||
val requestJson = JSONObject()
|
||||
val imagesJsonArray = JSONArray()
|
||||
images.iterator().forEach {
|
||||
imagesJsonArray.put(it)
|
||||
}
|
||||
requestJson.put("images",imagesJsonArray)
|
||||
requestJson.put("padSn",padSn)
|
||||
requestJson.put("releaseId",releaseId)
|
||||
val requestBody:RequestBody= RequestBody.create(
|
||||
MediaType.parse("application/json; charset=utf-8"),
|
||||
requestJson.toString()
|
||||
)
|
||||
loader{
|
||||
apiCall{
|
||||
getNetWorkApi(getBaseUrl()).upgradeConfirm(requestBody)
|
||||
}
|
||||
}
|
||||
onSuccess{
|
||||
onSuccess.invoke("")
|
||||
}
|
||||
|
||||
onError {
|
||||
onError.invoke("")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新工控机docker版本
|
||||
* @param padSn SN
|
||||
*/
|
||||
fun queryContainers(padSn: String,onSuccess: ((String) -> Unit),onError: ((String) -> Unit)){
|
||||
request<Response<Any?>>{
|
||||
loader {
|
||||
apiResponseCall{
|
||||
getNetWorkApi(getBaseUrl()).queryContainers(padSn)
|
||||
}
|
||||
}
|
||||
onSuccess{
|
||||
if(it.msg == "success"){
|
||||
onSuccess.invoke(GsonUtils.toJson(it.data))
|
||||
}else{
|
||||
onError.invoke("query Containers fail")
|
||||
}
|
||||
}
|
||||
|
||||
onError {
|
||||
if(it.message!=null){
|
||||
onError.invoke(it.message!!)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.mogo.eagle.core.function.ipcupgrade.network
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
|
||||
/**
|
||||
* @author XuXinChao
|
||||
* @description 工控机升级域名管理
|
||||
* @since: 2022/5/17
|
||||
*/
|
||||
class UpgradeHostConst {
|
||||
|
||||
companion object{
|
||||
|
||||
private const val HOST_DEV = "http://mysunflower-qa.zhidaoauto.com"
|
||||
private const val HOST_RELEASE = "http://mysunflower.zhidaoauto.com"
|
||||
|
||||
fun getBaseUrl(): String {
|
||||
return when (DebugConfig.getNetMode()) {
|
||||
DebugConfig.NET_MODE_DEV -> HOST_DEV
|
||||
DebugConfig.NET_MODE_QA -> HOST_DEV
|
||||
DebugConfig.NET_MODE_DEMO -> HOST_RELEASE
|
||||
DebugConfig.NET_MODE_RELEASE -> HOST_RELEASE
|
||||
else -> HOST_RELEASE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user