Merge remote-tracking branch 'origin/dev_robotaxi-d_230612_3.3.0' into dev_robotaxi-d_230612_3.3.0
This commit is contained in:
14
OCH/mogo-och-common-module/src/debug/AndroidManifest.xml
Normal file
14
OCH/mogo-och-common-module/src/debug/AndroidManifest.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.och.common.module">
|
||||
|
||||
<application>
|
||||
<receiver android:name="com.mogo.och.common.module.debug.BizBroadcastReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="com.mogo.launcher.debug" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mogo.och.common.module.debug
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
|
||||
class BizBroadcastReceiver: BroadcastReceiver() {
|
||||
|
||||
private var mContext: Context? = null
|
||||
|
||||
companion object {
|
||||
private const val TAG = "BizBroadcastReceiver"
|
||||
// 类型
|
||||
private const val type = "type"
|
||||
// 数据源
|
||||
private const val sourceFile = "path"
|
||||
// 数据频率 默认1s一次 -1 发送一次
|
||||
private const val frequencyKey = "fre"
|
||||
}
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
try {
|
||||
mContext = context
|
||||
val type = intent.getStringExtra(type)
|
||||
val frequency = intent.getIntExtra(frequencyKey,1)
|
||||
val sourceFilePath = intent.getStringExtra(sourceFile)
|
||||
CallerLogger.d("${SceneConstant.M_OCHCOMMON}${TAG}",
|
||||
"类型:${type} 频率:${frequency} 命令所在文件:${sourceFilePath}"
|
||||
)
|
||||
DebugDataDispatch.disPathc(type,frequency,sourceFilePath)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.mogo.och.common.module.debug
|
||||
|
||||
import android.os.Environment
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.och.common.module.debug.location.MogoLocationExit
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import java.io.BufferedReader
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
|
||||
object DebugDataDispatch {
|
||||
|
||||
const val TAG = "DebugDataDispatch"
|
||||
|
||||
const val globalPathMock = "globalPath"
|
||||
const val locationMock = "location"
|
||||
|
||||
val ROOT_PATH =
|
||||
Environment.getExternalStorageDirectory().absolutePath + File.separator + "MLog" + File.separator + "APPLog" + File.separator //程序外部存储跟目录
|
||||
|
||||
|
||||
fun disPathc(type: String?, frequency: Int, sourceFilePath: String?) {
|
||||
when (type) {
|
||||
globalPathMock -> {
|
||||
sourceFilePath?.let {
|
||||
loadRawPoints(ROOT_PATH+it)
|
||||
}
|
||||
}
|
||||
locationMock -> {
|
||||
sourceFilePath?.let {
|
||||
getLocaitonByLog(ROOT_PATH+it)
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun getLocaitonByLog(path:String) {
|
||||
ThreadUtils.getIoPool().execute {
|
||||
val inputStream = FileInputStream(path)
|
||||
val reader = BufferedReader(InputStreamReader(inputStream))
|
||||
var line: String? = ""
|
||||
try {
|
||||
while (reader.readLine().also { line = it } != null) {
|
||||
val list = GsonUtils.fromJson<MogoLocationExit>(
|
||||
line.toString(),
|
||||
object : TypeToken<MogoLocationExit>() {}.type
|
||||
)
|
||||
val mogoLocation = MogoLocation()
|
||||
mogoLocation.latitude = list.msg.GnssInfo.latitude
|
||||
mogoLocation.longitude = list.msg.GnssInfo.longitude
|
||||
mogoLocation.heading = list.msg.GnssInfo.heading
|
||||
mogoLocation.gnssSpeed = list.msg.GnssInfo.gnssSpeed.toFloat()
|
||||
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(
|
||||
mogoLocation,
|
||||
DataSourceType.OBU
|
||||
)
|
||||
Thread.sleep(100)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun loadRawPoints(path:String) {
|
||||
val inputStream = FileInputStream(path)
|
||||
val reader = BufferedReader(InputStreamReader(inputStream))
|
||||
val jsonStr = StringBuilder()
|
||||
var line: String? = ""
|
||||
try {
|
||||
while (reader.readLine().also { line = it } != null) {
|
||||
jsonStr.append(line)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
val list = GsonUtils.fromJson<List<LatLng>>(
|
||||
jsonStr.toString(),
|
||||
object : TypeToken<List<LatLng?>?>() {}.type
|
||||
)
|
||||
val newBuilder = MessagePad.GlobalPathResp.newBuilder()
|
||||
|
||||
for (latLng in list) {
|
||||
val locationBuilder = MessagePad.Location.newBuilder()
|
||||
locationBuilder.latitude = latLng.latitude
|
||||
locationBuilder.longitude = latLng.longitude
|
||||
newBuilder.addWayPoints(locationBuilder)
|
||||
}
|
||||
|
||||
val mogoLocation = MogoLocation()
|
||||
|
||||
mogoLocation.latitude = list[0].latitude
|
||||
mogoLocation.longitude = list[0].longitude
|
||||
|
||||
val mogoSecondLocation = MogoLocation()
|
||||
mogoSecondLocation.latitude = list[1].latitude
|
||||
mogoSecondLocation.longitude = list[1].longitude
|
||||
val angle = CoordinateCalculateRouteUtil.getHeadingAngle(
|
||||
mogoLocation,
|
||||
mogoSecondLocation
|
||||
)
|
||||
mogoLocation.heading = angle
|
||||
|
||||
CallerChassisLocationGCJ02ListenerManager.invokeChassisLocationGCJ02(
|
||||
mogoLocation,
|
||||
DataSourceType.OBU
|
||||
)
|
||||
CallerLogger.d(SceneConstant.M_OCHCOMMON + TAG,"轨迹点个数:${list.size}")
|
||||
// 发送轨迹
|
||||
CallerPlanningRottingListenerManager.invokeAutopilotRotting(newBuilder.build())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mogo.och.common.module.debug.location
|
||||
|
||||
data class MogoLocationExit(
|
||||
val localTime: Long,
|
||||
val msg: Msg
|
||||
)
|
||||
data class Msg(
|
||||
val GnssInfo: GnssInfo,
|
||||
val Header: Header,
|
||||
val stringDate0: String
|
||||
)
|
||||
|
||||
data class Header(
|
||||
val msgID: Int,
|
||||
val msgType: String,
|
||||
val sourceTimestamp: Double,
|
||||
val timestamp: Double
|
||||
)
|
||||
|
||||
data class GnssInfo(
|
||||
val acceleration: Double,
|
||||
val altitude: Double,
|
||||
val gnssSpeed: Double,
|
||||
val heading: Double,
|
||||
val latitude: Double,
|
||||
val longitude: Double,
|
||||
val satelliteTime: Double,
|
||||
val systemTime: Double,
|
||||
val yawRate: Double
|
||||
)
|
||||
@@ -139,6 +139,9 @@ object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
endCalculateDistanceLoop()
|
||||
return
|
||||
}
|
||||
if(it.latitude==0.0&&it.longitude==0.0){
|
||||
return
|
||||
}
|
||||
calculateRouteSumLength(it)
|
||||
}
|
||||
}
|
||||
@@ -180,7 +183,7 @@ object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
this.startStationInfo.distance = startStationInfo.third
|
||||
preCarLocationIndexInTrajectory = startStationInfo.first
|
||||
val calculateData = "距离起始站点最近的点:${startStationInfo.first} 点在站的后面:${startStationInfo.second} 距离点的距离:${startStationInfo.third}"
|
||||
val locationInfo = "定位信息:${location.latitude},${location.longitude}"
|
||||
val locationInfo = "定位信息:${location.latitude},${location.longitude},${location.heading}"
|
||||
writeLog(calculateData,locationInfo)
|
||||
}
|
||||
|
||||
@@ -198,7 +201,7 @@ object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
this.endStationInfo.index = endStationInfo.first
|
||||
this.endStationInfo.distance = endStationInfo.third
|
||||
val calculateData = "距离结束站点最近的点:${endStationInfo.first} 点在站的后面:${endStationInfo.second} 距离点的距离:${endStationInfo.third}"
|
||||
val locationInfo = "定位信息:${location.latitude},${location.longitude}"
|
||||
val locationInfo = "定位信息:${location.latitude},${location.longitude},${location.heading}"
|
||||
writeLog(calculateData, locationInfo)
|
||||
}
|
||||
|
||||
@@ -214,7 +217,7 @@ object TrajectoryAndDistanceManager: IMoGoPlanningRottingListener{
|
||||
)
|
||||
}
|
||||
val calculateData = "距离结束站点最近的点:${carLocationInfo.first} 点在站的后面:${carLocationInfo.second} 距离点的距离:${carLocationInfo.third}"
|
||||
val locationInfo = "定位信息:${location.latitude},${location.longitude}"
|
||||
val locationInfo = "定位信息:${location.latitude},${location.longitude},${location.heading}"
|
||||
writeLog(calculateData, locationInfo)
|
||||
if(carLocationInfo.second==null||carLocationInfo.third>1_000){
|
||||
preCarLocationIndexInTrajectory = 0
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.amap.api.maps.CoordinateConverter
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.och.common.module.manager.trajectorymamager.DistanceDegree
|
||||
@@ -597,9 +598,12 @@ object CoordinateCalculateRouteUtil {
|
||||
endIndex: Int,
|
||||
mRoutePoints: List<MogoLocation>,
|
||||
location: MogoLocation,
|
||||
type:Int, //
|
||||
size:Int = 8
|
||||
type:Int,
|
||||
size:Int = 4
|
||||
): Triple<Int,Boolean?,Float> {
|
||||
Logger.d(SceneConstant.M_OCHCOMMON + "calculateRouteSumLength",
|
||||
"参数:[$preIndex $endIndex) mRoutePoints:${mRoutePoints.size} type:$type size:$size" +
|
||||
" location:(${location.latitude},${location.longitude},${location.heading})")
|
||||
var currentIndex:Int = preIndex //记录疑似点 //基础点
|
||||
// 轨迹中的点和定位点的距离集合
|
||||
val distanceMap: TreeMap<DistanceDegree, Int> = TreeMap()
|
||||
@@ -710,6 +714,10 @@ object CoordinateCalculateRouteUtil {
|
||||
}
|
||||
}
|
||||
|
||||
if(distanceMap.size==0&&size<16){
|
||||
return getNearestPointInfo(preIndex,endIndex,mRoutePoints,location,type,size+2)
|
||||
}
|
||||
|
||||
// 最近点中包含上次计算的点和上次计算的最近的一个点
|
||||
if(distanceMap.containsValue(preIndex)&&distanceMap.containsValue(preIndex+1)){
|
||||
var preIndexDistance:DistanceDegree?=null
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.och.taxi.callback;
|
||||
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -10,6 +11,6 @@ import java.util.List;
|
||||
* @date: 2021/11/1
|
||||
*/
|
||||
public interface IOCHTaxiAutopilotPlanningCallback {
|
||||
void setLineMarker(List<LatLng> models);
|
||||
void routeResult(List<LatLng> models, int haveArrivedIndex);
|
||||
void setLineMarker(LatLng startStation,LatLng endStation);
|
||||
void routeResult(List<LatLng> routeArrivied,List<LatLng> routeArriving, MogoLocation location);
|
||||
}
|
||||
@@ -50,6 +50,8 @@ import com.mogo.och.common.module.biz.provider.LoginService;
|
||||
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
|
||||
import com.mogo.och.common.module.manager.AbnormalFactorsLoopManager;
|
||||
import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.common.module.manager.trajectorymamager.IDistanceListener;
|
||||
import com.mogo.och.common.module.manager.trajectorymamager.ITrajectoryListener;
|
||||
import com.mogo.och.common.module.manager.trajectorymamager.TrajectoryAndDistanceManager;
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel;
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil;
|
||||
@@ -238,6 +240,9 @@ public class TaxiModel {
|
||||
|
||||
AbnormalFactorsLoopManager.INSTANCE.startLoopAbnormalFactors(mContext);
|
||||
|
||||
TrajectoryAndDistanceManager.INSTANCE.addDistanceListener(TAG,distanceListener);
|
||||
TrajectoryAndDistanceManager.INSTANCE.addTrajectoryListener(TAG,trajectoryListener);
|
||||
|
||||
}
|
||||
|
||||
private final IMogoOnMessageListener<OCHOperationalMessage> mMogoOnMessageListener =
|
||||
@@ -1299,11 +1304,25 @@ public class TaxiModel {
|
||||
/**
|
||||
* 设置路径规划起终点
|
||||
*
|
||||
* @param latLngModels
|
||||
*/
|
||||
public void setRouteLineMarker(List<LatLng> latLngModels) {
|
||||
public void setRouteLineMarker() {
|
||||
OrderQueryRespBean.Result currentOCHOrder = getCurrentOCHOrder();
|
||||
if(currentOCHOrder!=null) {
|
||||
if (currentOCHOrder.startSiteGcjPoint == null || currentOCHOrder.startSiteGcjPoint.isEmpty() || currentOCHOrder.startSiteGcjPoint.size() < 2||
|
||||
currentOCHOrder.endSiteGcjPoint == null || currentOCHOrder.endSiteGcjPoint.isEmpty() || currentOCHOrder.endSiteGcjPoint.size() < 2) {
|
||||
cleanLineMarker();
|
||||
return;
|
||||
}
|
||||
LatLng startStation = new LatLng(currentOCHOrder.startSiteGcjPoint.get(1),currentOCHOrder.startSiteGcjPoint.get(0));
|
||||
LatLng endStation = new LatLng(currentOCHOrder.endSiteGcjPoint.get(1),currentOCHOrder.endSiteGcjPoint.get(0));
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback.setLineMarker(startStation,endStation);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void cleanLineMarker(){
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback.setLineMarker(latLngModels);
|
||||
mAutopilotPlanningCallback.setLineMarker(null,null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1395,44 +1414,47 @@ public class TaxiModel {
|
||||
* 实时计算当前剩余里程和时间
|
||||
*/
|
||||
public void dynamicCalculateRouteInfo() {
|
||||
if (mLocation == null) {
|
||||
return;
|
||||
// if (mLocation == null) {
|
||||
// return;
|
||||
// }
|
||||
// if (mRoutePoints.size() > 0 && mLocation != null) {
|
||||
// Map<Integer, List<MogoLocation>> lastPointsMap = CoordinateCalculateRouteUtil
|
||||
// .getRemainPointListByCompareNew(mPreRouteIndex, mRoutePoints, mLocation);
|
||||
//
|
||||
// for (int index : lastPointsMap.keySet()) {
|
||||
// mPreRouteIndex = index;
|
||||
// break;
|
||||
// }
|
||||
// for (List<MogoLocation> lastPoints : lastPointsMap.values()) {
|
||||
// float lastSumLength = 0;
|
||||
// if (lastPoints.size() == 1) { //只是最后一个点,计算当前位置和最后一个点的距离
|
||||
// lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
// lastPoints.get(0).getLongitude(), lastPoints.get(0).getLatitude(),
|
||||
// mLocation.getLongitude(), mLocation.getLatitude());
|
||||
// } else {
|
||||
// lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
|
||||
// }
|
||||
// updateDistance(lastSumLength);
|
||||
// break;
|
||||
// }
|
||||
// routeAndWipe();
|
||||
// }
|
||||
}
|
||||
|
||||
private void updateDistance(float lastSumLength){
|
||||
double lastTime = lastSumLength / TaxiConst.TAXI_AVERAGE_SPEED * 3.6; //秒
|
||||
CallerLogger.INSTANCE.d(M_TAXI + "dynamicCalculateRouteInfo"
|
||||
, "---lastSumLength: " + lastSumLength + "----lastTime : " + lastTime
|
||||
+ " thread = " + Thread.currentThread().getName());
|
||||
|
||||
if (mCurrentOCHOrder != null) {
|
||||
mCurrentOCHOrder.decreaseTravelDistance(lastSumLength);
|
||||
}
|
||||
if (mRoutePoints.size() > 0 && mLocation != null) {
|
||||
Map<Integer, List<MogoLocation>> lastPointsMap = CoordinateCalculateRouteUtil
|
||||
.getRemainPointListByCompareNew(mPreRouteIndex, mRoutePoints, mLocation);
|
||||
|
||||
for (int index : lastPointsMap.keySet()) {
|
||||
mPreRouteIndex = index;
|
||||
break;
|
||||
}
|
||||
for (List<MogoLocation> lastPoints : lastPointsMap.values()) {
|
||||
float lastSumLength = 0;
|
||||
if (lastPoints.size() == 1) { //只是最后一个点,计算当前位置和最后一个点的距离
|
||||
lastSumLength = CoordinateUtils.calculateLineDistance(
|
||||
lastPoints.get(0).getLongitude(), lastPoints.get(0).getLatitude(),
|
||||
mLocation.getLongitude(), mLocation.getLatitude());
|
||||
} else {
|
||||
lastSumLength = CoordinateCalculateRouteUtil.calculateRouteSumLength(lastPoints);
|
||||
}
|
||||
|
||||
double lastTime = lastSumLength / TaxiConst.TAXI_AVERAGE_SPEED * 3.6; //秒
|
||||
CallerLogger.INSTANCE.d(M_TAXI + "dynamicCalculateRouteInfo"
|
||||
, "---lastSumLength: " + lastSumLength + "----lastTime : " + lastTime
|
||||
+ " thread = " + Thread.currentThread().getName());
|
||||
|
||||
if (mCurrentOCHOrder != null) {
|
||||
mCurrentOCHOrder.decreaseTravelDistance(lastSumLength);
|
||||
}
|
||||
if (mOrderStatusCallback != null) {
|
||||
mOrderStatusCallback.onCurrentOrderDistToEndChanged((long) lastSumLength, (long) lastTime);
|
||||
}
|
||||
|
||||
reportOrderRemain((long) lastSumLength, (long) lastTime);
|
||||
break;
|
||||
}
|
||||
routeAndWipe();
|
||||
if (mOrderStatusCallback != null) {
|
||||
mOrderStatusCallback.onCurrentOrderDistToEndChanged((long) lastSumLength, (long) lastTime);
|
||||
}
|
||||
|
||||
reportOrderRemain((long) lastSumLength, (long) lastTime);
|
||||
}
|
||||
|
||||
private void routeAndWipe() {
|
||||
@@ -1444,13 +1466,43 @@ public class TaxiModel {
|
||||
mLocation.getLatitude());
|
||||
List<LatLng> routePoints = CoordinateCalculateRouteUtil
|
||||
.coordinateConverterLocationToLatLng(mContext, mRoutePoints);
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback.routeResult(routePoints, haveArrivedIndex);
|
||||
List<LatLng> routeArrivied = new ArrayList<>();
|
||||
List<LatLng> routeArriving = new ArrayList<>();
|
||||
for (int i = 0; i < routePoints.size(); i++){
|
||||
if (i <= haveArrivedIndex){
|
||||
routeArrivied.add(routePoints.get(i));
|
||||
}else {
|
||||
routeArriving.add(routePoints.get(i));
|
||||
}
|
||||
}
|
||||
setRouteLineMarker(routePoints);
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
mAutopilotPlanningCallback.routeResult(routeArrivied,routeArriving, mLocation);
|
||||
}
|
||||
setRouteLineMarker();
|
||||
}
|
||||
}
|
||||
|
||||
private final IDistanceListener distanceListener = this::updateDistance;
|
||||
|
||||
private final ITrajectoryListener trajectoryListener = (routeArrivied, routeArriving, location) -> {
|
||||
if (mAutopilotPlanningCallback != null) {
|
||||
List<LatLng> routeArriviedTemp = new ArrayList<>();
|
||||
List<LatLng> routeArrivingTemp = new ArrayList<>();
|
||||
LatLng temp;
|
||||
for (MogoLocation mogoLocation : routeArrivied) {
|
||||
temp = new LatLng(mogoLocation.getLatitude(),mogoLocation.getLongitude());
|
||||
routeArriviedTemp.add(temp);
|
||||
}
|
||||
for (MogoLocation mogoLocation : routeArriving) {
|
||||
temp = new LatLng(mogoLocation.getLatitude(),mogoLocation.getLongitude());
|
||||
routeArrivingTemp.add(temp);
|
||||
}
|
||||
mAutopilotPlanningCallback.routeResult(routeArriviedTemp, routeArrivingTemp,location);
|
||||
setRouteLineMarker();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 查询当前订单的全局路径 (当自动驾驶开启后,订单前往乘客上车点,杀掉应用再次进来时候)
|
||||
*/
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.mvp.Presenter;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.taxi.callback.IOCHTaxiAutopilotPlanningCallback;
|
||||
@@ -65,12 +66,12 @@ public class NaviPresenter extends Presenter<TaxiRottingNaviFragment> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker(List<LatLng> models) {
|
||||
runOnUIThread(() -> mView.setLineMarker(models));
|
||||
public void setLineMarker(LatLng startStation, LatLng endStation) {
|
||||
runOnUIThread(() -> mView.setLineMarker(startStation,endStation));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void routeResult(List<LatLng> models, int haveArrivedIndex) {
|
||||
mView.routeResult(models,haveArrivedIndex);
|
||||
public void routeResult(List<LatLng> routeArrivied, List<LatLng> routeArriving, MogoLocation location) {
|
||||
mView.routeResult(routeArrivied,routeArriving,location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
|
||||
TaxiOrderStatusEnum.Cancel.getCode() == order.orderStatus ||
|
||||
TaxiOrderStatusEnum.JourneyCompleted.getCode() == order.orderStatus){
|
||||
TaxiModel.getInstance().startOrStopCalculateRouteInfo(false);
|
||||
TaxiModel.getInstance().setRouteLineMarker(null);
|
||||
TaxiModel.getInstance().cleanLineMarker();
|
||||
TaxiModel.getInstance().cleanStation();
|
||||
runOnUIThread(() -> {
|
||||
if(TaxiOrderStatusEnum.ArriveAtEnd.getCode() == order.orderStatus){
|
||||
|
||||
@@ -15,7 +15,6 @@ import androidx.annotation.Nullable;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptor;
|
||||
@@ -28,7 +27,6 @@ import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
import com.amap.api.maps.model.PolylineOptions;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
@@ -55,12 +53,14 @@ public class TaxiMapDirectionView
|
||||
private Marker mStartMarker;
|
||||
private Marker mEndMarker;
|
||||
|
||||
private int zoomLevel = 13;
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
|
||||
private final int zoomLevel = 13;
|
||||
private final List<LatLng> routeArrivied = new ArrayList<>();
|
||||
private final List<LatLng> routeArriving = new ArrayList<>();
|
||||
private MogoLocation location;
|
||||
|
||||
private LatLng startStation;
|
||||
private LatLng endStation;
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
private int mHaveArrivedIndex;
|
||||
|
||||
List<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
List<Integer> texIndexList = new ArrayList<>();
|
||||
@@ -89,16 +89,14 @@ public class TaxiMapDirectionView
|
||||
private void initView(Context context) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "initView");
|
||||
|
||||
mContext = context;
|
||||
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.taxi_map_view, this);
|
||||
|
||||
mAMapNaviView = (TextureMapView) smpView.findViewById(R.id.taxi_amap_view);
|
||||
mAMapNaviView = smpView.findViewById(R.id.taxi_amap_view);
|
||||
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 10,this);
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 10, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,7 +107,7 @@ public class TaxiMapDirectionView
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
CameraUpdate mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
@@ -134,8 +132,8 @@ public class TaxiMapDirectionView
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data"))
|
||||
.setStyleExtraData(TaxiMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data"));
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(getContext(), "map_style.data"))
|
||||
.setStyleExtraData(TaxiMapAssetStyleUtil.getAssetsExtraStyle(getContext(), "map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
|
||||
@@ -156,8 +154,8 @@ public class TaxiMapDirectionView
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data"))
|
||||
.setStyleExtraData(TaxiMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data"));
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(getContext(), "map_style.data"))
|
||||
.setStyleExtraData(TaxiMapAssetStyleUtil.getAssetsExtraStyle(getContext(), "map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2);
|
||||
@@ -176,21 +174,21 @@ public class TaxiMapDirectionView
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (gnssInfo == null){
|
||||
if (gnssInfo == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
LatLng currentLatLng = new LatLng(gnssInfo.getLatitude(), gnssInfo.getLongitude());
|
||||
if (mCoordinatesLatLng.size() > 1) {
|
||||
if (mPolyline!=null&&mPolyline.getPoints().size() > 1) {
|
||||
List<LatLng> points = mPolyline.getPoints();
|
||||
//圈定地图显示范围
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
LatLng endLatLng = points.get(points.size() - 1);
|
||||
//存放经纬度
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
boundsBuilder.include(currentLatLng);
|
||||
boundsBuilder.include(endLatLng);
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100,100,100,100));
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--moveCamera :" + location.getLatitude()+", "+location.getLongitude());
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100));
|
||||
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
@@ -200,40 +198,30 @@ public class TaxiMapDirectionView
|
||||
}
|
||||
//更新车辆位置
|
||||
if (mCarMarker != null) {
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "location.getBearing() = " + location.getBearing());
|
||||
mCarMarker.setRotateAngle((float) (360 - gnssInfo.getHeading()));
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--loacation :" + location.getLatitude()+", "+location.getLongitude());
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker() {
|
||||
// if (mStartMarker != null) {
|
||||
// mStartMarker.setVisible(false);
|
||||
// }
|
||||
// if (mEndMarker != null) {
|
||||
// mEndMarker.setVisible(false);
|
||||
// }
|
||||
if (mStartMarker != null && mEndMarker != null
|
||||
&& mStartMarker.isVisible() && mEndMarker.isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mCoordinatesLatLng.size() > 2) {
|
||||
if (startStation != null && endStation != null) {
|
||||
// 设置开始结束Marker位置
|
||||
LatLng startLatLng = mCoordinatesLatLng.get(0);
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setPosition(startLatLng);
|
||||
mStartMarker.setPosition(startStation);
|
||||
mStartMarker.setVisible(true);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setPosition(endLatLng);
|
||||
mEndMarker.setPosition(endStation);
|
||||
mEndMarker.setVisible(true);
|
||||
}
|
||||
}
|
||||
@@ -241,62 +229,43 @@ public class TaxiMapDirectionView
|
||||
|
||||
@Override
|
||||
public void drawablePolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
if(routeArrivied.isEmpty()&&routeArriving.isEmpty()){
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "没有点");
|
||||
return;
|
||||
}
|
||||
if (mAMap != null) {
|
||||
|
||||
addRouteColorList();
|
||||
|
||||
if (mCoordinatesLatLng.size() > 2) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(mCoordinatesLatLng);
|
||||
polylineOptions.setUseTexture(true);
|
||||
polylineOptions.width(15);
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加画线颜色值
|
||||
*/
|
||||
private void addRouteColorList() {
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++){
|
||||
if (i <= mHaveArrivedIndex){
|
||||
textureList.add(mArrivedRes);
|
||||
}else {
|
||||
textureList.add(mUnArrivedRes);
|
||||
ArrayList<LatLng> allPoints = new ArrayList<>(routeArrivied);
|
||||
for (int i = 0; i < routeArrivied.size(); i++) {
|
||||
if(routeArrivied.size()>1&&i<routeArrivied.size()-1){
|
||||
texIndexList.add(0);
|
||||
}
|
||||
texIndexList.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LatLng CoordinateConverterFrom84(Context mContext, MogoLatLng mogoLatLng) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(mogoLatLng.lat, mogoLatLng.lon));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
public List<LatLng> CoordinateConverterFrom84ForList(Context mContext, List<MogoLatLng> mogoLatLngList) {
|
||||
List<LatLng> list = new ArrayList<>();
|
||||
for (MogoLatLng m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateConverterFrom84(mContext, m);
|
||||
list.add(mogoLatLng);
|
||||
texIndexList.add(0);
|
||||
allPoints.add(new LatLng(location.getLatitude(),location.getLongitude()));
|
||||
allPoints.addAll(routeArriving);
|
||||
for (LatLng ignored : routeArrivied) {
|
||||
texIndexList.add(1);
|
||||
}
|
||||
|
||||
if (mPolyline != null) {
|
||||
mPolyline.setPoints(allPoints);
|
||||
mPolyline.getOptions().setCustomTextureIndex(texIndexList);
|
||||
return;
|
||||
}
|
||||
textureList.add(mArrivedRes);
|
||||
textureList.add(mUnArrivedRes);
|
||||
if (mAMap != null) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(allPoints);
|
||||
polylineOptions.setUseTexture(true);
|
||||
polylineOptions.width(15);
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -312,19 +281,6 @@ public class TaxiMapDirectionView
|
||||
}
|
||||
}
|
||||
|
||||
public void resetPolyLine() {
|
||||
mCoordinatesLatLng.clear();
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onCreate(savedInstanceState);
|
||||
@@ -349,21 +305,17 @@ public class TaxiMapDirectionView
|
||||
}
|
||||
}
|
||||
|
||||
public void convert(List<MogoLatLng> coordinates) {
|
||||
mCoordinatesLatLng.clear();
|
||||
List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext, coordinates);
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
public void setStartMarkAndEndMark(LatLng startStation, LatLng endStation) {
|
||||
this.startStation = startStation;
|
||||
this.endStation = endStation;
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs){
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs, int haveArrivedIndex){
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
mHaveArrivedIndex = haveArrivedIndex;
|
||||
public void setCoordinatesLatLng(List<LatLng> routeArrivied, List<LatLng> routeArriving, MogoLocation location) {
|
||||
this.routeArrivied.clear();
|
||||
this.routeArrivied.addAll(routeArrivied);
|
||||
this.routeArriving.clear();
|
||||
this.routeArriving.addAll(routeArriving);
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.presenter.NaviPresenter;
|
||||
@@ -79,49 +80,34 @@ public class TaxiRottingNaviFragment extends MvpFragment<TaxiRottingNaviFragment
|
||||
return new NaviPresenter(this);
|
||||
}
|
||||
|
||||
public void routeResult(List<LatLng> latLngList, int haveArrivedIndex){
|
||||
if (latLngList.size() > 0) {
|
||||
drawablePolylineByRoute(latLngList,haveArrivedIndex);
|
||||
public void routeResult(List<LatLng> routeArrivied, List<LatLng> routeArriving, MogoLocation location){
|
||||
if ((routeArrivied.size()+routeArriving.size()) > 0) {
|
||||
drawablePolylineByRoute(routeArrivied,routeArriving,location);
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
public void setLineMarker(List<LatLng> latLngList){
|
||||
if (null != latLngList && latLngList.size() > 0) {
|
||||
public void setLineMarker(LatLng startStation, LatLng endStation){
|
||||
if (startStation!=null&&endStation!=null) {
|
||||
if (mMapDirectionView != null) {
|
||||
mMapDirectionView.setCoordinatesLatLng(latLngList);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.setLineMarker();
|
||||
}
|
||||
});
|
||||
mMapDirectionView.setStartMarkAndEndMark(startStation,endStation);
|
||||
UiThreadHandler.post(() -> mMapDirectionView.setLineMarker());
|
||||
}
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
}
|
||||
|
||||
public void drawablePolylineByRoute(List<LatLng> mCoordinatesLatLng,int haveArrivedIndex){
|
||||
public void drawablePolylineByRoute(List<LatLng> routeArrivied, List<LatLng> routeArriving, MogoLocation location){
|
||||
if (mMapDirectionView != null){
|
||||
mMapDirectionView.setCoordinatesLatLng(mCoordinatesLatLng,haveArrivedIndex);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.drawablePolyline();
|
||||
}
|
||||
});
|
||||
mMapDirectionView.setCoordinatesLatLng(routeArrivied,routeArriving,location);
|
||||
UiThreadHandler.post(() -> mMapDirectionView.drawablePolyline());
|
||||
}
|
||||
}
|
||||
private void clearPolyline() {
|
||||
if (mMapDirectionView != null) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMapDirectionView.clearPolyline();
|
||||
}
|
||||
});
|
||||
UiThreadHandler.post(() -> mMapDirectionView.clearPolyline());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.mogo.launcher.lancet;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.knightboost.lancet.api.Origin;
|
||||
import com.knightboost.lancet.api.Scope;
|
||||
import com.knightboost.lancet.api.This;
|
||||
import com.knightboost.lancet.api.annotations.Group;
|
||||
import com.knightboost.lancet.api.annotations.Insert;
|
||||
import com.knightboost.lancet.api.annotations.ReplaceInvoke;
|
||||
import com.knightboost.lancet.api.annotations.TargetClass;
|
||||
import com.knightboost.lancet.api.annotations.TargetMethod;
|
||||
import com.knightboost.lancet.api.annotations.Weaver;
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.IMoGoMoFangProvider;
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
|
||||
|
||||
@Keep
|
||||
@Weaver
|
||||
@Group("window_callback")
|
||||
public class WindowCallbackLancet {
|
||||
|
||||
@Insert(mayCreateSuper = true)
|
||||
@TargetClass(value = "androidx.appcompat.app.AppCompatActivity", scope = Scope.SELF)
|
||||
@TargetMethod(methodName = "onCreate")
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
Origin.callVoid();
|
||||
Object o = This.get();
|
||||
if (o instanceof Activity) {
|
||||
Activity activity = (Activity) o;
|
||||
IMoGoMoFangProvider mofang = CallerDevaToolsManager.INSTANCE.mofang();
|
||||
if (mofang != null) {
|
||||
Window.Callback callback = mofang.provideWindowCallback(activity.getWindow().getCallback());
|
||||
activity.getWindow().setCallback(callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Insert(mayCreateSuper = true)
|
||||
@TargetClass(value = "androidx.fragment.app.DialogFragment", scope = Scope.SELF)
|
||||
@TargetMethod(methodName = "onCreateDialog")
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
Dialog dialog = (Dialog) Origin.call();
|
||||
IMoGoMoFangProvider mofang = CallerDevaToolsManager.INSTANCE.mofang();
|
||||
if (dialog.getWindow() != null && mofang != null) {
|
||||
dialog.getWindow().setCallback(mofang.provideWindowCallback(dialog.getWindow().getCallback()));
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
// @TargetClass(value = "android.view.WindowManager",scope = Scope.SELF)
|
||||
// @TargetMethod(methodName = "addView")
|
||||
// @ReplaceInvoke
|
||||
// public static void proxyWindowManagerAddView(WindowManager manager, View view, ViewGroup.LayoutParams params) {
|
||||
// manager.addView(view, params);
|
||||
// Log.d("XXXXXX", "--- add view ---- 1 ---");
|
||||
// IMoGoMoFangProvider mofang = CallerDevaToolsManager.INSTANCE.mofang();
|
||||
// if (mofang != null) {
|
||||
// Log.d("XXXXXX", "--- add view ---- 2 ---");
|
||||
// Window.Callback callback = mofang.provideWindowCallback(null);
|
||||
// view.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
|
||||
// @Override
|
||||
// public void onViewAttachedToWindow(@NonNull View v) {
|
||||
// Log.d("XXXXXX", "--- add view ---- 3 ---");
|
||||
// v.setOnKeyListener((v1, keyCode, event) -> {
|
||||
// Log.d("XXXXXX", "--- add view ---- 4 ---");
|
||||
// return callback.dispatchKeyEvent(event);
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onViewDetachedFromWindow(@NonNull View v) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -216,7 +216,9 @@ ext {
|
||||
|
||||
thread_opt : "com.mogo.thread.opt:lib:${plugin_version}",
|
||||
|
||||
weak_network : "com.mogo.weak:network:1.0.0"
|
||||
weak_network : "com.mogo.weak:network:1.0.0",
|
||||
|
||||
mofang_runtime : "com.mogo.eagle.core.mofang:runtime:1.0.0"
|
||||
]
|
||||
android = [
|
||||
launcherApplicationId : "com.mogo.launcher",
|
||||
@@ -227,7 +229,7 @@ ext {
|
||||
bydautoIndependentApiValue : "b1e1d527b02a493913c50985827c943a",
|
||||
commonLauncherAmapApiValue : "a36b9f7b086fa3951bb35338a5a06dd3",
|
||||
commonIndependentAmapApiValue : "1c3fbc5f5e183619ffb1e7bc01e6751f",
|
||||
compileSdkVersion : 29,
|
||||
compileSdkVersion : 33,
|
||||
buildToolsVersion : "29.0.2",
|
||||
minSdkVersion : 23,
|
||||
targetSdkVersion : 27,
|
||||
|
||||
@@ -8,24 +8,22 @@ import android.util.Log
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.currentRoadTrafficLight
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.isGreen
|
||||
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.BIZ_VIP
|
||||
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.V2N
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.currentRoadTrafficLight
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.isGreen
|
||||
import com.mogo.eagle.core.data.biz.trafficlight.isRed
|
||||
import com.mogo.eagle.core.data.v2x.VipMessage
|
||||
import com.mogo.eagle.core.function.api.datacenter.union.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallVipSetListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
@@ -49,12 +47,16 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
@Volatile
|
||||
private var turnLight = false
|
||||
|
||||
@Volatile
|
||||
private var vip: Boolean = false
|
||||
|
||||
@Volatile
|
||||
private var exit: Boolean = false
|
||||
|
||||
@Volatile
|
||||
private var result: TrafficLightResult? = null
|
||||
|
||||
private val vipNetWorkModel = VipNetWorkModel()
|
||||
@@ -87,14 +89,14 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
|
||||
@BizConfig(V2N, "", BIZ_VIP)
|
||||
override fun onMsgReceived(vipMessage: VipMessage?) {
|
||||
CallerLogger.d("$M_V2X$TAG", "onMsgReceived vipMessage : ${vipMessage.toString()}")
|
||||
V2XBizTrace.onAck("$M_V2X$TAG", "onMsgReceived vipMessage : ${vipMessage.toString()}")
|
||||
vipMessage?.let {
|
||||
when (it.vipType) {
|
||||
0 -> { //取消VIP
|
||||
cancelVip()
|
||||
}
|
||||
1 -> { //设置VIP
|
||||
CallerLogger.d(
|
||||
V2XBizTrace.onAck(
|
||||
"$M_V2X$TAG",
|
||||
"设置handler超时时间 " + ", time : ${System.currentTimeMillis() - vipMessage.timeOut}"
|
||||
)
|
||||
@@ -110,36 +112,25 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
}
|
||||
|
||||
if (exit) {
|
||||
CallerLogger.d("$M_V2X$TAG", "驶离路口,返回 , then resetConditions")
|
||||
V2XBizTrace.onAck("驶离路口","resetConditions")
|
||||
V2XBizTrace.onAck("$M_V2X$TAG", "驶离路口 resetConditions")
|
||||
resetConditions()
|
||||
exit = false
|
||||
return
|
||||
}
|
||||
|
||||
if (trafficLightResult.currentRoadTrafficLight() == null) {
|
||||
CallerLogger.d(
|
||||
"$M_V2X$TAG",
|
||||
"vip 获取到灯态,但没找到对应车道数据 trafficLightResult : $trafficLightResult , then resetConditions"
|
||||
)
|
||||
V2XBizTrace.onAck("$M_V2X$TAG", "vip获取到灯态,但没找到对应车道数据 trafficLight:$$trafficLightResult")
|
||||
result = null
|
||||
return
|
||||
}
|
||||
|
||||
val currentResult = trafficLightResult.currentRoadTrafficLight()
|
||||
val lastResult = result?.currentRoadTrafficLight()
|
||||
CallerLogger.d(
|
||||
"$M_V2X$TAG",
|
||||
"检查是否变灯 last.remain : ${lastResult?.remain} , color : ${lastResult?.color} , current.remain : ${currentResult?.remain} , color : ${currentResult?.color}, turnLight : $turnLight"
|
||||
)
|
||||
|
||||
this.result = trafficLightResult
|
||||
|
||||
if (!turnLight) {
|
||||
// 首次判断,变灯
|
||||
turnLight = true
|
||||
val controlTime = if (currentResult!!.isGreen()) 45 - currentResult.remain else 45
|
||||
CallerLogger.d("$M_V2X$TAG", "触发变灯 , controlTime : $controlTime")
|
||||
turnLight(controlTime)
|
||||
}
|
||||
|
||||
@@ -157,7 +148,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
MSG_WHAT_VIP_CANCEL,
|
||||
cancelDelayTime - System.currentTimeMillis()
|
||||
)
|
||||
V2XBizTrace.onAck("setVip","time:$cancelDelayTime")
|
||||
V2XBizTrace.onAck("$M_V2X$TAG", "setVip time:$cancelDelayTime")
|
||||
CallVipSetListenerManager.invokeVipSetStatus(true)
|
||||
CallerTrafficLightListenerManager.addListener(TAG, this)
|
||||
}
|
||||
@@ -167,7 +158,7 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
if (handler.hasMessages(MSG_WHAT_VIP_CANCEL)) {
|
||||
handler.removeMessages(MSG_WHAT_VIP_CANCEL)
|
||||
}
|
||||
V2XBizTrace.onAck("cancelVip","resetConditions")
|
||||
V2XBizTrace.onAck("$M_V2X$TAG", "cancelVip resetConditions")
|
||||
resetConditions()
|
||||
CallVipSetListenerManager.invokeVipSetStatus(false)
|
||||
CallerTrafficLightListenerManager.removeListener(TAG)
|
||||
@@ -184,7 +175,6 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
cancelVip()
|
||||
}
|
||||
}, {
|
||||
CallerLogger.e("$M_V2X$TAG", "获取VIP信息失败, 准备间隔5秒重新获取")
|
||||
handler.sendEmptyMessageDelayed(MSG_WHAT_VIP_SEARCH, 5_000L)
|
||||
})
|
||||
}
|
||||
@@ -198,41 +188,39 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
|
||||
private fun turnLight(controlTime: Int) {
|
||||
if (result == null || mContext == null) return
|
||||
val mogoLocation = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
if (mogoLocation != null) {
|
||||
val bearing = mogoLocation.heading
|
||||
CallerLogger.d("$M_V2X$TAG", "-- turnLight -- ")
|
||||
MogoTrafficLightManager.INSTANCE.turnLightToGreen(
|
||||
result!!.lightId, result!!.crossId, bearing, controlTime,
|
||||
val bearing = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().heading
|
||||
V2XBizTrace.onAck("$M_V2X$TAG", "触发变灯 controlTime : $controlTime , bearing: $bearing")
|
||||
MogoTrafficLightManager.INSTANCE.turnLightToGreen(
|
||||
result!!.lightId, result!!.crossId, bearing, controlTime,
|
||||
// 100445, "10037", 90.0, controlTime, //衡阳25号路口测试数据
|
||||
{
|
||||
V2XBizTrace.onAck(
|
||||
TAG + "turnLight", "code:${it.code}" +
|
||||
",light:${this.result ?: ""}" +
|
||||
",lightId:${result?.lightId}" +
|
||||
",crossId:${result?.crossId}" +
|
||||
",bearing:$bearing" +
|
||||
",controlTime:$controlTime"
|
||||
)
|
||||
// 请求变灯成功,直接提示
|
||||
if (it.sn == MoGoAiCloudClientConfig.getInstance().sn && it.code == 0) {
|
||||
CallerLogger.d("$M_V2X$TAG", "变灯请求成功")
|
||||
val light = this.result?.currentRoadTrafficLight()
|
||||
if (light != null && light.isGreen()) {
|
||||
showWarning(
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.poiType,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.content,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.tts
|
||||
)
|
||||
} else {
|
||||
showWarning(
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.poiType,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.content,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.tts
|
||||
)
|
||||
}
|
||||
return@turnLightToGreen
|
||||
{
|
||||
V2XBizTrace.onAck(
|
||||
"$M_V2X$TAG turnLight", "code:${it.code}" +
|
||||
",light:${this.result ?: ""}" +
|
||||
",lightId:${result?.lightId}" +
|
||||
",crossId:${result?.crossId}" +
|
||||
",bearing:$bearing" +
|
||||
",controlTime:$controlTime"
|
||||
)
|
||||
// 请求变灯成功,直接提示
|
||||
if (it.sn == MoGoAiCloudClientConfig.getInstance().sn && it.code == 0) {
|
||||
V2XBizTrace.onAck("$M_V2X$TAG", "变灯请求成功")
|
||||
val light = this.result?.currentRoadTrafficLight()
|
||||
if (light != null && light.isGreen()) {
|
||||
showWarning(
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.poiType,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.content,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_EXTEND.tts
|
||||
)
|
||||
} else {
|
||||
showWarning(
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.poiType,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.content,
|
||||
EventTypeEnumNew.TYPE_VIP_IDENTIFICATION_PASS.tts
|
||||
)
|
||||
}
|
||||
return@turnLightToGreen
|
||||
}
|
||||
|
||||
// // 如果当前为红灯,则提示
|
||||
// if (this.result!!.currentRoadTrafficLight()!!.isRed()) {
|
||||
@@ -257,19 +245,18 @@ class VipCarManager : IMogoOnMessageListener<VipMessage>, IMoGoTrafficLightListe
|
||||
// "变灯请求失败,当前为非红灯不做展示 , light : ${result.toString()} , trafficLightControl : $it"
|
||||
// )
|
||||
// }
|
||||
},
|
||||
{ errorMsg ->
|
||||
CallerLogger.e("$M_V2X$TAG", "变灯请求失败 msg : $errorMsg")
|
||||
V2XBizTrace.onAck(
|
||||
TAG + "turnLight", "变灯请求失败 msg:$errorMsg" +
|
||||
",lightId:${result?.lightId}" +
|
||||
",crossId:${result?.crossId}" +
|
||||
",bearing:$bearing" +
|
||||
",controlTime:$controlTime"
|
||||
)
|
||||
ToastUtils.showLong("服务异常,请稍后重试")
|
||||
})
|
||||
}
|
||||
},
|
||||
{ errorMsg ->
|
||||
V2XBizTrace.onAck(
|
||||
"$M_V2X$TAG turnLight", "变灯请求失败 msg:$errorMsg" +
|
||||
",loc:${CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()}" +
|
||||
",lightId:${result?.lightId}" +
|
||||
",crossId:${result?.crossId}" +
|
||||
",bearing:$bearing" +
|
||||
",controlTime:$controlTime"
|
||||
)
|
||||
ToastUtils.showLong("服务异常,请稍后重试")
|
||||
})
|
||||
}
|
||||
|
||||
private fun showWarning(
|
||||
|
||||
@@ -279,10 +279,6 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
*/
|
||||
override fun onGnssInfo(gnssInfo: MessagePad.GnssInfo?) {
|
||||
if (gnssInfo != null) {
|
||||
CallerLogger.d(
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
|
||||
"onGnssInfo lon = ${gnssInfo.longitude} --- lat = ${gnssInfo.latitude} ---speed = ${gnssInfo.gnssSpeed} ---heading = ${gnssInfo.heading} --acceleration = ${gnssInfo.acceleration} --yawRate = ${gnssInfo.yawRate}"
|
||||
)
|
||||
// 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统,1-工控机,2-OBU
|
||||
if (2 == FunctionBuildConfig.gpsProvider) {
|
||||
// 同步给MAP地图
|
||||
|
||||
@@ -89,6 +89,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.androidautoSize
|
||||
implementation rootProject.ext.dependencies.koomnative
|
||||
implementation rootProject.ext.dependencies.koomxhook
|
||||
implementation rootProject.ext.dependencies.mofang_runtime
|
||||
implementation group: "com.tencent.matrix", name: "matrix-android-lib", version: MATRIX_VERSION, changing: true
|
||||
implementation group: "com.tencent.matrix", name: "matrix-android-commons", version: MATRIX_VERSION, changing: true
|
||||
implementation group: "com.tencent.matrix", name: "matrix-trace-canary", version: MATRIX_VERSION, changing: true
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zhjt.mogo_core_function_devatools
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -19,6 +20,7 @@ import com.mogo.eagle.core.function.api.devatools.IDevaToolsProvider
|
||||
import com.mogo.eagle.core.function.api.devatools.apm.*
|
||||
import com.mogo.eagle.core.function.api.devatools.strict.*
|
||||
import com.mogo.eagle.core.function.api.devatools.download.*
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.*
|
||||
import com.mogo.eagle.core.function.api.lookaround.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w
|
||||
@@ -44,7 +46,7 @@ import com.zhjt.mogo_core_function_devatools.koom.KoomInitTask
|
||||
import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchManager
|
||||
import com.zhjt.mogo_core_function_devatools.lookaround.*
|
||||
import com.zhjt.mogo_core_function_devatools.matrix.DynamicConfigImpl
|
||||
import com.zhjt.mogo_core_function_devatools.mofang.MoFangManager.Companion.moFangManager
|
||||
import com.zhjt.mogo_core_function_devatools.mofang.*
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.MonitorManager
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb
|
||||
import com.zhjt.mogo_core_function_devatools.monitor.db.MonitorDb.Companion.getDb
|
||||
@@ -75,6 +77,8 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
|
||||
private val lookAroundDataProvider by lazy { MoGoLookAroundProviderImpl() }
|
||||
|
||||
private val mofangProvider by lazy { MoGoMoFangProviderImpl() }
|
||||
|
||||
@Volatile
|
||||
private var mDockerVersion: String? = null
|
||||
|
||||
@@ -97,7 +101,6 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
|
||||
//升级(鹰眼/工控)与监控服务
|
||||
iPCReportManager.initServer()
|
||||
moFangManager.init(mContext!!)
|
||||
BindingCarManager.init(mContext!!)
|
||||
apmEnvProvider.init(if(DebugConfig.isDebug()) "0" else "1", "${ DebugConfig.getNetMode() }", mDockerVersion ?: "")
|
||||
BadCaseManager.init()
|
||||
@@ -107,6 +110,9 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
WeakNetworkStrategy.startListen()
|
||||
}
|
||||
lookAroundDataProvider.init(mContext!!)
|
||||
(mContext as? Application)?.also {
|
||||
mofangProvider.init(it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun checkMonitorDb() {
|
||||
@@ -358,4 +364,6 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
override fun strict(): IStrictModeProvider = strictModeProvider
|
||||
|
||||
override fun lookAroundDataProvider(): IMoGoLookAroundProvider = lookAroundDataProvider
|
||||
|
||||
override fun mofang(): IMoGoMoFangProvider = mofangProvider
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package com.zhjt.mogo_core_function_devatools.mofang
|
||||
|
||||
import android.os.*
|
||||
import android.util.*
|
||||
import android.view.KeyEvent
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
|
||||
internal class MoFangCommandExecutor {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MoFangCommandExecutor"
|
||||
private const val MSG_WHAT_KEY_CODE_A = 0x01
|
||||
private const val MSG_WHAT_KEY_CODE_BL = 0x02
|
||||
private const val MSG_WHAT_KEY_CODE_C = 0x03
|
||||
private const val MSG_WHAT_KEY_CODE_D = 0x04
|
||||
private const val MSG_WHAT_KEY_CODE_E = 0x05
|
||||
private const val MSG_WHAT_KEY_CODE_EL = 0x06
|
||||
private const val MSG_WHAT_KEY_CODE_AB = 0x07
|
||||
}
|
||||
|
||||
private val handlerCallback = Handler.Callback { msg ->
|
||||
when(msg.what) {
|
||||
MSG_WHAT_KEY_CODE_A, MSG_WHAT_KEY_CODE_AB, MSG_WHAT_KEY_CODE_BL -> {
|
||||
Log.d(TAG, "--- msg: $msg ---")
|
||||
var send = false
|
||||
try {
|
||||
val acc = msg.obj as? Double
|
||||
if (acc != null && acc != 0.0) {
|
||||
send = true
|
||||
CallerAutoPilotControlManager.sendOperatorSetAcceleratedSpeed(acc)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
Log.e(TAG, "error: ${t.message}, msg-> $msg")
|
||||
} finally {
|
||||
if (send) {
|
||||
msg.target.sendMessageDelayed(Message.obtain(msg), 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
MSG_WHAT_KEY_CODE_C, MSG_WHAT_KEY_CODE_D -> {
|
||||
try {
|
||||
if (msg.arg1 != -1 && msg.arg1 != 1) {
|
||||
return@Callback true
|
||||
}
|
||||
val isLeft = msg.arg1 == -1
|
||||
if (isLeft) {
|
||||
Log.d(TAG, "--- 左变道执行了 ----")
|
||||
CallerAutoPilotControlManager.sendOperatorChangeLaneLeft()
|
||||
} else {
|
||||
Log.d(TAG, "--- 右变道执行了 ----")
|
||||
CallerAutoPilotControlManager.sendOperatorChangeLaneRight()
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
Log.e(TAG, "error: ${t.message}, msg-> $msg")
|
||||
}
|
||||
}
|
||||
MSG_WHAT_KEY_CODE_E -> {
|
||||
try {
|
||||
val autoPilotStatusInfo = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo()
|
||||
val parameters = autoPilotStatusInfo.autopilotControlParameters
|
||||
Log.d(TAG, "--- 启动自驾 ----入参:${GsonUtil.jsonFromObject(parameters)}")
|
||||
CallerAutoPilotControlManager.startAutoPilot(parameters)
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
Log.e(TAG, "error: ${t.message}, msg-> $msg")
|
||||
}
|
||||
}
|
||||
MSG_WHAT_KEY_CODE_EL -> {
|
||||
var send = false
|
||||
try {
|
||||
val value = msg.obj as? Double
|
||||
if (value != null && value != 0.0) {
|
||||
send = value != 2.0
|
||||
Log.d(TAG, "--- 长按鸣笛 ---入参:$value")
|
||||
CallerAutoPilotControlManager.sendOperatorSetHorn(value)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
Log.e(TAG, "error: ${t.message}, msg-> $msg")
|
||||
} finally {
|
||||
if (send) {
|
||||
msg.target.sendMessageDelayed(Message.obtain(msg).also { it.obj = 2.0 }, 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
private val handler by lazy {
|
||||
HandlerThread("mf-command-executor").let {
|
||||
it.start()
|
||||
Handler(it.looper, handlerCallback)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun handleSingleClick(keycode: Int) {
|
||||
if (keycode == KeyEvent.KEYCODE_A) {
|
||||
Log.d(TAG, "--- 单机键A --- 加速度每隔500ms减少1 ----")
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_BL)
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_A)
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_AB)
|
||||
handler.sendMessage(Message.obtain().also {
|
||||
it.what = MSG_WHAT_KEY_CODE_A
|
||||
it.obj = -1.0
|
||||
})
|
||||
}
|
||||
if (keycode == KeyEvent.KEYCODE_B) {
|
||||
Log.d(TAG, "--- 单机键B --- 复原 ----")
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_BL)
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_A)
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_AB)
|
||||
try {
|
||||
CallerAutoPilotControlManager.sendOperatorSetAcceleratedSpeed(0.0)
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
if (keycode == KeyEvent.KEYCODE_C) {
|
||||
Log.d(TAG, "--- 单机键C --- 左变道 ----")
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_C)
|
||||
handler.sendMessage(Message.obtain().also {
|
||||
it.what = MSG_WHAT_KEY_CODE_C
|
||||
it.arg1 = -1
|
||||
})
|
||||
}
|
||||
|
||||
if (keycode == KeyEvent.KEYCODE_D) {
|
||||
Log.d(TAG, "--- 单机键D --- 右变道 ----")
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_D)
|
||||
handler.sendMessage(Message.obtain().also {
|
||||
it.what = MSG_WHAT_KEY_CODE_D
|
||||
it.arg1 = 1
|
||||
})
|
||||
}
|
||||
|
||||
if (keycode == KeyEvent.KEYCODE_E) {
|
||||
Log.d(TAG, "--- 单机键E --- 启动自驾 ----")
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_E)
|
||||
handler.sendMessage(Message.obtain().also {
|
||||
it.what = MSG_WHAT_KEY_CODE_E
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun handleLongClick(keyCode: Int) {
|
||||
if (keyCode == KeyEvent.KEYCODE_E) {
|
||||
Log.d(TAG, "--- 长按键E --- 鸣笛 ----")
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_EL)
|
||||
handler.sendMessage(Message.obtain().also {
|
||||
it.what = MSG_WHAT_KEY_CODE_EL
|
||||
it.obj = 1.0
|
||||
})
|
||||
}
|
||||
if (keyCode == KeyEvent.KEYCODE_B) {
|
||||
Log.d(TAG, "--- 长按键B --- 加速度加1 ----")
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_BL)
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_A)
|
||||
handler.removeMessages(MSG_WHAT_KEY_CODE_AB)
|
||||
handler.sendMessage(Message.obtain().also {
|
||||
it.what = MSG_WHAT_KEY_CODE_BL
|
||||
it.obj = 1.0
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun handleCombineClick(vararg keyCodes: Int) {
|
||||
if (isCombineEqual(KeyEvent.KEYCODE_A, KeyEvent.KEYCODE_B, *keyCodes)) {
|
||||
//AB组合键,加速度每隔500毫秒,减小2
|
||||
Log.d(TAG, "---- 组合键AB ---- 按下,加速度每隔500毫秒,减小2 ---")
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
handler.sendMessage(Message.obtain().also {
|
||||
it.what = MSG_WHAT_KEY_CODE_AB
|
||||
it.obj = -2.0
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun isCombineEqual(key1: Int, key2: Int, vararg keyCodes: Int): Boolean {
|
||||
if (keyCodes.size < 2) {
|
||||
return false
|
||||
}
|
||||
val k1 = keyCodes[0]
|
||||
val k2 = keyCodes[1]
|
||||
if ((k1 == key1 && k2 == key2) || (k1 == key2 && k2 == key1)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -1,353 +0,0 @@
|
||||
package com.zhjt.mogo_core_function_devatools.mofang
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
import android.bluetooth.BluetoothDevice
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.view.KeyEvent
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig
|
||||
import com.mogo.eagle.core.data.deva.mofang.MfConstants
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.IMoGoMoFangListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendOperatorChangeLaneLeft
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendOperatorChangeLaneRight
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendOperatorSetAcceleratedSpeed
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.sendOperatorSetHorn
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.startAutoPilot
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager.invokeMoFangStatus
|
||||
import com.mogo.eagle.core.function.call.mofang.CallerMofangListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_F
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import java.util.*
|
||||
|
||||
|
||||
/**
|
||||
* 魔方连接状态和设备管理
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
class MoFangManager private constructor() : IMoGoMoFangListener {
|
||||
|
||||
companion object {
|
||||
val moFangManager: MoFangManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MoFangManager()
|
||||
}
|
||||
}
|
||||
|
||||
private var mContext: Context? = null
|
||||
private val TAG = "MoFangManager"
|
||||
private lateinit var mBluetoothAdapter: BluetoothAdapter
|
||||
private var isMfConnect: Boolean = false //添加状态判断
|
||||
|
||||
private var startPressTime: Long = 0 //开始按键时间
|
||||
private var isPressEnd = false //按键是否结束
|
||||
@Volatile
|
||||
private var isCombinationKey = 0 //是否是组合按键 1单击,2长按,3组合
|
||||
private var pressADownTime: Long = 0
|
||||
private var pressAUpTime: Long = 0
|
||||
private var pressBDownTime: Long = 0
|
||||
private var pressBUpTime: Long = 0
|
||||
private var pressCDownTime: Long = 0
|
||||
private var pressCUpTime: Long = 0
|
||||
private var pressDDownTime: Long = 0
|
||||
private var pressDUpTime: Long = 0
|
||||
private var pressEDownTime: Long = 0
|
||||
private var pressEUpTime: Long = 0
|
||||
|
||||
private val clickTime = 300 //单击
|
||||
private val clickTimeInterval = 330
|
||||
private val longPressTime = 670
|
||||
private val longPressTimeInterval = 700
|
||||
private var timerHorn: Timer? = null
|
||||
private var timerAcc: Timer? = null
|
||||
|
||||
|
||||
fun init(context: Context) {
|
||||
mContext = context
|
||||
initBluetooth(context)
|
||||
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
|
||||
if (!mBluetoothAdapter.isEnabled) {
|
||||
mBluetoothAdapter.enable()
|
||||
}
|
||||
mBluetoothAdapter.startDiscovery()
|
||||
showBondedDevice(mBluetoothAdapter)
|
||||
|
||||
CallerMofangListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
fun release() {
|
||||
CallerMofangListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化蓝牙广播
|
||||
*/
|
||||
private fun initBluetooth(context: Context) {
|
||||
val intentFilter = IntentFilter();
|
||||
// 监视蓝牙关闭和打开的状态
|
||||
intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED)
|
||||
// 监视蓝牙设备与APP连接的状态
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED)
|
||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED)
|
||||
// 注册广播
|
||||
context.registerReceiver(bluetoothMonitorReceiver, intentFilter)
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找蓝牙连接过的蓝牙设备
|
||||
*/
|
||||
private fun showBondedDevice(bluetoothAdapter: BluetoothAdapter) {
|
||||
if (bluetoothAdapter != null) {
|
||||
val deviceList = bluetoothAdapter.bondedDevices
|
||||
for (device in deviceList) {
|
||||
try {
|
||||
//使用反射调用获取设备连接状态方
|
||||
val isConnectedMethod = BluetoothDevice::class.java.getDeclaredMethod("isConnected")
|
||||
isConnectedMethod.isAccessible = true
|
||||
val isConnected = isConnectedMethod.invoke(device) as Boolean
|
||||
d("$M_F${TAG}"," showBondedDevice name = ${device.name} ---address = ${device.address}----isMfConnect = $isMfConnect ---isConnected = $isConnected")
|
||||
if (device.name == "MINI_KEYBOARD") { //并且连接
|
||||
mContext?.let { SharedPrefsMgr.getInstance(it).putString(MfConstants.BLUETOOTH_NAME, device.name) }
|
||||
UiThreadHandler.postDelayed({
|
||||
invokeMoFangStatus(isConnected)
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean(MfConstants.BLUETOOTH_STATUS, isConnected) }
|
||||
if (isConnected) {
|
||||
isMfConnect = true
|
||||
}
|
||||
} catch (e: NoSuchMethodException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private val bluetoothMonitorReceiver: BroadcastReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
when (intent.action) {
|
||||
BluetoothAdapter.ACTION_STATE_CHANGED -> { //中间状态
|
||||
d("$M_F${TAG}","bluetoothMonitorReceiver ACTION_STATE_CHANGED action = ${intent.action}")
|
||||
}
|
||||
|
||||
BluetoothDevice.ACTION_ACL_CONNECTED -> { //蓝牙设备已连接
|
||||
if (!isMfConnect) {
|
||||
// showBondedDevice(mBluetoothAdapter)
|
||||
invokeMoFangStatus(true)
|
||||
isMfConnect = true
|
||||
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean(MfConstants.BLUETOOTH_STATUS, true) }
|
||||
}
|
||||
d("$M_F${TAG}","bluetoothMonitorReceiver ACTION_ACL_CONNECTED ----- isMfConnect = $isMfConnect")
|
||||
}
|
||||
|
||||
BluetoothDevice.ACTION_ACL_DISCONNECTED -> { //蓝牙设备已断开 主动更新
|
||||
d("$M_F${TAG}","bluetoothMonitorReceiver ACTION_ACL_DISCONNECTED ----- isMfConnect = $isMfConnect ")
|
||||
if (isMfConnect) {
|
||||
invokeMoFangStatus(false)
|
||||
isMfConnect = false
|
||||
mContext?.let { SharedPrefsMgr.getInstance(it).putBoolean(MfConstants.BLUETOOTH_STATUS, false) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 魔方按键处理
|
||||
*/
|
||||
override fun onMofangHandle(keyCode: Int, action: Int): Boolean {
|
||||
if(mContext == null){
|
||||
return false
|
||||
}
|
||||
val bluetoothName = SharedPrefsMgr.getInstance(mContext!!).getString(
|
||||
MfConstants.BLUETOOTH_NAME)
|
||||
if (bluetoothName == "MINI_KEYBOARD") {
|
||||
if (!isPressEnd) {
|
||||
isPressEnd = true
|
||||
startPressTime = System.currentTimeMillis()
|
||||
}
|
||||
e(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent ------ bluetoothName = $bluetoothName ---code = $keyCode -----action = $action ---HmiBuildConfig.isShowMfToastView = ${HmiBuildConfig.isShowMfToastView}")
|
||||
if (keyCode == KeyEvent.KEYCODE_A) { //单击 -1,长按无操作,AB组合-2
|
||||
if (action == KeyEvent.ACTION_DOWN) {
|
||||
pressADownTime = System.currentTimeMillis()
|
||||
d(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent A down pressADownTime = " + pressADownTime + "---" + (pressADownTime - startPressTime) + "----isCombinationKey = " + isCombinationKey + "--pressBDownTime = " + pressBDownTime)
|
||||
if (pressADownTime - startPressTime in (clickTimeInterval + 1) until longPressTime && pressBDownTime > 0) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 A 按AB组合 +1 timeInterval: ${pressADownTime - startPressTime}ms---$pressBDownTime")
|
||||
}
|
||||
sendAcc(true, +1.0)
|
||||
isCombinationKey = 3
|
||||
}
|
||||
if (isCombinationKey != 3 && isCombinationKey != 1) {
|
||||
if (pressADownTime - startPressTime > longPressTimeInterval) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 长按A -2 timeInterval: ${pressADownTime - startPressTime}ms")
|
||||
}
|
||||
sendAcc(true, -2.0)
|
||||
isCombinationKey = 2
|
||||
}
|
||||
}
|
||||
} else if (action == KeyEvent.ACTION_UP) {
|
||||
pressAUpTime = System.currentTimeMillis()
|
||||
d(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent A up pressAUpTime = " + pressAUpTime + "---" + (pressAUpTime - startPressTime) + "--pressBDownTime = " + pressBDownTime + "---isCombinationKey = $isCombinationKey")
|
||||
if (pressAUpTime - startPressTime < clickTime && isCombinationKey != 3) {
|
||||
isCombinationKey = 1
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 单击A -1 timeInterval: ${pressAUpTime - startPressTime}ms")
|
||||
}
|
||||
sendAcc(true, -1.0)
|
||||
}
|
||||
pressADownTime = 0
|
||||
isPressEnd = false
|
||||
UiThreadHandler.postDelayed({ isCombinationKey = 0 }, 300)
|
||||
}
|
||||
} else if (keyCode == KeyEvent.KEYCODE_B) { //单击复原,长按+1,AB组合-2
|
||||
if (action == KeyEvent.ACTION_DOWN) {
|
||||
pressBDownTime = System.currentTimeMillis()
|
||||
d(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent B down pressBDownTime = " + pressBDownTime + "--差-" + (pressBDownTime - startPressTime) + "---isCombinationKey = " + isCombinationKey + "--pressADownTime = " + pressADownTime
|
||||
)
|
||||
if (pressBDownTime - startPressTime > clickTimeInterval && pressBDownTime - startPressTime < longPressTime && pressADownTime > 0) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 B 按AB组合 +1 timeInterval: ${pressBDownTime - startPressTime}ms ---pressADownTime = $pressADownTime ")
|
||||
}
|
||||
sendAcc(true, +1.0)
|
||||
isCombinationKey = 3
|
||||
}
|
||||
if (isCombinationKey != 3 && isCombinationKey != 1) {
|
||||
if (pressBDownTime - startPressTime > longPressTimeInterval) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 长按B 无操作 timeInterval: ${pressBDownTime - startPressTime}ms")
|
||||
}
|
||||
isCombinationKey = 2
|
||||
}
|
||||
}
|
||||
} else if (action == KeyEvent.ACTION_UP) {
|
||||
pressBUpTime = System.currentTimeMillis()
|
||||
d(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent B up pressBUpTime = " + pressBUpTime + "--差-" + (pressBUpTime - startPressTime) + "--pressADownTime = " + pressADownTime + "----isCombinationKey = $isCombinationKey")
|
||||
if (pressBUpTime - startPressTime < clickTime && isCombinationKey != 3) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 单击B 0 timeInterval: ${pressBUpTime - startPressTime}ms")
|
||||
}
|
||||
sendAcc(false, 0.0)
|
||||
isCombinationKey = 1
|
||||
}
|
||||
pressBDownTime = 0
|
||||
isPressEnd = false
|
||||
UiThreadHandler.postDelayed({ isCombinationKey = 0 }, 300)
|
||||
}
|
||||
} else if (keyCode == KeyEvent.KEYCODE_C) { //单击左变道,长按无操作
|
||||
if (action == KeyEvent.ACTION_DOWN) {
|
||||
pressCDownTime = System.currentTimeMillis()
|
||||
d(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent 方块 长按C 无操作 time dif = " + (pressCDownTime - startPressTime))
|
||||
if (pressCDownTime - startPressTime > longPressTimeInterval) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 长按C 无操作 timeInterval: ${pressCDownTime - startPressTime}ms")
|
||||
}
|
||||
}
|
||||
} else if (action == KeyEvent.ACTION_UP) {
|
||||
pressCUpTime = System.currentTimeMillis()
|
||||
isPressEnd = false
|
||||
d(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent 方块 单击C ← 向左变道 time dif = " + (pressCUpTime - startPressTime))
|
||||
if (pressCUpTime - startPressTime < clickTime) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 单击C ← 向左变道 timeInterval: ${pressCUpTime - startPressTime}ms")
|
||||
}
|
||||
sendOperatorChangeLaneLeft()
|
||||
}
|
||||
}
|
||||
} else if (keyCode == KeyEvent.KEYCODE_D) { //单击向右变道,双击无操作
|
||||
if (action == KeyEvent.ACTION_DOWN) {
|
||||
pressDDownTime = System.currentTimeMillis()
|
||||
d(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent 方块 长按D 无操作 time dif = " + (pressDDownTime - startPressTime))
|
||||
if (pressDDownTime - startPressTime > longPressTimeInterval) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 长按D 无操作 timeInterval: ${pressDDownTime - startPressTime}ms")
|
||||
}
|
||||
}
|
||||
} else if (action == KeyEvent.ACTION_UP) {
|
||||
pressDUpTime = System.currentTimeMillis()
|
||||
isPressEnd = false
|
||||
d(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent 方块 单击D → 向右变道 time dif = " + (pressDUpTime - startPressTime))
|
||||
if (pressDUpTime - startPressTime < clickTime) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 单击D → 向右变道 timeInterval: ${pressDUpTime - startPressTime}ms")
|
||||
}
|
||||
sendOperatorChangeLaneRight()
|
||||
}
|
||||
}
|
||||
} else if (keyCode == KeyEvent.KEYCODE_E) { //单击启动自驾,长按鸣笛
|
||||
if (action == KeyEvent.ACTION_DOWN) {
|
||||
pressEDownTime = System.currentTimeMillis()
|
||||
d(M_F + "MoFangManager",
|
||||
"dispatchKeyEvent 方块 长按E 鸣笛 time dif = " + (pressEDownTime - startPressTime))
|
||||
if (pressEDownTime - startPressTime > longPressTimeInterval) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 长按E 鸣笛 timeInterval: ${pressEDownTime - startPressTime}ms")
|
||||
}
|
||||
sendOperatorSetHorn(1.0)
|
||||
if (timerHorn == null) {
|
||||
timerHorn = Timer()
|
||||
}
|
||||
timerHorn!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
sendOperatorSetHorn(2.0)
|
||||
timerHorn = null
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
} else if (action == KeyEvent.ACTION_UP) {
|
||||
pressEUpTime = System.currentTimeMillis()
|
||||
isPressEnd = false
|
||||
d(M_F + "MoFangManager",
|
||||
"方块 单击E 开启自动驾驶 time dif = " + (pressEUpTime - startPressTime))
|
||||
if (pressEUpTime - startPressTime < clickTime) {
|
||||
if (HmiBuildConfig.isShowMfToastView) {
|
||||
ToastUtils.showShort("方块 单击E 开启自动驾驶 timeInterval: ${pressEUpTime - startPressTime}ms")
|
||||
}
|
||||
startAutoPilot(getAutoPilotStatusInfo().autopilotControlParameters)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun sendAcc(isSend: Boolean, acc: Double) {
|
||||
if (isSend) {
|
||||
if (timerAcc == null) {
|
||||
timerAcc = Timer()
|
||||
timerAcc!!.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
sendOperatorSetAcceleratedSpeed(acc)
|
||||
}
|
||||
}, 0, 500)
|
||||
}
|
||||
} else {
|
||||
if (timerAcc != null) {
|
||||
timerAcc!!.cancel()
|
||||
timerAcc = null
|
||||
}
|
||||
sendOperatorSetAcceleratedSpeed(acc)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
package com.zhjt.mogo_core_function_devatools.mofang
|
||||
|
||||
import android.app.*
|
||||
import android.bluetooth.*
|
||||
import android.util.*
|
||||
import android.view.*
|
||||
import android.view.Window.Callback
|
||||
import android.widget.Toast
|
||||
import com.mogo.core.mofang.connect.MoFangManager
|
||||
import com.mogo.core.mofang.connect.device.*
|
||||
import com.mogo.core.mofang.connect.listener.*
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.*
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.IMoGoMoFangProvider.OnMoFangStatusListener
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
internal class MoGoMoFangProviderImpl: IMoGoMoFangProvider, OnMoFangDeviceListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MoGoMoFangProviderImpl"
|
||||
}
|
||||
|
||||
private val battery by lazy { AtomicInteger(0) }
|
||||
|
||||
private val listeners by lazy { ConcurrentHashMap<String, OnMoFangStatusListener>() }
|
||||
|
||||
private val executor by lazy { MoFangCommandExecutor() }
|
||||
|
||||
override fun init(app: Application) {
|
||||
MoFangManager.init(MoFangDevice.Builder().application(app).listener(this))
|
||||
}
|
||||
|
||||
override fun connect() {
|
||||
MoFangManager.connect()
|
||||
}
|
||||
|
||||
override fun disconnect() {
|
||||
MoFangManager.disconnect()
|
||||
}
|
||||
|
||||
override fun isConnected(): Boolean {
|
||||
return MoFangManager.isConnected()
|
||||
}
|
||||
|
||||
override fun provideWindowCallback(delegate: Callback?): Callback {
|
||||
val ret = MoFangManager.providerWindowCallback()
|
||||
ret.setDelegate(delegate)
|
||||
return ret
|
||||
}
|
||||
|
||||
override fun registerMoFangStatusListener(tag: String, listener: OnMoFangStatusListener) {
|
||||
listeners[tag] = listener
|
||||
}
|
||||
|
||||
override fun unRegisterMoFangStatusListener(listener: OnMoFangStatusListener) {
|
||||
listeners.entries.find { it.value == listener }?.also { listeners.remove(it.key) }
|
||||
}
|
||||
|
||||
override fun onBluetoothBatteryChanged(battery: Int) {
|
||||
if (this.battery.get() != battery) {
|
||||
UiThreadHandler.post {
|
||||
listeners.values.forEach {
|
||||
it.onMoFangBatteryChanged(battery)
|
||||
}
|
||||
}
|
||||
this.battery.set(battery)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBluetoothConnected(device: BluetoothDevice?) {
|
||||
UiThreadHandler.post {
|
||||
listeners.values.forEach {
|
||||
it.onMoFangConnected()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBluetoothDisconnected(device: BluetoothDevice?, systemOff: Boolean) {
|
||||
UiThreadHandler.post {
|
||||
listeners.values.forEach {
|
||||
it.onMoFangDisconnected()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBluetoothKeyBoardCombineClicked(vararg keyCodes: Int) {
|
||||
try {
|
||||
executor.handleCombineClick(*keyCodes)
|
||||
} finally {
|
||||
UiThreadHandler.post { listeners.values.forEach {
|
||||
it.onMoFangCombineClicked(*keyCodes)
|
||||
} }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onBluetoothKeyBoardLongClicked(keyCode: Int) {
|
||||
try {
|
||||
executor.handleLongClick(keyCode)
|
||||
} finally {
|
||||
UiThreadHandler.post {
|
||||
listeners.values.forEach {
|
||||
it.onMoFangLongClicked(keyCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBluetoothKeyboardClicked(keyCode: Int) {
|
||||
try {
|
||||
executor.handleSingleClick(keyCode)
|
||||
} finally {
|
||||
UiThreadHandler.post {
|
||||
listeners.values.forEach {
|
||||
it.onMoFangClicked(keyCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBluetoothKeyboardEvent(event: KeyEvent) { }
|
||||
|
||||
override fun onBluetoothKeyboardInputInvalid() {
|
||||
Log.d(TAG, "--- onBluetoothKeyboardInputInvalid ---")
|
||||
UiThreadHandler.post {
|
||||
listeners.values.forEach {
|
||||
it.onMoFangStatusError("检测到鹰眼未处于前台, 魔方指令暂不能使用, 请将鹰眼切换到前台运行...")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBluetoothKeyboardInputValid() {
|
||||
Log.d(TAG, "--- onBluetoothKeyboardInputValid ---")
|
||||
}
|
||||
|
||||
override fun onBluetoothOpenAgreed() {
|
||||
Log.d(TAG, "--- onBluetoothOpenAgreed ---")
|
||||
}
|
||||
|
||||
override fun onBluetoothOpenDenied() {
|
||||
Log.d(TAG, "--- onBluetoothOpenDenied ---")
|
||||
}
|
||||
|
||||
override fun onBluetoothSettingRequest() {
|
||||
Log.d(TAG, "--- onBluetoothSettingRequest ---")
|
||||
UiThreadHandler.post {
|
||||
Toast.makeText(Utils.getApp(), "检测到魔方未正确连接,请在系统蓝牙设置页面,找到魔方并配对连接...", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,9 +172,9 @@ internal class WarningFloatWindowHelper(
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||
|
||||
addListener(object : Animator.AnimatorListener {
|
||||
override fun onAnimationRepeat(animation: Animator?) {}
|
||||
override fun onAnimationRepeat(animation: Animator) {}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
config.isAnim = false
|
||||
if (!config.immersionStatusBar) {
|
||||
// 不需要延伸到屏幕外了,防止屏幕旋转的时候,浮窗处于屏幕外
|
||||
@@ -183,9 +183,9 @@ internal class WarningFloatWindowHelper(
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAnimationCancel(animation: Animator?) {}
|
||||
override fun onAnimationCancel(animation: Animator) {}
|
||||
|
||||
override fun onAnimationStart(animation: Animator?) {
|
||||
override fun onAnimationStart(animation: Animator) {
|
||||
floatingView.visibility = View.VISIBLE
|
||||
config.isAnim = true
|
||||
}
|
||||
@@ -216,13 +216,13 @@ internal class WarningFloatWindowHelper(
|
||||
params.flags =
|
||||
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||
animator.addListener(object : Animator.AnimatorListener {
|
||||
override fun onAnimationRepeat(animation: Animator?) {}
|
||||
override fun onAnimationRepeat(animation: Animator) {}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator?) = remove()
|
||||
override fun onAnimationEnd(animation: Animator) = remove()
|
||||
|
||||
override fun onAnimationCancel(animation: Animator?) {}
|
||||
override fun onAnimationCancel(animation: Animator) {}
|
||||
|
||||
override fun onAnimationStart(animation: Animator?) {}
|
||||
override fun onAnimationStart(animation: Animator) {}
|
||||
})
|
||||
animator.start()
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ abstract class AbsLogView : ILogView, TouchProxy.OnTouchEventListener {
|
||||
}
|
||||
systemLayoutParams?.apply {
|
||||
format = PixelFormat.TRANSPARENT
|
||||
gravity = GravityCompat.START or Gravity.TOP
|
||||
gravity = Gravity.START or Gravity.TOP
|
||||
}
|
||||
mLogViewLayoutParams.gravity = GravityCompat.START or Gravity.TOP
|
||||
//动态注册关闭系统弹窗的广播
|
||||
@@ -352,7 +352,7 @@ abstract class AbsLogView : ILogView, TouchProxy.OnTouchEventListener {
|
||||
mWindowManager.updateViewLayout(mRootView, layoutAttrs)
|
||||
}
|
||||
addListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
endMoveAndRecord()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -86,7 +86,7 @@ class M1LookAroundView: SurfaceView, SurfaceHolder.Callback, Runnable, IMoGoChas
|
||||
@Volatile
|
||||
private var data: LookAroundData? = null
|
||||
|
||||
override fun surfaceCreated(holder: SurfaceHolder?) {
|
||||
override fun surfaceCreated(holder: SurfaceHolder) {
|
||||
val old = handler.get()
|
||||
if (old == null) {
|
||||
handler.set(HandlerThread("look-around-drawer").let { it.start(); Handler(it.looper) })
|
||||
@@ -99,12 +99,12 @@ class M1LookAroundView: SurfaceView, SurfaceHolder.Callback, Runnable, IMoGoChas
|
||||
isSurfaceValid = true
|
||||
}
|
||||
|
||||
override fun surfaceChanged(holder: SurfaceHolder?, format: Int, width: Int, height: Int) {
|
||||
override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
|
||||
this.surfaceWidth = width
|
||||
this.surfaceHeight = height
|
||||
}
|
||||
|
||||
override fun surfaceDestroyed(holder: SurfaceHolder?) {
|
||||
override fun surfaceDestroyed(holder: SurfaceHolder) {
|
||||
isSurfaceValid = false
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig
|
||||
@@ -11,11 +12,12 @@ import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig
|
||||
import com.mogo.eagle.core.data.multidisplay.TelematicConstant
|
||||
import com.mogo.eagle.core.data.obu.MogoObuConst
|
||||
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsFuncConfigListener
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.*
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener
|
||||
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.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsFuncConfigListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.*
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuApiManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
@@ -37,7 +39,7 @@ internal class SOPSettingView @JvmOverloads constructor(
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoDevaToolsFuncConfigListener,
|
||||
IViewControlListener {
|
||||
IViewControlListener, IMoGoMoFangProvider.OnMoFangStatusListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "SOPSettingView"
|
||||
@@ -284,6 +286,39 @@ internal class SOPSettingView @JvmOverloads constructor(
|
||||
btnSpeedSet.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
||||
mfStatusLayout.setClickEnabled(false)
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
val mf = CallerDevaToolsManager.mofang()
|
||||
if (mf != null) {
|
||||
mfStatusLayout.setClickEnabled(true)
|
||||
mfStatusLayout.setClickedTextAndTag(if (mf.isConnected()) "断开魔方连接" else "开始连接魔方", if (mf.isConnected()) 0 else 1)
|
||||
mf.registerMoFangStatusListener(TAG, this)
|
||||
mfStatusLayout.setOnClickCallback {
|
||||
val tag = it.tag as? Int
|
||||
if (tag == 0) {
|
||||
//断开魔方连接
|
||||
if (!mf.isConnected()) {
|
||||
Toast.makeText(context, "尚未建立连接", Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickCallback
|
||||
}
|
||||
mfStatusLayout.showLoadingView()
|
||||
mfStatusLayout.setLoadingViewText("正在断开魔方连接, 请稍候...")
|
||||
mf.disconnect()
|
||||
}
|
||||
if (tag == 1) {
|
||||
//建立魔方连接
|
||||
if (mf.isConnected()) {
|
||||
Toast.makeText(context, "已连接,不要重复连接", Toast.LENGTH_SHORT).show()
|
||||
return@setOnClickCallback
|
||||
}
|
||||
mf.connect()
|
||||
mfStatusLayout.showLoadingView()
|
||||
mfStatusLayout.setLoadingViewText("正在连接魔方, 请稍候")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
@@ -317,6 +352,8 @@ internal class SOPSettingView @JvmOverloads constructor(
|
||||
// } catch (e: Exception) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
|
||||
CallerDevaToolsManager.mofang()?.unRegisterMoFangStatusListener(this)
|
||||
}
|
||||
|
||||
// private val timerTaskRefresh = object : TimerTask(){
|
||||
@@ -357,4 +394,30 @@ internal class SOPSettingView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onMoFangConnected() {
|
||||
mfStatusLayout?.also {
|
||||
it.hideLoadingView()
|
||||
it.setClickedTextAndTag("断开魔方连接", 0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoFangDisconnected() {
|
||||
mfStatusLayout?.also {
|
||||
it.hideLoadingView()
|
||||
it.setClickedTextAndTag("开始连接魔方", 1)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoFangBatteryChanged(battery: Int) {
|
||||
}
|
||||
|
||||
override fun onMoFangClicked(keyCode: Int) {}
|
||||
|
||||
override fun onMoFangLongClicked(keyCode: Int) {}
|
||||
|
||||
override fun onMoFangCombineClicked(vararg keyCodes: Int) {}
|
||||
|
||||
override fun onMoFangStatusError(msg: String) {}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.setting
|
||||
|
||||
import android.content.*
|
||||
import android.graphics.*
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.util.*
|
||||
import android.view.*
|
||||
import android.widget.*
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.function.hmi.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
|
||||
class StateViewLayout: ConstraintLayout {
|
||||
|
||||
constructor(context: Context) : this(context, null)
|
||||
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : this(context, attrs, defStyleAttr, 0)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_status_layout, this, true)
|
||||
background = ColorDrawable(Color.GRAY)
|
||||
}
|
||||
|
||||
private val loadingView by lazy { findViewById<View>(R.id.loading_view) }
|
||||
|
||||
private val loadingTextView by lazy { findViewById<TextView>(R.id.loading_text) }
|
||||
|
||||
private val clicked by lazy { findViewById<Button>(R.id.clicked) }
|
||||
|
||||
|
||||
fun showLoadingView() {
|
||||
clicked.visibility = View.INVISIBLE
|
||||
loadingView.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
fun hideLoadingView() {
|
||||
clicked.visibility = View.VISIBLE
|
||||
loadingView.visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
fun setLoadingViewText(text: String) {
|
||||
loadingTextView.text = text
|
||||
}
|
||||
|
||||
fun setClickedTextAndTag(text: String, tag: Int) {
|
||||
clicked.text = text
|
||||
clicked.tag = tag
|
||||
}
|
||||
|
||||
fun setOnClickCallback(block: ((v: View) -> Unit)?) {
|
||||
clicked.onClick {
|
||||
block?.invoke(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun setClickEnabled(enabled: Boolean) {
|
||||
clicked.isEnabled = enabled
|
||||
}
|
||||
}
|
||||
@@ -1,59 +1,72 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.annotation.*
|
||||
import android.content.Context
|
||||
import android.graphics.*
|
||||
import android.graphics.drawable.*
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.RelativeLayout
|
||||
import com.mogo.eagle.core.data.deva.mofang.MfConstants
|
||||
import com.mogo.eagle.core.function.api.devatools.IMoGoDevaToolsListener
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsListenerManager
|
||||
import android.view.*
|
||||
import android.widget.LinearLayout
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.*
|
||||
import com.mogo.eagle.core.function.call.devatools.*
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import kotlinx.android.synthetic.main.view_blue_tooth.view.*
|
||||
|
||||
/**
|
||||
* 魔戒蓝牙控件
|
||||
* 放置于StatusBar右侧位置
|
||||
*/
|
||||
open class BlueToothView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RelativeLayout(context, attrs, defStyleAttr),IMoGoDevaToolsListener {
|
||||
open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListener {
|
||||
|
||||
constructor(context: Context) : this(context, null)
|
||||
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : this(context, attrs, defStyleAttr, 0)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
|
||||
orientation = HORIZONTAL
|
||||
LayoutInflater.from(context).inflate(R.layout.view_blue_tooth
|
||||
, this, true)
|
||||
visibility = View.GONE
|
||||
}
|
||||
|
||||
companion object{
|
||||
private const val TAG = "BlueToothView"
|
||||
}
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_blue_tooth, this, true)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
val isBluetoothConnect =
|
||||
SharedPrefsMgr.getInstance(context).getBoolean(MfConstants.BLUETOOTH_STATUS, false)
|
||||
if (isBluetoothConnect) {
|
||||
mofangStatus(true)
|
||||
}
|
||||
CallerDevaToolsListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun mofangStatus(status: Boolean) {
|
||||
super.mofangStatus(status)
|
||||
ThreadUtils.runOnUiThread {
|
||||
if (status) {
|
||||
mofangView.setImageResource(R.drawable.icon_bluetooth_p)
|
||||
} else {
|
||||
mofangView.setImageResource(R.drawable.blue_tooth)
|
||||
}
|
||||
}
|
||||
val isConnected = CallerDevaToolsManager.mofang()?.isConnected() ?: false
|
||||
visibility = if (isConnected) View.VISIBLE else View.GONE
|
||||
CallerDevaToolsManager.mofang()?.registerMoFangStatusListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerDevaToolsListenerManager.removeListener(TAG)
|
||||
CallerDevaToolsManager.mofang()?.unRegisterMoFangStatusListener(this)
|
||||
}
|
||||
|
||||
override fun onMoFangConnected() {
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun onMoFangDisconnected() {
|
||||
visibility = View.GONE
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onMoFangBatteryChanged(battery: Int) {
|
||||
ivMoFangBattery?.also {
|
||||
if (it.visibility != View.VISIBLE) {
|
||||
it.visibility = View.VISIBLE
|
||||
}
|
||||
it.text = "${battery}%"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoFangClicked(keyCode: Int) {}
|
||||
|
||||
override fun onMoFangLongClicked(keyCode: Int) {}
|
||||
|
||||
override fun onMoFangCombineClicked(vararg keyCodes: Int) {}
|
||||
|
||||
override fun onMoFangStatusError(msg: String) {}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -22,7 +23,6 @@ import com.mogo.commons.module.intent.IntentManager;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener;
|
||||
import com.mogo.eagle.core.function.call.mofang.CallerMofangListenerManager;
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
@@ -30,10 +30,8 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.rousetime.android_startup.model.CostTimesModel;
|
||||
import com.zhjt.service.chain.ChainLog;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -202,21 +200,6 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 魔方按键分发
|
||||
*
|
||||
* @param event
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
if(CallerMofangListenerManager.INSTANCE.invokeMofangHandle(event.getKeyCode(), event.getAction())) {
|
||||
return true;
|
||||
} else {
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkinModeChange(int skinMode) {
|
||||
}
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="@dimen/dp_54"
|
||||
android:layout_height="@dimen/dp_54">
|
||||
tools:layout_width="wrap_content"
|
||||
tools:layout_height="@dimen/dp_54"
|
||||
tools:parentTag="android.widget.LinearLayout"
|
||||
tools:orientation="horizontal"
|
||||
tools:background="@color/black">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/mofangView"
|
||||
android:id="@+id/ivMoFangStatus"
|
||||
android:layout_width="@dimen/dp_54"
|
||||
android:layout_height="@dimen/dp_54"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/blue_tooth"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
</RelativeLayout>
|
||||
<TextView
|
||||
android:id="@+id/ivMoFangBattery"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="12dip"
|
||||
android:textColor="@color/white"
|
||||
android:layout_gravity="bottom"
|
||||
android:visibility="gone"
|
||||
tools:text="18%"/>
|
||||
|
||||
</merge>
|
||||
@@ -336,4 +336,15 @@
|
||||
android:layout_marginStart="10dp"
|
||||
/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.setting.StateViewLayout
|
||||
android:id="@+id/mfStatusLayout"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvSpeedThresholdTitle"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"
|
||||
tools:layout_width="400dp"
|
||||
tools:layout_height="200dp">
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/loading_view"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="0dip"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:gravity="center"
|
||||
tools:visibility="visible"
|
||||
android:visibility="invisible"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loading_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/black"
|
||||
tools:text="正在加载,请稍候..."
|
||||
android:textSize="20dip"/>
|
||||
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyleSmall"
|
||||
android:layout_marginStart="5dip"
|
||||
android:layout_width="30dip"
|
||||
android:layout_height="30dip" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<Button
|
||||
android:id="@+id/clicked"
|
||||
tools:visibility="visible"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="0dip"
|
||||
android:textSize="20dip"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:textColor="@color/black"
|
||||
tools:text="连接魔方"/>
|
||||
</merge>
|
||||
@@ -14,6 +14,7 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.function.api.devatools.apm.*
|
||||
import com.mogo.eagle.core.function.api.devatools.strict.*
|
||||
import com.mogo.eagle.core.function.api.devatools.download.*
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.*
|
||||
import com.mogo.eagle.core.function.api.lookaround.*
|
||||
import com.mogo.eagle.core.function.api.upgrade.*
|
||||
|
||||
@@ -212,4 +213,9 @@ interface IDevaToolsProvider : IProvider {
|
||||
* 360环视数据提供者
|
||||
*/
|
||||
fun lookAroundDataProvider(): IMoGoLookAroundProvider
|
||||
|
||||
/**
|
||||
* 魔方功能提供者
|
||||
*/
|
||||
fun mofang(): IMoGoMoFangProvider
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.mogo.eagle.core.function.api.devatools.mofang
|
||||
|
||||
|
||||
/**
|
||||
* 魔方数据的数据处理
|
||||
* @author lixiaopeng
|
||||
* @date 2023-02-20
|
||||
*/
|
||||
interface IMoGoMoFangListener {
|
||||
/**
|
||||
* 魔方数据的数据处理
|
||||
* @param keyCode 按键类型
|
||||
* @param action 按键状态
|
||||
*/
|
||||
fun onMofangHandle(keyCode: Int, action: Int): Boolean
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.mogo.eagle.core.function.api.devatools.mofang
|
||||
|
||||
import android.app.Application
|
||||
import android.view.*
|
||||
|
||||
interface IMoGoMoFangProvider {
|
||||
|
||||
fun init(app: Application)
|
||||
|
||||
fun connect()
|
||||
|
||||
fun disconnect()
|
||||
|
||||
fun isConnected(): Boolean
|
||||
|
||||
fun provideWindowCallback(delegate: Window.Callback?): Window.Callback
|
||||
|
||||
fun registerMoFangStatusListener(tag: String, listener: OnMoFangStatusListener)
|
||||
|
||||
fun unRegisterMoFangStatusListener(listener: OnMoFangStatusListener)
|
||||
|
||||
/**
|
||||
* 魔方状态监听器
|
||||
*/
|
||||
interface OnMoFangStatusListener {
|
||||
|
||||
/**
|
||||
* 魔方已连接
|
||||
*/
|
||||
fun onMoFangConnected()
|
||||
|
||||
/**
|
||||
* 魔方断开连接了
|
||||
*/
|
||||
fun onMoFangDisconnected()
|
||||
|
||||
/**
|
||||
* 魔方电量变化了
|
||||
*/
|
||||
fun onMoFangBatteryChanged(battery: Int)
|
||||
|
||||
/**
|
||||
* 魔方单键点击了
|
||||
*/
|
||||
fun onMoFangClicked(keyCode: Int)
|
||||
|
||||
/**
|
||||
* 魔方单键长按了
|
||||
*/
|
||||
fun onMoFangLongClicked(keyCode: Int)
|
||||
|
||||
/**
|
||||
* 魔方触发了组合键
|
||||
*/
|
||||
fun onMoFangCombineClicked(vararg keyCodes: Int)
|
||||
|
||||
/**
|
||||
* 魔方状态异常
|
||||
*/
|
||||
fun onMoFangStatusError(msg: String)
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.function.api.devatools.IDevaToolsProvider
|
||||
import com.mogo.eagle.core.function.api.devatools.apm.*
|
||||
import com.mogo.eagle.core.function.api.devatools.download.*
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.*
|
||||
import com.mogo.eagle.core.function.api.upgrade.*
|
||||
import com.mogo.eagle.core.function.api.devatools.strict.*
|
||||
import com.mogo.eagle.core.function.api.lookaround.*
|
||||
@@ -258,4 +259,6 @@ object CallerDevaToolsManager {
|
||||
fun strict(): IStrictModeProvider? = devaToolsProviderApi?.strict()
|
||||
|
||||
fun lookAroundProvider(): IMoGoLookAroundProvider? = devaToolsProviderApi?.lookAroundDataProvider()
|
||||
|
||||
fun mofang(): IMoGoMoFangProvider? = devaToolsProviderApi?.mofang()
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.mogo.eagle.core.function.call.mofang
|
||||
|
||||
import com.mogo.eagle.core.function.api.devatools.mofang.IMoGoMoFangListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
|
||||
/**
|
||||
* 魔方按键的处理
|
||||
*/
|
||||
object CallerMofangListenerManager : CallerBase<IMoGoMoFangListener>() {
|
||||
fun invokeMofangHandle(keyCode: Int, action: Int): Boolean {
|
||||
var isConsume = false
|
||||
M_LISTENERS.forEach {
|
||||
val tag = it.key
|
||||
val listener = it.value
|
||||
if (listener.onMofangHandle(keyCode, action))
|
||||
isConsume = true
|
||||
}
|
||||
return isConsume
|
||||
}
|
||||
|
||||
}
|
||||
@@ -57,7 +57,7 @@ val <T: View> T.lifecycleOwner: LifecycleOwner
|
||||
|
||||
|
||||
addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: View?) {
|
||||
override fun onViewAttachedToWindow(v: View) {
|
||||
lifecycle.let {
|
||||
if (it.currentState.isAtLeast(Lifecycle.State.INITIALIZED)) {
|
||||
it.currentState = Lifecycle.State.CREATED
|
||||
@@ -73,7 +73,7 @@ val <T: View> T.lifecycleOwner: LifecycleOwner
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewDetachedFromWindow(v: View?) {
|
||||
override fun onViewDetachedFromWindow(v: View) {
|
||||
lifecycle.let {
|
||||
if (it.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
|
||||
this@lifecycleOwner.removeOnAttachStateChangeListener(this)
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.elegant.utils.IOUtils;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -648,6 +649,8 @@ public class BitmapHelper {
|
||||
retriever.release();
|
||||
} catch ( RuntimeException e ) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return b;
|
||||
|
||||
@@ -15,6 +15,9 @@ LancetX {
|
||||
textview_opt {
|
||||
enable true
|
||||
}
|
||||
window_callback {
|
||||
enable true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
if (!rootProject.isReleaseBuild()) {
|
||||
apply plugin: 'bytex.matrix'
|
||||
matrix {
|
||||
trace {
|
||||
enable = true //if you don't want to use trace canary, set false
|
||||
baseMethodMapFile = "${project.buildDir}/matrix_output/customMethodMapping.txt"
|
||||
blackListFile = "${project.projectDir}/matrixTrace/blackMethodList.txt"
|
||||
}
|
||||
logLevel = "D"
|
||||
}
|
||||
// apply plugin: 'bytex.matrix'
|
||||
// matrix {
|
||||
// trace {
|
||||
// enable = true //if you don't want to use trace canary, set false
|
||||
// baseMethodMapFile = "${project.buildDir}/matrix_output/customMethodMapping.txt"
|
||||
// blackListFile = "${project.projectDir}/matrixTrace/blackMethodList.txt"
|
||||
// }
|
||||
// logLevel = "D"
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user