[new_ota]测试截图

This commit is contained in:
xuxinchao
2025-07-03 17:53:17 +08:00
parent 6d05e427ee
commit cde3c4e74a
4 changed files with 259 additions and 54 deletions

View File

@@ -6,8 +6,10 @@ import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Environment.*
import android.os.Process
@@ -27,6 +29,9 @@ import androidx.core.content.ContextCompat
import androidx.core.view.MenuCompat
import androidx.lifecycle.lifecycleScope
import chassis.Chassis
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.Target
import com.mogo.cloud.network.cronet.NetworkQualityListener
import com.mogo.cloud.network.cronet.QuicConfig
import com.mogo.cloud.passport.MoGoAiCloudClient
@@ -73,6 +78,7 @@ import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener.Companion.FUNC_FUSION_COLOR
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener.Companion.FUNC_MODE_DEMO
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener.Companion.FUNC_MODE_RAIN
import com.mogo.eagle.core.function.api.map.deva.IMoGoMapScreenListener
import com.mogo.eagle.core.function.api.setting.ISopSettingListener
import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
@@ -90,6 +96,7 @@ import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManage
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager
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.map.CallerVisualAngleManager
import com.mogo.eagle.core.function.call.obu.CallerObuApiManager
@@ -115,6 +122,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.mogo.permissions.BackgrounderPermission
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast
import com.mogo.eagle.core.utilcode.util.ActivityUtils
import com.mogo.eagle.core.utilcode.util.AppStateManager
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.BarUtils
import com.mogo.eagle.core.utilcode.util.CommonUtils
@@ -140,23 +148,17 @@ import com.mogo.support.device.DevicesManager
import com.mogo.support.device.IBindStateChangeListener
import com.mogo.tts.base.IMogoTTSCallback
import com.zhjt.mogo.adas.data.AdasConstants
import com.zhjt.mogo_core_function_devatools.rviz.common.config.SSHAccountConfig
import com.zhjt.mogo_core_function_devatools.rviz.dialog.ChangeDefaultConfigDialog
import com.zhjt.mogo_core_function_devatools.rviz.ui.activity.AutopilotCheckAct
import com.zhjt.mogo_core_function_devatools.rviz.ui.activity.FmdAct
import com.zhjt.service.chain.ChainLog
import kotlinx.android.synthetic.main.view_debug_setting.view.appVersionInfoLayout
import kotlinx.android.synthetic.main.view_debug_setting.view.brakeThresholdDivider
import kotlinx.android.synthetic.main.view_debug_setting.view.btChangeEnv
import kotlinx.android.synthetic.main.view_debug_setting.view.btnAppReboot
import kotlinx.android.synthetic.main.view_debug_setting.view.btnAutoCheck
import kotlinx.android.synthetic.main.view_debug_setting.view.btnBrakeThreshold
import kotlinx.android.synthetic.main.view_debug_setting.view.btnConnectServerIp
import kotlinx.android.synthetic.main.view_debug_setting.view.btnDeleteDB
import kotlinx.android.synthetic.main.view_debug_setting.view.btnDisconnectIpc
import kotlinx.android.synthetic.main.view_debug_setting.view.btnDrawFusion
import kotlinx.android.synthetic.main.view_debug_setting.view.btnEnsureMap
import kotlinx.android.synthetic.main.view_debug_setting.view.btnFmd
import kotlinx.android.synthetic.main.view_debug_setting.view.btnHdVisualAdjust
import kotlinx.android.synthetic.main.view_debug_setting.view.btnIpcReboot
import kotlinx.android.synthetic.main.view_debug_setting.view.btnPointCloudColor
@@ -195,7 +197,6 @@ import kotlinx.android.synthetic.main.view_debug_setting.view.changesight_top_bt
import kotlinx.android.synthetic.main.view_debug_setting.view.clDebugContain
import kotlinx.android.synthetic.main.view_debug_setting.view.commonLayout
import kotlinx.android.synthetic.main.view_debug_setting.view.controlCenterLayout
import kotlinx.android.synthetic.main.view_debug_setting.view.debugCenterLayout
import kotlinx.android.synthetic.main.view_debug_setting.view.deviceBindLayout
import kotlinx.android.synthetic.main.view_debug_setting.view.domainControllerLayout
import kotlinx.android.synthetic.main.view_debug_setting.view.eagleEyeControllerLayout
@@ -214,6 +215,9 @@ import kotlinx.android.synthetic.main.view_debug_setting.view.etThreshold
import kotlinx.android.synthetic.main.view_debug_setting.view.exportAllLogs
import kotlinx.android.synthetic.main.view_debug_setting.view.hdMapControllerLayout
import kotlinx.android.synthetic.main.view_debug_setting.view.hmiControllerLayout
import kotlinx.android.synthetic.main.view_debug_setting.view.ivScreenTest
import kotlinx.android.synthetic.main.view_debug_setting.view.ivScreenTestThree
import kotlinx.android.synthetic.main.view_debug_setting.view.ivScreenTestTwo
import kotlinx.android.synthetic.main.view_debug_setting.view.logLoadingView
import kotlinx.android.synthetic.main.view_debug_setting.view.logcatCenterLayout
import kotlinx.android.synthetic.main.view_debug_setting.view.obuConnectStatusTv
@@ -234,7 +238,6 @@ import kotlinx.android.synthetic.main.view_debug_setting.view.tbChangeCurrentSki
import kotlinx.android.synthetic.main.view_debug_setting.view.tbControlCenter
import kotlinx.android.synthetic.main.view_debug_setting.view.tbControlPassengerDriverMonitor
import kotlinx.android.synthetic.main.view_debug_setting.view.tbCronet
import kotlinx.android.synthetic.main.view_debug_setting.view.tbDebugCenter
import kotlinx.android.synthetic.main.view_debug_setting.view.tbDeviceBind
import kotlinx.android.synthetic.main.view_debug_setting.view.tbDomainController
import kotlinx.android.synthetic.main.view_debug_setting.view.tbDrawPointCloudData
@@ -373,7 +376,7 @@ internal class DebugSettingView @JvmOverloads constructor(
IMoGoSweeperFutianCleanSystemListener,
IMoGoObuInfoListener,
ISopSettingListener, IViewControlListener, IMoGoCloudListener, IBindStateChangeListener,
IReceivedMsgListener {
IReceivedMsgListener , IMoGoMapScreenListener {
companion object {
private const val TAG = "DebugSettingView"
@@ -608,10 +611,6 @@ internal class DebugSettingView @JvmOverloads constructor(
}
}
//动态配置鹰眼显示MAP版本
if(AppConfigInfo.mapShowName.isEmpty()){
AppConfigInfo.mapShowName = CallerAutoPilotStatusListenerManager.getDockerVersion()+""
SPUtils.getInstance().put("mapShowName", AppConfigInfo.mapShowName)
}
etMapShowName.setText(AppConfigInfo.mapShowName)
etMapShowName.text?.let { etMapShowName.setSelection(it.length) }
btnEnsureMap.setOnClickListener {
@@ -635,6 +634,13 @@ internal class DebugSettingView @JvmOverloads constructor(
//隐藏状态中心
statusCenterLayout.visibility = View.GONE
}
//高精地图屏幕截图
CallerMapScreenListenerManager.addListener(TAG,this)
//开启高精地图截图
CallerMapUIServiceManager.getMapUIController()?.getMapScreenShot()
}
/**
@@ -812,41 +818,6 @@ internal class DebugSettingView @JvmOverloads constructor(
}
}
/**
* 调试中心
*/
tbDebugCenter.setOnCheckedChangeListener { buttonView, isChecked ->
if (isChecked) {
buttonView.setCompoundDrawables(null, null, iconDown, null)
//展示调试中心
debugCenterLayout.visibility = View.VISIBLE
} else {
buttonView.setCompoundDrawables(null, null, iconRight, null)
//隐藏日志中心
debugCenterLayout.visibility = View.GONE
}
}
/**
* 故障诊断
*/
btnFmd.onClick{
ActivityUtils.startActivity(FmdAct::class.java)
}
/**
* 故障诊断 长按设置
*/
btnFmd.setOnLongClickListener {
ChangeDefaultConfigDialog(ActivityUtils.getTopActivity()).show()
true
}
/**
* 自动驾驶检测
*/
btnAutoCheck.onClick {
ActivityUtils.startActivity(AutopilotCheckAct::class.java)
}
/**
* 日志中心
*/
@@ -1422,6 +1393,45 @@ internal class DebugSettingView @JvmOverloads constructor(
}
}
override fun onMapScreen(bitmap: Bitmap) {
super.onMapScreen(bitmap)
// //图片保存本地
// val currentDay = millis2String(System.currentTimeMillis(), TimeUtils.getMdFormat())
// val fileDir: String = Environment.getExternalStorageDirectory().absolutePath + File.separator+
// "MapScreen" + File.separator+ currentDay + File.separator
// val fileName = "$takeOverBagId.png"
// val path = fileDir + fileName
// if (!File(fileDir).exists()) {
// File(fileDir).mkdirs()
// }
// RecordBitmapUtils.bitmap2Path(bitmap,path)
val forBitmap = ScreenUtilsTest.captureWithStatusBar(AppStateManager.currentActivity())
// Log.i("xuxinchao","bitmap="+forBitmap)
//
// val result = ScreenUtilsTest.mergeBitmaps(bitmap,forBitmap)
val result = ScreenUtilsTest.compoundBitmap(forBitmap,bitmap)
ThreadUtils.runOnUiThread {
ivScreenTest.setImageBitmap(forBitmap)
ivScreenTestTwo.setImageBitmap(bitmap)
ivScreenTestThree.setImageBitmap(result)
}
//注销高精地图截图监听回调
CallerMapScreenListenerManager.removeListener(TAG)
}
/**
* 设置鹰眼本地参数配置监听
*/
@@ -1570,17 +1580,13 @@ internal class DebugSettingView @JvmOverloads constructor(
*/
@SuppressLint("SetTextI18n")
private fun setDomainControllerCheckedChangeListener() {
val string = SharedPrefsMgr.getInstance()
.getString(SharedPrefsConstants.inputIpDomainController, "192.168.1.")
etAutopilotIP.setText(string)
etAutopilotIP.setText("192.168.1.")
etAutopilotIP.text?.let { etAutopilotIP.setSelection(it.length) }
//设置工控机IP
btnSetAutopilotIP.setOnClickListener {
val autoPilotIp = etAutopilotIP.text.toString()
if (autoPilotIp.isNotEmpty()) {
SSHAccountConfig.setRosMasterIp(autoPilotIp.split(":", "").first())
CallerAutoPilotControlManager.resetIpAddress(autoPilotIp)
SharedPrefsMgr.getInstance().putString(SharedPrefsConstants.inputIpDomainController,autoPilotIp)
} else {
ToastUtils.showShort("请输入正确的IP地址")
}

View File

@@ -0,0 +1,183 @@
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

@@ -742,6 +742,22 @@
android:layout_height="1dp"
android:background="#F0F0F0" />
<ImageView
android:id="@+id/ivScreenTest"
android:layout_width="match_parent"
android:layout_height="600dp"
/>
<ImageView
android:id="@+id/ivScreenTestTwo"
android:layout_width="match_parent"
android:layout_height="600dp"/>
<ImageView
android:id="@+id/ivScreenTestThree"
android:layout_width="match_parent"
android:layout_height="600dp"/>
</LinearLayout>

View File

@@ -85,7 +85,7 @@ rootProject.gradle.taskGraph.whenReady { TaskExecutionGraph graph ->
def packageTask = (PackageApplication) t2
def outDir = packageTask.outputDirectory
def apkNames = packageTask.apkNames
if (apkNames != null && apkNames.size() > 0) {
if (false) {
apkNames.forEach { apkName ->
def apk = new File(outDir, apkName)
def lp = new File(rootProject.rootDir, "local.properties")