Call noteAppRestrictionChanged when toggling restrictions/exemptions

This is to log the reasons for restriction level change and force stop

Bug: 333882527
Test: statsd_testdrive 863
      Toggle battery restrictions manually for an app and verify logging
      of reason
      atest BatteryOptimizeUtilsTest
Change-Id: Ifcc99efc1b6acc5a992f7d952967210b07319f2e
This commit is contained in:
Amith Yamasani
2024-04-10 10:30:57 -07:00
parent d1894bd823
commit 7676217e4d
6 changed files with 30 additions and 8 deletions

View File

@@ -206,8 +206,8 @@ public class BatteryOptimizeUtilsTest {
TimeUnit.SECONDS.sleep(1);
verify(mMockBatteryUtils, never()).setForceAppStandby(anyInt(), anyString(), anyInt());
verify(mMockBackend, never()).addApp(anyString());
verify(mMockBackend, never()).removeApp(anyString());
verify(mMockBackend, never()).addApp(anyString(), anyInt());
verify(mMockBackend, never()).removeApp(anyString(), anyInt());
verifyNoInteractions(mObserver);
}
@@ -358,9 +358,9 @@ public class BatteryOptimizeUtilsTest {
private void verifySetAppOptimizationMode(int appStandbyMode, boolean allowListed) {
verify(mMockBatteryUtils).setForceAppStandby(UID, PACKAGE_NAME, appStandbyMode);
if (allowListed) {
verify(mMockBackend).addApp(PACKAGE_NAME);
verify(mMockBackend).addApp(PACKAGE_NAME, UID);
} else {
verify(mMockBackend).removeApp(PACKAGE_NAME);
verify(mMockBackend).removeApp(PACKAGE_NAME, UID);
}
}
}