summaryrefslogtreecommitdiff
path: root/core/java/android/os/PowerManager.java
diff options
context:
space:
mode:
authorYogisha Dixit <ydixit@google.com>2020-01-15 15:55:51 +0000
committerYogisha Dixit <ydixit@google.com>2020-01-22 13:20:06 +0000
commit9c20afa9d0ca2af91b0f7a1aac8b0573cb63440f (patch)
tree1b1a61392f69618652edc69bd4750b420d229998 /core/java/android/os/PowerManager.java
parentce7f6e8925ba1f07f137bc370122d63dd3b475a2 (diff)
Add APIs in PowerManager for suppressing ambient display.
Added 4 methods: boolean isAmbientDisplayAvailable() void suppressAmbientDisplay(String token, boolean suppress) boolean isAmbientDisplaySuppressedForToken(String token) boolean isAmbientDisplaySuppressed() This CL simply adds the API to toggle SUPPRESS_DOZE. The code for actually turning off doze when the secure setting is updated will be implemented in a follow-up CL. Test: manual, atest FrameworksServicesTests:PowerManagerServiceTest Bug: 147584235, 147587449 Change-Id: I54f46f75fb84aae2ae806690e73eeb427ad8e8e1
Diffstat (limited to 'core/java/android/os/PowerManager.java')
-rw-r--r--core/java/android/os/PowerManager.java71
1 files changed, 71 insertions, 0 deletions
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 0414b14ae02d..bf13c35867a4 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -1870,6 +1870,77 @@ public final class PowerManager {
}
/**
+ * Returns true if ambient display is available on the device.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_DREAM_STATE)
+ public boolean isAmbientDisplayAvailable() {
+ try {
+ return mService.isAmbientDisplayAvailable();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * If true, suppresses the current ambient display configuration and disables ambient display.
+ *
+ * <p>This method has no effect if {@link #isAmbientDisplayAvailable()} is false.
+ *
+ * @param token A persistable identifier for the ambient display suppression that is unique
+ * within the calling application.
+ * @param suppress If set to {@code true}, ambient display will be suppressed. If set to
+ * {@code false}, ambient display will no longer be suppressed for the given
+ * token.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)
+ public void suppressAmbientDisplay(@NonNull String token, boolean suppress) {
+ try {
+ mService.suppressAmbientDisplay(token, suppress);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Returns true if ambient display is suppressed by the calling app with the given
+ * {@code token}.
+ *
+ * <p>This method will return false if {@link #isAmbientDisplayAvailable()} is false.
+ *
+ * @param token The identifier of the ambient display suppression.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_DREAM_STATE)
+ public boolean isAmbientDisplaySuppressedForToken(@NonNull String token) {
+ try {
+ return mService.isAmbientDisplaySuppressedForToken(token);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Returns true if ambient display is suppressed by <em>any</em> app with <em>any</em> token.
+ *
+ * <p>This method will return false if {@link #isAmbientDisplayAvailable()} is false.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.READ_DREAM_STATE)
+ public boolean isAmbientDisplaySuppressed() {
+ try {
+ return mService.isAmbientDisplaySuppressed();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
* Returns the reason the phone was last shutdown. Calling app must have the
* {@link android.Manifest.permission#DEVICE_POWER} permission to request this information.
* @return Reason for shutdown as an int, {@link #SHUTDOWN_REASON_UNKNOWN} if the file could