Loading core/java/android/os/IPowerManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,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(); Loading core/java/android/os/PowerManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -2190,6 +2190,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. Loading core/res/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -4322,6 +4322,10 @@ <permission android:name="android.permission.WRITE_DREAM_STATE" android:protectionLevel="signature|privileged" /> <!-- @hide Allows applications to read whether ambient display is suppressed. --> <permission android:name="android.permission.READ_DREAM_SUPPRESSION" android:protectionLevel="signature" /> <!-- @SystemApi Allow an application to read and write the cache partition. @hide --> <permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" Loading services/core/java/com/android/server/power/PowerManagerService.java +16 −0 Original line number Diff line number Diff line Loading @@ -5407,6 +5407,22 @@ public final class PowerManagerService extends SystemService } } @Override // Binder call public boolean isAmbientDisplaySuppressedForTokenByApp(@NonNull String token, int appUid) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.READ_DREAM_STATE, null); mContext.enforceCallingOrSelfPermission( android.Manifest.permission.READ_DREAM_SUPPRESSION, null); final long ident = Binder.clearCallingIdentity(); try { return isAmbientDisplayAvailable() && mAmbientDisplaySuppressionController.isSuppressed(token, appUid); } finally { Binder.restoreCallingIdentity(ident); } } @Override // Binder call public boolean isAmbientDisplaySuppressed() { mContext.enforceCallingOrSelfPermission( Loading services/tests/servicestests/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/> <uses-permission android:name="android.permission.DUMP"/> <uses-permission android:name="android.permission.READ_DREAM_STATE"/> <uses-permission android:name="android.permission.READ_DREAM_SUPPRESSION"/> <uses-permission android:name="android.permission.WRITE_DREAM_STATE"/> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> <uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE"/> Loading Loading
core/java/android/os/IPowerManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,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(); Loading
core/java/android/os/PowerManager.java +21 −0 Original line number Diff line number Diff line Loading @@ -2190,6 +2190,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. Loading
core/res/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -4322,6 +4322,10 @@ <permission android:name="android.permission.WRITE_DREAM_STATE" android:protectionLevel="signature|privileged" /> <!-- @hide Allows applications to read whether ambient display is suppressed. --> <permission android:name="android.permission.READ_DREAM_SUPPRESSION" android:protectionLevel="signature" /> <!-- @SystemApi Allow an application to read and write the cache partition. @hide --> <permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" Loading
services/core/java/com/android/server/power/PowerManagerService.java +16 −0 Original line number Diff line number Diff line Loading @@ -5407,6 +5407,22 @@ public final class PowerManagerService extends SystemService } } @Override // Binder call public boolean isAmbientDisplaySuppressedForTokenByApp(@NonNull String token, int appUid) { mContext.enforceCallingOrSelfPermission( android.Manifest.permission.READ_DREAM_STATE, null); mContext.enforceCallingOrSelfPermission( android.Manifest.permission.READ_DREAM_SUPPRESSION, null); final long ident = Binder.clearCallingIdentity(); try { return isAmbientDisplayAvailable() && mAmbientDisplaySuppressionController.isSuppressed(token, appUid); } finally { Binder.restoreCallingIdentity(ident); } } @Override // Binder call public boolean isAmbientDisplaySuppressed() { mContext.enforceCallingOrSelfPermission( Loading
services/tests/servicestests/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/> <uses-permission android:name="android.permission.DUMP"/> <uses-permission android:name="android.permission.READ_DREAM_STATE"/> <uses-permission android:name="android.permission.READ_DREAM_SUPPRESSION"/> <uses-permission android:name="android.permission.WRITE_DREAM_STATE"/> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> <uses-permission android:name="android.permission.MODIFY_DAY_NIGHT_MODE"/> Loading