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

Commit 43b7beb1 authored by Matías Hernández's avatar Matías Hernández Committed by Android (Google) Code Review
Browse files

Revert "Prevent accidental creation of PackagePreferences for non-existing packages"

This reverts commit ba67a156.

Reason for revert: b/432953209 needs investigation, let's revert first

Bug: 432953209
Bug: 430250142
Change-Id: Ia70632610700424d3184576eed134eee5362b729
parent ba67a156
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -110,7 +110,6 @@ import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_CRITICAL;
import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL;
import static android.os.PowerWhitelistManager.REASON_NOTIFICATION_SERVICE;
import static android.os.PowerWhitelistManager.TEMPORARY_ALLOWLIST_TYPE_FOREGROUND_SERVICE_ALLOWED;
import static android.os.Process.INVALID_UID;
import static android.os.UserHandle.USER_ALL;
import static android.os.UserHandle.USER_NULL;
import static android.os.UserHandle.USER_SYSTEM;
@@ -504,6 +503,7 @@ public class NotificationManagerService extends SystemService {
     */
    private static final int NOTIFICATION_RAPID_CLEAR_THRESHOLD_MS = 5000;
    static final int INVALID_UID = -1;
    static final String ROOT_PKG = "root";
    static final String[] DEFAULT_ALLOWED_ADJUSTMENTS = new String[] {
@@ -5184,7 +5184,7 @@ public class NotificationManagerService extends SystemService {
                String conversationId) {
            if (canNotifyAsPackage(callingPkg, targetPkg, userId)
                    || isCallerSystemOrSystemUiOrShell()) {
                int targetUid = INVALID_UID;
                int targetUid = -1;
                try {
                    targetUid = mPackageManagerClient.getPackageUidAsUser(targetPkg, userId);
                } catch (NameNotFoundException e) {
@@ -5486,7 +5486,7 @@ public class NotificationManagerService extends SystemService {
                String targetPkg, @CannotBeSpecialUser @UserIdInt int userId) {
            if (canNotifyAsPackage(callingPkg, targetPkg, userId)
                || isCallingUidSystem()) {
                int targetUid = INVALID_UID;
                int targetUid = -1;
                try {
                    targetUid = mPackageManagerClient.getPackageUidAsUser(targetPkg, userId);
                } catch (NameNotFoundException e) {
@@ -7405,6 +7405,9 @@ public class NotificationManagerService extends SystemService {
                }
            }
            int uid = getUidForPackageAndUser(pkg, user);
            if (uid == INVALID_UID) {
                return null;
            }
            NotificationChannel parentChannel =
                    mPreferencesHelper.getNotificationChannel(pkg, uid, parentId, false);
            if (parentChannel == null) {
@@ -7559,12 +7562,14 @@ public class NotificationManagerService extends SystemService {
        }
        private int getUidForPackageAndUser(String pkg, UserHandle user) throws RemoteException {
            int uid = INVALID_UID;
            final long identity = Binder.clearCallingIdentity();
            try {
                return mPackageManager.getPackageUid(pkg, 0, user.getIdentifier());
                uid = mPackageManager.getPackageUid(pkg, 0, user.getIdentifier());
            } finally {
                Binder.restoreCallingIdentity(identity);
            }
            return uid;
        }
        @Override
@@ -9219,10 +9224,12 @@ public class NotificationManagerService extends SystemService {
                if (canPostPromoted) {
                    notification.flags |= FLAG_PROMOTED_ONGOING;
                }
            }
        }
    }
    /**
     * Whether a notification can be non-dismissible.
     * A notification should be dismissible, unless it's exempted for some reason.
+88 −97

File changed.

Preview size limit exceeded, changes collapsed.

+0 −52

File changed.

Preview size limit exceeded, changes collapsed.

+73 −76

File changed.

Preview size limit exceeded, changes collapsed.