From ee43aa5034d92153204f55f3ac0f70af3a70844f Mon Sep 17 00:00:00 2001 From: Lars Greiss Date: Mon, 24 Nov 2014 23:45:41 +0100 Subject: Frameworks: Add per app controls for LP keyguard notifications (1/2) Nice done by google but the UX is a problem especially for ppl who are using a lot apps and just want to see from important apps the notifications on the lockscreen. This commit adds the ability to - enable/disable per app the keyguard notification at all - enable/disable per app ongoing notifications on the keyguard We handle this over the app policy conf file like the other per app notification options. CRACKLING-1127 Change-Id: Ib166db1b1673aeaea132c8eeb16c650d2f254a82 --- .../android/systemui/statusbar/BaseStatusBar.java | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'packages/SystemUI') 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) { -- cgit v1.1