Allow user-prioritized packages through in priority mode.

Bug:16396715
Change-Id: I115d717e5c25500407d4f7876f070a1497fb2887
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index fefa6f6..0186b8c 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -211,7 +211,7 @@
     }
 
     public void setPackagePriority(int packagePriority) {
-      mPackagePriority = packagePriority;
+        mPackagePriority = packagePriority;
     }
 
     public int getPackagePriority() {
diff --git a/services/core/java/com/android/server/notification/PackagePriorityExtractor.java b/services/core/java/com/android/server/notification/PackagePriorityExtractor.java
index 9cdb3e1..a13e54a 100644
--- a/services/core/java/com/android/server/notification/PackagePriorityExtractor.java
+++ b/services/core/java/com/android/server/notification/PackagePriorityExtractor.java
@@ -15,7 +15,6 @@
 */
 package com.android.server.notification;
 
-import android.app.Notification;
 import android.content.Context;
 import android.util.Slog;
 
diff --git a/services/core/java/com/android/server/notification/ZenLog.java b/services/core/java/com/android/server/notification/ZenLog.java
index 64efa67..b22ed2d 100644
--- a/services/core/java/com/android/server/notification/ZenLog.java
+++ b/services/core/java/com/android/server/notification/ZenLog.java
@@ -58,6 +58,7 @@
     private static final int TYPE_UNSUBSCRIBE = 8;
     private static final int TYPE_CONFIG = 9;
     private static final int TYPE_FOLLOW_RINGER_MODE = 10;
+    private static final int TYPE_NOT_INTERCEPTED = 11;
 
     private static int sNext;
     private static int sSize;
@@ -67,6 +68,11 @@
         append(TYPE_INTERCEPTED, record.getKey() + "," + reason);
     }
 
+    public static void traceNotIntercepted(NotificationRecord record, String reason) {
+        if (record != null && record.isUpdate) return;  // already logged
+        append(TYPE_NOT_INTERCEPTED, record.getKey() + "," + reason);
+    }
+
     public static void traceAllowDisable(String pkg, boolean allowDisable, String reason) {
         if (SYSTEM_PACKAGES.contains(pkg)) return;
         append(TYPE_ALLOW_DISABLE, allowDisable + "," + pkg + "," + reason);
@@ -122,6 +128,7 @@
             case TYPE_UNSUBSCRIBE: return "unsubscribe";
             case TYPE_CONFIG: return "config";
             case TYPE_FOLLOW_RINGER_MODE: return "follow_ringer_mode";
+            case TYPE_NOT_INTERCEPTED: return "not_intercepted";
             default: return "unknown";
         }
     }
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index 6b55213..9f97583 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -137,6 +137,13 @@
                 }
                 return false;
             }
+            // allow user-prioritized packages through in priority mode
+            if (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS) {
+                if (record.getPackagePriority() == Notification.PRIORITY_MAX) {
+                    ZenLog.traceNotIntercepted(record, "priorityApp");
+                    return false;
+                }
+            }
             // audience has veto power over all following rules
             if (!audienceMatches(record)) {
                 ZenLog.traceIntercepted(record, "!audienceMatches");