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

Commit 91b7c1f2 authored by Wesley.CW Wang's avatar Wesley.CW Wang
Browse files

Add isAllowlistedExceptIdle method to check target package is under it

BYPASS_INCLUSIVE_LANGUAGE_REASON=legacy naming, not edit by this code change

Bug: 199892006
Test: make SettingsLibRoboTests
Change-Id: Ie609233ab820bf9079d7e4dc37eb61a4195a4a97
parent f90a4897
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();
    }
}