Optimize battery optimize page control flow

- Post the setup logic into background and setup once only when leaving
 this page, this can improve the performance since we won't setup
 every time when switching preference

Bug: 195306545
Bug: 199892006
Test: make SettingsRoboTests
Change-Id: I1c3ee4673cf5cdba0abe39f208dfb1412082c579
This commit is contained in:
Wesley.CW Wang
2021-10-28 16:20:55 +08:00
parent 9b325cd54f
commit 151b88f76f
11 changed files with 89 additions and 86 deletions

View File

@@ -74,12 +74,6 @@ public class UnrestrictedPreferenceController extends AbstractPreferenceControll
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (!KEY_UNRESTRICTED_PREF.equals(preference.getKey())) {
return false;
}
mBatteryOptimizeUtils.setAppOptimizationMode(BatteryOptimizeUtils.MODE_UNRESTRICTED);
Log.d(TAG, "Set unrestricted");
return true;
return getPreferenceKey().equals(preference.getKey());
}
}