diff options
author | Lars Greiss <kufikugel@googlemail.com> | 2014-11-24 23:45:41 +0100 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-06-01 10:38:58 -0700 |
commit | ee43aa5034d92153204f55f3ac0f70af3a70844f (patch) | |
tree | 642e2f0be78616cd41a9f8380b0c7c8fddc03ea6 /services/core | |
parent | 44e91e0ed2b3056e30ccfbb009be5f19495061ce (diff) | |
download | frameworks_base-ee43aa5034d92153204f55f3ac0f70af3a70844f.zip frameworks_base-ee43aa5034d92153204f55f3ac0f70af3a70844f.tar.gz frameworks_base-ee43aa5034d92153204f55f3ac0f70af3a70844f.tar.bz2 |
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
Diffstat (limited to 'services/core')
3 files changed, 48 insertions, 1 deletions
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; } } |