Loading services/core/java/com/android/server/notification/NotificationManagerService.java +1 −3 Original line number Diff line number Diff line Loading @@ -5697,19 +5697,17 @@ public class NotificationManagerService extends SystemService { } int indexBefore = findNotificationRecordIndexLocked(record); boolean interceptBefore = record.isIntercepted(); float contactAffinityBefore = record.getContactAffinity(); int visibilityBefore = record.getPackageVisibilityOverride(); recon.applyChangesLocked(record); applyZenModeLocked(record); mRankingHelper.sort(mNotificationList); int indexAfter = findNotificationRecordIndexLocked(record); boolean interceptAfter = record.isIntercepted(); float contactAffinityAfter = record.getContactAffinity(); int visibilityAfter = record.getPackageVisibilityOverride(); changed = indexBefore != indexAfter || interceptBefore != interceptAfter || visibilityBefore != visibilityAfter; if (interceptBefore && !interceptAfter && Float.compare(contactAffinityBefore, contactAffinityAfter) != 0) { && record.isNewEnoughForAlerting(System.currentTimeMillis())) { buzzBeepBlinkLocked(record); } } Loading services/core/java/com/android/server/notification/NotificationRecord.java +8 −1 Original line number Diff line number Diff line Loading @@ -92,6 +92,8 @@ public final class NotificationRecord { static final String TAG = "NotificationRecord"; static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); private static final int MAX_LOGTAG_LENGTH = 35; // the period after which a notification is updated where it can make sound private static final int MAX_SOUND_DELAY_MS = 2000; final StatusBarNotification sbn; IActivityManager mAm; UriGrantsManagerInternal mUgmInternal; Loading Loading @@ -125,7 +127,8 @@ public final class NotificationRecord { private long mVisibleSinceMs; // The most recent update time, or the creation time if no updates. private long mUpdateTimeMs; @VisibleForTesting final long mUpdateTimeMs; // The most recent interruption time, or the creation time if no updates. Differs from the // above value because updates are filtered based on whether they actually interrupted the Loading Loading @@ -826,6 +829,10 @@ public final class NotificationRecord { return mIntercept; } public boolean isNewEnoughForAlerting(long now) { return getFreshnessMs(now) <= MAX_SOUND_DELAY_MS; } public void setHidden(boolean hidden) { mHidden = hidden; } Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -825,4 +825,24 @@ public class NotificationRecordTest extends UiServiceTestCase { assertNotEquals(-1, record.getLastAudiblyAlertedMs()); } @Test public void testIsNewEnoughForAlerting_new() { StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertTrue(record.isNewEnoughForAlerting(record.mUpdateTimeMs)); } @Test public void testIsNewEnoughForAlerting_old() { StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertFalse(record.isNewEnoughForAlerting(record.mUpdateTimeMs + (1000 * 60 * 60))); } } Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +1 −3 Original line number Diff line number Diff line Loading @@ -5697,19 +5697,17 @@ public class NotificationManagerService extends SystemService { } int indexBefore = findNotificationRecordIndexLocked(record); boolean interceptBefore = record.isIntercepted(); float contactAffinityBefore = record.getContactAffinity(); int visibilityBefore = record.getPackageVisibilityOverride(); recon.applyChangesLocked(record); applyZenModeLocked(record); mRankingHelper.sort(mNotificationList); int indexAfter = findNotificationRecordIndexLocked(record); boolean interceptAfter = record.isIntercepted(); float contactAffinityAfter = record.getContactAffinity(); int visibilityAfter = record.getPackageVisibilityOverride(); changed = indexBefore != indexAfter || interceptBefore != interceptAfter || visibilityBefore != visibilityAfter; if (interceptBefore && !interceptAfter && Float.compare(contactAffinityBefore, contactAffinityAfter) != 0) { && record.isNewEnoughForAlerting(System.currentTimeMillis())) { buzzBeepBlinkLocked(record); } } Loading
services/core/java/com/android/server/notification/NotificationRecord.java +8 −1 Original line number Diff line number Diff line Loading @@ -92,6 +92,8 @@ public final class NotificationRecord { static final String TAG = "NotificationRecord"; static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); private static final int MAX_LOGTAG_LENGTH = 35; // the period after which a notification is updated where it can make sound private static final int MAX_SOUND_DELAY_MS = 2000; final StatusBarNotification sbn; IActivityManager mAm; UriGrantsManagerInternal mUgmInternal; Loading Loading @@ -125,7 +127,8 @@ public final class NotificationRecord { private long mVisibleSinceMs; // The most recent update time, or the creation time if no updates. private long mUpdateTimeMs; @VisibleForTesting final long mUpdateTimeMs; // The most recent interruption time, or the creation time if no updates. Differs from the // above value because updates are filtered based on whether they actually interrupted the Loading Loading @@ -826,6 +829,10 @@ public final class NotificationRecord { return mIntercept; } public boolean isNewEnoughForAlerting(long now) { return getFreshnessMs(now) <= MAX_SOUND_DELAY_MS; } public void setHidden(boolean hidden) { mHidden = hidden; } Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -825,4 +825,24 @@ public class NotificationRecordTest extends UiServiceTestCase { assertNotEquals(-1, record.getLastAudiblyAlertedMs()); } @Test public void testIsNewEnoughForAlerting_new() { StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertTrue(record.isNewEnoughForAlerting(record.mUpdateTimeMs)); } @Test public void testIsNewEnoughForAlerting_old() { StatusBarNotification sbn = getNotification(PKG_O, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /* defaultLights */, groupId /* group */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, channel); assertFalse(record.isNewEnoughForAlerting(record.mUpdateTimeMs + (1000 * 60 * 60))); } }