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

Commit 3724aa89 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Use a real pkg name and uid"

parents 92685613 5bc56484
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -5805,6 +5805,7 @@ public class NotificationManagerService extends SystemService {
                            || channel.isImportanceLockedByCriticalDeviceFunction());
            final StatusBarNotification adjustedSbn = notificationRecord.getSbn();
            userId = adjustedSbn.getUser().getIdentifier();
            int uid =  adjustedSbn.getUid();
            ArrayMap<String, String> summaries = mAutobundledSummaries.get(userId);
            if (summaries == null) {
                summaries = new ArrayMap<>();
@@ -5851,7 +5852,7 @@ public class NotificationManagerService extends SystemService {
                        notificationRecord.getIsAppImportanceLocked());
                summaries.put(pkg, summarySbn.getKey());
            }
            if (summaryRecord != null && checkDisqualifyingFeatures(userId, MY_UID,
            if (summaryRecord != null && checkDisqualifyingFeatures(userId, uid,
                    summaryRecord.getSbn().getId(), summaryRecord.getSbn().getTag(), summaryRecord,
                    true)) {
                return summaryRecord;
@@ -6837,7 +6838,6 @@ public class NotificationManagerService extends SystemService {
            return false;
        }
        // blocked apps
        boolean isBlocked = !areNotificationsEnabledForPackageInt(pkg, uid);
        synchronized (mNotificationLock) {
@@ -7230,10 +7230,12 @@ public class NotificationManagerService extends SystemService {
                if (mAssistants.isEnabled()) {
                    mAssistants.onNotificationEnqueuedLocked(r);
                    mHandler.postDelayed(
                            new PostNotificationRunnable(r.getKey(), enqueueElapsedTimeMs),
                            new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                                    r.getUid(), enqueueElapsedTimeMs),
                            DELAY_FOR_ASSISTANT_TIME);
                } else {
                    mHandler.post(new PostNotificationRunnable(r.getKey(), enqueueElapsedTimeMs));
                    mHandler.post(new PostNotificationRunnable(r.getKey(),
                            r.getSbn().getPackageName(), r.getUid(), enqueueElapsedTimeMs));
                }
            }
        }
@@ -7257,16 +7259,19 @@ public class NotificationManagerService extends SystemService {
    protected class PostNotificationRunnable implements Runnable {
        private final String key;
        private final long postElapsedTimeMs;
        private final String pkg;
        private final int uid;
        PostNotificationRunnable(String key, @ElapsedRealtimeLong long postElapsedTimeMs) {
        PostNotificationRunnable(String key, String pkg, int uid,
                @ElapsedRealtimeLong long postElapsedTimeMs) {
            this.key = key;
            this.pkg = pkg;
            this.uid = uid;
            this.postElapsedTimeMs = postElapsedTimeMs;
        }
        @Override
        public void run() {
            String pkg = StatusBarNotification.getPkgFromKey(key);
            int uid = StatusBarNotification.getUidFromKey(key);
            boolean appBanned = !areNotificationsEnabledForPackageInt(pkg, uid);
            synchronized (mNotificationLock) {
                try {
+20 −8
Original line number Diff line number Diff line
@@ -1340,7 +1340,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        mBinderService.applyEnqueuedAdjustmentFromAssistant(null, adjustment);

        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
                mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                        r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();

@@ -1361,7 +1362,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        when(mPreferencesHelper.getImportance(anyString(), anyInt())).thenReturn(IMPORTANCE_NONE);

        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
                mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                        r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();

@@ -3923,7 +3925,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        NotificationRecord r = generateNotificationRecord(mTestNotificationChannel, 0, null, false);
        mService.addEnqueuedNotification(r);
        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
                mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                        r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();

@@ -3940,7 +3943,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        r = generateNotificationRecord(mTestNotificationChannel, 0, null, false);
        mService.addEnqueuedNotification(r);
        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
                mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                        r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();

@@ -3956,7 +3960,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        mService.addEnqueuedNotification(r);

        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
                mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                        r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();

@@ -3969,12 +3974,14 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        r.setCriticality(CriticalNotificationExtractor.CRITICAL_LOW);
        mService.addEnqueuedNotification(r);
        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
                mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                        r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();

        r = generateNotificationRecord(mTestNotificationChannel, 1, null, false);
        r.setCriticality(CriticalNotificationExtractor.CRITICAL);
        runnable = mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
        runnable = mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                r.getUid(), SystemClock.elapsedRealtime());
        mService.addEnqueuedNotification(r);

        runnable.run();
@@ -4475,6 +4482,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {

        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(original.getKey(),
                        original.getSbn().getPackageName(),
                        original.getUid(),
                        SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();
@@ -4497,6 +4506,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {

        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(update.getKey(),
                        update.getSbn().getPackageName(),
                        update.getUid(),
                        SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();
@@ -6592,7 +6603,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        assertNull(update.getSbn().getNotification().getSmallIcon());

        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(update.getKey(),
                mService.new PostNotificationRunnable(update.getKey(), r.getSbn().getPackageName(),
                        r.getUid(),
                        SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();
+8 −4
Original line number Diff line number Diff line
@@ -657,7 +657,8 @@ public class NotificationPermissionMigrationTest extends UiServiceTestCase {
        when(mPermissionHelper.hasPermission(anyInt())).thenReturn(false);

        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
                mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                        r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();

@@ -790,7 +791,8 @@ public class NotificationPermissionMigrationTest extends UiServiceTestCase {

        mService.addEnqueuedNotification(r);
        NotificationManagerService.PostNotificationRunnable runnable =
                mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
                mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                        r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();

@@ -806,7 +808,8 @@ public class NotificationPermissionMigrationTest extends UiServiceTestCase {
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);

        mService.addEnqueuedNotification(r);
        runnable = mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
        runnable = mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();

@@ -822,7 +825,8 @@ public class NotificationPermissionMigrationTest extends UiServiceTestCase {
        r = new NotificationRecord(mContext, sbn, mTestNotificationChannel);

        mService.addEnqueuedNotification(r);
        runnable = mService.new PostNotificationRunnable(r.getKey(), SystemClock.elapsedRealtime());
        runnable = mService.new PostNotificationRunnable(r.getKey(), r.getSbn().getPackageName(),
                r.getUid(), SystemClock.elapsedRealtime());
        runnable.run();
        waitForIdle();