Reset the dynamic set denylist after reboot the device
Reset the uids which are set into the POLICY_REJECT_METERED_BACKGROUND from the dynamic configured mechanism, rather than set by users manually, to avoid it still take effect after rebooting the device. Bug: 306329984 Test: make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.fuelgauge" Change-Id: Idc0c21350cad7e48e6a5c7190565d5364236c2cd
This commit is contained in:
@@ -51,8 +51,7 @@ public final class BatterySettingsMigrateChecker extends BroadcastReceiver {
|
||||
context = context.getApplicationContext();
|
||||
verifySaverConfiguration(context);
|
||||
verifyBatteryOptimizeModes(context);
|
||||
// Initialize and sync settings into SharedPreferences for migration.
|
||||
DynamicDenylistManager.getInstance(context);
|
||||
DynamicDenylistManager.getInstance(context).onBootComplete();
|
||||
}
|
||||
|
||||
/** Avoid users set important apps into the unexpected battery optimize modes */
|
||||
|
||||
@@ -139,16 +139,25 @@ public final class DynamicDenylistManager {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
for (int uid : mNetworkPolicyManager
|
||||
.getUidsWithPolicy(POLICY_REJECT_METERED_BACKGROUND)) {
|
||||
if (!getDenylistAllUids(getManualDenylistPref()).contains(uid)) {
|
||||
mNetworkPolicyManager.setUidPolicy(uid, POLICY_NONE);
|
||||
final int[] uids = mNetworkPolicyManager
|
||||
.getUidsWithPolicy(POLICY_REJECT_METERED_BACKGROUND);
|
||||
if (uids != null && uids.length != 0) {
|
||||
for (int uid : uids) {
|
||||
if (!getDenylistAllUids(getManualDenylistPref()).contains(uid)) {
|
||||
mNetworkPolicyManager.setUidPolicy(uid, POLICY_NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
clearSharedPreferences();
|
||||
}
|
||||
|
||||
/** Reset the POLICY_REJECT_METERED uids when device is boot completed. */
|
||||
public void onBootComplete() {
|
||||
resetDenylistIfNeeded(/* packageName= */ null, /* force= */ true);
|
||||
syncPolicyIfNeeded();
|
||||
}
|
||||
|
||||
/** Dump the data stored in the {@link SharedPreferences}. */
|
||||
public void dump(PrintWriter writer) {
|
||||
writer.println("Dump of DynamicDenylistManager:");
|
||||
|
||||
Reference in New Issue
Block a user