summaryrefslogtreecommitdiff
path: root/location/java/android
diff options
context:
space:
mode:
author Eva Chen <evaschen@google.com> 2021-09-23 23:33:55 -0700
committer Eva Chen <evaschen@google.com> 2021-11-04 14:20:32 -0700
commitc6a673d409ae9cd3666fa8f4e915375c7817a44f (patch)
tree85ab37c029a2930b5467a73362bac8ab99ac4046 /location/java/android
parenta913e1f4e8add651cea850e4a9f33c5ed1c23a02 (diff)
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
Diffstat (limited to 'location/java/android')
-rw-r--r--location/java/android/location/ILocationManager.aidl3
-rw-r--r--location/java/android/location/LocationManager.java45
2 files changed, 48 insertions, 0 deletions
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<String> 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
@@ -758,6 +758,51 @@ public class LocationManager {
}
/**
+ * 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
* location should always be checked.