Loading core/java/android/service/notification/NotificationListenerService.java +4 −14 Original line number Diff line number Diff line Loading @@ -1002,13 +1002,12 @@ public abstract class NotificationListenerService extends Service { return mImportanceExplanation; } private void populate(String key, int rank, boolean isAmbient, boolean matchesInterruptionFilter, int visibilityOverride, int suppressedVisualEffects, int importance, private void populate(String key, int rank, boolean matchesInterruptionFilter, int visibilityOverride, int suppressedVisualEffects, int importance, CharSequence explanation) { mKey = key; mRank = rank; mIsAmbient = isAmbient; mIsAmbient = importance < IMPORTANCE_DEFAULT; mMatchesInterruptionFilter = matchesInterruptionFilter; mVisibilityOverride = visibilityOverride; mSuppressedVisualEffects = suppressedVisualEffects; Loading Loading @@ -1079,7 +1078,7 @@ public abstract class NotificationListenerService extends Service { */ public boolean getRanking(String key, Ranking outRanking) { int rank = getRank(key); outRanking.populate(key, rank, isAmbient(key), !isIntercepted(key), outRanking.populate(key, rank, !isIntercepted(key), getVisibilityOverride(key), getSuppressedVisualEffects(key), getImportance(key), getImportanceExplanation(key)); return rank >= 0; Loading @@ -1095,15 +1094,6 @@ public abstract class NotificationListenerService extends Service { return rank != null ? rank : -1; } private boolean isAmbient(String key) { int firstAmbientIndex = mRankingUpdate.getFirstAmbientIndex(); if (firstAmbientIndex < 0) { return false; } int rank = getRank(key); return rank >= 0 && rank >= firstAmbientIndex; } private boolean isIntercepted(String key) { synchronized (this) { if (mIntercepted == null) { Loading core/java/android/service/notification/NotificationRankingUpdate.java +1 −9 Original line number Diff line number Diff line Loading @@ -26,17 +26,15 @@ public class NotificationRankingUpdate implements Parcelable { // TODO: Support incremental updates. private final String[] mKeys; private final String[] mInterceptedKeys; private final int mFirstAmbientIndex; private final Bundle mVisibilityOverrides; private final Bundle mSuppressedVisualEffects; private final int[] mImportance; private final Bundle mImportanceExplanation; public NotificationRankingUpdate(String[] keys, String[] interceptedKeys, Bundle visibilityOverrides, int firstAmbientIndex, Bundle suppressedVisualEffects, Bundle visibilityOverrides, Bundle suppressedVisualEffects, int[] importance, Bundle explanation) { mKeys = keys; mFirstAmbientIndex = firstAmbientIndex; mInterceptedKeys = interceptedKeys; mVisibilityOverrides = visibilityOverrides; mSuppressedVisualEffects = suppressedVisualEffects; Loading @@ -46,7 +44,6 @@ public class NotificationRankingUpdate implements Parcelable { public NotificationRankingUpdate(Parcel in) { mKeys = in.readStringArray(); mFirstAmbientIndex = in.readInt(); mInterceptedKeys = in.readStringArray(); mVisibilityOverrides = in.readBundle(); mSuppressedVisualEffects = in.readBundle(); Loading @@ -63,7 +60,6 @@ public class NotificationRankingUpdate implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { out.writeStringArray(mKeys); out.writeInt(mFirstAmbientIndex); out.writeStringArray(mInterceptedKeys); out.writeBundle(mVisibilityOverrides); out.writeBundle(mSuppressedVisualEffects); Loading @@ -86,10 +82,6 @@ public class NotificationRankingUpdate implements Parcelable { return mKeys; } public int getFirstAmbientIndex() { return mFirstAmbientIndex; } public String[] getInterceptedKeys() { return mInterceptedKeys; } Loading services/core/java/com/android/server/notification/NotificationComparator.java +8 −8 Original line number Diff line number Diff line Loading @@ -18,20 +18,13 @@ package com.android.server.notification; import java.util.Comparator; /** * Sorts notifications individually into attention-relelvant order. * Sorts notifications individually into attention-relevant order. */ public class NotificationComparator implements Comparator<NotificationRecord> { @Override public int compare(NotificationRecord left, NotificationRecord right) { final int leftPackagePriority = left.getPackagePriority(); final int rightPackagePriority = right.getPackagePriority(); if (leftPackagePriority != rightPackagePriority) { // by priority, high to low return -1 * Integer.compare(leftPackagePriority, rightPackagePriority); } final int leftImportance = left.getImportance(); final int rightImportance = right.getImportance(); if (leftImportance != rightImportance) { Loading @@ -39,6 +32,13 @@ public class NotificationComparator return -1 * Integer.compare(leftImportance, rightImportance); } final int leftPackagePriority = left.getPackagePriority(); final int rightPackagePriority = right.getPackagePriority(); if (leftPackagePriority != rightPackagePriority) { // by priority, high to low return -1 * Integer.compare(leftPackagePriority, rightPackagePriority); } final float leftPeople = left.getContactAffinity(); final float rightPeople = right.getContactAffinity(); if (leftPeople != rightPeople) { Loading services/core/java/com/android/server/notification/NotificationIntrusivenessExtractor.java +2 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.notification; import android.app.Notification; import android.content.Context; import android.service.notification.NotificationListenerService; import android.util.Log; import android.util.Slog; Loading @@ -44,11 +45,7 @@ public class NotificationIntrusivenessExtractor implements NotificationSignalExt } final Notification notification = record.getNotification(); if ((notification.defaults & Notification.DEFAULT_VIBRATE) != 0 || notification.vibrate != null || (notification.defaults & Notification.DEFAULT_SOUND) != 0 || notification.sound != null || notification.fullScreenIntent != null) { if (record.getImportance() > NotificationListenerService.Ranking.IMPORTANCE_DEFAULT) { record.setRecentlyIntrusive(true); } Loading services/core/java/com/android/server/notification/NotificationManagerService.java +1 −14 Original line number Diff line number Diff line Loading @@ -3294,7 +3294,6 @@ public class NotificationManagerService extends SystemService { * <p>Caller must hold a lock on mNotificationList.</p> */ private NotificationRankingUpdate makeRankingUpdateLocked(ManagedServiceInfo info) { int speedBumpIndex = -1; final int N = mNotificationList.size(); ArrayList<String> keys = new ArrayList<String>(N); ArrayList<String> interceptedKeys = new ArrayList<String>(N); Loading Loading @@ -3322,18 +3321,6 @@ public class NotificationManagerService extends SystemService { != NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE) { visibilityOverrides.putInt(key, record.getPackageVisibilityOverride()); } // Find first min-prio notification for speedbump placement. if (speedBumpIndex == -1 && // Intrusiveness trumps priority, hence ignore intrusives. !record.isRecentlyIntrusive() && // Currently, package priority is either PRIORITY_DEFAULT or PRIORITY_MAX, so // scanning for PRIORITY_MIN within the package bucket PRIORITY_DEFAULT // (or lower as a safeguard) is sufficient to find the speedbump index. // We'll have to revisit this when more package priority buckets are introduced. record.getPackagePriority() <= Notification.PRIORITY_DEFAULT && record.sbn.getNotification().priority == Notification.PRIORITY_MIN) { speedBumpIndex = keys.size() - 1; } } final int M = keys.size(); String[] keysAr = keys.toArray(new String[M]); Loading @@ -3343,7 +3330,7 @@ public class NotificationManagerService extends SystemService { importanceAr[i] = importance.get(i); } return new NotificationRankingUpdate(keysAr, interceptedKeysAr, visibilityOverrides, speedBumpIndex, suppressedVisualEffects, importanceAr, explanation); suppressedVisualEffects, importanceAr, explanation); } private boolean isVisibleToListener(StatusBarNotification sbn, ManagedServiceInfo listener) { Loading Loading
core/java/android/service/notification/NotificationListenerService.java +4 −14 Original line number Diff line number Diff line Loading @@ -1002,13 +1002,12 @@ public abstract class NotificationListenerService extends Service { return mImportanceExplanation; } private void populate(String key, int rank, boolean isAmbient, boolean matchesInterruptionFilter, int visibilityOverride, int suppressedVisualEffects, int importance, private void populate(String key, int rank, boolean matchesInterruptionFilter, int visibilityOverride, int suppressedVisualEffects, int importance, CharSequence explanation) { mKey = key; mRank = rank; mIsAmbient = isAmbient; mIsAmbient = importance < IMPORTANCE_DEFAULT; mMatchesInterruptionFilter = matchesInterruptionFilter; mVisibilityOverride = visibilityOverride; mSuppressedVisualEffects = suppressedVisualEffects; Loading Loading @@ -1079,7 +1078,7 @@ public abstract class NotificationListenerService extends Service { */ public boolean getRanking(String key, Ranking outRanking) { int rank = getRank(key); outRanking.populate(key, rank, isAmbient(key), !isIntercepted(key), outRanking.populate(key, rank, !isIntercepted(key), getVisibilityOverride(key), getSuppressedVisualEffects(key), getImportance(key), getImportanceExplanation(key)); return rank >= 0; Loading @@ -1095,15 +1094,6 @@ public abstract class NotificationListenerService extends Service { return rank != null ? rank : -1; } private boolean isAmbient(String key) { int firstAmbientIndex = mRankingUpdate.getFirstAmbientIndex(); if (firstAmbientIndex < 0) { return false; } int rank = getRank(key); return rank >= 0 && rank >= firstAmbientIndex; } private boolean isIntercepted(String key) { synchronized (this) { if (mIntercepted == null) { Loading
core/java/android/service/notification/NotificationRankingUpdate.java +1 −9 Original line number Diff line number Diff line Loading @@ -26,17 +26,15 @@ public class NotificationRankingUpdate implements Parcelable { // TODO: Support incremental updates. private final String[] mKeys; private final String[] mInterceptedKeys; private final int mFirstAmbientIndex; private final Bundle mVisibilityOverrides; private final Bundle mSuppressedVisualEffects; private final int[] mImportance; private final Bundle mImportanceExplanation; public NotificationRankingUpdate(String[] keys, String[] interceptedKeys, Bundle visibilityOverrides, int firstAmbientIndex, Bundle suppressedVisualEffects, Bundle visibilityOverrides, Bundle suppressedVisualEffects, int[] importance, Bundle explanation) { mKeys = keys; mFirstAmbientIndex = firstAmbientIndex; mInterceptedKeys = interceptedKeys; mVisibilityOverrides = visibilityOverrides; mSuppressedVisualEffects = suppressedVisualEffects; Loading @@ -46,7 +44,6 @@ public class NotificationRankingUpdate implements Parcelable { public NotificationRankingUpdate(Parcel in) { mKeys = in.readStringArray(); mFirstAmbientIndex = in.readInt(); mInterceptedKeys = in.readStringArray(); mVisibilityOverrides = in.readBundle(); mSuppressedVisualEffects = in.readBundle(); Loading @@ -63,7 +60,6 @@ public class NotificationRankingUpdate implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { out.writeStringArray(mKeys); out.writeInt(mFirstAmbientIndex); out.writeStringArray(mInterceptedKeys); out.writeBundle(mVisibilityOverrides); out.writeBundle(mSuppressedVisualEffects); Loading @@ -86,10 +82,6 @@ public class NotificationRankingUpdate implements Parcelable { return mKeys; } public int getFirstAmbientIndex() { return mFirstAmbientIndex; } public String[] getInterceptedKeys() { return mInterceptedKeys; } Loading
services/core/java/com/android/server/notification/NotificationComparator.java +8 −8 Original line number Diff line number Diff line Loading @@ -18,20 +18,13 @@ package com.android.server.notification; import java.util.Comparator; /** * Sorts notifications individually into attention-relelvant order. * Sorts notifications individually into attention-relevant order. */ public class NotificationComparator implements Comparator<NotificationRecord> { @Override public int compare(NotificationRecord left, NotificationRecord right) { final int leftPackagePriority = left.getPackagePriority(); final int rightPackagePriority = right.getPackagePriority(); if (leftPackagePriority != rightPackagePriority) { // by priority, high to low return -1 * Integer.compare(leftPackagePriority, rightPackagePriority); } final int leftImportance = left.getImportance(); final int rightImportance = right.getImportance(); if (leftImportance != rightImportance) { Loading @@ -39,6 +32,13 @@ public class NotificationComparator return -1 * Integer.compare(leftImportance, rightImportance); } final int leftPackagePriority = left.getPackagePriority(); final int rightPackagePriority = right.getPackagePriority(); if (leftPackagePriority != rightPackagePriority) { // by priority, high to low return -1 * Integer.compare(leftPackagePriority, rightPackagePriority); } final float leftPeople = left.getContactAffinity(); final float rightPeople = right.getContactAffinity(); if (leftPeople != rightPeople) { Loading
services/core/java/com/android/server/notification/NotificationIntrusivenessExtractor.java +2 −5 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.notification; import android.app.Notification; import android.content.Context; import android.service.notification.NotificationListenerService; import android.util.Log; import android.util.Slog; Loading @@ -44,11 +45,7 @@ public class NotificationIntrusivenessExtractor implements NotificationSignalExt } final Notification notification = record.getNotification(); if ((notification.defaults & Notification.DEFAULT_VIBRATE) != 0 || notification.vibrate != null || (notification.defaults & Notification.DEFAULT_SOUND) != 0 || notification.sound != null || notification.fullScreenIntent != null) { if (record.getImportance() > NotificationListenerService.Ranking.IMPORTANCE_DEFAULT) { record.setRecentlyIntrusive(true); } Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +1 −14 Original line number Diff line number Diff line Loading @@ -3294,7 +3294,6 @@ public class NotificationManagerService extends SystemService { * <p>Caller must hold a lock on mNotificationList.</p> */ private NotificationRankingUpdate makeRankingUpdateLocked(ManagedServiceInfo info) { int speedBumpIndex = -1; final int N = mNotificationList.size(); ArrayList<String> keys = new ArrayList<String>(N); ArrayList<String> interceptedKeys = new ArrayList<String>(N); Loading Loading @@ -3322,18 +3321,6 @@ public class NotificationManagerService extends SystemService { != NotificationListenerService.Ranking.VISIBILITY_NO_OVERRIDE) { visibilityOverrides.putInt(key, record.getPackageVisibilityOverride()); } // Find first min-prio notification for speedbump placement. if (speedBumpIndex == -1 && // Intrusiveness trumps priority, hence ignore intrusives. !record.isRecentlyIntrusive() && // Currently, package priority is either PRIORITY_DEFAULT or PRIORITY_MAX, so // scanning for PRIORITY_MIN within the package bucket PRIORITY_DEFAULT // (or lower as a safeguard) is sufficient to find the speedbump index. // We'll have to revisit this when more package priority buckets are introduced. record.getPackagePriority() <= Notification.PRIORITY_DEFAULT && record.sbn.getNotification().priority == Notification.PRIORITY_MIN) { speedBumpIndex = keys.size() - 1; } } final int M = keys.size(); String[] keysAr = keys.toArray(new String[M]); Loading @@ -3343,7 +3330,7 @@ public class NotificationManagerService extends SystemService { importanceAr[i] = importance.get(i); } return new NotificationRankingUpdate(keysAr, interceptedKeysAr, visibilityOverrides, speedBumpIndex, suppressedVisualEffects, importanceAr, explanation); suppressedVisualEffects, importanceAr, explanation); } private boolean isVisibleToListener(StatusBarNotification sbn, ManagedServiceInfo listener) { Loading