diff options
| author | Yogisha Dixit <ydixit@google.com> | 2020-09-25 13:15:00 +0100 |
|---|---|---|
| committer | Yogisha Dixit <ydixit@google.com> | 2020-11-03 11:21:43 +0000 |
| commit | 4b1a1f130979c751f7690f5ecf75be7438121a83 (patch) | |
| tree | 134cd385f729208f6ea948d333265c69be9c66a1 /core/java/android/os | |
| parent | 34407ea59b283f1951eca9f876af916693ce8318 (diff) | |
RESTRICT AUTOMERGE
Add a hidden API to check if ambient display is suppressed for a token.
Added 1 method:
boolean isAmbientDisplaySuppressedForTokenByApp(String token, int appUid)
Context:
The Settings team is working on adding a string to the AOD settings page when ambient display is suppressed by Bedtime mode: b/168790245.
The current PowerManager#isAmbientDisplaySuppressedForToken(String token) method will only work if the calling app is also the app that suppressed the ambient display. That is, if Digital Wellbeing called suppressAmbientDisplay("winddown"), then isAmbientDisplaySuppressedForToken("winddown") will only return true for Digital Wellbeing. It will return false for Settings app
This CL adds a hidden API PowerManager#isAmbientDisplaySuppressedForTokenByApp(String token, int appUid) that will return true if the given app is suppressing ambient display with the given token. Settings can then call isAmbientDisplaySuppressedForTokenByApp("winddown", digitalWellbeingUid) to get whether ambient display is suppressed by Bedtime mode.
Test: atest FrameworksServicesTests:PowerManagerServiceTest
Bug: 169241595
Change-Id: I41aecc4ff0ab159d67e62193af27362a96c3174c
(cherry picked from commit 784b62a517d869d639f7da8e4977c68367b38f84)
Diffstat (limited to 'core/java/android/os')
| -rw-r--r-- | core/java/android/os/IPowerManager.aidl | 2 | ||||
| -rw-r--r-- | core/java/android/os/PowerManager.java | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl index 187fd590c080..f171441bb787 100644 --- a/core/java/android/os/IPowerManager.aidl +++ b/core/java/android/os/IPowerManager.aidl @@ -94,6 +94,8 @@ interface IPowerManager boolean isAmbientDisplaySuppressedForToken(String token); // returns whether ambient display is suppressed by any app with any token. boolean isAmbientDisplaySuppressed(); + // returns whether ambient display is suppressed by the given app with the given token. + boolean isAmbientDisplaySuppressedForTokenByApp(String token, int appUid); // Forces the system to suspend even if there are held wakelocks. boolean forceSuspend(); diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index be2de0edda2d..e3a0d18a23cd 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -2127,6 +2127,27 @@ public final class PowerManager { } /** + * Returns true if ambient display is suppressed by the given {@code appUid} 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. + * @param appUid The uid of the app that suppressed ambient display. + * @hide + */ + @RequiresPermission(allOf = { + android.Manifest.permission.READ_DREAM_STATE, + android.Manifest.permission.READ_DREAM_SUPPRESSION }) + public boolean isAmbientDisplaySuppressedForTokenByApp(@NonNull String token, int appUid) { + try { + return mService.isAmbientDisplaySuppressedForTokenByApp(token, appUid); + } 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 |
