Loading play-services-location/core/src/main/kotlin/org/microg/gms/location/extensions.kt +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ internal val FEATURES = arrayOf( Feature("use_safe_parcelable_in_intents", 1) ) internal fun Long.formatRealtime(): CharSequence = DateUtils.getRelativeTimeSpanString((SystemClock.elapsedRealtime() - this) + System.currentTimeMillis()) internal fun Long.formatRealtime(): CharSequence = DateUtils.getRelativeTimeSpanString((this - SystemClock.elapsedRealtime()) + System.currentTimeMillis(), System.currentTimeMillis(), 0) internal fun Long.formatDuration(): CharSequence { if (this == 0L) return "0ms" if (this > 315360000000L /* ten years */) return "\u221e" Loading play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManager.kt +3 −3 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ class LocationManager(private val context: Context, private val lifecycle: Lifec suspend fun addBinderRequest(clientIdentity: ClientIdentity, binder: IBinder, callback: ILocationCallback, request: LocationRequest) { request.verify(context, clientIdentity) requestManager.add(binder, clientIdentity, callback, request) requestManager.add(binder, clientIdentity, callback, request, lastLocationCapsule) } suspend fun updateBinderRequest( Loading @@ -113,7 +113,7 @@ class LocationManager(private val context: Context, private val lifecycle: Lifec request: LocationRequest ) { request.verify(context, clientIdentity) requestManager.update(oldBinder, binder, clientIdentity, callback, request) requestManager.update(oldBinder, binder, clientIdentity, callback, request, lastLocationCapsule) } suspend fun removeBinderRequest(binder: IBinder) { Loading @@ -122,7 +122,7 @@ class LocationManager(private val context: Context, private val lifecycle: Lifec suspend fun addIntentRequest(clientIdentity: ClientIdentity, pendingIntent: PendingIntent, request: LocationRequest) { request.verify(context, clientIdentity) requestManager.add(pendingIntent, clientIdentity, request) requestManager.add(pendingIntent, clientIdentity, request, lastLocationCapsule) } suspend fun removeIntentRequest(pendingIntent: PendingIntent) { Loading play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationRequestManager.kt +19 −5 Original line number Diff line number Diff line Loading @@ -61,11 +61,16 @@ class LocationRequestManager(private val context: Context, private val lifecycle } } suspend fun add(binder: IBinder, clientIdentity: ClientIdentity, callback: ILocationCallback, request: LocationRequest) { suspend fun add(binder: IBinder, clientIdentity: ClientIdentity, callback: ILocationCallback, request: LocationRequest, lastLocationCapsule: LastLocationCapsule) { lock.withLock { val holder = LocationRequestHolder(context, clientIdentity, request, callback, null) try { holder.start() holder.start().also { var effectiveGranularity = it.effectiveGranularity if (effectiveGranularity == GRANULARITY_FINE && database.getForceCoarse(it.clientIdentity.packageName)) effectiveGranularity = GRANULARITY_COARSE val lastLocation = lastLocationCapsule.getLocation(effectiveGranularity, request.maxUpdateAgeMillis) if (lastLocation != null) it.processNewLocation(lastLocation) } binderRequests[binder] = holder binder.linkToDeath(this, 0) } catch (e: Exception) { Loading @@ -76,12 +81,17 @@ class LocationRequestManager(private val context: Context, private val lifecycle notifyRequestDetailsUpdated() } suspend fun update(oldBinder: IBinder, binder: IBinder, clientIdentity: ClientIdentity, callback: ILocationCallback, request: LocationRequest) { suspend fun update(oldBinder: IBinder, binder: IBinder, clientIdentity: ClientIdentity, callback: ILocationCallback, request: LocationRequest, lastLocationCapsule: LastLocationCapsule) { lock.withLock { oldBinder.unlinkToDeath(this, 0) val holder = binderRequests.remove(oldBinder) try { val startedHolder = holder?.update(callback, request) ?: LocationRequestHolder(context, clientIdentity, request, callback, null).start() val startedHolder = holder?.update(callback, request) ?: LocationRequestHolder(context, clientIdentity, request, callback, null).start().also { var effectiveGranularity = it.effectiveGranularity if (effectiveGranularity == GRANULARITY_FINE && database.getForceCoarse(it.clientIdentity.packageName)) effectiveGranularity = GRANULARITY_COARSE val lastLocation = lastLocationCapsule.getLocation(effectiveGranularity, request.maxUpdateAgeMillis) if (lastLocation != null) it.processNewLocation(lastLocation) } binderRequests[binder] = startedHolder binder.linkToDeath(this, 0) } catch (e: Exception) { Loading @@ -100,11 +110,15 @@ class LocationRequestManager(private val context: Context, private val lifecycle notifyRequestDetailsUpdated() } suspend fun add(pendingIntent: PendingIntent, clientIdentity: ClientIdentity, request: LocationRequest) { suspend fun add(pendingIntent: PendingIntent, clientIdentity: ClientIdentity, request: LocationRequest, lastLocationCapsule: LastLocationCapsule) { lock.withLock { try { pendingIntentRequests[pendingIntent] = LocationRequestHolder(context, clientIdentity, request, null, pendingIntent).start().also { cacheManager.add(it.asParcelable()) { it.pendingIntent == pendingIntent } var effectiveGranularity = it.effectiveGranularity if (effectiveGranularity == GRANULARITY_FINE && database.getForceCoarse(it.clientIdentity.packageName)) effectiveGranularity = GRANULARITY_COARSE val lastLocation = lastLocationCapsule.getLocation(effectiveGranularity, request.maxUpdateAgeMillis) if (lastLocation != null) it.processNewLocation(lastLocation) } } catch (e: Exception) { // Ignore Loading Loading
play-services-location/core/src/main/kotlin/org/microg/gms/location/extensions.kt +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ internal val FEATURES = arrayOf( Feature("use_safe_parcelable_in_intents", 1) ) internal fun Long.formatRealtime(): CharSequence = DateUtils.getRelativeTimeSpanString((SystemClock.elapsedRealtime() - this) + System.currentTimeMillis()) internal fun Long.formatRealtime(): CharSequence = DateUtils.getRelativeTimeSpanString((this - SystemClock.elapsedRealtime()) + System.currentTimeMillis(), System.currentTimeMillis(), 0) internal fun Long.formatDuration(): CharSequence { if (this == 0L) return "0ms" if (this > 315360000000L /* ten years */) return "\u221e" Loading
play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationManager.kt +3 −3 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ class LocationManager(private val context: Context, private val lifecycle: Lifec suspend fun addBinderRequest(clientIdentity: ClientIdentity, binder: IBinder, callback: ILocationCallback, request: LocationRequest) { request.verify(context, clientIdentity) requestManager.add(binder, clientIdentity, callback, request) requestManager.add(binder, clientIdentity, callback, request, lastLocationCapsule) } suspend fun updateBinderRequest( Loading @@ -113,7 +113,7 @@ class LocationManager(private val context: Context, private val lifecycle: Lifec request: LocationRequest ) { request.verify(context, clientIdentity) requestManager.update(oldBinder, binder, clientIdentity, callback, request) requestManager.update(oldBinder, binder, clientIdentity, callback, request, lastLocationCapsule) } suspend fun removeBinderRequest(binder: IBinder) { Loading @@ -122,7 +122,7 @@ class LocationManager(private val context: Context, private val lifecycle: Lifec suspend fun addIntentRequest(clientIdentity: ClientIdentity, pendingIntent: PendingIntent, request: LocationRequest) { request.verify(context, clientIdentity) requestManager.add(pendingIntent, clientIdentity, request) requestManager.add(pendingIntent, clientIdentity, request, lastLocationCapsule) } suspend fun removeIntentRequest(pendingIntent: PendingIntent) { Loading
play-services-location/core/src/main/kotlin/org/microg/gms/location/manager/LocationRequestManager.kt +19 −5 Original line number Diff line number Diff line Loading @@ -61,11 +61,16 @@ class LocationRequestManager(private val context: Context, private val lifecycle } } suspend fun add(binder: IBinder, clientIdentity: ClientIdentity, callback: ILocationCallback, request: LocationRequest) { suspend fun add(binder: IBinder, clientIdentity: ClientIdentity, callback: ILocationCallback, request: LocationRequest, lastLocationCapsule: LastLocationCapsule) { lock.withLock { val holder = LocationRequestHolder(context, clientIdentity, request, callback, null) try { holder.start() holder.start().also { var effectiveGranularity = it.effectiveGranularity if (effectiveGranularity == GRANULARITY_FINE && database.getForceCoarse(it.clientIdentity.packageName)) effectiveGranularity = GRANULARITY_COARSE val lastLocation = lastLocationCapsule.getLocation(effectiveGranularity, request.maxUpdateAgeMillis) if (lastLocation != null) it.processNewLocation(lastLocation) } binderRequests[binder] = holder binder.linkToDeath(this, 0) } catch (e: Exception) { Loading @@ -76,12 +81,17 @@ class LocationRequestManager(private val context: Context, private val lifecycle notifyRequestDetailsUpdated() } suspend fun update(oldBinder: IBinder, binder: IBinder, clientIdentity: ClientIdentity, callback: ILocationCallback, request: LocationRequest) { suspend fun update(oldBinder: IBinder, binder: IBinder, clientIdentity: ClientIdentity, callback: ILocationCallback, request: LocationRequest, lastLocationCapsule: LastLocationCapsule) { lock.withLock { oldBinder.unlinkToDeath(this, 0) val holder = binderRequests.remove(oldBinder) try { val startedHolder = holder?.update(callback, request) ?: LocationRequestHolder(context, clientIdentity, request, callback, null).start() val startedHolder = holder?.update(callback, request) ?: LocationRequestHolder(context, clientIdentity, request, callback, null).start().also { var effectiveGranularity = it.effectiveGranularity if (effectiveGranularity == GRANULARITY_FINE && database.getForceCoarse(it.clientIdentity.packageName)) effectiveGranularity = GRANULARITY_COARSE val lastLocation = lastLocationCapsule.getLocation(effectiveGranularity, request.maxUpdateAgeMillis) if (lastLocation != null) it.processNewLocation(lastLocation) } binderRequests[binder] = startedHolder binder.linkToDeath(this, 0) } catch (e: Exception) { Loading @@ -100,11 +110,15 @@ class LocationRequestManager(private val context: Context, private val lifecycle notifyRequestDetailsUpdated() } suspend fun add(pendingIntent: PendingIntent, clientIdentity: ClientIdentity, request: LocationRequest) { suspend fun add(pendingIntent: PendingIntent, clientIdentity: ClientIdentity, request: LocationRequest, lastLocationCapsule: LastLocationCapsule) { lock.withLock { try { pendingIntentRequests[pendingIntent] = LocationRequestHolder(context, clientIdentity, request, null, pendingIntent).start().also { cacheManager.add(it.asParcelable()) { it.pendingIntent == pendingIntent } var effectiveGranularity = it.effectiveGranularity if (effectiveGranularity == GRANULARITY_FINE && database.getForceCoarse(it.clientIdentity.packageName)) effectiveGranularity = GRANULARITY_COARSE val lastLocation = lastLocationCapsule.getLocation(effectiveGranularity, request.maxUpdateAgeMillis) if (lastLocation != null) it.processNewLocation(lastLocation) } } catch (e: Exception) { // Ignore Loading