Loading core/java/android/app/INotificationManager.aidl +3 −0 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,9 @@ interface INotificationManager void setPackagePriority(String pkg, int uid, int priority); void setPackagePriority(String pkg, int uid, int priority); int getPackagePriority(String pkg, int uid); int getPackagePriority(String pkg, int uid); void setPackagePeekable(String pkg, int uid, boolean peekable); boolean getPackagePeekable(String pkg, int uid); void setPackageVisibilityOverride(String pkg, int uid, int visibility); void setPackageVisibilityOverride(String pkg, int uid, int visibility); int getPackageVisibilityOverride(String pkg, int uid); int getPackageVisibilityOverride(String pkg, int uid); Loading core/java/android/app/Notification.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -1839,6 +1839,26 @@ public class Notification implements Parcelable } } } } /** * {@hide} */ public static String priorityToString(@Priority int pri) { switch (pri) { case PRIORITY_MIN: return "MIN"; case PRIORITY_LOW: return "LOW"; case PRIORITY_DEFAULT: return "DEFAULT"; case PRIORITY_HIGH: return "HIGH"; case PRIORITY_MAX: return "MAX"; default: return "UNKNOWN(" + String.valueOf(pri) + ")"; } } /** /** * @hide * @hide */ */ Loading services/core/java/com/android/server/notification/NotificationIntrusivenessExtractor.java +5 −4 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.notification; import android.app.Notification; import android.app.Notification; import android.content.Context; import android.content.Context; import android.util.Log; import android.util.Slog; import android.util.Slog; /** /** Loading @@ -25,8 +26,8 @@ import android.util.Slog; * notifications and marks them to get a temporary ranking bump. * notifications and marks them to get a temporary ranking bump. */ */ public class NotificationIntrusivenessExtractor implements NotificationSignalExtractor { public class NotificationIntrusivenessExtractor implements NotificationSignalExtractor { private static final String TAG = "NotificationNoiseExtractor"; private static final String TAG = "IntrusivenessExtractor"; private static final boolean DBG = false; private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); /** Length of time (in milliseconds) that an intrusive or noisy notification will stay at /** Length of time (in milliseconds) that an intrusive or noisy notification will stay at the top of the ranking order, before it falls back to its natural position. */ the top of the ranking order, before it falls back to its natural position. */ Loading @@ -48,7 +49,7 @@ public class NotificationIntrusivenessExtractor implements NotificationSignalExt (notification.defaults & Notification.DEFAULT_SOUND) != 0 || (notification.defaults & Notification.DEFAULT_SOUND) != 0 || notification.sound != null || notification.sound != null || notification.fullScreenIntent != null) { notification.fullScreenIntent != null) { record.setRecentlyIntusive(true); record.setRecentlyIntrusive(true); } } return new RankingReconsideration(record.getKey(), HANG_TIME_MS) { return new RankingReconsideration(record.getKey(), HANG_TIME_MS) { Loading @@ -59,7 +60,7 @@ public class NotificationIntrusivenessExtractor implements NotificationSignalExt @Override @Override public void applyChangesLocked(NotificationRecord record) { public void applyChangesLocked(NotificationRecord record) { record.setRecentlyIntusive(false); record.setRecentlyIntrusive(false); } } }; }; } } Loading services/core/java/com/android/server/notification/NotificationManagerService.java +21 −0 Original line number Original line Diff line number Diff line Loading @@ -1215,6 +1215,19 @@ public class NotificationManagerService extends SystemService { return mRankingHelper.getPackagePriority(pkg, uid); return mRankingHelper.getPackagePriority(pkg, uid); } } @Override public void setPackagePeekable(String pkg, int uid, boolean peekable) { checkCallerIsSystem(); mRankingHelper.setPackagePeekable(pkg, uid, peekable); } @Override public boolean getPackagePeekable(String pkg, int uid) { checkCallerIsSystem(); return mRankingHelper.getPackagePeekable(pkg, uid); } @Override @Override public void setPackageVisibilityOverride(String pkg, int uid, int visibility) { public void setPackageVisibilityOverride(String pkg, int uid, int visibility) { checkCallerIsSystem(); checkCallerIsSystem(); Loading Loading @@ -1845,6 +1858,14 @@ public class NotificationManagerService extends SystemService { notification.priority = Notification.PRIORITY_HIGH; notification.priority = Notification.PRIORITY_HIGH; } } } } // force no heads up per package config if (!mRankingHelper.getPackagePeekable(pkg, callingUid)) { if (notification.extras == null) { notification.extras = new Bundle(); } notification.extras.putInt(Notification.EXTRA_AS_HEADS_UP, Notification.HEADS_UP_NEVER); } // 1. initial score: buckets of 10, around the app [-20..20] // 1. initial score: buckets of 10, around the app [-20..20] final int score = notification.priority * NOTIFICATION_PRIORITY_MULTIPLIER; final int score = notification.priority * NOTIFICATION_PRIORITY_MULTIPLIER; Loading services/core/java/com/android/server/notification/NotificationRecord.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -209,7 +209,7 @@ public final class NotificationRecord { return mContactAffinity; return mContactAffinity; } } public void setRecentlyIntusive(boolean recentlyIntrusive) { public void setRecentlyIntrusive(boolean recentlyIntrusive) { mRecentlyIntrusive = recentlyIntrusive; mRecentlyIntrusive = recentlyIntrusive; } } Loading Loading
core/java/android/app/INotificationManager.aidl +3 −0 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,9 @@ interface INotificationManager void setPackagePriority(String pkg, int uid, int priority); void setPackagePriority(String pkg, int uid, int priority); int getPackagePriority(String pkg, int uid); int getPackagePriority(String pkg, int uid); void setPackagePeekable(String pkg, int uid, boolean peekable); boolean getPackagePeekable(String pkg, int uid); void setPackageVisibilityOverride(String pkg, int uid, int visibility); void setPackageVisibilityOverride(String pkg, int uid, int visibility); int getPackageVisibilityOverride(String pkg, int uid); int getPackageVisibilityOverride(String pkg, int uid); Loading
core/java/android/app/Notification.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -1839,6 +1839,26 @@ public class Notification implements Parcelable } } } } /** * {@hide} */ public static String priorityToString(@Priority int pri) { switch (pri) { case PRIORITY_MIN: return "MIN"; case PRIORITY_LOW: return "LOW"; case PRIORITY_DEFAULT: return "DEFAULT"; case PRIORITY_HIGH: return "HIGH"; case PRIORITY_MAX: return "MAX"; default: return "UNKNOWN(" + String.valueOf(pri) + ")"; } } /** /** * @hide * @hide */ */ Loading
services/core/java/com/android/server/notification/NotificationIntrusivenessExtractor.java +5 −4 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.notification; import android.app.Notification; import android.app.Notification; import android.content.Context; import android.content.Context; import android.util.Log; import android.util.Slog; import android.util.Slog; /** /** Loading @@ -25,8 +26,8 @@ import android.util.Slog; * notifications and marks them to get a temporary ranking bump. * notifications and marks them to get a temporary ranking bump. */ */ public class NotificationIntrusivenessExtractor implements NotificationSignalExtractor { public class NotificationIntrusivenessExtractor implements NotificationSignalExtractor { private static final String TAG = "NotificationNoiseExtractor"; private static final String TAG = "IntrusivenessExtractor"; private static final boolean DBG = false; private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); /** Length of time (in milliseconds) that an intrusive or noisy notification will stay at /** Length of time (in milliseconds) that an intrusive or noisy notification will stay at the top of the ranking order, before it falls back to its natural position. */ the top of the ranking order, before it falls back to its natural position. */ Loading @@ -48,7 +49,7 @@ public class NotificationIntrusivenessExtractor implements NotificationSignalExt (notification.defaults & Notification.DEFAULT_SOUND) != 0 || (notification.defaults & Notification.DEFAULT_SOUND) != 0 || notification.sound != null || notification.sound != null || notification.fullScreenIntent != null) { notification.fullScreenIntent != null) { record.setRecentlyIntusive(true); record.setRecentlyIntrusive(true); } } return new RankingReconsideration(record.getKey(), HANG_TIME_MS) { return new RankingReconsideration(record.getKey(), HANG_TIME_MS) { Loading @@ -59,7 +60,7 @@ public class NotificationIntrusivenessExtractor implements NotificationSignalExt @Override @Override public void applyChangesLocked(NotificationRecord record) { public void applyChangesLocked(NotificationRecord record) { record.setRecentlyIntusive(false); record.setRecentlyIntrusive(false); } } }; }; } } Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +21 −0 Original line number Original line Diff line number Diff line Loading @@ -1215,6 +1215,19 @@ public class NotificationManagerService extends SystemService { return mRankingHelper.getPackagePriority(pkg, uid); return mRankingHelper.getPackagePriority(pkg, uid); } } @Override public void setPackagePeekable(String pkg, int uid, boolean peekable) { checkCallerIsSystem(); mRankingHelper.setPackagePeekable(pkg, uid, peekable); } @Override public boolean getPackagePeekable(String pkg, int uid) { checkCallerIsSystem(); return mRankingHelper.getPackagePeekable(pkg, uid); } @Override @Override public void setPackageVisibilityOverride(String pkg, int uid, int visibility) { public void setPackageVisibilityOverride(String pkg, int uid, int visibility) { checkCallerIsSystem(); checkCallerIsSystem(); Loading Loading @@ -1845,6 +1858,14 @@ public class NotificationManagerService extends SystemService { notification.priority = Notification.PRIORITY_HIGH; notification.priority = Notification.PRIORITY_HIGH; } } } } // force no heads up per package config if (!mRankingHelper.getPackagePeekable(pkg, callingUid)) { if (notification.extras == null) { notification.extras = new Bundle(); } notification.extras.putInt(Notification.EXTRA_AS_HEADS_UP, Notification.HEADS_UP_NEVER); } // 1. initial score: buckets of 10, around the app [-20..20] // 1. initial score: buckets of 10, around the app [-20..20] final int score = notification.priority * NOTIFICATION_PRIORITY_MULTIPLIER; final int score = notification.priority * NOTIFICATION_PRIORITY_MULTIPLIER; Loading
services/core/java/com/android/server/notification/NotificationRecord.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -209,7 +209,7 @@ public final class NotificationRecord { return mContactAffinity; return mContactAffinity; } } public void setRecentlyIntusive(boolean recentlyIntrusive) { public void setRecentlyIntrusive(boolean recentlyIntrusive) { mRecentlyIntrusive = recentlyIntrusive; mRecentlyIntrusive = recentlyIntrusive; } } Loading