[3.4.0-map-sdk] code safe

This commit is contained in:
zhongchao
2023-09-22 11:37:06 +08:00
parent b3da6ab1ac
commit f7ac138d73
9 changed files with 42 additions and 39 deletions

View File

@@ -138,7 +138,7 @@ class SoftControlViewModel : ViewModel(), LightAirconditionDoorCallback {
*/
fun openAndSetAircondition(modeCmd: Int, windSpeedCmd: Int, temperatureCmd: Int) {
CallerLogger.d(
M_BUS_P + TAG, "" + "打开空调,模式$modeCmd--档位${windSpeedCmd}--温度:$temperatureCmd"
M_BUS_P + TAG, "打开空调,模式$modeCmd--档位${windSpeedCmd}--温度:$temperatureCmd"
)
CallerAutoPilotControlManager.sendRoboBusJinlvM1AirConditionerCmd(
1, modeCmd, windSpeedCmd, temperatureCmd

View File

@@ -694,7 +694,7 @@ final class DiskLruCache implements Closeable {
private void validateKey(String key) {
Matcher matcher = LEGAL_KEY_PATTERN.matcher(key);
if (!matcher.matches()) {
throw new IllegalArgumentException("keys must match regex [a-z0-9_-]{1,64}: \"" + key + "\"");
throw new IllegalArgumentException("keys must match regex [a-z0-9_-]{1,64}: " + key);
}
}
@@ -964,11 +964,11 @@ final class DiskLruCache implements Closeable {
}
public File getCleanFile(int i) {
return new File(directory, key + "" + i);
return new File(directory, key + i);
}
public File getDirtyFile(int i) {
return new File(directory, key + "" + i + ".tmp");
return new File(directory, key + i + ".tmp");
}
}
}

View File

@@ -35,7 +35,7 @@ public class CrashSystem implements UncaughtExceptionHandler {
private String mOsVersion = null;
private String mDeviceId = null;
private UncaughtExceptionHandler mDefaultHandler;
private final Map<String, String> info = new HashMap();
private final Map<String, String> info = new HashMap<>();
private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
private boolean mDebug = false;
private final List<CrashCallback> callbackList = new ArrayList<>();
@@ -109,15 +109,13 @@ public class CrashSystem implements UncaughtExceptionHandler {
}
private boolean handleException(Throwable ex) {
if(ex == null) {
return true;
} else {
if (ex != null) {
String msg = ex.getLocalizedMessage();
Log.e("CrashSystem", msg);
String filePath = saveCrashInfo2File(ex);
Log.i(TAG, "handleException: filePath = " + filePath);
return true;
}
return true;
}
private String saveCrashInfo2File(Throwable ex) {
@@ -148,7 +146,7 @@ public class CrashSystem implements UncaughtExceptionHandler {
result = entry.getValue();
sb.append(key).append("=").append(result).append("\n");
}
sb.append("TIME=").append(String.valueOf(System.currentTimeMillis())).append("\n");
sb.append("TIME=").append(System.currentTimeMillis()).append("\n");
sb.append("fileName=").append(fileName).append("\n");
Writer writer = new StringWriter();
PrintWriter pw = new PrintWriter(writer);
@@ -187,7 +185,7 @@ public class CrashSystem implements UncaughtExceptionHandler {
PackageManager pm = context.getPackageManager();
try {
PackageInfo packageInfo = pm.getPackageInfo(this.mAppPackage, 0);
this.mAppVersionCode = "" + packageInfo.versionCode;
this.mAppVersionCode = String.valueOf(packageInfo.versionCode);
this.mAppVersionName = packageInfo.versionName;
this.mAppPackage = packageInfo.packageName;
this.mAppName = packageInfo.applicationInfo.loadLabel(context.getPackageManager()).toString();

View File

@@ -60,11 +60,11 @@ class IdentifyOriginDataDrawer : Identify {
//清除缓存
for (data in resultList) {
if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains("" + data.uuid)) {
if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains(data.uuid.toString())) {
if (TrackerSourceFilterHelper.filterData(data)) {
continue
}
trafficDataUuidList.remove("" + data.uuid)
trafficDataUuidList.remove(data.uuid.toString())
}
}
@@ -100,7 +100,7 @@ class IdentifyOriginDataDrawer : Identify {
continue
}
var temp: TrackedObject = data
val uuid = "" + data.uuid
val uuid = data.uuid.toString()
val cacheData = mMarkersCaches[uuid]
if (cacheData != null) {
val color = TrackerSourceFilterHelper.getDefaultColor(data)

View File

@@ -1,11 +1,13 @@
package com.mogo.eagle.core.function.business.identify;
import android.annotation.SuppressLint;
import android.os.Build;
import android.util.ArraySet;
import androidx.annotation.RequiresApi;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.eagle.core.data.traffic.TrafficData;
import com.mogo.eagle.core.utilcode.geometry.S2CellId;
import com.mogo.eagle.core.utilcode.geometry.S2LatLng;
@@ -71,13 +73,13 @@ public class TrackManager {
public HashMap<String, MessagePad.TrackedObject> filterTrafficData(List<MessagePad.TrackedObject> trafficData) {
//清空上次返回数据,做到缓存复用
mFilterTrafficData.clear();
long cost = System.currentTimeMillis();
// long cost = System.currentTimeMillis();
//进入过滤机制的感知物体,首先从缓存队列中进行查找 uuid
for (MessagePad.TrackedObject data : trafficData) {
if (TrackerSourceFilterHelper.INSTANCE.filterData(data)) {
continue;
}
String uuid = "" + data.getUuid();
String uuid = Integer.toString(data.getUuid());
TrackObj trackObj = mMarkersCaches.get(uuid);
String color = TrackerSourceFilterHelper.INSTANCE.getDefaultColor(data);
@@ -93,24 +95,26 @@ public class TrackManager {
if (cellIdCaches.containsValue(pos)) {
String findSameValue = cellIdCaches.inverse().get(pos);
//uuid处理
data = data.toBuilder().setUuid(Integer.parseInt(findSameValue)).build();
TrackObj cacheTrack = mMarkersCaches.get(findSameValue);
if (cacheTrack != null) {
trackObj = cacheTrack;
MessagePad.TrackedObject cache = cacheTrack.getCache();
if (cache != null) {
//相对静止物体 感知融合同位置物体,使用缓存数据做覆盖
if (cacheTrack.relativeStatic()) {
if (data.getColor() != null && !data.getColor().isEmpty()) {
cache = cache.toBuilder().setColor(data.getColor()).build();
if(findSameValue != null && !findSameValue.isEmpty()){
data = data.toBuilder().setUuid(Integer.parseInt(findSameValue)).build();
TrackObj cacheTrack = mMarkersCaches.get(findSameValue);
if (cacheTrack != null) {
trackObj = cacheTrack;
MessagePad.TrackedObject cache = cacheTrack.getCache();
if (cache != null) {
//相对静止物体 感知融合同位置物体,使用缓存数据做覆盖
if (cacheTrack.relativeStatic()) {
if (data.getColor() != null && !data.getColor().isEmpty()) {
cache = cache.toBuilder().setColor(data.getColor()).build();
}
data = cache;
}
data = cache;
}
uuid = findSameValue;
trackObj.updateObj(data);
} else {
trackObj = new TrackObj(data,s2CellId,s2LatLng);
}
uuid = findSameValue;
trackObj.updateObj(data);
} else {
trackObj = new TrackObj(data,s2CellId,s2LatLng);
}
} else {
trackObj = new TrackObj(data,s2CellId,s2LatLng);
@@ -128,7 +132,7 @@ public class TrackManager {
public void clearCache(List<MessagePad.TrackedObject> resultList) {
//过滤现有元素
for (MessagePad.TrackedObject data : resultList) {
String uuid = "" + data.getUuid();
String uuid = Integer.toString(data.getUuid());
if (trafficDataUuid.size() > 0 && trafficDataUuid.contains(uuid)) {
if (TrackerSourceFilterHelper.INSTANCE.filterData(data)) {
continue;
@@ -154,6 +158,7 @@ public class TrackManager {
.removeMarker(key);
}
@RequiresApi(api = Build.VERSION_CODES.N)
public void clearAll() {
cellIdCaches.clear();
trafficDataUuid.clear();

View File

@@ -41,7 +41,7 @@ object WarningHelper {
return
}
planningObjects.forEach(Consumer { planningObj: PlanningObject ->
val trackId = "" + planningObj.uuid
val trackId = planningObj.uuid.toString()
if (mMarkersCaches.containsKey(trackId)) {
mMarkersCaches[trackId] ?: return@Consumer
if (planningObj.type == 0) { //0是leading障碍物障碍物车身红色提示
@@ -72,7 +72,7 @@ object WarningHelper {
return
}
planningObjects.forEach(Consumer { planningObj: PlanningObject ->
val trackId = "" + planningObj.uuid
val trackId = planningObj.uuid.toString()
if (mMarkersCaches.containsKey(trackId)) {
mMarkersCaches[trackId] ?: return@Consumer
if (planningObj.type == 0) { //0是leading障碍物障碍物车身红色提示

View File

@@ -964,11 +964,11 @@ final class DiskLruCache implements Closeable {
}
public File getCleanFile(int i) {
return new File(directory, key + "" + i);
return new File(directory, key + i);
}
public File getDirtyFile(int i) {
return new File(directory, key + "" + i + ".tmp");
return new File(directory, key + i + ".tmp");
}
}
}

View File

@@ -665,7 +665,7 @@ public final class DiskLruCache implements Closeable {
Matcher matcher = LEGAL_KEY_PATTERN.matcher(key);
if (!matcher.matches()) {
throw new IllegalArgumentException("keys must match regex "
+ STRING_KEY_PATTERN + ": \"" + key + "\"");
+ STRING_KEY_PATTERN + ": " + key);
}
}

View File

@@ -310,7 +310,7 @@ public final class UriUtils {
InputStream is = null;
try {
is = Utils.getApp().getContentResolver().openInputStream(uri);
File file = new File(Utils.getApp().getCacheDir(), "" + System.currentTimeMillis());
File file = new File(Utils.getApp().getCacheDir(), String.valueOf(System.currentTimeMillis()));
UtilsBridge.writeFileFromIS(file.getAbsolutePath(), is);
return file;
} catch (FileNotFoundException e) {