Fix parantheses in conditional

((A or B) and C) was written as (A or B and C), leading to
unnecessary code execution and clearing distracting
restrictions whenever any app is disabled by the user.

Also, adding distraction flags to the package dump.

Test: Set distraction flags on any app via Digital Wellbeing
Disable any app and confirm that restrictions don't get cleared via:
adb shell dumpsys package <package-name>

Bug: 145735990
Change-Id: I096fe8e8f13c8b83c86041b993b1faf0cc1582b0
This commit is contained in:
Suprabh Shukla
2020-02-27 15:18:31 -08:00
parent 9f186350a0
commit fe0fc291b4
2 changed files with 6 additions and 4 deletions

View File

@@ -13061,7 +13061,7 @@ public class PackageManagerService extends IPackageManager.Stub
synchronized (mLock) {
allPackages = mPackages.keySet().toArray(new String[mPackages.size()]);
}
PackageManagerService.this.removeDistractingPackageRestrictions(allPackages, userId);
removeDistractingPackageRestrictions(allPackages, userId);
}
/**
@@ -20105,13 +20105,13 @@ public class PackageManagerService extends IPackageManager.Stub
}
synchronized (mLock) {
pkgSetting.setEnabled(newState, userId, callingPackage);
if (newState == COMPONENT_ENABLED_STATE_DISABLED_USER
|| newState == COMPONENT_ENABLED_STATE_DISABLED
if ((newState == COMPONENT_ENABLED_STATE_DISABLED_USER
|| newState == COMPONENT_ENABLED_STATE_DISABLED)
&& pkgSetting.getPermissionsState().hasPermission(
Manifest.permission.SUSPEND_APPS, userId)) {
// This app should not generally be allowed to get disabled by the UI, but if it
// ever does, we don't want to end up with some of the user's apps permanently
// blocked
// suspended.
unsuspendForSuspendingPackage(packageName, userId);
removeAllDistractingPackageRestrictions(userId);
}

View File

@@ -4835,6 +4835,8 @@ public final class Settings {
pw.print(ps.getHidden(user.id));
pw.print(" suspended=");
pw.print(ps.getSuspended(user.id));
pw.print(" distractionFlags=");
pw.print(ps.getDistractionFlags(user.id));
pw.print(" stopped=");
pw.print(ps.getStopped(user.id));
pw.print(" notLaunched=");