summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2014-05-28 16:52:42 -0400
committerChris Wren <cwren@android.com>2014-05-30 16:16:23 -0400
commit99f963ea04d7a86219ece00c356f3f6bce33b6d6 (patch)
treeb91873408609e6d8f4704879b4bd7f7c21b4d316 /services
parent4f0e39a929f2043c46ada9f34b23654616f93227 (diff)
downloadframeworks_base-99f963ea04d7a86219ece00c356f3f6bce33b6d6.zip
frameworks_base-99f963ea04d7a86219ece00c356f3f6bce33b6d6.tar.gz
frameworks_base-99f963ea04d7a86219ece00c356f3f6bce33b6d6.tar.bz2
Add people signals to Zen mode.
Depends-On: I51fcf689ddbee7715e3387b865f18a715887c943 Change-Id: I7c91dec1afeb54505426c4da59ec4d072a60c240
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/notification/ValidateNotificationPeople.java17
-rw-r--r--services/core/java/com/android/server/notification/ZenModeHelper.java24
2 files changed, 36 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/notification/ValidateNotificationPeople.java b/services/core/java/com/android/server/notification/ValidateNotificationPeople.java
index 14be9b2..02f95e9 100644
--- a/services/core/java/com/android/server/notification/ValidateNotificationPeople.java
+++ b/services/core/java/com/android/server/notification/ValidateNotificationPeople.java
@@ -47,9 +47,20 @@ public class ValidateNotificationPeople implements NotificationSignalExtractor {
private static final int MAX_PEOPLE = 10;
private static final int PEOPLE_CACHE_SIZE = 200;
- private static final float NONE = 0f;
- private static final float VALID_CONTACT = 0.5f;
- private static final float STARRED_CONTACT = 1f;
+ /** Indicates that the notification does not reference any valid contacts. */
+ static final float NONE = 0f;
+
+ /**
+ * Affinity will be equal to or greater than this value on notifications
+ * that reference a valid contact.
+ */
+ static final float VALID_CONTACT = 0.5f;
+
+ /**
+ * Affinity will be equal to or greater than this value on notifications
+ * that reference a starred contact.
+ */
+ static final float STARRED_CONTACT = 1f;
protected boolean mEnabled;
private Context mContext;
diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java
index a52b706..50a32c4 100644
--- a/services/core/java/com/android/server/notification/ZenModeHelper.java
+++ b/services/core/java/com/android/server/notification/ZenModeHelper.java
@@ -77,11 +77,13 @@ public class ZenModeHelper {
// temporary, until we update apps to provide metadata
private static final Set<String> CALL_PACKAGES = new HashSet<String>(Arrays.asList(
"com.google.android.dialer",
- "com.android.phone"
+ "com.android.phone",
+ "com.android.example.notificationshowcase"
));
private static final Set<String> MESSAGE_PACKAGES = new HashSet<String>(Arrays.asList(
"com.google.android.talk",
- "com.android.mms"
+ "com.android.mms",
+ "com.android.example.notificationshowcase"
));
private static final Set<String> ALARM_PACKAGES = new HashSet<String>(Arrays.asList(
"com.google.android.deskclock"
@@ -131,6 +133,10 @@ public class ZenModeHelper {
if (isAlarm(record)) {
return false;
}
+ // audience has veto power over all following rules
+ if (!audienceMatches(record)) {
+ return true;
+ }
if (isCall(record)) {
return !mConfig.allowCalls;
}
@@ -245,6 +251,20 @@ public class ZenModeHelper {
return MESSAGE_PACKAGES.contains(record.sbn.getPackageName());
}
+ private boolean audienceMatches(NotificationRecord record) {
+ switch (mConfig.allowFrom) {
+ case ZenModeConfig.SOURCE_ANYONE:
+ return true;
+ case ZenModeConfig.SOURCE_CONTACT:
+ return record.getContactAffinity() >= ValidateNotificationPeople.VALID_CONTACT;
+ case ZenModeConfig.SOURCE_STAR:
+ return record.getContactAffinity() >= ValidateNotificationPeople.STARRED_CONTACT;
+ default:
+ Slog.w(TAG, "Encountered unknown source: " + mConfig.allowFrom);
+ return true;
+ }
+ }
+
private void updateAlarms() {
updateAlarm(ACTION_ENTER_ZEN, REQUEST_CODE_ENTER,
mConfig.sleepStartHour, mConfig.sleepStartMinute);