Merge "Reduce unnecessary NotificationListener binder transaction." am: d3ec7950e3 am: c3918379eb
am: 3797fd2b58
Change-Id: I9375842043dc95b0095f3df7c9ac8cae695a4d65
This commit is contained in:
5
services/core/java/com/android/server/notification/NotificationManagerService.java
Normal file → Executable file
5
services/core/java/com/android/server/notification/NotificationManagerService.java
Normal file → Executable file
@@ -1284,17 +1284,16 @@ public class NotificationManagerService extends SystemService {
|
|||||||
uidList = new int[] {intent.getIntExtra(Intent.EXTRA_UID, -1)};
|
uidList = new int[] {intent.getIntExtra(Intent.EXTRA_UID, -1)};
|
||||||
}
|
}
|
||||||
if (pkgList != null && (pkgList.length > 0)) {
|
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,
|
cancelAllNotificationsInt(MY_UID, MY_PID, pkgName, null, 0, 0,
|
||||||
!queryRestart, changeUserId, reason, null);
|
!queryRestart, changeUserId, reason, null);
|
||||||
|
}
|
||||||
} else if (hideNotifications) {
|
} else if (hideNotifications) {
|
||||||
hideNotificationsForPackages(pkgList);
|
hideNotificationsForPackages(pkgList);
|
||||||
} else if (unhideNotifications) {
|
} else if (unhideNotifications) {
|
||||||
unhideNotificationsForPackages(pkgList);
|
unhideNotificationsForPackages(pkgList);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mHandler.scheduleOnPackageChanged(removingPackage, changeUserId, pkgList, uidList);
|
mHandler.scheduleOnPackageChanged(removingPackage, changeUserId, pkgList, uidList);
|
||||||
|
|||||||
8
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
Normal file → Executable file
8
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
Normal file → Executable file
@@ -3664,7 +3664,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
mService.simulatePackageDistractionBroadcast(
|
mService.simulatePackageDistractionBroadcast(
|
||||||
PackageManager.RESTRICTION_HIDE_NOTIFICATIONS, new String[] {"a", "b"});
|
PackageManager.RESTRICTION_HIDE_NOTIFICATIONS, new String[] {"a", "b"});
|
||||||
ArgumentCaptor<List<NotificationRecord>> captorHide = ArgumentCaptor.forClass(List.class);
|
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(2, captorHide.getValue().size());
|
||||||
assertEquals("a", captorHide.getValue().get(0).sbn.getPackageName());
|
assertEquals("a", captorHide.getValue().get(0).sbn.getPackageName());
|
||||||
assertEquals("b", captorHide.getValue().get(1).sbn.getPackageName());
|
assertEquals("b", captorHide.getValue().get(1).sbn.getPackageName());
|
||||||
@@ -3673,7 +3675,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
|
|||||||
mService.simulatePackageDistractionBroadcast(
|
mService.simulatePackageDistractionBroadcast(
|
||||||
PackageManager.RESTRICTION_HIDE_FROM_SUGGESTIONS, new String[] {"a", "b"});
|
PackageManager.RESTRICTION_HIDE_FROM_SUGGESTIONS, new String[] {"a", "b"});
|
||||||
ArgumentCaptor<List<NotificationRecord>> captorUnhide = ArgumentCaptor.forClass(List.class);
|
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(2, captorUnhide.getValue().size());
|
||||||
assertEquals("a", captorUnhide.getValue().get(0).sbn.getPackageName());
|
assertEquals("a", captorUnhide.getValue().get(0).sbn.getPackageName());
|
||||||
assertEquals("b", captorUnhide.getValue().get(1).sbn.getPackageName());
|
assertEquals("b", captorUnhide.getValue().get(1).sbn.getPackageName());
|
||||||
|
|||||||
Reference in New Issue
Block a user