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

Commit 0436a155 authored by Wesley Wang's avatar Wesley Wang Committed by Automerger Merge Worker
Browse files

Merge "Add isAllowlistedExceptIdle method to check target package is under it"...

Merge "Add isAllowlistedExceptIdle method to check target package is under it" into sc-v2-dev am: 2a15391a am: 8ecdf4b9

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15837567

Change-Id: I56a18570e413ba1b20afb232324be39841bb5640
parents 45c5860b 8ecdf4b9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -109,6 +109,18 @@ public class PowerAllowlistBackend {
        return false;
    }

    /**
     * Check if target package is in allow list except idle app
     */
    public boolean isAllowlistedExceptIdle(String pkg) {
        try {
            return mDeviceIdleService.isPowerSaveWhitelistExceptIdleApp(pkg);
        } catch (RemoteException e) {
            Log.w(TAG, "Unable to reach IDeviceIdleController", e);
            return true;
        }
    }

    /**
     *
     * @param pkgs a list of packageName
+10 −0
Original line number Diff line number Diff line
@@ -151,4 +151,14 @@ public class PowerAllowlistBackendTest {
        assertThat(mPowerAllowlistBackend.isSysAllowlisted(PACKAGE_TWO)).isFalse();
        assertThat(mPowerAllowlistBackend.isAllowlisted(PACKAGE_ONE)).isFalse();
    }

    @Test
    public void testIsPowerSaveWhitelistExceptIdleApp() throws Exception {
        doReturn(true).when(mDeviceIdleService)
                .isPowerSaveWhitelistExceptIdleApp(PACKAGE_ONE);

        mPowerAllowlistBackend.refreshList();

        assertThat(mPowerAllowlistBackend.isAllowlistedExceptIdle(PACKAGE_ONE)).isTrue();
    }
}