[8.2.0]OTA升级查询

This commit is contained in:
xuxinchao
2025-08-06 17:17:11 +08:00
parent a5fbd94d11
commit 0ad3339b04
5 changed files with 49 additions and 202 deletions

View File

@@ -48,6 +48,9 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
private var versionTwoTimeoutNum: Int = 0 //OTA2.0版本响应超时次数
private var shouldToast: Boolean = false //OTA1.0升级是否需要提示没有升级任务
private var secondVersionShouldToast: Boolean = true //OTA2.0升级是否需要提示没有任务升级
private val handler =object : Handler(Looper.getMainLooper()){
override fun handleMessage(msg: Message) {
super.handleMessage(msg)
@@ -80,7 +83,7 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
val query = JSONObject()
query.put("cmd","PAD_QUERY_UPGRADE_STATUS")
query.put("token",OTAUpgradeConfig.token)
Log.i("xuxinchao",query.toString())
Log.i(TAG,query.toString())
CallerAutoPilotControlManager.sendOtaPadMsgQuery(query.toString())
this.sendEmptyMessageDelayed(3,30000)
}else{
@@ -88,6 +91,10 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
CallerHmiManager.showOTADownloadStatusDialog(false, emptyList())
CallerHmiManager.showOTAResultDialog(isShow = true, result = false)
}
}else if(msg.what == 4){
if(shouldToast && secondVersionShouldToast){
ToastUtils.showLong("暂无待升级任务!")
}
}
}
}
@@ -279,7 +286,8 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
//解析JSON
if(status.otaInfo.productName.isEmpty()){
if(OTAUpgradeConfig.isQuery){
ToastUtils.showLong("暂无待升级任务!")
// ToastUtils.showLong("暂无待升级任务!")
shouldToast = true
OTAUpgradeConfig.isQuery = false
}else{
//没有升级任务,取消查询,关掉弹窗
@@ -481,6 +489,7 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
//请求升级
if(cmd == "ASK_PAD_UPGRADE" && otaStatus == "init"){
secondVersionShouldToast = false //收到请求升级,故不需要进行提示
//冷启动已完成(包括成功/失败),且驾驶状态为非自驾状态,且当前无订单进行强提示,否则为弱提示
if(OTAUpgradeConfig.coldStartCompleted && !OTAUpgradeConfig.autopilotStatus
&& !OTAUpgradeConfig.inOrder){
@@ -503,7 +512,7 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
query.put("token",OTAUpgradeConfig.token)
query.put("allow_upgrade",false)
query.put("reason",reason)
Log.i("xuxinchao",query.toString())
Log.i(TAG,query.toString())
CallerAutoPilotControlManager.sendOtaPadMsgQuery(query.toString())
ToastUtils.showLong("收到车辆部署任务,请在车辆空闲时发起升级")
@@ -540,6 +549,13 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
}
override fun sendOtaPadMsgQuery() {
super.sendOtaPadMsgQuery()
shouldToast = false
secondVersionShouldToast = true
handler.sendEmptyMessageDelayed(4,3000)
}
private val pattern = Pattern.compile("\\d+\\.\\d+\\.\\d+")

View File

@@ -22,6 +22,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84Lis
import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizListener
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.function.call.devatools.CallerOTAManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiListenerManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
@@ -154,23 +155,21 @@ class CarInfoTabView @JvmOverloads constructor(
"${SceneConstant.M_HMI}${TAG}",
"ad version view clicked"
)
// if(OTAUpgradeConfig.supportOTA){
// //查询OTA状态
// OTAUpgradeConfig.isQuery = true
// OTAUpgradeConfig.promptedUpgrade.remove(OTAUpgradeConfig.otaToken)
// CallerAutoPilotControlManager.sendSsmFuncOtaStatusQuery(OTAUpgradeConfig.otaToken)
// }else{
// ToastUtils.showLong("当前SSM节点未成功启动或当前版本不支持OTA升级")
// }
//查询OTA升级
val query = JSONObject()
query.put("cmd","PAD_QUERY_UPGRADE_STATUS")
query.put("token",OTAUpgradeConfig.token)
Log.i("xuxinchao",query.toString())
CallerAutoPilotControlManager.sendOtaPadMsgQuery(query.toString())
if(OTAUpgradeConfig.supportOTA){
//查询OTA状态
OTAUpgradeConfig.isQuery = true
OTAUpgradeConfig.promptedUpgrade.remove(OTAUpgradeConfig.otaToken)
CallerAutoPilotControlManager.sendSsmFuncOtaStatusQuery(OTAUpgradeConfig.otaToken)
//查询OTA2.0升级
val query = JSONObject()
query.put("cmd","PAD_QUERY_UPGRADE_STATUS")
query.put("token",OTAUpgradeConfig.token)
CallerAutoPilotControlManager.sendOtaPadMsgQuery(query.toString())
CallerOTAManager.invokeOtaPadMsgQuery()
}else{
ToastUtils.showLong("当前SSM节点未成功启动或当前版本不支持OTA升级")
}
}
tvHDMapVersion.text = tvHDMapVersion.text.toString() + DebugConfig.getMapVersion()

View File

@@ -1,183 +0,0 @@
package com.mogo.eagle.core.function.hmi.ui.setting;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
public class ScreenUtilsTest {
/**
* 获取当前屏幕截图,包含状态栏
*
* @param activity activity
* @return Bitmap
*/
public static Bitmap captureWithStatusBar(Activity activity) {
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bmp = view.getDrawingCache();
int width = getScreenWidth(activity);
int height = getScreenHeight(activity);
Bitmap ret = Bitmap.createBitmap(bmp, 0, 0, width, height);
view.destroyDrawingCache();
return ret;
}
/**
* 获取当前屏幕截图,不包含状态栏
*
* @param activity activity
* @return Bitmap
*/
public static Bitmap captureWithoutStatusBar(Activity activity) {
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bmp = view.getDrawingCache();
int statusBarHeight = getStatusBarHeight(activity);
int width = getScreenWidth(activity);
int height = getScreenHeight(activity);
Bitmap ret = Bitmap.createBitmap(bmp, 0, statusBarHeight, width, height - statusBarHeight);
view.destroyDrawingCache();
return ret;
}
/**
* 得到屏幕的高
*
* @param context
* @return
*/
public static int getScreenHeight(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
int height = wm.getDefaultDisplay().getHeight();
return height;
}
/**
* 得到屏幕的宽
*
* @param context
* @return
*/
public static int getScreenWidth(Context context) {
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
int width = wm.getDefaultDisplay().getWidth();
return width;
}
/**
* 获取状态栏高度
*
* @param context 上下文
* @return 状态栏高度
*/
public static int getStatusBarHeight(Context context) {
int result = 0;
int resourceId = context.getResources()
.getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = context.getResources().getDimensionPixelSize(resourceId);
}
return result;
}
public static Bitmap mergeBitmaps(Bitmap background, Bitmap foreground) {
// 创建一个新的Bitmap大小为两个Bitmap的最大宽度和最大高度
int width = Math.max(background.getWidth(), foreground.getWidth());
int height = Math.max(background.getHeight(), foreground.getHeight());
Bitmap mergedBitmap = Bitmap.createBitmap(width, height, background.getConfig());
Canvas canvas = new Canvas(mergedBitmap);
// 绘制背景图
canvas.drawBitmap(background, 0, 0, null);
// 绘制前景图,可以调整位置
canvas.drawBitmap(foreground, 0, 0, null); // 根据需要调整位置
return mergedBitmap;
}
public static Bitmap overlayBitmaps(Bitmap bitmap1, Bitmap bitmap2, int xOffset, int yOffset) {
// 创建一个新的Bitmap其大小足以容纳两个重叠的bitmap
int width = Math.max(bitmap1.getWidth(), bitmap2.getWidth());
int height = bitmap1.getHeight() + bitmap2.getHeight(); // 假定重叠在垂直方向
Bitmap result = Bitmap.createBitmap(width, height, bitmap1.getConfig());
// 使用Canvas绘制bitmap1和bitmap2
Canvas canvas = new Canvas(result);
canvas.drawBitmap(bitmap1, 0, 0, null); // 首先绘制bitmap1
canvas.drawBitmap(bitmap2, xOffset, bitmap1.getHeight() + yOffset, null); // 然后绘制bitmap2根据需要调整xOffset和yOffset
return result;
}
/**
* 将2张图片合成
* @param downBitmap 底部图片
* @param upBitmap 置顶的图片
* @return
*/
public static Bitmap compoundBitmap(Bitmap downBitmap,Bitmap upBitmap)
{
Bitmap mBitmap = downBitmap.copy(Bitmap.Config.ARGB_8888, true);
//如果遇到黑色则显示downBitmap里面的颜色值如果不是则显示upBitmap里面的颜色值
//循环获得bitmap所有像素点
int mBitmapWidth = mBitmap.getWidth();
int mBitmapHeight = mBitmap.getHeight();
//首先保证downBitmap和 upBitmap是一致的高宽大小
Log.i("xuxinchao","mBitmapWidth="+mBitmapWidth);
Log.i("xuxinchao","mBitmapHeight="+mBitmapHeight);
Log.i("xuxinchao","upBitmap.getWidth()="+upBitmap.getWidth());
Log.i("xuxinchao","upBitmap.getHeight()="+upBitmap.getHeight());
// if(mBitmapWidth==upBitmap.getWidth() && mBitmapHeight==upBitmap.getHeight())
// {
// for (int i = 0; i < mBitmapHeight; i++) {
// for (int j = 0; j < mBitmapWidth; j++) {
// //获得Bitmap 图片中每一个点的color颜色值
// //将需要填充的颜色值如果不是
// //在这说明一下 如果color 是全透明 或者全黑 返回值为 0
// //getPixel()不带透明通道 getPixel32()才带透明部分 所以全透明是0x00000000
// //而不透明黑色是0xFF000000 如果不计算透明部分就都是0了
// int color = upBitmap.getPixel(j, i);
// Log.i("xuxinchao","color="+color);
// //将颜色值存在一个数组中 方便后面修改
// if (color != Color.BLACK) {
// mBitmap.setPixel(j, i, upBitmap.getPixel(j, i)); //将白色替换成透明色
// }
// }
// }
// }
for (int i = 0; i < mBitmapHeight; i++) {
for (int j = 0; j < mBitmapWidth; j++) {
//获得Bitmap 图片中每一个点的color颜色值
//将需要填充的颜色值如果不是
//在这说明一下 如果color 是全透明 或者全黑 返回值为 0
//getPixel()不带透明通道 getPixel32()才带透明部分 所以全透明是0x00000000
//而不透明黑色是0xFF000000 如果不计算透明部分就都是0了
int color = upBitmap.getPixel(j, i);
Log.i("xuxinchao","color="+color);
//将颜色值存在一个数组中 方便后面修改
if (color != Color.BLACK) {
mBitmap.setPixel(j, i, upBitmap.getPixel(j, i)); //将白色替换成透明色
}
}
}
// downBitmap.recycle();
// upBitmap.recycle();
return mBitmap;
}
}

View File

@@ -42,4 +42,9 @@ interface IOTAListener {
*/
fun onOtaPureStr(token: Long,timestamp: Long,status: SsmInfo.PureStr){}
/**
* OTA 2.0任务查询
*/
fun sendOtaPadMsgQuery(){}
}

View File

@@ -69,4 +69,14 @@ object CallerOTAManager: CallerBase<IOTAListener>() {
}
}
/**
* OTA 2.0任务查询
*/
fun invokeOtaPadMsgQuery(){
M_LISTENERS.forEach {
val listener = it.value
listener.sendOtaPadMsgQuery()
}
}
}