[dev_arch_opt_3.0]

[Change]
[
1、关闭一些狂刷的日志
2、增加EB5获取SN的方法,但系统有限制,需要先adb root ;setenforce 0 ,需要等系统厂商修改下
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-02-08 20:47:16 +08:00
parent bc83dd608e
commit 89b038054d
11 changed files with 100 additions and 28 deletions

View File

@@ -37,7 +37,7 @@ public class V2XAlarmServer {
CopyOnWriteArrayList<V2XRoadEventEntity> v2XRoadEventEntityList,
MogoLocation currentLocation) {
try {
Logger.d(TAG, "getDriveFrontAlarmEvent --- 1 ---" + currentLocation );
//Logger.d(TAG, "getDriveFrontAlarmEvent --- 1 ---" + currentLocation );
if (!showedEvents.isEmpty()) {
Iterator<V2XRoadEventEntity> iterator = showedEvents.iterator();
while (iterator.hasNext()) {
@@ -54,18 +54,18 @@ public class V2XAlarmServer {
}
}
}
Logger.d(TAG, "getDriveFrontAlarmEvent --- 2 ---" + currentLocation);
//Logger.d(TAG, "getDriveFrontAlarmEvent --- 2 ---" + currentLocation);
if (currentLocation != null && v2XRoadEventEntityList != null) {
// 因为集合是按照距离排序后的所以这里检索出来第一个就发出警告
for (V2XRoadEventEntity v2XRoadEventEntity : v2XRoadEventEntityList) {
// 0、道路事件必须有朝向角度>=0;
Logger.d(TAG, "entity:" + v2XRoadEventEntity.getLocation());
//Logger.d(TAG, "entity:" + v2XRoadEventEntity.getLocation());
if (v2XRoadEventEntity.getLocation().getAngle() >= 0) {
// 计算车辆距离指定气泡的距离
MarkerLocation eventLocation = v2XRoadEventEntity.getLocation();
// 1、判断是否到达了触发距离,20 ~ 500,
double distance = v2XRoadEventEntity.getDistance();
Logger.d(TAG, "distance:" + distance);
//Logger.d(TAG, "distance:" + distance);
if (distance <= 500) {
if (EventTypeEnumNew.GHOST_PROBE.getPoiType().equals(v2XRoadEventEntity.getPoiType())) {
if (distance > 25) {
@@ -76,7 +76,7 @@ public class V2XAlarmServer {
double carBearing = currentLocation.getHeading();
double eventBearing = eventLocation.getAngle();
double diffAngle = DrivingDirectionUtils.getAngleDiff(carBearing, eventBearing);
Logger.d(TAG, "car_bearing:" + carBearing + ",eventBearing:" + eventBearing + ",diffAngle:" + diffAngle);
//Logger.d(TAG, "car_bearing:" + carBearing + ",eventBearing:" + eventBearing + ",diffAngle:" + diffAngle);
if (diffAngle <= 20) {
// 3、计算当前车辆行驶方向与事件位置之间夹角《20度保证道路事件在车辆前方
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
@@ -87,12 +87,12 @@ public class V2XAlarmServer {
(int) currentLocation.getHeading()
);
Logger.d(TAG, "eventAngle:" + eventAngle);
//Logger.d(TAG, "eventAngle:" + eventAngle);
if (0 <= eventAngle && eventAngle <= 20) {
if (showedEvents.contains(v2XRoadEventEntity)) {
return null;
}
Logger.d(TAG, "showed---");
//Logger.d(TAG, "showed---");
showedEvents.add(v2XRoadEventEntity);
return v2XRoadEventEntity;
}

View File

@@ -209,7 +209,7 @@ object V2XManager {
if (!started.get()) {
return
}
V2XLogger.d(TAG, "--- onLocationChanged --[longitude: $longitude, latitude: $latitude]")
//V2XLogger.d(TAG, "--- onLocationChanged --[longitude: $longitude, latitude: $latitude]")
realLongitude.set(longitude)
realLatitude.set(latitude)
val oldLon = lastLongitude.get()

View File

@@ -15,26 +15,26 @@ import java.lang.reflect.Method;
public class DevicesUtils {
private static final String PROPERTIES = "android.os.SystemProperties";
private static final String GSM_SERIAL = "gsm.serial";
private static final String GSM_SERIAL = "persist.device.sn";
private static final String GET = "get";
public static String getSn(){
public static String getSn() {
return getSystemProperties(GSM_SERIAL);
}
public static String getSystemProperties(String name ) {
public static String getSystemProperties(String name) {
String value = "";
try {
Class< ? > c = Class.forName( PROPERTIES );
Method get = c.getMethod( GET, String.class );
value = (String) get.invoke( c, name );
} catch ( ClassNotFoundException var3 ) {
Class<?> c = Class.forName(PROPERTIES);
Method get = c.getMethod(GET, String.class);
value = (String) get.invoke(c, name);
} catch (ClassNotFoundException var3) {
var3.printStackTrace();
} catch ( NoSuchMethodException var4 ) {
} catch (NoSuchMethodException var4) {
var4.printStackTrace();
} catch ( InvocationTargetException var5 ) {
} catch (InvocationTargetException var5) {
var5.printStackTrace();
} catch ( IllegalAccessException var6 ) {
} catch (IllegalAccessException var6) {
var6.printStackTrace();
}
return value;

View File

@@ -8,7 +8,6 @@ import android.os.Build;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import java.lang.reflect.Field;
@@ -154,6 +153,10 @@ public class TelephoneUtil {
if (TextUtils.isEmpty(serial)) {
serial = (String) get.invoke(c, "ro.serialno");
}
if (TextUtils.isEmpty(serial)) {
serial = (String) get.invoke(c, "persist.device.sn");
}
} catch (Exception e) {
e.printStackTrace();
}

View File

@@ -554,7 +554,7 @@ public final class DeviceUtils {
* @return 当前EB5设备SN
*/
public static String getEB5DevicesSN() {
ShellUtils.CommandResult result = UtilsBridge.execCmd("getprop persist.device.sn", false);
ShellUtils.CommandResult result = UtilsBridge.execCmd("adb shell getprop persist.device.sn", false);
if (result.result == 0) {
LogUtils.d("", result.toString());
}

View File

@@ -0,0 +1,35 @@
package com.mogo.eagle.core.utilcode.util;
import java.lang.reflect.Method;
/**
* Android API从21后开始不再直接支持通过SystemProperties.get/set方式来获取/设置系统属性。
* 通过反射方式来进行系统属性操作,代码如下:
*/
public final class SystemPropertiesUtils {
private static final String CLASS_NAME = "android.os.SystemProperties";
public static String getProperty(String key, String defaultValue) {
String value = defaultValue;
try {
Class<?> c = Class.forName(CLASS_NAME);
Method get = c.getMethod("get", String.class, String.class);
value = (String) (get.invoke(c, key, defaultValue));
} catch (Exception e) {
e.printStackTrace();
} finally {
return value;
}
}
public static void setProperty(String key, String value) {
try {
Class<?> c = Class.forName(CLASS_NAME);
Method set = c.getMethod("set", String.class, String.class);
set.invoke(c, key, value);
} catch (Exception e) {
e.printStackTrace();
}
}
}