Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e57d5ac3 authored by Kweku Adams's avatar Kweku Adams
Browse files

Remove unnecessary permission check.

There's no reason for getPowerSaveModeTrigger to require the POWER_SAVER
permission. The API is only marked as a SystemApi because it was designed
for a specific use case and 3rd party apps don't need to know the
information, but there's no problem if they get the value. All the value
tells you is whether the device will turn on battery saver automatically
based on the percentage level or if it'll turn on automatically based on
a different dynamic signal.

Bug: 174241855
Test: atest android.os.cts.PowerManagerTest
Test: atest android.permission.cts.PowerManagerServicePermissionTest
Test: atest CtsPermission2TestCases
Test: atest SettingsProviderTest
Change-Id: I3146a681d9c5da9c68a7e6b38b50314b293dc924
parent f3efab13
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8574,7 +8574,7 @@ package android.os {
    method @RequiresPermission(allOf={android.Manifest.permission.READ_DREAM_STATE, android.Manifest.permission.WRITE_DREAM_STATE}) public void dream(long);
    method @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public boolean forceSuspend();
    method @NonNull public android.os.BatterySaverPolicyConfig getFullPowerSavePolicy();
    method @RequiresPermission(android.Manifest.permission.POWER_SAVER) public int getPowerSaveModeTrigger();
    method public int getPowerSaveModeTrigger();
    method @RequiresPermission(android.Manifest.permission.READ_DREAM_STATE) public boolean isAmbientDisplayAvailable();
    method @RequiresPermission(android.Manifest.permission.READ_DREAM_STATE) public boolean isAmbientDisplaySuppressed();
    method @RequiresPermission(android.Manifest.permission.READ_DREAM_STATE) public boolean isAmbientDisplaySuppressedForToken(@NonNull String);
+4 −1
Original line number Diff line number Diff line
@@ -1875,6 +1875,10 @@ public final class PowerManager {
     * Returns the current battery saver control mode. Values it may return are defined in
     * AutoPowerSaveModeTriggers. Note that this is a global device state, not a per user setting.
     *
     * <p>Note: Prior to Android version {@link Build.VERSION_CODES#S}, any app calling this method
     * was required to hold the {@link android.Manifest.permission#POWER_SAVER} permission. Starting
     * from Android version {@link Build.VERSION_CODES#S}, that permission is no longer required.
     *
     * @return The current value power saver mode for the system.
     *
     * @see AutoPowerSaveModeTriggers
@@ -1883,7 +1887,6 @@ public final class PowerManager {
     */
    @AutoPowerSaveModeTriggers
    @SystemApi
    @RequiresPermission(android.Manifest.permission.POWER_SAVER)
    public int getPowerSaveModeTrigger() {
        try {
            return mService.getPowerSaveModeTrigger();
+0 −1
Original line number Diff line number Diff line
@@ -5121,7 +5121,6 @@ public final class PowerManagerService extends SystemService

        @Override // Binder call
        public int getPowerSaveModeTrigger() {
            mContext.enforceCallingOrSelfPermission(android.Manifest.permission.POWER_SAVER, null);
            final long ident = Binder.clearCallingIdentity();
            try {
                return Settings.Global.getInt(mContext.getContentResolver(),