[sonar] fix

This commit is contained in:
zhongchao
2023-10-18 19:42:58 +08:00
parent 523ae08c5a
commit c265850024
24 changed files with 91 additions and 139 deletions

View File

@@ -29,6 +29,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.function.biz.v2x.v2n.utils.V2XEventAnalyticsManager;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
@@ -68,7 +69,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoChas
if (mMarkerEntity != null) {
CallerLogger.d(M_V2X + TAG, "----- show --- 2 --:\n" + mMarkerEntity);
String v2xType = getV2XTypeForFrontWarning(mMarkerEntity);
V2XMessageEntity entity = getV2XMessageEntity();
// V2XMessageEntity entity = getV2XMessageEntity();
if (!v2xType.equals("0")) {
if (getAlertContentForFrontWarning(mMarkerEntity).toString() == null
|| getAlertContentForFrontWarning(mMarkerEntity).toString().isEmpty()
@@ -112,8 +113,8 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoChas
private CharSequence getAlertContentForFrontWarning(V2XWarningTarget entity) {
double dis = entity.getDistance();
//距离四舍五入保留整数
BigDecimal bg = new BigDecimal(dis);
double disBig = bg.setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue();
BigDecimal bg = BigDecimal.valueOf(dis);
double disBig = bg.setScale(0, RoundingMode.HALF_UP).doubleValue();
String distance = String.format(Locale.getDefault(), "%.0f", disBig) + "";
String content = entity.getWarningContent();
SpannableStringBuilder ssb = new SpannableStringBuilder(content + distance);

View File

@@ -48,10 +48,10 @@ public class CaseTopicListDialog extends Dialog implements IMoGoAutopilotRecordL
private RecyclerView rvTopicList;
private TopicListAdapter topicListAdapter;
private String searchStr;
private List<TopicEntity> allTopicList = new ArrayList<>();
private final List<TopicEntity> allTopicList = new ArrayList<>();
private RecordTypeEntity recordType;
private List<String> addTopicList = new ArrayList<>();
private List<TopicEntity> searchTopicList = new ArrayList<>();
private final List<String> addTopicList = new ArrayList<>();
private final List<TopicEntity> searchTopicList = new ArrayList<>();
public CaseTopicListDialog(@NonNull Context context) {
super(context, R.style.bad_case_dialog);

View File

@@ -60,8 +60,10 @@ public class RemoteUserServiceImp extends Binder implements IUserInterface {
String _arg0;
_arg0 = data.readString();
String _result = this.exec(_arg0);
reply.writeNoException();
reply.writeString(_result);
if (reply != null) {
reply.writeNoException();
reply.writeString(_result);
}
return true;
default:
return super.onTransact(code, data, reply, flags);

View File

@@ -249,11 +249,7 @@ public class LogItemAdapter extends AbsRecyclerAdapter<AbsViewBinder<LogLine>, L
protected void publishResults(CharSequence constraint, FilterResults results) {
//noinspection unchecked
mList = (List<LogLine>) results.values;
if (results.count > 0) {
notifyDataSetChanged();
} else {
notifyDataSetChanged();
}
notifyDataSetChanged();
}
}
}

View File

@@ -25,6 +25,7 @@ public class LogLine {
"\\): ");
private static final String filterPattern = "ResourceType|memtrack|android.os.Debug|BufferItemConsumer|DPM.*|MDM.*|ChimeraUtils|BatteryExternalStats.*|chatty.*|DisplayPowerController|WidgetHelper|WearableService|DigitalWidget.*|^ANDR-PERF-.*";
private static final String failPattern = "^maxLineHeight.*|Failed to read.*";
private int logLevel;
private String tag;
private String logOutput;
@@ -57,7 +58,7 @@ public class LogLine {
char logLevelChar = matcher.group(1).charAt(0);
String logText = originalLine.substring(matcher.end());
if (logText.matches("^maxLineHeight.*|Failed to read.*")) {
if (logText.matches(failPattern)) {
logLine.setLogLevel(convertCharToLogLevel('V'));
} else {
logLine.setLogLevel(convertCharToLogLevel(logLevelChar));

View File

@@ -120,10 +120,12 @@ public class TrackManager {
trackObj = new TrackObj(data,s2CellId,s2LatLng);
}
}
mFilterTrafficData.put(uuid, trackObj.getCache());
cellIdCaches.forcePut(uuid, trackObj.getCellIdPos());
mMarkersCaches.put(uuid, trackObj);
trafficDataUuid.add(uuid);
if(trackObj != null){
mFilterTrafficData.put(uuid, trackObj.getCache());
cellIdCaches.forcePut(uuid, trackObj.getCellIdPos());
mMarkersCaches.put(uuid, trackObj);
trafficDataUuid.add(uuid);
}
//Log.i("costTime","" + (System.currentTimeMillis() - cost));
}
return mFilterTrafficData;

View File

@@ -1,4 +1,4 @@
package com.mogo.eagle.core.function.smp;
package com.mogo.eagle.core.function.utils;
import com.mogo.eagle.core.data.map.MogoLatLng;
@@ -6,7 +6,6 @@ import java.util.List;
public class RoutePathConvertUtils {
public List<MogoLatLng> routeList;
public int ROUTE_LEFT = 1;
@@ -21,7 +20,7 @@ public class RoutePathConvertUtils {
double v1x = latLng1.lat - latLng0.lat;
double v1y = latLng1.lon - latLng0.lon;
double v2x = latLng2.lat - latLng1.lat;
double v2y = latLng2.lon - latLng2.lon;
double v2y = latLng2.lon - latLng1.lon;
double r = v1x* v2y - v1y*v2x;
if (r > 0.0){
route_direction = ROUTE_LEFT;

View File

@@ -898,14 +898,6 @@ enum class EventTypeEnumNew(
TYPE_ERROR_WEAKNESS.poiType ->{
TYPE_ERROR_WEAKNESS.poiTypeStr
}
//学校
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType ->{
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiTypeStr
}
//禁止停车
TYPE_USECASE_ID_ROAD_NO_PARKING.poiType ->{
TYPE_USECASE_ID_ROAD_NO_PARKING.poiTypeStr
}
//超速行驶
TYPE_USECASE_ID_SLW.poiType ->{
TYPE_USECASE_ID_SLW.poiTypeStr
@@ -918,10 +910,6 @@ enum class EventTypeEnumNew(
TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType ->{
TYPE_USECASE_ID_BREAKDOWN_WARNING.poiTypeStr
}
//道路积水
FOURS_PONDING.poiType ->{
FOURS_PONDING.poiTypeStr
}
//异常停车
TYPE_USECASE_ID_ROAD_PARKING.poiType ->{
TYPE_USECASE_ID_ROAD_PARKING.poiTypeStr
@@ -1093,10 +1081,6 @@ enum class EventTypeEnumNew(
FOURS_BLOCK_UP.poiType -> {
R.drawable.icon_warning_v2x_congestion
}
//积水
FOURS_PONDING.poiType -> {
R.drawable.v2x_icon_jishui_vr
}
//结冰
FOURS_ICE.poiType -> {
R.drawable.v2x_icon_jiebing_vr
@@ -1210,9 +1194,6 @@ enum class EventTypeEnumNew(
TYPE_ERROR_WEAKNESS.poiType -> {
R.drawable.icon_warning_v2x_abnormal_vehicle
}
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiTypeSrcVr
TYPE_USECASE_ID_ROAD_NO_PARKING.poiType -> TYPE_USECASE_ID_ROAD_NO_PARKING.poiTypeSrcVr
TYPE_USECASE_ID_SLW.poiType -> TYPE_USECASE_ID_SLW.poiTypeSrcVr
TYPE_USECASE_ID_TJW.poiType -> TYPE_USECASE_ID_TJW.poiTypeSrcVr
TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType -> TYPE_USECASE_ID_BREAKDOWN_WARNING.poiTypeSrcVr
@@ -1232,13 +1213,13 @@ enum class EventTypeEnumNew(
TYPE_VEHICLE_QUEUE.poiType -> TYPE_VEHICLE_QUEUE.poiTypeSrcVr
TYPE_NO_PASSING.poiType -> TYPE_NO_PASSING.poiTypeSrcVr
TYPE_NO_TURNING_AROUND.poiType -> TYPE_NO_TURNING_AROUND.poiTypeSrcVr
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiTypeSrcVr
TYPE_USECASE_ID_ROAD_NO_PARKING.poiType -> TYPE_USECASE_ID_ROAD_NO_PARKING.poiTypeSrcVr
TYPE_USECASE_ID_ROAD_NO_TOOTING.poiType -> TYPE_USECASE_ID_ROAD_NO_TOOTING.poiTypeSrcVr
TYPE_USECASE_ID_ROAD_SPEED_LIMIT.poiType -> TYPE_USECASE_ID_ROAD_SPEED_LIMIT.poiTypeSrcVr
TYPE_USECASE_ID_BUS_WARNING.poiType -> TYPE_USECASE_ID_BUS_WARNING.poiTypeSrcVr
TYPE_USECASE_ID_NARROW_RIGHT.poiType -> TYPE_USECASE_ID_NARROW_RIGHT.poiTypeSrcVr
TYPE_USECASE_ID_GAS_STATION.poiType -> TYPE_USECASE_ID_GAS_STATION.poiTypeSrcVr
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiTypeSrcVr
TYPE_USECASE_ID_ACCIDENT.poiType -> TYPE_USECASE_ID_ACCIDENT.poiTypeSrcVr
TYPE_ATTENTION_CONFLUENCE.poiType -> TYPE_ATTENTION_CONFLUENCE.poiTypeSrcVr
TYPE_PEDESTRIAN_CROSSING.poiType -> TYPE_PEDESTRIAN_CROSSING.poiTypeSrcVr
@@ -1284,18 +1265,12 @@ enum class EventTypeEnumNew(
TYPE_ERROR.poiType -> TYPE_ERROR.content
TYPE_OPTIMAL_ROUTE_RECOMMEND.poiType -> TYPE_OPTIMAL_ROUTE_RECOMMEND.content
GHOST_PROBE.poiType -> GHOST_PROBE.content
TYPE_USECASE_ID_IVP_RED.poiType -> TYPE_USECASE_ID_IVP_RED.content
TYPE_USECASE_ID_IVP_GREEN.poiType -> TYPE_USECASE_ID_IVP_GREEN.content
TYPE_USECASE_ID_VRUCW_PERSON.poiType -> TYPE_USECASE_ID_VRUCW_PERSON.content
TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.poiType -> TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.content
TYPE_USECASE_ID_VRUCW_NOT_MOTOR_VEHICLES.poiType -> TYPE_USECASE_ID_VRUCW_NOT_MOTOR_VEHICLES.content
TYPE_ERROR_WEAKNESS.poiType -> TYPE_ERROR_WEAKNESS.content
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.content
TYPE_USECASE_ID_ROAD_NO_PARKING.poiType -> TYPE_USECASE_ID_ROAD_NO_PARKING.content
TYPE_FOURS_ROAD_WORK.poiType -> TYPE_FOURS_ROAD_WORK.content
TYPE_USECASE_ID_SLW.poiType -> TYPE_USECASE_ID_SLW.content
TYPE_USECASE_ID_TJW.poiType -> TYPE_USECASE_ID_TJW.content
TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType -> TYPE_USECASE_ID_BREAKDOWN_WARNING.content
@@ -1318,10 +1293,10 @@ enum class EventTypeEnumNew(
TYPE_USECASE_ID_ROAD_NO_PARKING.poiType -> TYPE_USECASE_ID_ROAD_NO_PARKING.content
TYPE_USECASE_ID_ROAD_NO_TOOTING.poiType -> TYPE_USECASE_ID_ROAD_NO_TOOTING.content
TYPE_USECASE_ID_ROAD_SPEED_LIMIT.poiType -> TYPE_USECASE_ID_ROAD_SPEED_LIMIT.content
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.content
TYPE_USECASE_ID_BUS_WARNING.poiType -> TYPE_USECASE_ID_BUS_WARNING.content
TYPE_USECASE_ID_NARROW_RIGHT.poiType -> TYPE_USECASE_ID_NARROW_RIGHT.content
TYPE_USECASE_ID_GAS_STATION.poiType -> TYPE_USECASE_ID_GAS_STATION.content
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.content
TYPE_USECASE_ID_ACCIDENT.poiType -> TYPE_USECASE_ID_ACCIDENT.content
TYPE_ATTENTION_CONFLUENCE.poiType -> TYPE_ATTENTION_CONFLUENCE.content
TYPE_PEDESTRIAN_CROSSING.poiType -> TYPE_PEDESTRIAN_CROSSING.content
@@ -1353,18 +1328,12 @@ enum class EventTypeEnumNew(
TYPE_ERROR.poiType -> TYPE_ERROR.tts
TYPE_OPTIMAL_ROUTE_RECOMMEND.poiType -> TYPE_OPTIMAL_ROUTE_RECOMMEND.tts
GHOST_PROBE.poiType -> GHOST_PROBE.tts
TYPE_USECASE_ID_IVP_RED.poiType -> TYPE_USECASE_ID_IVP_RED.tts
TYPE_USECASE_ID_IVP_GREEN.poiType -> TYPE_USECASE_ID_IVP_GREEN.tts
TYPE_USECASE_ID_VRUCW_PERSON.poiType -> TYPE_USECASE_ID_VRUCW_PERSON.tts
TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.poiType -> TYPE_USECASE_ID_VRUCW_MOTOR_VEHICLES.tts
TYPE_USECASE_ID_VRUCW_NOT_MOTOR_VEHICLES.poiType -> TYPE_USECASE_ID_VRUCW_NOT_MOTOR_VEHICLES.tts
TYPE_ERROR_WEAKNESS.poiType -> TYPE_ERROR_WEAKNESS.tts
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.tts
TYPE_USECASE_ID_ROAD_NO_PARKING.poiType -> TYPE_USECASE_ID_ROAD_NO_PARKING.tts
TYPE_FOURS_ROAD_WORK.poiType -> TYPE_FOURS_ROAD_WORK.tts
TYPE_USECASE_ID_SLW.poiType -> TYPE_USECASE_ID_SLW.tts
TYPE_USECASE_ID_TJW.poiType -> TYPE_USECASE_ID_TJW.tts
TYPE_USECASE_ID_BREAKDOWN_WARNING.poiType -> TYPE_USECASE_ID_BREAKDOWN_WARNING.tts
@@ -1387,10 +1356,10 @@ enum class EventTypeEnumNew(
TYPE_USECASE_ID_ROAD_NO_PARKING.poiType -> TYPE_USECASE_ID_ROAD_NO_PARKING.tts
TYPE_USECASE_ID_ROAD_NO_TOOTING.poiType -> TYPE_USECASE_ID_ROAD_NO_TOOTING.tts
TYPE_USECASE_ID_ROAD_SPEED_LIMIT.poiType -> TYPE_USECASE_ID_ROAD_SPEED_LIMIT.tts
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.tts
TYPE_USECASE_ID_BUS_WARNING.poiType -> TYPE_USECASE_ID_BUS_WARNING.tts
TYPE_USECASE_ID_NARROW_RIGHT.poiType -> TYPE_USECASE_ID_NARROW_RIGHT.tts
TYPE_USECASE_ID_GAS_STATION.poiType -> TYPE_USECASE_ID_GAS_STATION.tts
TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.poiType -> TYPE_USECASE_ID_ROAD_PEDESTRIAN_SCHOOL.tts
TYPE_USECASE_ID_ACCIDENT.poiType -> TYPE_USECASE_ID_ACCIDENT.tts
TYPE_ATTENTION_CONFLUENCE.poiType -> TYPE_ATTENTION_CONFLUENCE.tts
TYPE_PEDESTRIAN_CROSSING.poiType -> TYPE_PEDESTRIAN_CROSSING.tts

View File

@@ -154,6 +154,6 @@ final class Platform {
* {@code x}, emulating the behavior of {@link BigDecimal#BigDecimal(double)}.
*/
static BigDecimal newBigDecimal(double x) {
return new BigDecimal(x);
return BigDecimal.valueOf(x);
}
}

View File

@@ -284,18 +284,16 @@ strictfp class Real extends Number {
/** Returns a BigDecimal representation of this extended precision real value. */
public BigDecimal bigValue() {
BigDecimal sum = new BigDecimal(values[0]);
BigDecimal sum = BigDecimal.valueOf(values[0]);
for (int i = 1; i < values.length; i++) {
sum = sum.add(new BigDecimal(values[i]));
sum = sum.add(BigDecimal.valueOf(values[i]));
}
return sum.stripTrailingZeros();
}
private static double[] copyOf(double[] array, int newLength) {
double[] result = new double[newLength];
for (int i = 0; i < newLength; i++) {
result[i] = array[i];
}
System.arraycopy(array, 0, result, 0, newLength);
return result;
}

View File

@@ -17,10 +17,10 @@ import java.security.MessageDigest;
public class GlideCircleBitmapTransform extends BitmapTransformation {
private int mBorderWidth;
private int mBorderColor;
private String mKey;
private Context mContext;
private final int mBorderWidth;
private final int mBorderColor;
private final String mKey;
private final Context mContext;
public GlideCircleBitmapTransform( Context context, String key, int borderWidth, int borderColor ) {
this.mContext = context;

View File

@@ -133,7 +133,7 @@ public final class ActivityUtils {
@Nullable
private static Activity getActivityFromDecorContext(@Nullable Context context) {
if (context == null) return null;
if (context.getClass().getName().equals("com.android.internal.policy.DecorContext")) {
if ("com.android.internal.policy.DecorContext".equals(context.getClass().getName())) {
try {
Field mActivityContextField = context.getClass().getDeclaredField("mActivityContext");
mActivityContextField.setAccessible(true);

View File

@@ -6,6 +6,7 @@ import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
/**
@@ -308,10 +309,10 @@ public final class ShellUtils {
successMsg = new StringBuilder();
errorMsg = new StringBuilder();
successResult = new BufferedReader(
new InputStreamReader(process.getInputStream(), "UTF-8")
new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)
);
errorResult = new BufferedReader(
new InputStreamReader(process.getErrorStream(), "UTF-8")
new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8)
);
String line;
if ((line = successResult.readLine()) != null) {
@@ -334,17 +335,9 @@ public final class ShellUtils {
if (os != null) {
os.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (successResult != null) {
successResult.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (errorResult != null) {
errorResult.close();
}