@glassly/crust 0.4.3-dev.1283 → 0.4.3-dev.1287
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.glassly.crust.navigation
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
|
+
import android.app.ActivityManager
|
|
4
5
|
import android.content.Context
|
|
5
6
|
import android.util.Log
|
|
6
7
|
import com.mapbox.api.directions.v5.DirectionsCriteria
|
|
@@ -509,6 +510,17 @@ object NavigationManager {
|
|
|
509
510
|
else -> DirectionsCriteria.PROFILE_DRIVING_TRAFFIC
|
|
510
511
|
}
|
|
511
512
|
|
|
513
|
+
/**
|
|
514
|
+
* Mapbox's trip service is a location foreground service, and Android 14+ refuses to start one
|
|
515
|
+
* unless the app is in the foreground. A trip started from the glasses with the phone locked
|
|
516
|
+
* runs without it: the glasses link already holds a foreground service for the process.
|
|
517
|
+
*/
|
|
518
|
+
private fun tripServiceAllowed(): Boolean {
|
|
519
|
+
val process = ActivityManager.RunningAppProcessInfo()
|
|
520
|
+
ActivityManager.getMyMemoryState(process)
|
|
521
|
+
return process.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
|
|
522
|
+
}
|
|
523
|
+
|
|
512
524
|
/** Begin the trip session — either live GPS or the replay session for simulate mode. */
|
|
513
525
|
@OptIn(ExperimentalPreviewMapboxNavigationAPI::class)
|
|
514
526
|
private fun startTripSession(nav: MapboxNavigation, options: StartOptions) {
|
|
@@ -530,10 +542,10 @@ object NavigationManager {
|
|
|
530
542
|
)
|
|
531
543
|
replaySession = session
|
|
532
544
|
replayer = nav.mapboxReplayer
|
|
533
|
-
nav.startReplayTripSession()
|
|
545
|
+
nav.startReplayTripSession(tripServiceAllowed())
|
|
534
546
|
session.onAttached(nav)
|
|
535
547
|
} else {
|
|
536
|
-
nav.startTripSession()
|
|
548
|
+
nav.startTripSession(tripServiceAllowed())
|
|
537
549
|
}
|
|
538
550
|
}
|
|
539
551
|
|
|
@@ -560,7 +572,7 @@ object NavigationManager {
|
|
|
560
572
|
// provider again, so the next onLocation fix is the user's true spot.
|
|
561
573
|
nav.setNavigationRoutes(emptyList())
|
|
562
574
|
nav.stopTripSession()
|
|
563
|
-
nav.startTripSession()
|
|
575
|
+
nav.startTripSession(tripServiceAllowed())
|
|
564
576
|
Log.d(TAG, "sim arrival — handed location source back to real GPS")
|
|
565
577
|
} catch (e: Throwable) {
|
|
566
578
|
Log.w(TAG, "returnToRealLocationAfterSimArrival failed: ${e.message}")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glassly/crust",
|
|
3
|
-
"version": "0.4.3-dev.
|
|
3
|
+
"version": "0.4.3-dev.1287",
|
|
4
4
|
"description": "Glassly Native Module",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"homepage": "https://github.com/fossephate/crust#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@glassly/jspolyfill": "0.4.3-dev.
|
|
37
|
+
"@glassly/jspolyfill": "0.4.3-dev.1287"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@expo/config-plugins": ">=8.0.0",
|