[6.9.0]录包截图修改

This commit is contained in:
xuxinchao
2024-12-02 19:44:05 +08:00
parent 806cb9a5be
commit ac756f3b66
3 changed files with 124 additions and 120 deletions

View File

@@ -5,6 +5,7 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Environment
import android.os.SystemClock
import android.util.Log
@@ -42,6 +43,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisStatesListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoTakeoverListener
import com.mogo.eagle.core.function.api.datacenter.IDataCenterBizListener
import com.mogo.eagle.core.function.api.datacenter.msgbox.IMsgBoxListener
import com.mogo.eagle.core.function.api.devatools.ICaptureImgListener
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
import com.mogo.eagle.core.function.api.map.deva.IMoGoMapScreenListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
@@ -52,6 +54,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84Lis
import com.mogo.eagle.core.function.call.autopilot.CallerChassisStatesListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerTakeoverListenerManager
import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizListener
import com.mogo.eagle.core.function.call.devatools.CallerCaptureImgManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapScreenListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
@@ -72,6 +75,7 @@ import com.zhjt.mogo_core_function_devatools.badcase.util.RecordBitmapUtils
import com.zhjt.mogo_core_function_devatools.ext.enqueuePop
import com.zhjt.mogo_core_function_devatools.workorder.ReportTypeWindow
import me.jessyan.autosize.utils.AutoSizeUtils
import mogo.telematics.pad.MessagePad
import record_cache.RecordPanelOuterClass
import java.io.File
import java.util.Random
@@ -81,7 +85,7 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
IMoGoChassisLocationGCJ02Listener, IMsgBoxListener, IMoGoDevaToolsListener,
IMogoStatusChangedListener, IMoGoMapScreenListener,
IMoGoChassisStatesListener, IMoGoAutopilotStatusListener,
IDataCenterBizListener, IMoGoTakeoverListener {
IDataCenterBizListener, IMoGoTakeoverListener, ICaptureImgListener {
const val TAG = "BadCase"
@@ -91,6 +95,7 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
private var record: AutoPilotRecord? = null
private var recordKey: Long = 0 //主动录制bag包key
private var takeOverBagId: Long = 0 //接管录包Bag Id(key)
@SuppressLint("StaticFieldLeak")
private var reportTypeWindow: ReportTypeWindow ?= null
@@ -116,6 +121,8 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
//消息盒子监听获取FM和Report信息
CallerMsgBoxListenerManager.addListener(TAG,this)
CallerDevaToolsListenerManager.addListener(TAG, this)
//接管时前方和后方摄像头数据请求响应回调监听
CallerCaptureImgManager.addListener(TAG, this)
// 云socket连接状态
MogoStatusManager.getInstance()
.registerStatusChangedListener(TAG, StatusDescriptor.CLOUD_SOCKET, this)
@@ -297,8 +304,6 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
}else{
//进行录包,但不展示录包弹窗
BadCaseConfig.notDisplayBagWindow = true
//高精地图屏幕截图
CallerMapScreenListenerManager.addListener(TAG,this)
val recordKey = Random(SystemClock.elapsedRealtime()).nextInt().toLong()
CallerAutoPilotControlManager.recordPackage(BadCaseConfig.type,recordKey.toInt(),
BadCaseConfig.totalDuration, BadCaseConfig.previousDuration)
@@ -416,8 +421,6 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
//保存录包状态
recordSet.add(recordPanel.key.toString())
BadCaseConfig.setInitiativeRecordSet(recordSet)
//开启高精地图截图
CallerMapUIServiceManager.getMapUIController()?.getMapScreenShot()
//将当次主动录包设置标签还原
BadCaseConfig.notDisplayBagWindow = false
}
@@ -457,6 +460,13 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
val latLon = LatLonPoint(CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().latitude, CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().longitude)
val q = RegeocodeQuery(latLon,200f,GeocodeSearch.AMAP)
geocodeSearch.getFromLocationAsyn(q)
takeOverBagId = recordPanel.key
//触发域控前后120度摄像头截图和高精地图截图
CallerAutoPilotControlManager.sendCaptureImgReqOnTakeOver(recordPanel.key)
//高精地图屏幕截图
CallerMapScreenListenerManager.addListener(TAG,this)
//开启高精地图截图
CallerMapUIServiceManager.getMapUIController()?.getMapScreenShot()
}
}
}
@@ -578,42 +588,16 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
override fun onMapScreen(bitmap: Bitmap) {
super.onMapScreen(bitmap)
//在截图上保存即时信息
val time = "时间:${millis2String(System.currentTimeMillis(), TimeUtils.getHourMinSecondFormat())}"
val lineId = "路线ID:${CallerAutoPilotStatusListenerManager.getLineId()}"
val state = when(CallerAutoPilotStatusListenerManager.getState()){
0->"自驾状态:不可自驾"
1->"自驾状态:可自驾"
2->"自驾状态:自驾中"
7->"自驾状态:平行驾驶中"
else->"自驾状态:未知"
}
val speed = "当前车速:${BadCaseConfig.currentSpeed}"
val site = if(CallerAutoPilotStatusListenerManager.getLineStartName().isNullOrEmpty() || CallerAutoPilotStatusListenerManager.getLineEndName().isNullOrEmpty()){
"路线起始点:无"
}else{
"路线起点:${CallerAutoPilotStatusListenerManager.getLineStartName()};终点:${CallerAutoPilotStatusListenerManager.getLineEndName()}"
}
val outBitmap = RecordBitmapUtils.drawTextOnBitmap(bitmap,time,lineId,state,speed,site,
BadCaseConfig.gpsStatus,BadCaseConfig.tracingStatus,BadCaseConfig.socketStatus
,BadCaseConfig.newFMInfoMsg,BadCaseConfig.newReportEntity)
//图片保存本地
val currentDay = millis2String(System.currentTimeMillis(), TimeUtils.getMdFormat())
val fileDir: String = Environment.getExternalStorageDirectory().absolutePath + File.separator+
"MapScreen" + File.separator+ currentDay + File.separator
val fileName = "$recordKey.png"
val fileName = "$takeOverBagId.png"
val path = fileDir + fileName
if (!File(fileDir).exists()) {
File(fileDir).mkdirs()
}
if(outBitmap != null){
RecordBitmapUtils.bitmap2Path(outBitmap,path)
}else{
RecordBitmapUtils.bitmap2Path(bitmap,path)
}
//遍历是否有非当日的文件并删除
RecordBitmapUtils.deleteExpiredFile(currentDay)
RecordBitmapUtils.bitmap2Path(bitmap,path)
//注销高精地图截图监听回调
CallerMapScreenListenerManager.removeListener(TAG)
}
@@ -648,4 +632,30 @@ internal object BadCaseManager : LifecycleEventObserver, IMoGoAutopilotRecordLis
}
/**
* 接管时前方和后方摄像头数据请求的响应
* @param isFront true前方摄像头 false后方摄像头
* @param data 数据
*/
override fun onCaptureImgOnTakeOver(isFront: Boolean, data: MessagePad.CaptureImgOnTakeOver) {
super.onCaptureImgOnTakeOver(isFront, data)
//将byte字节流转为Bitmap
val bitmap = BitmapFactory.decodeByteArray(data.data.toByteArray(),0,data.toByteArray().size)
//图片保存本地
val currentDay = millis2String(System.currentTimeMillis(), TimeUtils.getMdFormat())
val imageName = if(isFront){
"FrontCamera"
}else{
"RearCamera"
}
val fileDir: String = Environment.getExternalStorageDirectory().absolutePath + File.separator+
imageName + File.separator+ currentDay + File.separator
val fileName = "$takeOverBagId.png"
val path = fileDir + fileName
if (!File(fileDir).exists()) {
File(fileDir).mkdirs()
}
RecordBitmapUtils.bitmap2Path(bitmap,path)
}
}

