From 2d7d9ea25a36ce996fb840edee1f4c295536ab12 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 18 Dec 2023 12:01:23 +0800 Subject: [PATCH] [6.2.4] fix bug of sound play helper , devices extends lenovo , npl of map init --- .../och/common/module/utils/SoundPoolHelper.java | 9 ++++++++- .../v2n/scenario/scene/airoad/AiRoadMarker.kt | 5 +++++ .../eagle/core/function/impl/MogoMapService.kt | 2 +- .../eagle/core/utilcode/util/DeviceUtils.java | 12 +++++++++++- .../src/main/java/com/mogo/map/MogoMap.kt | 6 +++--- .../mogo/map/identify/MogoIdentifyManager.java | 16 +++++++++++++--- .../mogo/map/overlay/MoGoOverlayManagerImpl.kt | 6 +++--- 7 files changed, 44 insertions(+), 12 deletions(-) diff --git a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/SoundPoolHelper.java b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/SoundPoolHelper.java index 3d785f53dc..3fdb6980d9 100644 --- a/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/SoundPoolHelper.java +++ b/OCH/mogo-och-common-module/src/main/java/com/mogo/och/common/module/utils/SoundPoolHelper.java @@ -4,6 +4,7 @@ import android.annotation.SuppressLint; import android.media.*; import android.content.*; import android.app.*; +import android.util.Log; public class SoundPoolHelper { private SoundPool mSoundPool; @@ -38,7 +39,9 @@ public class SoundPoolHelper { //init settings private void init(){ // AudioManager audio settings for adjusting the volume - mAudioManager = (AudioManager)this.mContext. getSystemService(Context.AUDIO_SERVICE); + if(mAudioManager == null){ + mAudioManager = (AudioManager)this.mContext. getSystemService(Context.AUDIO_SERVICE); + } // Current volumn Index of particular stream type. float currentVolumeIndex = (float) mAudioManager.getStreamVolume(streamType); @@ -87,6 +90,10 @@ public class SoundPoolHelper { //play the sound res private void playSound(){ + if(mSoundPool == null){ + Log.e("SoundPoolHelper","playSound mSoundPool is null"); + return; + } float leftVolume = volume; float rightVolume = volume; // Play sound of gunfire. Returns the ID of the new stream. diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt index a421d6ea73..f002941989 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt @@ -119,6 +119,11 @@ class AiRoadMarker { countDown.incrementAndGet() realMark(marker, wrapper, l1, l2, location.heading) }) + }else{ + wrapper.onRemoved = { id -> + aiMakers.remove(id) + } + MarkerRemoveManager.addMarker(wrapper) } } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.kt index 9f54c75167..38b2e75994 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.kt @@ -22,7 +22,7 @@ import com.mogo.map.location.IMogoGDLocationClient class MogoMapService : IMogoMapService { override fun getMapUIController(mapTag:String): IMogoMapUIController? { - return mapInstance.getMogoMap().uiController + return mapInstance.getMogoMap()?.uiController } override fun getOverlayManager(): IMoGoOverlayManager { diff --git a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/DeviceUtils.java b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/DeviceUtils.java index a2dea6cc72..8c02fce617 100644 --- a/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/DeviceUtils.java +++ b/core/mogo-core-utils/src/main/java/com/mogo/eagle/core/utilcode/util/DeviceUtils.java @@ -313,7 +313,7 @@ public final class DeviceUtils { } public static Boolean isLenovoModel(){ - return getModel().contains("Lenovo"); + return getModel().contains("Lenovo") || getBrand().contains("Lenovo"); } public static Boolean isEB5Model(){ @@ -336,6 +336,16 @@ public final class DeviceUtils { return model; } + public static String getBrand() { + String brand = Build.BRAND; + if (brand != null) { + brand = brand.trim().replaceAll("\\s*", ""); + } else { + brand = ""; + } + return brand; + } + /** * Return an ordered list of ABIs supported by this device. The most preferred ABI is the first * element in the list. diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.kt b/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.kt index b62777654d..da6ff519fa 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.kt +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/MogoMap.kt @@ -36,12 +36,12 @@ class MogoMap private constructor() { /** * 业务使用时根据地图是否加载来判定 是否获取IMogoMap实例 */ - fun getMogoMap(instance: String = DEFAULT): IMogoMap { + fun getMogoMap(instance: String = DEFAULT): IMogoMap? { return if (mapCache[instance] == null) { CallerLogger.e("$M_MAP$TAG", "getMogoMap func has error with no instance in mapCache") - mapCache[DEFAULT]!! + mapCache[DEFAULT] } else { - mapCache[instance]!! + mapCache[instance] } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/identify/MogoIdentifyManager.java b/libraries/mogo-map/src/main/java/com/mogo/map/identify/MogoIdentifyManager.java index ed095f55a9..bfd1882488 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/identify/MogoIdentifyManager.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/identify/MogoIdentifyManager.java @@ -1,5 +1,6 @@ package com.mogo.map.identify; +import com.mogo.map.IMogoMap; import com.mogo.map.MogoMap; import com.mogo.map.identity.IMogoIdentifyManager; import java.util.HashMap; @@ -32,7 +33,10 @@ public class MogoIdentifyManager implements IMogoIdentifyManager { @Override public void removeMarker(String uuidString) { try { - MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT).removeMarker(uuidString); + IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT); + if(iMogoMap != null){ + iMogoMap.removeMarker(uuidString); + } } catch (Exception e) { e.printStackTrace(); } @@ -44,7 +48,10 @@ public class MogoIdentifyManager implements IMogoIdentifyManager { @Override public void updateBatchMarkerPosition(HashMap optionsArrayList) { try { - MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT).updateBatchMarkerPosition(optionsArrayList); + IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT); + if(iMogoMap != null){ + iMogoMap.updateBatchMarkerPosition(optionsArrayList); + } } catch (Exception e) { e.printStackTrace(); } @@ -53,7 +60,10 @@ public class MogoIdentifyManager implements IMogoIdentifyManager { @Override public void updateBatchAiMarkerPosition(HashMap optionsArrayList) { try { - MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT).updateBatchAiMarkerPosition(optionsArrayList); + IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT); + if(iMogoMap != null){ + iMogoMap.updateBatchAiMarkerPosition(optionsArrayList); + } } catch (Exception e) { e.printStackTrace(); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/overlay/MoGoOverlayManagerImpl.kt b/libraries/mogo-map/src/main/java/com/mogo/map/overlay/MoGoOverlayManagerImpl.kt index ee2cc14ff6..7a9a880957 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/overlay/MoGoOverlayManagerImpl.kt +++ b/libraries/mogo-map/src/main/java/com/mogo/map/overlay/MoGoOverlayManagerImpl.kt @@ -28,7 +28,7 @@ internal class MoGoOverlayManagerImpl: IMoGoOverlayManager { point.setOptions(options) return key } else { - val p = mapInstance.getMogoMap(mapTag).addPoint(options) + val p = mapInstance.getMogoMap(mapTag)?.addPoint(options) if (p != null) { p.onRemove { removed -> val keys = points.filterKeys { it.id == removed } @@ -232,7 +232,7 @@ internal class MoGoOverlayManagerImpl: IMoGoOverlayManager { line.setOptions(options) return key } else { - val newLine = mapInstance.getMogoMap(mapTag).addLine(options) + val newLine = mapInstance.getMogoMap(mapTag)?.addLine(options) if (newLine != null) { newLine.onRemove { removed -> val keys = lines.filterKeys { it.id == removed } @@ -259,7 +259,7 @@ internal class MoGoOverlayManagerImpl: IMoGoOverlayManager { private fun moveToCenter(mapTag:String, id: String, eventLon: Double, eventLat: Double, carLon: Double, carLat: Double) { try { - mapInstance.getMogoMap(mapTag).uiController?.showBounds( + mapInstance.getMogoMap(mapTag)?.uiController?.showBounds( id, MogoLatLng(carLat, carLon), listOf(MogoLatLng(eventLat, eventLon)),