From 10bc6990b16eed73d135d7f26082c4a57cdab9de Mon Sep 17 00:00:00 2001 From: davinci9196 Date: Wed, 8 Jan 2025 17:18:10 +0800 Subject: [PATCH 1/3] HmsMap: Uber route drift modification --- .../hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt b/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt index aef3dd8e36..3f87905062 100644 --- a/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt +++ b/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt @@ -807,7 +807,7 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) for (i in 0 until parentView.childCount) { val viewChild = parentView.getChildAt(i) // Uber is prone to route drift, so here we hide the corresponding layer - if (viewChild::class.qualifiedName == "com.ubercab.android.map.fu") { + if (viewChild::class.qualifiedName?.contains("com.ubercab") == true) { viewChild.visibility = if (hide) View.INVISIBLE else View.VISIBLE } } From da80a750fc73ae694233a17c93fdbbe4cc2a64c4 Mon Sep 17 00:00:00 2001 From: davinci9196 Date: Wed, 8 Jan 2025 17:28:34 +0800 Subject: [PATCH 2/3] cleanup --- .../hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt b/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt index 3f87905062..66b306aecd 100644 --- a/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt +++ b/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt @@ -807,7 +807,7 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) for (i in 0 until parentView.childCount) { val viewChild = parentView.getChildAt(i) // Uber is prone to route drift, so here we hide the corresponding layer - if (viewChild::class.qualifiedName?.contains("com.ubercab") == true) { + if (viewChild::class.qualifiedName?.startsWith("com.ubercab") == true) { viewChild.visibility = if (hide) View.INVISIBLE else View.VISIBLE } } From a3816df599a3431794b09198dd89a9116a2e15b0 Mon Sep 17 00:00:00 2001 From: davinci9196 Date: Wed, 15 Jan 2025 16:00:42 +0800 Subject: [PATCH 3/3] fixed #2743 crash --- .../org/microg/gms/maps/hms/GoogleMap.kt | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt b/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt index 66b306aecd..b566323547 100644 --- a/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt +++ b/play-services-maps/core/hms/src/main/kotlin/org/microg/gms/maps/hms/GoogleMap.kt @@ -705,6 +705,7 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) markers.map { it.value.remove() } markers.clear() // BitmapDescriptorFactoryImpl.unregisterMap(map) + view.removeCallbacks(controlLayerRun) view.removeView(mapView) // TODO can crash? mapView?.onDestroy() @@ -798,17 +799,20 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) } private fun refreshContainerLayer(hide: Boolean = false) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - view.onDescendantInvalidated(mapView!!, mapView!!) - } - val parentView = view.parent?.parent - if (parentView != null) { - if (parentView is ViewGroup) { - for (i in 0 until parentView.childCount) { - val viewChild = parentView.getChildAt(i) - // Uber is prone to route drift, so here we hide the corresponding layer - if (viewChild::class.qualifiedName?.startsWith("com.ubercab") == true) { - viewChild.visibility = if (hide) View.INVISIBLE else View.VISIBLE + runCatching { + if (mapView == null) return + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + view.onDescendantInvalidated(mapView!!, mapView!!) + } + val parentView = view.parent?.parent + if (parentView != null) { + if (parentView is ViewGroup) { + for (i in 0 until parentView.childCount) { + val viewChild = parentView.getChildAt(i) + // Uber is prone to route drift, so here we hide the corresponding layer + if (viewChild::class.qualifiedName?.startsWith("com.ubercab") == true) { + viewChild.visibility = if (hide) View.INVISIBLE else View.VISIBLE + } } } }