OSDN Git Service

Cleanup log spam on system notification post.
authorJulia Reynolds <juliacr@google.com>
Mon, 12 Dec 2016 13:51:08 +0000 (08:51 -0500)
committerJulia Reynolds <juliacr@google.com>
Tue, 13 Dec 2016 13:57:54 +0000 (13:57 +0000)
Bug: 33209911
Test: unplug/replug adb cable, monitor log. runtest systemui-notifications
Change-Id: I294ccdcb0a353463fe0c6b52f1dbbd97f4c75079

services/core/java/com/android/server/notification/NotificationManagerService.java
services/core/java/com/android/server/notification/NotificationRecord.java
services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java

index f58522b..2096626 100644 (file)
@@ -3924,7 +3924,7 @@ public class NotificationManagerService extends SystemService {
         }
     }
 
-    private static boolean isUidSystem(int uid) {
+    protected static boolean isUidSystem(int uid) {
         final int appid = UserHandle.getAppId(uid);
         return (appid == Process.SYSTEM_UID || appid == Process.PHONE_UID || uid == 0);
     }
index 4fcc987..a03c4aa 100644 (file)
@@ -136,6 +136,12 @@ public final class NotificationRecord {
     private boolean isPreChannelsNotification() {
         try {
             if (NotificationChannel.DEFAULT_CHANNEL_ID.equals(getChannel().getId())) {
+                final boolean isSystemNotification =
+                        NotificationManagerService.isUidSystem(sbn.getUid())
+                                || ("android".equals(sbn.getPackageName()));
+                if (isSystemNotification) {
+                    return false;
+                }
                 final ApplicationInfo applicationInfo =
                         mContext.getPackageManager().getApplicationInfoAsUser(sbn.getPackageName(),
                                 0, sbn.getUserId());
index a7d2c04..fc94271 100644 (file)
@@ -59,7 +59,7 @@ public class NotificationRecordTest {
     @Mock PackageManager mPm;
 
     private final String pkg = "com.android.server.notification";
-    private final int uid = 0;
+    private final int uid = 9583;
     private final String pkg2 = "pkg2";
     private final int uid2 = 1111111;
     private final int id1 = 1;