summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/INotificationManager.aidl3
-rw-r--r--core/java/android/app/Notification.java15
-rw-r--r--core/java/android/app/NotificationManager.java11
-rwxr-xr-xpackages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java24
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java14
-rw-r--r--services/core/java/com/android/server/notification/RankingConfig.java5
-rw-r--r--services/core/java/com/android/server/notification/RankingHelper.java30
7 files changed, 94 insertions, 8 deletions
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index f78fb47..e749d0a 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -55,6 +55,9 @@ interface INotificationManager
void setPackageVisibilityOverride(String pkg, int uid, int visibility);
int getPackageVisibilityOverride(String pkg, int uid);
+ void setShowNotificationForPackageOnKeyguard(String pkg, int uid, int status);
+ int getShowNotificationForPackageOnKeyguard(String pkg, int uid);
+
// TODO: Remove this when callers have been migrated to the equivalent
// INotificationListener method.
StatusBarNotification[] getActiveNotifications(String callingPkg);
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index d8e01cd..8835a09 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -523,6 +523,21 @@ public class Notification implements Parcelable
public int priority;
/**
+ * Default.
+ * Show all notifications from an app on keyguard.
+ *
+ * @hide
+ */
+ public static final int SHOW_ALL_NOTI_ON_KEYGUARD = 0x01;
+
+ /**
+ * Show only notifications from an app which are not ongoing ones.
+ *
+ * @hide
+ */
+ public static final int SHOW_NO_ONGOING_NOTI_ON_KEYGUARD = 0x02;
+
+ /**
* Accent color (an ARGB integer like the constants in {@link android.graphics.Color})
* to be applied by the standard Style templates when presenting this notification.
*
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index 605c006..2219e64 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -19,6 +19,7 @@ package android.app;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
+import android.app.Notification;
import android.app.Notification.Builder;
import android.content.ComponentName;
import android.content.Context;
@@ -512,6 +513,16 @@ public class NotificationManager
return new ArraySet<String>();
}
+ /** @hide */
+ public int getShowNotificationForPackageOnKeyguard(String pkg, int uid) {
+ INotificationManager service = getService();
+ try {
+ return getService().getShowNotificationForPackageOnKeyguard(pkg, uid);
+ } catch (RemoteException e) {
+ return Notification.SHOW_ALL_NOTI_ON_KEYGUARD;
+ }
+ }
+
private Context mContext;
private static void checkRequired(String name, Object value) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 3d7d4f6..39b6072 100755
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -226,6 +226,8 @@ public abstract class BaseStatusBar extends SystemUI implements
protected WindowManager mWindowManager;
protected IWindowManager mWindowManagerService;
+ private NotificationManager mNoMan;
+
protected abstract void refreshLayout(int layoutDirection);
protected Display mDisplay;
@@ -432,9 +434,7 @@ public abstract class BaseStatusBar extends SystemUI implements
}
}
} else if (BANNER_ACTION_CANCEL.equals(action) || BANNER_ACTION_SETUP.equals(action)) {
- NotificationManager noMan = (NotificationManager)
- mContext.getSystemService(Context.NOTIFICATION_SERVICE);
- noMan.cancel(R.id.notification_hidden);
+ mNoMan.cancel(R.id.notification_hidden);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.SHOW_NOTE_ABOUT_NOTIFICATION_HIDING, 0);
@@ -563,6 +563,9 @@ public abstract class BaseStatusBar extends SystemUI implements
public void start() {
mWindowManager = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
mWindowManagerService = WindowManagerGlobal.getWindowManagerService();
+
+ mNoMan = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
+
mDisplay = mWindowManager.getDefaultDisplay();
mDevicePolicyManager = (DevicePolicyManager)mContext.getSystemService(
Context.DEVICE_POLICY_SERVICE);
@@ -728,9 +731,7 @@ public abstract class BaseStatusBar extends SystemUI implements
mContext.getString(R.string.hidden_notifications_setup),
setupIntent);
- NotificationManager noMan =
- (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
- noMan.notify(R.id.notification_hidden, note.build());
+ mNoMan.notify(R.id.notification_hidden, note.build());
}
}
@@ -1901,7 +1902,16 @@ public abstract class BaseStatusBar extends SystemUI implements
}
private boolean shouldShowOnKeyguard(StatusBarNotification sbn) {
- return mShowLockscreenNotifications && !mNotificationData.isAmbient(sbn.getKey());
+ final int showOnKeyguard = mNoMan.getShowNotificationForPackageOnKeyguard(
+ sbn.getPackageName(), sbn.getUid());
+ boolean isKeyguardAllowedForApp =
+ (showOnKeyguard & Notification.SHOW_ALL_NOTI_ON_KEYGUARD) != 0;
+ if (isKeyguardAllowedForApp && sbn.isOngoing()) {
+ isKeyguardAllowedForApp =
+ (showOnKeyguard & Notification.SHOW_NO_ONGOING_NOTI_ON_KEYGUARD) == 0;
+ }
+ return mShowLockscreenNotifications && !mNotificationData.isAmbient(sbn.getKey())
+ && isKeyguardAllowedForApp;
}
protected void setZenMode(int mode) {
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index ceabec9..1540cd8 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1558,6 +1558,20 @@ public class NotificationManagerService extends SystemService {
return mRankingHelper.getPackageVisibilityOverride(pkg, uid);
}
+ @Override
+ public void setShowNotificationForPackageOnKeyguard(
+ String pkg, int uid, int status) {
+ checkCallerIsSystem();
+ mRankingHelper.setShowNotificationForPackageOnKeyguard(pkg, uid, status);
+ savePolicyFile();
+ }
+
+ @Override
+ public int getShowNotificationForPackageOnKeyguard(String pkg, int uid) {
+ enforceSystemOrSystemUI("INotificationManager.getShowNotificationForPackageOnKeyguard");
+ return mRankingHelper.getShowNotificationForPackageOnKeyguard(pkg, uid);
+ }
+
/**
* System-only API for getting a list of current (i.e. not cleared) notifications.
*
diff --git a/services/core/java/com/android/server/notification/RankingConfig.java b/services/core/java/com/android/server/notification/RankingConfig.java
index 803db10..320cf75 100644
--- a/services/core/java/com/android/server/notification/RankingConfig.java
+++ b/services/core/java/com/android/server/notification/RankingConfig.java
@@ -27,4 +27,9 @@ public interface RankingConfig {
int getPackageVisibilityOverride(String packageName, int uid);
void setPackageVisibilityOverride(String packageName, int uid, int visibility);
+
+ void setShowNotificationForPackageOnKeyguard(String packageName, int uid, int status);
+
+ int getShowNotificationForPackageOnKeyguard(String packageName, int uid);
+
}
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index 2e986a9..5112370 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -51,6 +51,7 @@ public class RankingHelper implements RankingConfig {
private static final String ATT_PRIORITY = "priority";
private static final String ATT_PEEKABLE = "peekable";
private static final String ATT_VISIBILITY = "visibility";
+ private static final String ATT_KEYGUARD = "keyguard";
private static final int DEFAULT_PRIORITY = Notification.PRIORITY_DEFAULT;
private static final boolean DEFAULT_PEEKABLE = true;
@@ -143,6 +144,8 @@ public class RankingHelper implements RankingConfig {
int priority = safeInt(parser, ATT_PRIORITY, DEFAULT_PRIORITY);
boolean peekable = safeBool(parser, ATT_PEEKABLE, DEFAULT_PEEKABLE);
int vis = safeInt(parser, ATT_VISIBILITY, DEFAULT_VISIBILITY);
+ int keyguard = safeInt(parser, ATT_KEYGUARD,
+ Notification.SHOW_ALL_NOTI_ON_KEYGUARD);
String name = parser.getAttributeValue(null, ATT_NAME);
if (!TextUtils.isEmpty(name)) {
@@ -172,6 +175,9 @@ public class RankingHelper implements RankingConfig {
if (vis != DEFAULT_VISIBILITY) {
r.visibility = vis;
}
+ if (keyguard != Notification.SHOW_ALL_NOTI_ON_KEYGUARD) {
+ r.keyguard = keyguard;
+ }
}
}
}
@@ -200,7 +206,8 @@ public class RankingHelper implements RankingConfig {
for (int i = N - 1; i >= 0; i--) {
final Record r = mRecords.valueAt(i);
if (r.priority == DEFAULT_PRIORITY && r.peekable == DEFAULT_PEEKABLE
- && r.visibility == DEFAULT_VISIBILITY) {
+ && r.visibility == DEFAULT_VISIBILITY
+ && r.keyguard == Notification.SHOW_ALL_NOTI_ON_KEYGUARD) {
mRecords.removeAt(i);
}
}
@@ -227,6 +234,9 @@ public class RankingHelper implements RankingConfig {
if (r.visibility != DEFAULT_VISIBILITY) {
out.attribute(null, ATT_VISIBILITY, Integer.toString(r.visibility));
}
+ if (r.keyguard != Notification.SHOW_ALL_NOTI_ON_KEYGUARD) {
+ out.attribute(null, ATT_KEYGUARD, Integer.toBinaryString(r.keyguard));
+ }
if (!forBackup) {
out.attribute(null, ATT_UID, Integer.toString(r.uid));
}
@@ -377,6 +387,23 @@ public class RankingHelper implements RankingConfig {
updateConfig();
}
+ @Override
+ public int getShowNotificationForPackageOnKeyguard(String packageName, int uid) {
+ final Record r = mRecords.get(recordKey(packageName, uid));
+ return r != null ? r.keyguard : Notification.SHOW_ALL_NOTI_ON_KEYGUARD;
+ }
+
+ @Override
+ public void setShowNotificationForPackageOnKeyguard(
+ String packageName, int uid, int keyguard) {
+ if (keyguard == getShowNotificationForPackageOnKeyguard(packageName, uid)) {
+ return;
+ }
+ getOrCreateRecord(packageName, uid).keyguard = keyguard;
+ removeDefaultRecords();
+ updateConfig();
+ }
+
public void dump(PrintWriter pw, String prefix, NotificationManagerService.DumpFilter filter) {
if (filter == null) {
final int N = mSignalExtractors.length;
@@ -459,6 +486,7 @@ public class RankingHelper implements RankingConfig {
int priority = DEFAULT_PRIORITY;
boolean peekable = DEFAULT_PEEKABLE;
int visibility = DEFAULT_VISIBILITY;
+ int keyguard = Notification.SHOW_ALL_NOTI_ON_KEYGUARD;
}
}