From 7517e8058becac2200840cd0c289b236ab04dae2 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Wed, 26 Oct 2016 17:33:59 -0700 Subject: [PATCH] Revert "Add new importance level for blocking lock screen notifications (1/2)" * Quail star. This reverts commit a9931cbb6bdbf15845a486299a5bb27ac08c8862. Change-Id: I695f2f9bb2ff39a183a8d3b695f4cff8ba262351 (cherry picked from commit 38b8a900e81c5d0a910f4788f3e7e2117d8de961) --- .../java/android/app/NotificationManager.java | 16 +++----- .../NotificationListenerService.java | 11 +----- .../power_notification_controls_settings.xml | 2 +- packages/SystemUI/res/values/cm_strings.xml | 38 ------------------- packages/SystemUI/res/values/strings.xml | 36 ++++++++++++++++++ .../systemui/statusbar/BaseStatusBar.java | 4 +- .../systemui/statusbar/NotificationGuts.java | 12 +++--- .../notification/NotificationUsageStats.java | 4 +- .../server/notification/RankingHelper.java | 11 +----- 9 files changed, 54 insertions(+), 80 deletions(-) diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index 863a39a6e5aac..18b72e29e0e61 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -182,7 +182,7 @@ public class NotificationManager /** @hide */ @IntDef({VISIBILITY_NO_OVERRIDE, IMPORTANCE_UNSPECIFIED, IMPORTANCE_NONE, - IMPORTANCE_MIN, IMPORTANCE_VERY_LOW, IMPORTANCE_LOW, IMPORTANCE_DEFAULT, IMPORTANCE_HIGH, + IMPORTANCE_MIN, IMPORTANCE_LOW, IMPORTANCE_DEFAULT, IMPORTANCE_HIGH, IMPORTANCE_MAX}) @Retention(RetentionPolicy.SOURCE) public @interface Importance {} @@ -208,33 +208,27 @@ public class NotificationManager */ public static final int IMPORTANCE_MIN = 1; - /** - * Very low notification importance: shows on the status bar, but never - * on the lock screen and is not intrusive. - */ - public static final int IMPORTANCE_VERY_LOW = 2; - /** * Low notification importance: shows everywhere, but is not intrusive. */ - public static final int IMPORTANCE_LOW = 3; + public static final int IMPORTANCE_LOW = 2; /** * Default notification importance: shows everywhere, allowed to makes noise, * but does not visually intrude. */ - public static final int IMPORTANCE_DEFAULT = 4; + public static final int IMPORTANCE_DEFAULT = 3; /** * Higher notification importance: shows everywhere, allowed to makes noise and peek. */ - public static final int IMPORTANCE_HIGH = 5; + public static final int IMPORTANCE_HIGH = 4; /** * Highest notification importance: shows everywhere, allowed to makes noise, peek, and * use full screen intents. */ - public static final int IMPORTANCE_MAX = 6; + public static final int IMPORTANCE_MAX = 5; private static INotificationManager sService; diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java index 8308cd6fe223b..1557a2718b55a 100644 --- a/core/java/android/service/notification/NotificationListenerService.java +++ b/core/java/android/service/notification/NotificationListenerService.java @@ -1038,13 +1038,6 @@ public static class Ranking { */ public static final int IMPORTANCE_MIN = NotificationManager.IMPORTANCE_MIN; - /** - * Very low notification importance: not on lock screen and not intrusive. - * - * @hide - */ - public static final int IMPORTANCE_VERY_LOW = NotificationManager.IMPORTANCE_VERY_LOW; - /** * Low notification importance: shows everywhere, but is not intrusive. * @@ -1176,7 +1169,7 @@ private void populate(String key, int rank, boolean matchesInterruptionFilter, CharSequence explanation, String overrideGroupKey) { mKey = key; mRank = rank; - mIsAmbient = importance < IMPORTANCE_VERY_LOW; + mIsAmbient = importance < IMPORTANCE_LOW; mMatchesInterruptionFilter = matchesInterruptionFilter; mVisibilityOverride = visibilityOverride; mSuppressedVisualEffects = suppressedVisualEffects; @@ -1196,8 +1189,6 @@ public static String importanceToString(int importance) { return "NONE"; case IMPORTANCE_MIN: return "MIN"; - case IMPORTANCE_VERY_LOW: - return "VERY_LOW"; case IMPORTANCE_LOW: return "LOW"; case IMPORTANCE_DEFAULT: diff --git a/packages/SystemUI/res/layout/power_notification_controls_settings.xml b/packages/SystemUI/res/layout/power_notification_controls_settings.xml index cd0149fa6733a..83c8a51f63305 100644 --- a/packages/SystemUI/res/layout/power_notification_controls_settings.xml +++ b/packages/SystemUI/res/layout/power_notification_controls_settings.xml @@ -25,6 +25,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" - android:text="@string/cm_power_notification_controls_description"/> + android:text="@string/power_notification_controls_description"/> diff --git a/packages/SystemUI/res/values/cm_strings.xml b/packages/SystemUI/res/values/cm_strings.xml index 611ac1e7fcdd6..d05dd8059b639 100644 --- a/packages/SystemUI/res/values/cm_strings.xml +++ b/packages/SystemUI/res/values/cm_strings.xml @@ -36,44 +36,6 @@ Flashlight is on Tap to turn off - - With power notification controls, you can set an importance level from 0 to 6 for an app\'s notifications. - \n\nLevel 6 - \n- Show at the top of the notification list - \n- Allow full screen interruption - \n- Always peek - \n\nLevel 5 - \n- Prevent full screen interruption - \n- Always peek - \n\nLevel 4 - \n- Prevent full screen interruption - \n- Never peek - \n\nLevel 3 - \n- Prevent full screen interruption - \n- Never peek - \n- Never make sound and vibration - \n\nLevel 2 - \n- Prevent full screen interruption - \n- Never peek - \n- Never make sound or vibrate - \n- Hide from lock screen - \n- Show at the bottom of the notification list - \n\nLevel 1 - \n- Prevent full screen interruption - \n- Never peek - \n- Never make sound or vibrate - \n- Hide from lock screen and status bar - \n- Show at the bottom of the notification list - \n\nLevel 0 - \n- Block all notifications from the app - - - - Importance: Level %1$d - - - No full screen interruption, peeking, sound, or vibration. Hide from lock screen. - This keeps it in view until you unpin. Touch and hold the Back button to unpin. diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index de574f8cbe1fd..e20e09f0e3057 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1279,9 +1279,45 @@ Power notification controls On Off + With power notification controls, you can set an importance level from 0 to 5 for an app\'s notifications. + \n\nLevel 5 + \n- Show at the top of the notification list + \n- Allow full screen interruption + \n- Always peek + \n\nLevel 4 + \n- Prevent full screen interruption + \n- Always peek + \n\nLevel 3 + \n- Prevent full screen interruption + \n- Never peek + \n\nLevel 2 + \n- Prevent full screen interruption + \n- Never peek + \n- Never make sound and vibration + \n\nLevel 1 + \n- Prevent full screen interruption + \n- Never peek + \n- Never make sound or vibrate + \n- Hide from lock screen and status bar + \n- Show at the bottom of the notification list + \n\nLevel 0 + \n- Block all notifications from the app + Importance: Automatic + + Importance: Level 0 + + Importance: Level 1 + + Importance: Level 2 + + Importance: Level 3 + + Importance: Level 4 + + Importance: Level 5 App determines importance for each notification. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 32b4b4b34611f..d0abc1bb37689 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -118,7 +118,6 @@ import java.util.Locale; import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_HIGH; -import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_VERY_LOW; public abstract class BaseStatusBar extends SystemUI implements CommandQueue.Callbacks, ActivatableNotificationView.OnActivatedListener, @@ -2304,8 +2303,7 @@ protected void updateRowStates() { } public boolean shouldShowOnKeyguard(StatusBarNotification sbn) { - return mShowLockscreenNotifications && !mNotificationData.isAmbient(sbn.getKey()) - && mNotificationData.getImportance(sbn.getKey()) > IMPORTANCE_VERY_LOW; + return mShowLockscreenNotifications && !mNotificationData.isAmbient(sbn.getKey()); } protected void setZenMode(int mode) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java index 867fce0e55d0c..b61ef80bc317e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java @@ -339,36 +339,36 @@ private void applyAuto() { } private void updateTitleAndSummary(int progress) { - mImportanceTitle.setText(String.format(mContext.getString( - R.string.importance_level_title), progress)); switch (progress) { case Ranking.IMPORTANCE_NONE: mImportanceSummary.setText(mContext.getString( R.string.notification_importance_blocked)); + mImportanceTitle.setText(mContext.getString(R.string.blocked_importance)); break; case Ranking.IMPORTANCE_MIN: mImportanceSummary.setText(mContext.getString( R.string.notification_importance_min)); - break; - case Ranking.IMPORTANCE_VERY_LOW: - mImportanceSummary.setText(mContext.getString( - R.string.notification_importance_very_low)); + mImportanceTitle.setText(mContext.getString(R.string.min_importance)); break; case Ranking.IMPORTANCE_LOW: mImportanceSummary.setText(mContext.getString( R.string.notification_importance_low)); + mImportanceTitle.setText(mContext.getString(R.string.low_importance)); break; case Ranking.IMPORTANCE_DEFAULT: mImportanceSummary.setText(mContext.getString( R.string.notification_importance_default)); + mImportanceTitle.setText(mContext.getString(R.string.default_importance)); break; case Ranking.IMPORTANCE_HIGH: mImportanceSummary.setText(mContext.getString( R.string.notification_importance_high)); + mImportanceTitle.setText(mContext.getString(R.string.high_importance)); break; case Ranking.IMPORTANCE_MAX: mImportanceSummary.setText(mContext.getString( R.string.notification_importance_max)); + mImportanceTitle.setText(mContext.getString(R.string.max_importance)); break; } } diff --git a/services/core/java/com/android/server/notification/NotificationUsageStats.java b/services/core/java/com/android/server/notification/NotificationUsageStats.java index eaaa4325c2a8e..34c52833fbfde 100644 --- a/services/core/java/com/android/server/notification/NotificationUsageStats.java +++ b/services/core/java/com/android/server/notification/NotificationUsageStats.java @@ -699,9 +699,9 @@ private void maybePut(JSONObject dump, String name, float value) throws JSONExce private static class ImportanceHistogram { // TODO define these somewhere else - private static final int NUM_IMPORTANCES = 7; + private static final int NUM_IMPORTANCES = 6; private static final String[] IMPORTANCE_NAMES = - {"none", "min", "very-low", "low", "default", "high", "max"}; + {"none", "min", "low", "default", "high", "max"}; private final Context mContext; private final String[] mCounterNames; private final String mPrefix; diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java index d2b886d8b9d3f..78b3f4134dd3e 100644 --- a/services/core/java/com/android/server/notification/RankingHelper.java +++ b/services/core/java/com/android/server/notification/RankingHelper.java @@ -44,9 +44,7 @@ public class RankingHelper implements RankingConfig { private static final String TAG = "RankingHelper"; - private static final int VERSION_INIT = 1; - private static final int VERSION_ADDED_VERY_LOW_IMPORTANCE = 2; - private static final int VERSION_LATEST = VERSION_ADDED_VERY_LOW_IMPORTANCE; + private static final int XML_VERSION = 1; private static final String TAG_RANKING = "ranking"; private static final String TAG_PACKAGE = "package"; @@ -63,7 +61,6 @@ public class RankingHelper implements RankingConfig { private static final int DEFAULT_PRIORITY = Notification.PRIORITY_DEFAULT; private static final int DEFAULT_VISIBILITY = Ranking.VISIBILITY_NO_OVERRIDE; private static final int DEFAULT_IMPORTANCE = Ranking.IMPORTANCE_UNSPECIFIED; - private static final int VERY_LOW_IMPORTANCE = Ranking.IMPORTANCE_VERY_LOW; private final NotificationSignalExtractor[] mSignalExtractors; private final NotificationComparator mPreliminaryComparator = new NotificationComparator(); @@ -135,7 +132,6 @@ public void readXml(XmlPullParser parser, boolean forRestore) if (type != XmlPullParser.START_TAG) return; String tag = parser.getName(); if (!TAG_RANKING.equals(tag)) return; - int version = safeInt(parser, ATT_VERSION, VERSION_INIT); mRecords.clear(); mRestoredWithoutUids.clear(); while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) { @@ -168,9 +164,6 @@ public void readXml(XmlPullParser parser, boolean forRestore) r = getOrCreateRecord(name, uid); } r.importance = safeInt(parser, ATT_IMPORTANCE, DEFAULT_IMPORTANCE); - if (version < VERSION_ADDED_VERY_LOW_IMPORTANCE - && r.importance >= VERY_LOW_IMPORTANCE) - r.importance++; r.priority = safeInt(parser, ATT_PRIORITY, DEFAULT_PRIORITY); r.visibility = safeInt(parser, ATT_VISIBILITY, DEFAULT_VISIBILITY); } @@ -198,7 +191,7 @@ private Record getOrCreateRecord(String pkg, int uid) { public void writeXml(XmlSerializer out, boolean forBackup) throws IOException { out.startTag(null, TAG_RANKING); - out.attribute(null, ATT_VERSION, Integer.toString(VERSION_LATEST)); + out.attribute(null, ATT_VERSION, Integer.toString(XML_VERSION)); final int N = mRecords.size(); for (int i = 0; i < N; i++) {