[6.2.4] fix bug of request in main thread

This commit is contained in:
zhongchao
2023-12-05 14:29:54 +08:00
parent d716b618a7
commit 5b40018700
11 changed files with 37 additions and 150 deletions

View File

@@ -38,12 +38,12 @@ class FuncConfigNetWorkModel {
if (error == null) {
error = onError
}
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
map["mac"] = DeviceUtils.getMacAddress()
map["channelVersion"] = AppIdentityModeUtils.getMisChannelCode(FunctionBuildConfig.appIdentityMode)
}
loader {
apiCall {
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
map["mac"] = DeviceUtils.getMacAddress()
map["channelVersion"] = AppIdentityModeUtils.getMisChannelCode(FunctionBuildConfig.appIdentityMode)
getNetWorkApi().funcConfig(map)
}
}

View File

@@ -34,20 +34,20 @@ class IPCUpgradeNetWorkModel {
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{
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()
)
getNetWorkApi(getBaseUrl()).upgradeConfirm(requestBody)
}
}

View File

@@ -5,7 +5,6 @@ import android.graphics.*
import android.graphics.Paint.Style.STROKE
import android.os.Handler
import android.os.HandlerThread
import android.os.SystemClock
import android.util.*
import android.view.SurfaceHolder
import android.view.SurfaceView
@@ -15,6 +14,8 @@ import com.mogo.eagle.core.function.api.lookaround.data.*
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.devatools.*
import com.mogo.eagle.core.utilcode.kotlin.*
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.Utils
import kotlinx.coroutines.*
@@ -279,12 +280,11 @@ class M1LookAroundView: SurfaceView, SurfaceHolder.Callback, Runnable, IMoGoChas
override fun onAttachedToWindow() {
super.onAttachedToWindow()
CallerChassisSteeringStateListenerManager.addListener(TAG, this)
Log.d(TAG, "--- 发起订阅 ---")
CallerAutoPilotControlManager.setIsSubscribeM1StitchedVideo(true)
scope.launch(ThreadUtils.getCpuPool().asCoroutineDispatcher()) {
CallerDevaToolsManager.lookAroundProvider()?.flow()?.also { flow ->
flow.onEach {
Log.d(TAG, "-- onEach ---:$it")
CallerLogger.d("$M_HMI$TAG", "-- onEach ---:$it")
if (it.isValid()) {
data = it
handler.get()?.removeCallbacks(this@M1LookAroundView)
@@ -307,7 +307,6 @@ class M1LookAroundView: SurfaceView, SurfaceHolder.Callback, Runnable, IMoGoChas
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerChassisSteeringStateListenerManager.removeListener(TAG)
Log.d(TAG, "--- 取消订阅 ---")
CallerAutoPilotControlManager.setIsSubscribeM1StitchedVideo(false)
handler.get()?.looper?.quitSafely()
}

View File

@@ -18,13 +18,11 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningActionsListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisBrakeStateListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGearStateListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisSteeringStateListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisThrottleStateListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningActionsListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisBrakeStateListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGearStateListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisSteeringStateListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisThrottleStateListenerManager;
import com.mogo.eagle.core.function.hmi.R;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
@@ -33,8 +31,6 @@ import org.jetbrains.annotations.NotNull;
import chassis.Chassis;
import mogo.telematics.pad.MessagePad;
import chassis.ChassisStatesOuterClass;
import planning.RoboSweeperTaskIndexOuterClass;
/**
* @author Jing
@@ -42,7 +38,6 @@ import planning.RoboSweeperTaskIndexOuterClass;
* @since: 6/24/22
*/
public class TrafficDataView extends ConstraintLayout implements
IMoGoChassisSteeringStateListener,
IMoGoChassisGearStateListener ,
IMoGoChassisBrakeStateListener,
IMoGoChassisThrottleStateListener,
@@ -54,9 +49,6 @@ public class TrafficDataView extends ConstraintLayout implements
private ImageView speedImage;
private ImageView brakeStatus;
//圆弧颜色
private int mArcColor;
private static final int MSG_SEND_UPDATE = 1;
private volatile double acceleration;
private volatile float mBrake;
@@ -114,7 +106,6 @@ public class TrafficDataView extends ConstraintLayout implements
protected void onAttachedToWindow() {
super.onAttachedToWindow();
handler.sendEmptyMessageDelayed(MSG_SEND_UPDATE, 1000L);
CallerChassisSteeringStateListenerManager.INSTANCE.addListener(TAG, this);
CallerChassisGearStateListenerManager.INSTANCE.addListener(TAG, this);
CallerChassisBrakeStateListenerManager.INSTANCE.addListener(TAG, this);
CallerChassisThrottleStateListenerManager.INSTANCE.addListener(TAG, this);
@@ -133,7 +124,6 @@ public class TrafficDataView extends ConstraintLayout implements
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
CallerChassisSteeringStateListenerManager.INSTANCE.removeListener(TAG);
CallerChassisGearStateListenerManager.INSTANCE.removeListener(TAG);
CallerChassisBrakeStateListenerManager.INSTANCE.removeListener(TAG);
CallerChassisThrottleStateListenerManager.INSTANCE.removeListener(TAG);
@@ -145,20 +135,8 @@ public class TrafficDataView extends ConstraintLayout implements
acceleration = planningActionMsg.getDestinationAcc();
}
/**
* 方向盘转向角 左+右-
* @param steering
*/
@Override
public void onAutopilotSteeringData(float steering) {
if (Math.abs(steering) < 1) {
steering = 0;
}
}
/**
* 档位
* @param gear
*/
@Override
public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) {
@@ -178,23 +156,6 @@ public class TrafficDataView extends ConstraintLayout implements
public void onAutopilotThrottle(float throttle) {
mThrottle = throttle;
}
/**
* 设置弧形颜色
*
* @param value 颜色值
*/
public void setArcColor(int value) {
mArcColor = value;
}
/**
* 设置数据
*
* @param value 当前绘制的值
*/
public void setValues(int value) {
}
/**
* value呈现

View File

@@ -29,22 +29,20 @@ class AiCloudIdentifyNetWorkModel private constructor() {
onError: ((String) -> Unit)
) {
request<BaseResponse<Any>> {
val map = mutableMapOf<String, Any>()
start {
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
map["status"] = dataReceive
map["startMetre"] = START_METRE
map["endMetre"] = END_METRE
map["type"] = 1
if (lon != 0.0) {
map["lon"] = lon
}
if (lat != 0.0) {
map["lat"] = lat
}
}
loader {
apiCall {
val map = mutableMapOf<String, Any>()
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
map["status"] = dataReceive
map["startMetre"] = START_METRE
map["endMetre"] = END_METRE
map["type"] = 1
if (lon != 0.0) {
map["lon"] = lon
}
if (lat != 0.0) {
map["lat"] = lat
}
getNetWorkApi().identifyRange(map)
}
}