diff options
author | Brian Orr <brianorr@google.com> | 2021-05-13 20:42:01 -0700 |
---|---|---|
committer | Brian Orr <brianorr@google.com> | 2021-05-13 20:42:01 -0700 |
commit | 1b62159ffcebb2c102e129b2e778a8f65b7e5948 (patch) | |
tree | c28571796470b5c9e3d9e8c2dc8d49ddf819fd60 /location | |
parent | 86a43bb54c1ed3c75d072a2c465bf0447b5188c1 (diff) | |
parent | 3a582255fbbf0840208ec8cee02f8401982f0e39 (diff) |
Merge SP1A.210510.001
Change-Id: Ia86f3e18206beabe334e3081cedbaf5b3274f78e
Diffstat (limited to 'location')
-rw-r--r-- | location/java/android/location/GnssMeasurement.java | 8 | ||||
-rw-r--r-- | location/java/android/location/LocationManager.java | 106 |
2 files changed, 92 insertions, 22 deletions
diff --git a/location/java/android/location/GnssMeasurement.java b/location/java/android/location/GnssMeasurement.java index 242d9a3627db..f4466782ac8a 100644 --- a/location/java/android/location/GnssMeasurement.java +++ b/location/java/android/location/GnssMeasurement.java @@ -1530,6 +1530,10 @@ public final class GnssMeasurement implements Parcelable { * * <p>The value does not include the inter-frequency Ionospheric bias. * + * <p>The sign of the value is defined by the following equation: + * <pre> + * corrected pseudorange = raw pseudorange - FullInterSignalBiasNanos</pre> + * * <p>The value is only available if {@link #hasFullInterSignalBiasNanos()} is {@code true}. */ public double getFullInterSignalBiasNanos() { @@ -1626,6 +1630,10 @@ public final class GnssMeasurement implements Parcelable { * type in {@link GnssClock#getReferenceConstellationTypeForIsb())</li> * </ul> * + * <p>The sign of the value is defined by the following equation: + * <pre> + * corrected pseudorange = raw pseudorange - SatelliteInterSignalBiasNanos</pre> + * * <p>The value is only available if {@link #hasSatelliteInterSignalBiasNanos()} is {@code * true}. */ diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index e6d94539fcf1..bb7dbf4931a7 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -346,6 +346,43 @@ public class LocationManager { */ public static final String EXTRA_GNSS_CAPABILITIES = "android.location.extra.GNSS_CAPABILITIES"; + /** + * Broadcast intent action for Settings app to inject a footer at the bottom of location + * settings. This is for use only by apps that are included in the system image. + * + * <p>To inject a footer to location settings, you must declare a broadcast receiver for + * this action in the manifest: + * <pre> + * <receiver android:name="com.example.android.footer.MyFooterInjector"> + * <intent-filter> + * <action android:name="com.android.settings.location.INJECT_FOOTER" /> + * </intent-filter> + * <meta-data + * android:name="com.android.settings.location.FOOTER_STRING" + * android:resource="@string/my_injected_footer_string" /> + * </receiver> + * </pre> + * + * <p>This broadcast receiver will never actually be invoked. See also + * {#METADATA_SETTINGS_FOOTER_STRING}. + * + * @hide + */ + public static final String SETTINGS_FOOTER_DISPLAYED_ACTION = + "com.android.settings.location.DISPLAYED_FOOTER"; + + /** + * Metadata name for {@link LocationManager#SETTINGS_FOOTER_DISPLAYED_ACTION} broadcast + * receivers to specify a string resource id as location settings footer text. This is for use + * only by apps that are included in the system image. + * + * <p>See {@link #SETTINGS_FOOTER_DISPLAYED_ACTION} for more detail on how to use. + * + * @hide + */ + public static final String METADATA_SETTINGS_FOOTER_STRING = + "com.android.settings.location.FOOTER_STRING"; + private static final long MAX_SINGLE_LOCATION_TIMEOUT_MS = 30 * 1000; private static final String CACHE_KEY_LOCATION_ENABLED_PROPERTY = @@ -360,6 +397,9 @@ public class LocationManager { } } + private static volatile LocationEnabledCache sLocationEnabledCache = + new LocationEnabledCache(4); + @GuardedBy("sLocationListeners") private static final WeakHashMap<LocationListener, WeakReference<LocationListenerTransport>> sLocationListeners = new WeakHashMap<>(); @@ -386,20 +426,6 @@ public class LocationManager { final Context mContext; final ILocationManager mService; - private volatile PropertyInvalidatedCache<Integer, Boolean> mLocationEnabledCache = - new PropertyInvalidatedCache<Integer, Boolean>( - 4, - CACHE_KEY_LOCATION_ENABLED_PROPERTY) { - @Override - protected Boolean recompute(Integer userHandle) { - try { - return mService.isLocationEnabledForUser(userHandle); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } - }; - /** * @hide */ @@ -533,7 +559,7 @@ public class LocationManager { * @return true if location is enabled and false if location is disabled. */ public boolean isLocationEnabled() { - return isLocationEnabledForUser(Process.myUserHandle()); + return isLocationEnabledForUser(mContext.getUser()); } /** @@ -546,12 +572,17 @@ public class LocationManager { */ @SystemApi public boolean isLocationEnabledForUser(@NonNull UserHandle userHandle) { - PropertyInvalidatedCache<Integer, Boolean> cache = mLocationEnabledCache; - if (cache != null) { - return cache.query(userHandle.getIdentifier()); + // skip the cache for any "special" user ids - special ids like CURRENT_USER may change + // their meaning over time and should never be in the cache. we could resolve the special + // user ids here, but that would require an x-process call anyways, and the whole point of + // the cache is to avoid x-process calls. + if (userHandle.getIdentifier() >= 0) { + PropertyInvalidatedCache<Integer, Boolean> cache = sLocationEnabledCache; + if (cache != null) { + return cache.query(userHandle.getIdentifier()); + } } - // fallback if cache is disabled try { return mService.isLocationEnabledForUser(userHandle.getIdentifier()); } catch (RemoteException e) { @@ -3022,7 +3053,7 @@ public class LocationManager { ListenerExecutor, CancellationSignal.OnCancelListener { private final Executor mExecutor; - private volatile @Nullable Consumer<Location> mConsumer; + volatile @Nullable Consumer<Location> mConsumer; GetCurrentLocationTransport(Executor executor, Consumer<Location> consumer, @Nullable CancellationSignal cancellationSignal) { @@ -3483,6 +3514,37 @@ public class LocationManager { } } + private static class LocationEnabledCache extends PropertyInvalidatedCache<Integer, Boolean> { + + // this is not loaded immediately because this class is created as soon as LocationManager + // is referenced for the first time, and within the system server, the ILocationManager + // service may not have been loaded yet at that time. + private @Nullable ILocationManager mManager; + + LocationEnabledCache(int numEntries) { + super(numEntries, CACHE_KEY_LOCATION_ENABLED_PROPERTY); + } + + @Override + protected Boolean recompute(Integer userId) { + Preconditions.checkArgument(userId >= 0); + + if (mManager == null) { + try { + mManager = getService(); + } catch (RemoteException e) { + e.rethrowFromSystemServer(); + } + } + + try { + return mManager.isLocationEnabledForUser(userId); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + } + /** * @hide */ @@ -3493,7 +3555,7 @@ public class LocationManager { /** * @hide */ - public void disableLocalLocationEnabledCaches() { - mLocationEnabledCache = null; + public static void disableLocalLocationEnabledCaches() { + sLocationEnabledCache = null; } } |