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

Commit 1292d580 authored by Felipe Leme's avatar Felipe Leme
Browse files

Restricts PersonalAppsSuspensionHelper.dump() to system user.

It calls a pm method that fails if called for a different user.
As this dump is mostly useful for system user anyways, we can just
ignore the other users (rather than changing the permission check in
the PM method).

Also fixed the userId passed to that method.

Test: adb shell dumpsys device_policy |grep -A 20 PersonalAppsSuspensionHelper # on automotive
Bug: 181238156

Change-Id: Ib416fe9be81a12f40b0b95bfe864d0b2c45efe0b
parent fd8f4ae2
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -1598,10 +1598,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        void setDevicePolicySafetyChecker(DevicePolicySafetyChecker safetyChecker) {
            mSafetyChecker = safetyChecker;
        }
        void dumpPerUserData(IndentingPrintWriter pw, @UserIdInt int userId) {
            PersonalAppsSuspensionHelper.forUser(mContext, userId).dump(pw);
        }
    }
    /**
@@ -9166,15 +9162,23 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    private void dumpPerUserData(IndentingPrintWriter pw) {
        int userCount = mUserData.size();
        for (int userId = 0; userId < userCount; userId++) {
            DevicePolicyData policy = getUserData(mUserData.keyAt(userId));
        for (int i = 0; i < userCount; i++) {
            int userId = mUserData.keyAt(i);
            DevicePolicyData policy = getUserData(userId);
            policy.dump(pw);
            pw.println();
            if (userId == UserHandle.USER_SYSTEM) {
                pw.increaseIndent();
            mInjector.dumpPerUserData(pw, userId);
                PersonalAppsSuspensionHelper.forUser(mContext, userId).dump(pw);
                pw.decreaseIndent();
                pw.println();
            } else {
                // pm.getUnsuspendablePackages() will fail if it's called for a different user;
                // as this dump is mostly useful for system user anyways, we can just ignore the
                // others (rather than changing the permission check in the PM method)
                Slog.d(LOG_TAG, "skipping PersonalAppsSuspensionHelper.dump() for user " + userId);
            }
        }
    }