mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-10 16:02:25 +01:00
car apps: let hosted apps start their own location service, fixing MapQuest
Since Android 14, an app bound by a visible host may start a foreground service only if the host binds it with BIND_ALLOW_ACTIVITY_STARTS. Without it, MapQuest crashed as navigation began, and Flitsmeister and Vela ran their services without location. MapQuest now gets the working check.
This commit is contained in:
1 parent
fd658d4e57
commit
92d7940f56
2 files changed
+7
-1
No files matched your search
@@ -9,6 +9,7 @@ import android.content.res.Configuration
|
||||
import android.graphics.Rect
|
||||
import android.location.Location
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.IBinder
|
||||
import android.os.Looper
|
||||
@@ -139,7 +140,11 @@ class CarAppConnection(private val context: Context) {
|
||||
// Replaced by another connect (or a disconnect) while waiting on the location service.
|
||||
if (binding !== connection) return@bind
|
||||
var bindError: Throwable? = null
|
||||
val flags = Context.BIND_AUTO_CREATE or LocationKeepAlive.BIND_INCLUDE_CAPABILITIES
|
||||
// BIND_ALLOW_ACTIVITY_STARTS lets the app start its own location service while
|
||||
// Gearslip's car window is showing. Since Android 14 a bound app only inherits that
|
||||
// from a visible host that opts in, and MapQuest crashes as navigation starts without it.
|
||||
val flags = Context.BIND_AUTO_CREATE or LocationKeepAlive.BIND_INCLUDE_CAPABILITIES or
|
||||
(if (Build.VERSION.SDK_INT >= 34) Context.BIND_ALLOW_ACTIVITY_STARTS else 0)
|
||||
val bound = runCatching {
|
||||
// Without BIND_FOREGROUND_SERVICE, an app bound by a foreground service (which is
|
||||
// all Gearslip is once the phone screen leaves it) only reaches "important
|
||||
|
||||
@@ -18,6 +18,7 @@ object KnownApps {
|
||||
"com.vivi.vivimusic", // Vivi Music: browse, play, seek, works well
|
||||
"com.metrolist.music", // Metrolist: browse, play, works
|
||||
"nl.flitsmeister", // Flitsmeister: map, routing, alerts - works well
|
||||
"com.mapquest.android.ace", // MapQuest: map, routing, navigation
|
||||
)
|
||||
|
||||
fun works(packageName: String): Boolean = packageName in working
|
||||
|
||||
Reference in new issue
Block a user