View File

@@ -6,7 +6,6 @@ import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.PixelFormat
import android.os.Bundle
import android.os.Environment
import android.os.Handler
import android.os.SystemClock
import android.util.DisplayMetrics
@@ -36,12 +35,9 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener
import com.mogo.eagle.core.function.api.devatools.badcase.BadCaseNetListener
import com.mogo.eagle.core.function.api.map.deva.IMoGoMapScreenListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsNetManager
import com.mogo.eagle.core.function.call.map.CallerMapScreenListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
@@ -75,7 +71,6 @@ import record_cache.RecordPanelOuterClass
import java.io.File
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.absoluteValue
/**
@@ -198,7 +193,7 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
BadCaseNetManager.badCaseNetManager.getRecordOption(1,AppConfigInfo.iPCMacAddress)
// BadCaseNetManager.badCaseNetManager.getRecordOption(1,"48:b0:2d:3a:9c:8f")
//高精地图屏幕截图
CallerMapScreenListenerManager.addListener(this.hashCode().toString(),this)
// CallerMapScreenListenerManager.addListener(this.hashCode().toString(),this)
//采集结果回调监听
CallerAutopilotRecordListenerManager.addListener(this.hashCode().toString(),this)
//主动录包采集原因回调监听
@@ -561,7 +556,7 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
//注销采集原因回调监听
CallerDevaToolsNetManager.removeListener(this.hashCode().toString())
//注销高精地图截图监听回调
CallerMapScreenListenerManager.removeListener(this.hashCode().toString())
// CallerMapScreenListenerManager.removeListener(this.hashCode().toString())
if (mFloatLayout.parent != null){
mWindowManager!!.removeView(mFloatLayout)
@@ -580,8 +575,8 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
//保存录包状态
recordSet.add(recordPanel.key.toString())
BadCaseConfig.setInitiativeRecordSet(recordSet)
//开启高精地图截图
CallerMapUIServiceManager.getMapUIController()?.getMapScreenShot()
// //开启高精地图截图
// CallerMapUIServiceManager.getMapUIController()?.getMapScreenShot()
}
if(recordFileName==null){
recordFileName = recordPanel.filename
@@ -702,44 +697,44 @@ class InitiativeBadCaseWindow constructor(activity: Activity) : View.OnTouchList
* 高精地图截图回调
*/
override fun onMapScreen(bitmap: Bitmap) {
//在截图上保存即时信息
val time = "时间:${millis2String(System.currentTimeMillis(), TimeUtils.getHourMinSecondFormat())}"
val lineId = "路线ID:${CallerAutoPilotStatusListenerManager.getLineId()}"
val state = when(CallerAutoPilotStatusListenerManager.getState()){
0->"自驾状态:不可自驾"
1->"自驾状态:可自驾"
2->"自驾状态:自驾中"
7->"自驾状态:平行驾驶中"
else->"自驾状态:未知"
}
val speed = "当前车速:${BadCaseConfig.currentSpeed}"
val site = if(CallerAutoPilotStatusListenerManager.getLineStartName().isNullOrEmpty() || CallerAutoPilotStatusListenerManager.getLineEndName().isNullOrEmpty()){
"路线起始点:无"
}else{
"路线起点:${CallerAutoPilotStatusListenerManager.getLineStartName()};终点:${CallerAutoPilotStatusListenerManager.getLineEndName()}"
}
val outBitmap = RecordBitmapUtils.drawTextOnBitmap(bitmap,time,lineId,state,speed,site,
BadCaseConfig.gpsStatus,BadCaseConfig.tracingStatus,BadCaseConfig.socketStatus
,BadCaseConfig.newFMInfoMsg,BadCaseConfig.newReportEntity)
//图片保存本地
val currentDay = millis2String(System.currentTimeMillis(), TimeUtils.getMdFormat())
val fileDir: String = Environment.getExternalStorageDirectory().absolutePath + File.separator+
"MapScreen" + File.separator+ currentDay + File.separator
val fileName = "$recordKey.png"
val path = fileDir + fileName
if (!File(fileDir).exists()) {
File(fileDir).mkdirs()
}
if(outBitmap != null){
RecordBitmapUtils.bitmap2Path(outBitmap,path)
}else{
RecordBitmapUtils.bitmap2Path(bitmap,path)
}
screenSavePath = path
//遍历是否有非当日的文件并删除
RecordBitmapUtils.deleteExpiredFile(currentDay)
// //在截图上保存即时信息
// val time = "时间:${millis2String(System.currentTimeMillis(), TimeUtils.getHourMinSecondFormat())}"
// val lineId = "路线ID:${CallerAutoPilotStatusListenerManager.getLineId()}"
// val state = when(CallerAutoPilotStatusListenerManager.getState()){
// 0->"自驾状态:不可自驾"
// 1->"自驾状态:可自驾"
// 2->"自驾状态:自驾中"
// 7->"自驾状态:平行驾驶中"
// else->"自驾状态:未知"
// }
// val speed = "当前车速:${BadCaseConfig.currentSpeed}"
// val site = if(CallerAutoPilotStatusListenerManager.getLineStartName().isNullOrEmpty() || CallerAutoPilotStatusListenerManager.getLineEndName().isNullOrEmpty()){
// "路线起始点:无"
// }else{
// "路线起点:${CallerAutoPilotStatusListenerManager.getLineStartName()};终点:${CallerAutoPilotStatusListenerManager.getLineEndName()}"
// }
//
// val outBitmap = RecordBitmapUtils.drawTextOnBitmap(bitmap,time,lineId,state,speed,site,
// BadCaseConfig.gpsStatus,BadCaseConfig.tracingStatus,BadCaseConfig.socketStatus
// ,BadCaseConfig.newFMInfoMsg,BadCaseConfig.newReportEntity)
//
// //图片保存本地
// val currentDay = millis2String(System.currentTimeMillis(), TimeUtils.getMdFormat())
// val fileDir: String = Environment.getExternalStorageDirectory().absolutePath + File.separator+
// "MapScreen" + File.separator+ currentDay + File.separator
// val fileName = "$recordKey.png"
// val path = fileDir + fileName
// if (!File(fileDir).exists()) {
// File(fileDir).mkdirs()
// }
// if(outBitmap != null){
// RecordBitmapUtils.bitmap2Path(outBitmap,path)
// }else{
// RecordBitmapUtils.bitmap2Path(bitmap,path)
// }
// screenSavePath = path
// //遍历是否有非当日的文件并删除
// RecordBitmapUtils.deleteExpiredFile(currentDay)
}
}

