Merge remote-tracking branch 'origin/dev_robotaxi-d-app-module_2110_220915_2.11.0' into dev_robotaxi-d-app-module_2110_220915_2.11.0

This commit is contained in:
wangmingjun
2022-10-19 19:46:59 +08:00

View File

@@ -49,9 +49,19 @@ internal class GpsImpl(ctx: Context): IFlow<GpsStatus>(ctx) {
false
}
private val onStateListener = object : IAppStateListener {
override fun onAppStateChanged(isForeground: Boolean) {
if (isForeground) {
send(isLocationEnabled(), isGrandFineLocation())
}
}
}
override fun onCreate() {
val isGranted = isGrandFineLocation()
AppStateManager.registerAppStateListener(onStateListener)
send(isLocationEnabled(), isGranted)
if (!isGranted) {
PermissionUtils.requestAccessFineLocation(object : SimpleCallback {
@@ -88,6 +98,7 @@ internal class GpsImpl(ctx: Context): IFlow<GpsStatus>(ctx) {
} catch (t: Throwable) {
t.printStackTrace()
}
AppStateManager.unRegisterAppStateListener(onStateListener)
}
}