diff options
| author | 2019-10-04 07:24:36 -0700 | |
|---|---|---|
| committer | 2019-10-04 07:24:36 -0700 | |
| commit | dca919d8d8927451a1d3cc3564b9691cea09dbb3 (patch) | |
| tree | 30189e9a0c0b2647e596c9ad4b214eeb897c04ab | |
| parent | 0935b64e5b89fe29dadaebba6a9f33b011241b52 (diff) | |
| parent | 3797fd2b58d937b74d98ae6349f520d75864fa24 (diff) | |
Merge "Reduce unnecessary NotificationListener binder transaction." am: d3ec7950e3 am: c3918379eb
am: 3797fd2b58
Change-Id: I9375842043dc95b0095f3df7c9ac8cae695a4d65
| -rwxr-xr-x[-rw-r--r--] | services/core/java/com/android/server/notification/NotificationManagerService.java | 13 | ||||
| -rwxr-xr-x[-rw-r--r--] | services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java | 8 |
2 files changed, 12 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index a91630e72520..aba7ebb1df26 100644..100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -1284,16 +1284,15 @@ public class NotificationManagerService extends SystemService { uidList = new int[] {intent.getIntExtra(Intent.EXTRA_UID, -1)}; } if (pkgList != null && (pkgList.length > 0)) { - for (String pkgName : pkgList) { - if (cancelNotifications) { + if (cancelNotifications) { + for (String pkgName : pkgList) { cancelAllNotificationsInt(MY_UID, MY_PID, pkgName, null, 0, 0, !queryRestart, changeUserId, reason, null); - } else if (hideNotifications) { - hideNotificationsForPackages(pkgList); - } else if (unhideNotifications) { - unhideNotificationsForPackages(pkgList); } - + } else if (hideNotifications) { + hideNotificationsForPackages(pkgList); + } else if (unhideNotifications) { + unhideNotificationsForPackages(pkgList); } } diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index dc5edcd81586..389b68a7d4b7 100644..100755 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -3664,7 +3664,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mService.simulatePackageDistractionBroadcast( PackageManager.RESTRICTION_HIDE_NOTIFICATIONS, new String[] {"a", "b"}); ArgumentCaptor<List<NotificationRecord>> captorHide = ArgumentCaptor.forClass(List.class); - verify(mListeners, times(2)).notifyHiddenLocked(captorHide.capture()); + + // should be called only once. + verify(mListeners, times(1)).notifyHiddenLocked(captorHide.capture()); assertEquals(2, captorHide.getValue().size()); assertEquals("a", captorHide.getValue().get(0).sbn.getPackageName()); assertEquals("b", captorHide.getValue().get(1).sbn.getPackageName()); @@ -3673,7 +3675,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { mService.simulatePackageDistractionBroadcast( PackageManager.RESTRICTION_HIDE_FROM_SUGGESTIONS, new String[] {"a", "b"}); ArgumentCaptor<List<NotificationRecord>> captorUnhide = ArgumentCaptor.forClass(List.class); - verify(mListeners, times(2)).notifyUnhiddenLocked(captorUnhide.capture()); + + // should be called only once. + verify(mListeners, times(1)).notifyUnhiddenLocked(captorUnhide.capture()); assertEquals(2, captorUnhide.getValue().size()); assertEquals("a", captorUnhide.getValue().get(0).sbn.getPackageName()); assertEquals("b", captorUnhide.getValue().get(1).sbn.getPackageName()); |