View File

@@ -37,7 +37,6 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsNetManager
import com.mogo.eagle.core.function.call.map.CallerMapScreenListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
@@ -180,7 +179,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene
BadCaseNetManager.badCaseNetManager.getRecordOption(2,AppConfigInfo.iPCMacAddress)
// BadCaseNetManager.badCaseNetManager.getRecordOption(2,"48:b0:2d:3a:9c:8f")
//高精地图屏幕截图
CallerMapScreenListenerManager.addListener(this.hashCode().toString(),this)
// CallerMapScreenListenerManager.addListener(this.hashCode().toString(),this)
CallerDevaToolsNetManager.addListener(this.hashCode().toString(),this)
if(BadCaseConfig.windowNum<1){
BadCaseConfig.windowNum = 1
@@ -530,7 +529,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene
fun hideFloatWindow() {
//注销高精地图截图监听回调
CallerMapScreenListenerManager.removeListener(this.hashCode().toString())
// CallerMapScreenListenerManager.removeListener(this.hashCode().toString())
//注销采集原因回调监听
CallerDevaToolsNetManager.removeListener(this.hashCode().toString())
// 移除 ADAS车辆状态&定位 监听
@@ -552,7 +551,7 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene
receiveTime = msgBoxBean.timestamp.toString()
stat = recordBagMsg.stat.toString()
//获取高精地图截图
CallerMapUIServiceManager.getMapUIController()?.getMapScreenShot()
// CallerMapUIServiceManager.getMapUIController()?.getMapScreenShot()
}
fun setClickListener(clickListener: ClickListener) {
@@ -589,42 +588,42 @@ class PassiveBadCaseWindow constructor(activity: Activity) : View.OnTouchListene
*/
override fun onMapScreen(bitmap: Bitmap) {
//在截图上保存即时信息
val time = "时间:${millis2String(System.currentTimeMillis(), TimeUtils.getHourMinSecondFormat())}"
val lineId = "路线ID:${CallerAutoPilotStatusListenerManager.getLineId()}"
val state = when(CallerAutoPilotStatusListenerManager.getState()){
0->"自驾状态:不可自驾"
1->"自驾状态:可自驾"
2->"自驾状态:自驾中"
7->"自驾状态:平行驾驶中"
else->"自驾状态:未知"
}
val speed = "当前车速:${BadCaseConfig.currentSpeed}"
val site = if(CallerAutoPilotStatusListenerManager.getLineStartName().isNullOrEmpty() || CallerAutoPilotStatusListenerManager.getLineEndName().isNullOrEmpty()){
"路线起始点:无"
}else{
"路线起点:${CallerAutoPilotStatusListenerManager.getLineStartName()};终点:${CallerAutoPilotStatusListenerManager.getLineEndName()}"
}
val outBitmap = RecordBitmapUtils.drawTextOnBitmap(bitmap,time,lineId,state,speed,site,
BadCaseConfig.gpsStatus,BadCaseConfig.tracingStatus,BadCaseConfig.socketStatus
,BadCaseConfig.newFMInfoMsg,BadCaseConfig.newReportEntity)
//图片保存本地
val currentDay = millis2String(System.currentTimeMillis(), TimeUtils.getMdFormat())
val fileDir: String = Environment.getExternalStorageDirectory().absolutePath + File.separator+
"MapScreen" + File.separator+ currentDay + File.separator
val fileName = "$recordKey.png"
val path = fileDir + fileName
if (!File(fileDir).exists()) {
File(fileDir).mkdirs()
}
if(outBitmap != null){
RecordBitmapUtils.bitmap2Path(outBitmap,path)
}else{
RecordBitmapUtils.bitmap2Path(bitmap,path)
}
screenSavePath = path
//遍历是否有非当日的文件并删除
RecordBitmapUtils.deleteExpiredFile(currentDay)
// val time = "时间:${millis2String(System.currentTimeMillis(), TimeUtils.getHourMinSecondFormat())}"
// val lineId = "路线ID:${CallerAutoPilotStatusListenerManager.getLineId()}"
// val state = when(CallerAutoPilotStatusListenerManager.getState()){
// 0->"自驾状态:不可自驾"
// 1->"自驾状态:可自驾"
// 2->"自驾状态:自驾中"
// 7->"自驾状态:平行驾驶中"
// else->"自驾状态:未知"
// }
// val speed = "当前车速:${BadCaseConfig.currentSpeed}"
// val site = if(CallerAutoPilotStatusListenerManager.getLineStartName().isNullOrEmpty() || CallerAutoPilotStatusListenerManager.getLineEndName().isNullOrEmpty()){
// "路线起始点:无"
// }else{
// "路线起点:${CallerAutoPilotStatusListenerManager.getLineStartName()};终点:${CallerAutoPilotStatusListenerManager.getLineEndName()}"
// }
//
// val outBitmap = RecordBitmapUtils.drawTextOnBitmap(bitmap,time,lineId,state,speed,site,
// BadCaseConfig.gpsStatus,BadCaseConfig.tracingStatus,BadCaseConfig.socketStatus
// ,BadCaseConfig.newFMInfoMsg,BadCaseConfig.newReportEntity)
// //图片保存本地
// val currentDay = millis2String(System.currentTimeMillis(), TimeUtils.getMdFormat())
// val fileDir: String = Environment.getExternalStorageDirectory().absolutePath + File.separator+
// "MapScreen" + File.separator+ currentDay + File.separator
// val fileName = "$recordKey.png"
// val path = fileDir + fileName
// if (!File(fileDir).exists()) {
// File(fileDir).mkdirs()
// }
// if(outBitmap != null){
// RecordBitmapUtils.bitmap2Path(outBitmap,path)
// }else{
// RecordBitmapUtils.bitmap2Path(bitmap,path)
// }
// screenSavePath = path
// //遍历是否有非当日的文件并删除
// RecordBitmapUtils.deleteExpiredFile(currentDay)
}
/**