From c6a673d409ae9cd3666fa8f4e915375c7817a44f Mon Sep 17 00:00:00 2001 From: Eva Chen Date: Thu, 23 Sep 2021 23:33:55 -0700 Subject: Implement GNSS APIs for Automotive Power Management. Automotive Suspend to RAM doesn't work when GNSS requests are actively running. This change introduces system APIs for suspending and resuming GNSS. Bug: 187348886 CTS-Coverage-Bug: 203703449 Test: Presubmits Change-Id: If25c761e8618bebaf989392afc0a676f930dfd78 --- .../java/android/location/ILocationManager.aidl | 3 ++ .../java/android/location/LocationManager.java | 45 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) (limited to 'location/java') diff --git a/location/java/android/location/ILocationManager.aidl b/location/java/android/location/ILocationManager.aidl index 5d5c0fc6265d..8054fd452022 100644 --- a/location/java/android/location/ILocationManager.aidl +++ b/location/java/android/location/ILocationManager.aidl @@ -125,6 +125,9 @@ interface ILocationManager boolean isAdasGnssLocationEnabledForUser(int userId); void setAdasGnssLocationEnabledForUser(boolean enabled, int userId); + boolean isAutoGnssSuspended(); + void setAutoGnssSuspended(boolean suspended); + void addTestProvider(String name, in ProviderProperties properties, in List locationTags, String packageName, @nullable String attributionTag); void removeTestProvider(String provider, String packageName, @nullable String attributionTag); diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index 0681b8da43fd..2ff969316355 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -757,6 +757,51 @@ public class LocationManager { return false; } + /** + * Set whether GNSS requests are suspended on the device. + * + * This method was added to help support power management use cases on automotive devices. More + * specifically, it is being added to fix a suspend to RAM issue where the SoC can't go into + * a lower power state when applications are actively requesting GNSS updates. + * + * Ideally, the issue should be fixed at a lower layer in the stack, but this API introduces a + * workaround in the platform layer. This API allows car specific services to halt GNSS requests + * based on changes to the car power policy, which will in turn enable the device to go into + * suspend. + * + * @hide + */ + @SystemApi + @RequiresPermission(android.Manifest.permission.AUTOMOTIVE_GNSS_CONTROLS) + public void setAutoGnssSuspended(boolean suspended) { + try { + mService.setAutoGnssSuspended(suspended); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Return whether GNSS requests are suspended or not. + * + * This method was added to help support power management use cases on automotive devices. More + * specifically, it is being added as part of the fix for a suspend to RAM issue where the SoC + * can't go into a lower power state when applications are actively requesting GNSS updates. + * + * @return true if GNSS requests are suspended and false if they aren't. + * + * @hide + */ + @SystemApi + @RequiresPermission(android.Manifest.permission.AUTOMOTIVE_GNSS_CONTROLS) + public boolean isAutoGnssSuspended() { + try { + return mService.isAutoGnssSuspended(); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + /** * Gets the last known location from the fused provider, or null if there is no last known * location. The returned location may be quite old in some circumstances, so the age of the -- cgit v1.2.3-59-g8ed1b