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

Commit 611d42e4 authored by Matías Hernández's avatar Matías Hernández Committed by mse1969
Browse files

Prevent accidental creation of PackagePreferences for non-existing packages

This could be caused by (indirectly) invoking PreferencesHelper.getOrCreatePackagePreferences with an INVALID_UID (e.g. as the result of NMS passing along the result of getUidForPackageAndUser for a missing package). This was never intended -- API calls can result in the creation of PackagePreferences (since the structure is lazily initialized) but only for present packages. In most cases this was prevented by other checks (e.g. canNotifyAsPackage, which fails if missing) but specifically for the "fromPrivilegedListener" methods there was no similar enforcement.

Switch the PreferencesHelper usage so that:
* setters (e.g. create/updateChannel, groups) throw if supplied an invalid uid.
* getters that should have PackagePreferences creation as a side effect (e.g. getChannel) early exit if supplied an invalid uid.
* most getters don't actually create PackagePreferences and just return default values (e.g. canShowBadge) if they don't exist yet.

(Also, unify constants for representing a missing package into Process.INVALID_UID, and fix several tests that were impropely set up).

Bug: 426207912
Test: atest NotificationManagerServiceTest PreferencesHelperTest
(cherry picked from commit 236cff68)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:a629bb1b5e87dbcd82a0ab85c681f443b606ce10
Merged-In: I7d0717aed9fb26490f68801c9220833f2bed8e23
Change-Id: I7d0717aed9fb26490f68801c9220833f2bed8e23
parent f9d2665e
Loading
Loading
Loading
Loading
+23 −12
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import static android.media.AudioAttributes.FLAG_BYPASS_INTERRUPTION_POLICY;
import static android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL;
import static android.os.Process.INVALID_UID;
import static android.os.UserHandle.USER_NULL;
import static android.os.UserHandle.USER_SYSTEM;
import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS;
@@ -357,7 +358,6 @@ public class NotificationManagerService extends SystemService {

    static final int VIBRATE_PATTERN_MAXLEN = 8 * 2 + 1; // up to eight bumps

    static final int INVALID_UID = -1;
    static final String ROOT_PKG = "root";

    static final boolean ENABLE_BLOCKED_TOASTS = true;
@@ -3539,7 +3539,7 @@ public class NotificationManagerService extends SystemService {
                String conversationId) {
            if (canNotifyAsPackage(callingPkg, targetPkg, userId)
                    || isCallerIsSystemOrSysemUiOrShell()) {
                int targetUid = -1;
                int targetUid = INVALID_UID;
                try {
                    targetUid = mPackageManagerClient.getPackageUidAsUser(targetPkg, userId);
                } catch (NameNotFoundException e) {
@@ -3780,7 +3780,7 @@ public class NotificationManagerService extends SystemService {
                String callingPkg, String targetPkg, int userId) {
            if (canNotifyAsPackage(callingPkg, targetPkg, userId)
                || isCallingUidSystem()) {
                int targetUid = -1;
                int targetUid = INVALID_UID;
                try {
                    targetUid = mPackageManagerClient.getPackageUidAsUser(targetPkg, userId);
                } catch (NameNotFoundException e) {
@@ -5240,11 +5240,10 @@ public class NotificationManagerService extends SystemService {
            int uid = 0;
            long identity = Binder.clearCallingIdentity();
            try {
                uid = mPackageManager.getPackageUid(pkg, 0, user.getIdentifier());
                return mPackageManager.getPackageUid(pkg, 0, user.getIdentifier());
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
            return uid;
        }

        @Override
@@ -10194,15 +10193,22 @@ public class NotificationManagerService extends SystemService {
            List<UserInfo> users = mUm.getUsers();
            mNonBlockableDefaultApps = new ArrayMap<>();
            for (int i = 0; i < NON_BLOCKABLE_DEFAULT_ROLES.length; i++) {
                String role = NON_BLOCKABLE_DEFAULT_ROLES[i];
                final ArrayMap<Integer, ArraySet<String>> userToApprovedList = new ArrayMap<>();
                mNonBlockableDefaultApps.put(NON_BLOCKABLE_DEFAULT_ROLES[i], userToApprovedList);
                mNonBlockableDefaultApps.put(role, userToApprovedList);
                for (int j = 0; j < users.size(); j++) {
                    Integer userId = users.get(j).getUserHandle().getIdentifier();
                    int userId = users.get(j).getUserHandle().getIdentifier();
                    ArraySet<String> approvedForUserId = new ArraySet<>(mRm.getRoleHoldersAsUser(
                            NON_BLOCKABLE_DEFAULT_ROLES[i], UserHandle.of(userId)));
                            role, UserHandle.of(userId)));
                    ArraySet<Pair<String, Integer>> approvedAppUids = new ArraySet<>();
                    for (String pkg : approvedForUserId) {
                        approvedAppUids.add(new Pair(pkg, getUidForPackage(pkg, userId)));
                        int uid = getUidForPackage(pkg, userId);
                        if (uid != INVALID_UID) {
                            approvedAppUids.add(new Pair<>(pkg, uid));
                        } else {
                            Slog.e(TAG, "init: Invalid package for role " + role
                                    + " (user " + userId + "): " + pkg);
                        }
                    }
                    userToApprovedList.put(userId, approvedForUserId);
                    mPreferencesHelper.updateDefaultApps(userId, null, approvedAppUids);
@@ -10257,8 +10263,13 @@ public class NotificationManagerService extends SystemService {
            }
            for (String nowApproved : roleHolders) {
                if (!previouslyApproved.contains(nowApproved)) {
                    toAdd.add(new Pair(nowApproved,
                            getUidForPackage(nowApproved, user.getIdentifier())));
                    int uid = getUidForPackage(nowApproved, user.getIdentifier());
                    if (uid != INVALID_UID) {
                        toAdd.add(new Pair<>(nowApproved, uid));
                    } else {
                        Slog.e(TAG, "onRoleHoldersChanged: Invalid package for role " + roleName
                                + " (user " + user.getIdentifier() + "): " + nowApproved);
                    }
                }
            }

@@ -10279,7 +10290,7 @@ public class NotificationManagerService extends SystemService {
            } catch (RemoteException e) {
                Slog.e(TAG, "role manager has bad default " + pkg + " " + userId);
            }
            return -1;
            return INVALID_UID;
        }
    }

+94 −52
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.app.NotificationManager.BUBBLE_PREFERENCE_ALL;
import static android.app.NotificationManager.BUBBLE_PREFERENCE_NONE;
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
import static android.os.Process.INVALID_UID;

import static com.android.internal.util.FrameworkStatsLog.ANNOTATION_ID_IS_UID;
import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_CHANNEL_GROUP_PREFERENCES;
@@ -59,6 +60,7 @@ import android.util.StatsEvent;
import android.util.proto.ProtoOutputStream;

import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.Preconditions;
@@ -88,8 +90,6 @@ public class PreferencesHelper implements RankingConfig {
    private static final int XML_VERSION = 2;
    /** What version to check to do the upgrade for bubbles. */
    private static final int XML_VERSION_BUBBLES_UPGRADE = 1;
    @VisibleForTesting
    static final int UNKNOWN_UID = UserHandle.USER_NULL;
    private static final String NON_BLOCKABLE_CHANNEL_DELIM = ":";

    @VisibleForTesting
@@ -232,7 +232,7 @@ public class PreferencesHelper implements RankingConfig {
                        mHideSilentStatusBarIcons = XmlUtils.readBooleanAttribute(
                                parser, ATT_HIDE_SILENT, DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS);
                    } else if (TAG_PACKAGE.equals(tag)) {
                        int uid = XmlUtils.readIntAttribute(parser, ATT_UID, UNKNOWN_UID);
                        int uid = XmlUtils.readIntAttribute(parser, ATT_UID, INVALID_UID);
                        String name = parser.getAttributeValue(null, ATT_NAME);
                        if (!TextUtils.isEmpty(name)) {
                            if (forRestore) {
@@ -245,7 +245,7 @@ public class PreferencesHelper implements RankingConfig {
                            boolean skipWarningLogged = false;
                            boolean skipGroupWarningLogged = false;
                            boolean hasSAWPermission = false;
                            if (upgradeForBubbles && uid != UNKNOWN_UID) {
                            if (upgradeForBubbles && uid != INVALID_UID) {
                                hasSAWPermission = mAppOps.noteOpNoThrow(
                                        OP_SYSTEM_ALERT_WINDOW, uid, name, null,
                                        "check-notif-bubble") == AppOpsManager.MODE_ALLOWED;
@@ -255,7 +255,7 @@ public class PreferencesHelper implements RankingConfig {
                                    : XmlUtils.readIntAttribute(parser, ATT_ALLOW_BUBBLE,
                                            DEFAULT_BUBBLE_PREFERENCE);

                            PackagePreferences r = getOrCreatePackagePreferencesLocked(
                            PackagePreferences r = getOrCreatePackagePreferencesSupportingInvalidUidLocked(
                                    name, userId, uid,
                                    XmlUtils.readIntAttribute(
                                            parser, ATT_IMPORTANCE, DEFAULT_IMPORTANCE),
@@ -357,7 +357,7 @@ public class PreferencesHelper implements RankingConfig {
                                // Delegate
                                if (TAG_DELEGATE.equals(tagName)) {
                                    int delegateId =
                                            XmlUtils.readIntAttribute(parser, ATT_UID, UNKNOWN_UID);
                                            XmlUtils.readIntAttribute(parser, ATT_UID, INVALID_UID);
                                    String delegateName =
                                            XmlUtils.readStringAttribute(parser, ATT_NAME);
                                    boolean delegateEnabled = XmlUtils.readBooleanAttribute(
@@ -366,7 +366,7 @@ public class PreferencesHelper implements RankingConfig {
                                            parser, ATT_USER_ALLOWED,
                                            Delegate.DEFAULT_USER_ALLOWED);
                                    Delegate d = null;
                                    if (delegateId != UNKNOWN_UID && !TextUtils.isEmpty(
                                    if (delegateId != INVALID_UID && !TextUtils.isEmpty(
                                            delegateName)) {
                                        d = new Delegate(
                                                delegateName, delegateId, delegateEnabled,
@@ -390,31 +390,67 @@ public class PreferencesHelper implements RankingConfig {
        throw new IllegalStateException("Failed to reach END_DOCUMENT");
    }

    /**
     * Returns the {@link PackagePreferences} object associated to the pkg/uid pair. If it doesn't
     * exist, return {@code null}.
     */
    @GuardedBy("mPackagePreferences")
    @Nullable
    private PackagePreferences getPackagePreferencesLocked(String pkg, int uid) {
        final String key = packagePreferencesKey(pkg, uid);
        return mPackagePreferences.get(key);
    }

    private PackagePreferences getOrCreatePackagePreferencesLocked(String pkg,
            int uid) {
        return getOrCreatePackagePreferencesLocked(pkg, UserHandle.getUserId(uid), uid,
                DEFAULT_IMPORTANCE, DEFAULT_PRIORITY, DEFAULT_VISIBILITY, DEFAULT_SHOW_BADGE,
                DEFAULT_BUBBLE_PREFERENCE);
    /**
     * Returns the {@link PackagePreferences} object associated to the pkg/uid pair. If it doesn't
     * exist, a new one is initialized (with appropriate defaults, e.g. default channel if pre-O)
     * and stored in {@link #mPackagePreferences}.
     *
     * @throws IllegalArgumentException if the supplied uid is not valid (i.e. {@code INVALID_UID}).
     */
    @GuardedBy("mPackagePreferences")
    @NonNull
    private PackagePreferences getOrCreatePackagePreferencesLocked(String pkg, int uid) {
        Objects.requireNonNull(pkg);
        Preconditions.checkArgument(uid != INVALID_UID,
                "Valid uid required to get settings of %s", pkg);

        // TODO (b/194833441): use permissionhelper instead of DEFAULT_IMPORTANCE
        return getOrCreatePackagePreferencesSupportingInvalidUidLocked(pkg,
                UserHandle.getUserId(uid), uid, DEFAULT_IMPORTANCE, DEFAULT_PRIORITY,
                DEFAULT_VISIBILITY, DEFAULT_SHOW_BADGE, DEFAULT_BUBBLE_PREFERENCE);
    }

    private PackagePreferences getOrCreatePackagePreferencesLocked(String pkg,
            @UserIdInt int userId, int uid) {
        return getOrCreatePackagePreferencesLocked(pkg, userId, uid,
                DEFAULT_IMPORTANCE, DEFAULT_PRIORITY, DEFAULT_VISIBILITY, DEFAULT_SHOW_BADGE,
                DEFAULT_BUBBLE_PREFERENCE);
        Objects.requireNonNull(pkg);
        Preconditions.checkArgument(uid != INVALID_UID,
                "Valid uid required to get settings of %s", pkg);

        // TODO (b/194833441): use permissionhelper instead of DEFAULT_IMPORTANCE
        return getOrCreatePackagePreferencesSupportingInvalidUidLocked(pkg, userId,
                uid, DEFAULT_IMPORTANCE, DEFAULT_PRIORITY, DEFAULT_VISIBILITY,
                DEFAULT_SHOW_BADGE, DEFAULT_BUBBLE_PREFERENCE);
    }

    private PackagePreferences getOrCreatePackagePreferencesLocked(String pkg,
    /**
     * Returns the {@link PackagePreferences} object associated to the pkg/uid pair, and initializes
     * a new one (with appropriate defaults, e.g. default channel if pre-O) if it doesn't exist.
     *
     * <p>This method accepts {@link android.os.Process#INVALID_UID} as the {@code uid}
     * parameter, and in that case will create a (time-limited) entry in
     * {@link #mRestoredWithoutUids} instead of {@link #mPackagePreferences}. As such, should only
     * be used that way by the {@code readXml()} path, to support restoring NMS backups before all
     * packages have been reinstalled -- for API calls, we shouldn't create entries for
     * non-existing packages.
     */
    @GuardedBy("mPackagePreferences")
    private PackagePreferences getOrCreatePackagePreferencesSupportingInvalidUidLocked(String pkg,
            @UserIdInt int userId, int uid, int importance, int priority, int visibility,
            boolean showBadge, int bubblePreference) {
        final String key = packagePreferencesKey(pkg, uid);
        PackagePreferences
                r = (uid == UNKNOWN_UID)
                r = (uid == INVALID_UID)
                ? mRestoredWithoutUids.get(unrestoredPackageKey(pkg, userId))
                : mPackagePreferences.get(key);
        if (r == null) {
@@ -441,7 +477,7 @@ public class PreferencesHelper implements RankingConfig {
                Slog.e(TAG, "createDefaultChannelIfNeededLocked - Exception: " + e);
            }

            if (r.uid == UNKNOWN_UID) {
            if (r.uid == INVALID_UID) {
                mRestoredWithoutUids.put(unrestoredPackageKey(pkg, userId), r);
            } else {
                mPackagePreferences.put(key, r);
@@ -484,7 +520,7 @@ public class PreferencesHelper implements RankingConfig {

    private boolean createDefaultChannelIfNeededLocked(PackagePreferences r) throws
            PackageManager.NameNotFoundException {
        if (r.uid == UNKNOWN_UID) {
        if (r.uid == INVALID_UID) {
            return false;
        }

@@ -652,13 +688,15 @@ public class PreferencesHelper implements RankingConfig {
    @Override
    public int getBubblePreference(String pkg, int uid) {
        synchronized (mPackagePreferences) {
            return getOrCreatePackagePreferencesLocked(pkg, uid).bubblePreference;
            PackagePreferences p = getPackagePreferencesLocked(pkg, uid);
            return p != null ? p.bubblePreference : DEFAULT_BUBBLE_PREFERENCE;
        }
    }

    public int getAppLockedFields(String pkg, int uid) {
        synchronized (mPackagePreferences) {
            return getOrCreatePackagePreferencesLocked(pkg, uid).lockedAppFields;
            PackagePreferences p = getPackagePreferencesLocked(pkg, uid);
            return p != null ? p.lockedAppFields : DEFAULT_LOCKED_APP_FIELDS;
        }
    }

@@ -687,7 +725,8 @@ public class PreferencesHelper implements RankingConfig {
    @Override
    public boolean canShowBadge(String packageName, int uid) {
        synchronized (mPackagePreferences) {
            return getOrCreatePackagePreferencesLocked(packageName, uid).showBadge;
            PackagePreferences p = getPackagePreferencesLocked(packageName, uid);
            return p != null ? p.showBadge : DEFAULT_SHOW_BADGE;
        }
    }

@@ -701,15 +740,15 @@ public class PreferencesHelper implements RankingConfig {

    public boolean isInInvalidMsgState(String packageName, int uid) {
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(packageName, uid);
            return r.hasSentInvalidMessage && !r.hasSentValidMessage;
            PackagePreferences r = getPackagePreferencesLocked(packageName, uid);
            return r != null && r.hasSentInvalidMessage && !r.hasSentValidMessage;
        }
    }

    public boolean hasUserDemotedInvalidMsgApp(String packageName, int uid) {
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(packageName, uid);
            return isInInvalidMsgState(packageName, uid) ? r.userDemotedMsgApp : false;
            PackagePreferences r = getPackagePreferencesLocked(packageName, uid);
            return r != null && isInInvalidMsgState(packageName, uid) && r.userDemotedMsgApp;
        }
    }

@@ -743,24 +782,24 @@ public class PreferencesHelper implements RankingConfig {
    @VisibleForTesting
    boolean hasSentInvalidMsg(String packageName, int uid) {
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(packageName, uid);
            return r.hasSentInvalidMessage;
            PackagePreferences r = getPackagePreferencesLocked(packageName, uid);
            return r != null && r.hasSentInvalidMessage;
        }
    }

    @VisibleForTesting
    boolean hasSentValidMsg(String packageName, int uid) {
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(packageName, uid);
            return r.hasSentValidMessage;
            PackagePreferences r = getPackagePreferencesLocked(packageName, uid);
            return r != null && r.hasSentValidMessage;
        }
    }

    @VisibleForTesting
    boolean didUserEverDemoteInvalidMsgApp(String packageName, int uid) {
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(packageName, uid);
            return r.userDemotedMsgApp;
            PackagePreferences p = getPackagePreferencesLocked(packageName, uid);
            return p != null && p.userDemotedMsgApp;
        }
    }

@@ -770,7 +809,10 @@ public class PreferencesHelper implements RankingConfig {
            return false;
        }
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(packageName, uid);
            PackagePreferences r = getPackagePreferencesLocked(packageName, uid);
            if (r == null) {
                return false;
            }
            NotificationChannelGroup group = r.groups.get(groupId);
            if (group == null) {
                return false;
@@ -781,13 +823,15 @@ public class PreferencesHelper implements RankingConfig {

    int getPackagePriority(String pkg, int uid) {
        synchronized (mPackagePreferences) {
            return getOrCreatePackagePreferencesLocked(pkg, uid).priority;
            PackagePreferences p = getPackagePreferencesLocked(pkg, uid);
            return p != null ? p.priority : DEFAULT_PRIORITY;
        }
    }

    int getPackageVisibility(String pkg, int uid) {
        synchronized (mPackagePreferences) {
            return getOrCreatePackagePreferencesLocked(pkg, uid).visibility;
            PackagePreferences p = getPackagePreferencesLocked(pkg, uid);
            return p != null ? p.visibility : DEFAULT_VISIBILITY;
        }
    }

@@ -800,9 +844,6 @@ public class PreferencesHelper implements RankingConfig {
        Objects.requireNonNull(!TextUtils.isEmpty(group.getName()));
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(pkg, uid);
            if (r == null) {
                throw new IllegalArgumentException("Invalid package");
            }
            if (fromTargetApp) {
                group.setBlocked(false);
                if (r.groups.size() >= NOTIFICATION_CHANNEL_GROUP_COUNT_LIMIT) {
@@ -847,9 +888,6 @@ public class PreferencesHelper implements RankingConfig {
        boolean needsPolicyFileChange = false, wasUndeleted = false;
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(pkg, uid);
            if (r == null) {
                throw new IllegalArgumentException("Invalid package");
            }
            if (channel.getGroup() != null && !r.groups.containsKey(channel.getGroup())) {
                throw new IllegalArgumentException("NotificationChannelGroup doesn't exist");
            }
@@ -1006,9 +1044,6 @@ public class PreferencesHelper implements RankingConfig {
        Objects.requireNonNull(updatedChannel.getId());
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(pkg, uid);
            if (r == null) {
                throw new IllegalArgumentException("Invalid package");
            }
            NotificationChannel channel = r.channels.get(updatedChannel.getId());
            if (channel == null || channel.isDeleted()) {
                throw new IllegalArgumentException("Channel does not exist");
@@ -1067,6 +1102,9 @@ public class PreferencesHelper implements RankingConfig {
    public NotificationChannel getNotificationChannel(String pkg, int uid, String channelId,
            boolean includeDeleted) {
        Objects.requireNonNull(pkg);
        if (uid == INVALID_UID) {
            return null;
        }
        return getConversationNotificationChannel(pkg, uid, channelId, null, true, includeDeleted);
    }

@@ -1075,11 +1113,11 @@ public class PreferencesHelper implements RankingConfig {
            String channelId, String conversationId, boolean returnParentIfNoConversationChannel,
            boolean includeDeleted) {
        Preconditions.checkNotNull(pkg);
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(pkg, uid);
            if (r == null) {
        if (uid == INVALID_UID) {
            return null;
        }
        synchronized (mPackagePreferences) {
            PackagePreferences r = getOrCreatePackagePreferencesLocked(pkg, uid);
            if (channelId == null) {
                channelId = NotificationChannel.DEFAULT_CHANNEL_ID;
            }
@@ -1508,6 +1546,9 @@ public class PreferencesHelper implements RankingConfig {
    public ParceledListSlice<NotificationChannel> getNotificationChannels(String pkg, int uid,
            boolean includeDeleted) {
        Objects.requireNonNull(pkg);
        if (uid == INVALID_UID) {
            return ParceledListSlice.emptyList();
        }
        List<NotificationChannel> channels = new ArrayList<>();
        synchronized (mPackagePreferences) {
            PackagePreferences r = getPackagePreferencesLocked(pkg, uid);
@@ -1742,7 +1783,8 @@ public class PreferencesHelper implements RankingConfig {
     * {@code uid}, have their importance locked by the user. Locked notifications don't get
     * considered for sentiment adjustments (and thus never show a blocking helper).
     */
    public void setAppImportanceLocked(String packageName, int uid) {
    @VisibleForTesting
    void setAppImportanceLocked(String packageName, int uid) {
        synchronized (mPackagePreferences) {
            PackagePreferences prefs = getOrCreatePackagePreferencesLocked(packageName, uid);
            if ((prefs.lockedAppFields & LockableAppFields.USER_LOCKED_IMPORTANCE) != 0) {
@@ -1914,7 +1956,7 @@ public class PreferencesHelper implements RankingConfig {
                pw.print("  AppSettings: ");
                pw.print(r.pkg);
                pw.print(" (");
                pw.print(r.uid == UNKNOWN_UID ? "UNKNOWN_UID" : Integer.toString(r.uid));
                pw.print(r.uid == INVALID_UID ? "INVALID_UID" : Integer.toString(r.uid));
                pw.print(')');
                if (r.importance != DEFAULT_IMPORTANCE) {
                    pw.print(" importance=");
@@ -2439,7 +2481,7 @@ public class PreferencesHelper implements RankingConfig {

    private static class PackagePreferences {
        String pkg;
        int uid = UNKNOWN_UID;
        int uid = INVALID_UID;
        int importance = DEFAULT_IMPORTANCE;
        int priority = DEFAULT_PRIORITY;
        int visibility = DEFAULT_VISIBILITY;
@@ -2471,7 +2513,7 @@ public class PreferencesHelper implements RankingConfig {
        static final boolean DEFAULT_ENABLED = true;
        static final boolean DEFAULT_USER_ALLOWED = true;
        String mPkg;
        int mUid = UNKNOWN_UID;
        int mUid = INVALID_UID;
        boolean mEnabled = DEFAULT_ENABLED;
        boolean mUserAllowed = DEFAULT_USER_ALLOWED;

@@ -2483,7 +2525,7 @@ public class PreferencesHelper implements RankingConfig {
        }

        public boolean isAllowed(String pkg, int uid) {
            if (pkg == null || uid == UNKNOWN_UID) {
            if (pkg == null || uid == INVALID_UID) {
                return false;
            }
            return pkg.equals(mPkg)
+52 −0

File changed.

Preview size limit exceeded, changes collapsed.