Loading core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3000,6 +3000,10 @@ </string-array> <!-- Whether to show a notification informing users about notification permission settings upon upgrade to T from a pre-T version --> <bool name="config_notificationReviewPermissions">false</bool> <!-- Default Gravity setting for the system Toast view. Equivalent to: Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM --> <integer name="config_toastDefaultGravity">0x00000051</integer> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2266,6 +2266,7 @@ <java-symbol type="integer" name="config_screenshotChordKeyTimeout" /> <java-symbol type="integer" name="config_maxResolverActivityColumns" /> <java-symbol type="array" name="config_notificationSignalExtractors" /> <java-symbol type="bool" name="config_notificationReviewPermissions" /> <java-symbol type="layout" name="notification_material_action" /> <java-symbol type="layout" name="notification_material_action_list" /> Loading services/core/java/com/android/server/notification/NotificationManagerService.java +18 −1 Original line number Diff line number Diff line Loading @@ -657,6 +657,9 @@ public class NotificationManagerService extends SystemService { private int mWarnRemoteViewsSizeBytes; private int mStripRemoteViewsSizeBytes; @VisibleForTesting protected boolean mShowReviewPermissionsNotification; private MetricsLogger mMetricsLogger; private NotificationChannelLogger mNotificationChannelLogger; private TriPredicate<String, Integer, String> mAllowedManagedServicePackages; Loading Loading @@ -2280,7 +2283,8 @@ public class NotificationManagerService extends SystemService { mPermissionHelper, mNotificationChannelLogger, mAppOps, new SysUiStatsEvent.BuilderFactory()); new SysUiStatsEvent.BuilderFactory(), mShowReviewPermissionsNotification); mPreferencesHelper.updateFixedImportance(mUm.getUsers()); mRankingHelper = new RankingHelper(getContext(), mRankingHandler, Loading Loading @@ -2469,6 +2473,9 @@ public class NotificationManagerService extends SystemService { WorkerHandler handler = new WorkerHandler(Looper.myLooper()); mShowReviewPermissionsNotification = getContext().getResources().getBoolean( R.bool.config_notificationReviewPermissions); init(handler, new RankingHandlerWorker(mRankingThread.getLooper()), AppGlobals.getPackageManager(), getContext().getPackageManager(), getLocalService(LightsManager.class), Loading Loading @@ -6320,6 +6327,11 @@ public class NotificationManagerService extends SystemService { @Override public void sendReviewPermissionsNotification() { if (!mShowReviewPermissionsNotification) { // don't show if this notification is turned off return; } // This method is meant to be called from the JobService upon running the job for this // notification having been rescheduled; so without checking any other state, it will // send the notification. Loading Loading @@ -11648,6 +11660,11 @@ public class NotificationManagerService extends SystemService { } protected void maybeShowInitialReviewPermissionsNotification() { if (!mShowReviewPermissionsNotification) { // if this notification is disabled by settings do not ever show it return; } int currentState = Settings.Global.getInt(getContext().getContentResolver(), Settings.Global.REVIEW_PERMISSIONS_NOTIFICATION_STATE, REVIEW_NOTIF_STATE_UNKNOWN); services/core/java/com/android/server/notification/PreferencesHelper.java +6 −3 Original line number Diff line number Diff line Loading @@ -86,7 +86,6 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; Loading Loading @@ -191,6 +190,7 @@ public class PreferencesHelper implements RankingConfig { private boolean mIsMediaNotificationFilteringEnabled = DEFAULT_MEDIA_NOTIFICATION_FILTERING; private boolean mAreChannelsBypassingDnd; private boolean mHideSilentStatusBarIcons = DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS; private boolean mShowReviewPermissionsNotification; private boolean mAllowInvalidShortcuts = false; Loading @@ -198,7 +198,8 @@ public class PreferencesHelper implements RankingConfig { ZenModeHelper zenHelper, PermissionHelper permHelper, NotificationChannelLogger notificationChannelLogger, AppOpsManager appOpsManager, SysUiStatsEvent.BuilderFactory statsEventBuilderFactory) { SysUiStatsEvent.BuilderFactory statsEventBuilderFactory, boolean showReviewPermissionsNotification) { mContext = context; mZenModeHelper = zenHelper; mRankingHandler = rankingHandler; Loading @@ -207,6 +208,7 @@ public class PreferencesHelper implements RankingConfig { mNotificationChannelLogger = notificationChannelLogger; mAppOps = appOpsManager; mStatsEventBuilderFactory = statsEventBuilderFactory; mShowReviewPermissionsNotification = showReviewPermissionsNotification; XML_VERSION = 4; Loading @@ -226,7 +228,8 @@ public class PreferencesHelper implements RankingConfig { final int xmlVersion = parser.getAttributeInt(null, ATT_VERSION, -1); boolean upgradeForBubbles = xmlVersion == XML_VERSION_BUBBLES_UPGRADE; boolean migrateToPermission = (xmlVersion < XML_VERSION_NOTIF_PERMISSION); if (xmlVersion < XML_VERSION_REVIEW_PERMISSIONS_NOTIFICATION) { if (mShowReviewPermissionsNotification && (xmlVersion < XML_VERSION_REVIEW_PERMISSIONS_NOTIFICATION)) { // make a note that we should show the notification at some point. // it shouldn't be possible for the user to already have seen it, as the XML version // would be newer then. Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +28 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.server.notification; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.AppOpsManager.MODE_ALLOWED; import static android.app.Notification.FLAG_AUTO_CANCEL; import static android.app.Notification.FLAG_BUBBLE; import static android.app.Notification.FLAG_CAN_COLORIZE; Loading Loading @@ -9571,8 +9570,22 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(mListeners, times(2)).notifyPostedLocked(any(), any()); } @Test public void testMaybeShowReviewPermissionsNotification_flagOff() { mService.setShowReviewPermissionsNotification(false); reset(mMockNm); // If state is SHOULD_SHOW, it would show, but not if the flag is off! Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.REVIEW_PERMISSIONS_NOTIFICATION_STATE, NotificationManagerService.REVIEW_NOTIF_STATE_SHOULD_SHOW); mService.maybeShowInitialReviewPermissionsNotification(); verify(mMockNm, never()).notify(anyString(), anyInt(), any(Notification.class)); } @Test public void testMaybeShowReviewPermissionsNotification_unknown() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // Set up various possible states of the settings int and confirm whether or not the Loading @@ -9588,6 +9601,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_shouldShow() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // If state is SHOULD_SHOW, it ... should show Loading @@ -9602,6 +9616,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_alreadyShown() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // If state is either USER_INTERACTED or DISMISSED, we should not show this on boot Loading @@ -9620,6 +9635,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_reshown() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // If we have re-shown the notification and the user did not subsequently interacted with Loading @@ -9635,6 +9651,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testRescheduledReviewPermissionsNotification() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // when rescheduled, the notification goes through the NotificationManagerInternal service Loading @@ -9653,4 +9670,14 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { Settings.Global.REVIEW_PERMISSIONS_NOTIFICATION_STATE, NotificationManagerService.REVIEW_NOTIF_STATE_UNKNOWN)); } @Test public void testRescheduledReviewPermissionsNotification_flagOff() { mService.setShowReviewPermissionsNotification(false); reset(mMockNm); // no notification should be sent if the flag is off mInternalService.sendReviewPermissionsNotification(); verify(mMockNm, never()).notify(anyString(), anyInt(), any(Notification.class)); } } Loading
core/res/res/values/config.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3000,6 +3000,10 @@ </string-array> <!-- Whether to show a notification informing users about notification permission settings upon upgrade to T from a pre-T version --> <bool name="config_notificationReviewPermissions">false</bool> <!-- Default Gravity setting for the system Toast view. Equivalent to: Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM --> <integer name="config_toastDefaultGravity">0x00000051</integer> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2266,6 +2266,7 @@ <java-symbol type="integer" name="config_screenshotChordKeyTimeout" /> <java-symbol type="integer" name="config_maxResolverActivityColumns" /> <java-symbol type="array" name="config_notificationSignalExtractors" /> <java-symbol type="bool" name="config_notificationReviewPermissions" /> <java-symbol type="layout" name="notification_material_action" /> <java-symbol type="layout" name="notification_material_action_list" /> Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +18 −1 Original line number Diff line number Diff line Loading @@ -657,6 +657,9 @@ public class NotificationManagerService extends SystemService { private int mWarnRemoteViewsSizeBytes; private int mStripRemoteViewsSizeBytes; @VisibleForTesting protected boolean mShowReviewPermissionsNotification; private MetricsLogger mMetricsLogger; private NotificationChannelLogger mNotificationChannelLogger; private TriPredicate<String, Integer, String> mAllowedManagedServicePackages; Loading Loading @@ -2280,7 +2283,8 @@ public class NotificationManagerService extends SystemService { mPermissionHelper, mNotificationChannelLogger, mAppOps, new SysUiStatsEvent.BuilderFactory()); new SysUiStatsEvent.BuilderFactory(), mShowReviewPermissionsNotification); mPreferencesHelper.updateFixedImportance(mUm.getUsers()); mRankingHelper = new RankingHelper(getContext(), mRankingHandler, Loading Loading @@ -2469,6 +2473,9 @@ public class NotificationManagerService extends SystemService { WorkerHandler handler = new WorkerHandler(Looper.myLooper()); mShowReviewPermissionsNotification = getContext().getResources().getBoolean( R.bool.config_notificationReviewPermissions); init(handler, new RankingHandlerWorker(mRankingThread.getLooper()), AppGlobals.getPackageManager(), getContext().getPackageManager(), getLocalService(LightsManager.class), Loading Loading @@ -6320,6 +6327,11 @@ public class NotificationManagerService extends SystemService { @Override public void sendReviewPermissionsNotification() { if (!mShowReviewPermissionsNotification) { // don't show if this notification is turned off return; } // This method is meant to be called from the JobService upon running the job for this // notification having been rescheduled; so without checking any other state, it will // send the notification. Loading Loading @@ -11648,6 +11660,11 @@ public class NotificationManagerService extends SystemService { } protected void maybeShowInitialReviewPermissionsNotification() { if (!mShowReviewPermissionsNotification) { // if this notification is disabled by settings do not ever show it return; } int currentState = Settings.Global.getInt(getContext().getContentResolver(), Settings.Global.REVIEW_PERMISSIONS_NOTIFICATION_STATE, REVIEW_NOTIF_STATE_UNKNOWN);
services/core/java/com/android/server/notification/PreferencesHelper.java +6 −3 Original line number Diff line number Diff line Loading @@ -86,7 +86,6 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; Loading Loading @@ -191,6 +190,7 @@ public class PreferencesHelper implements RankingConfig { private boolean mIsMediaNotificationFilteringEnabled = DEFAULT_MEDIA_NOTIFICATION_FILTERING; private boolean mAreChannelsBypassingDnd; private boolean mHideSilentStatusBarIcons = DEFAULT_HIDE_SILENT_STATUS_BAR_ICONS; private boolean mShowReviewPermissionsNotification; private boolean mAllowInvalidShortcuts = false; Loading @@ -198,7 +198,8 @@ public class PreferencesHelper implements RankingConfig { ZenModeHelper zenHelper, PermissionHelper permHelper, NotificationChannelLogger notificationChannelLogger, AppOpsManager appOpsManager, SysUiStatsEvent.BuilderFactory statsEventBuilderFactory) { SysUiStatsEvent.BuilderFactory statsEventBuilderFactory, boolean showReviewPermissionsNotification) { mContext = context; mZenModeHelper = zenHelper; mRankingHandler = rankingHandler; Loading @@ -207,6 +208,7 @@ public class PreferencesHelper implements RankingConfig { mNotificationChannelLogger = notificationChannelLogger; mAppOps = appOpsManager; mStatsEventBuilderFactory = statsEventBuilderFactory; mShowReviewPermissionsNotification = showReviewPermissionsNotification; XML_VERSION = 4; Loading @@ -226,7 +228,8 @@ public class PreferencesHelper implements RankingConfig { final int xmlVersion = parser.getAttributeInt(null, ATT_VERSION, -1); boolean upgradeForBubbles = xmlVersion == XML_VERSION_BUBBLES_UPGRADE; boolean migrateToPermission = (xmlVersion < XML_VERSION_NOTIF_PERMISSION); if (xmlVersion < XML_VERSION_REVIEW_PERMISSIONS_NOTIFICATION) { if (mShowReviewPermissionsNotification && (xmlVersion < XML_VERSION_REVIEW_PERMISSIONS_NOTIFICATION)) { // make a note that we should show the notification at some point. // it shouldn't be possible for the user to already have seen it, as the XML version // would be newer then. Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +28 −1 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.server.notification; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_VISIBLE; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.AppOpsManager.MODE_ALLOWED; import static android.app.Notification.FLAG_AUTO_CANCEL; import static android.app.Notification.FLAG_BUBBLE; import static android.app.Notification.FLAG_CAN_COLORIZE; Loading Loading @@ -9571,8 +9570,22 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { verify(mListeners, times(2)).notifyPostedLocked(any(), any()); } @Test public void testMaybeShowReviewPermissionsNotification_flagOff() { mService.setShowReviewPermissionsNotification(false); reset(mMockNm); // If state is SHOULD_SHOW, it would show, but not if the flag is off! Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.REVIEW_PERMISSIONS_NOTIFICATION_STATE, NotificationManagerService.REVIEW_NOTIF_STATE_SHOULD_SHOW); mService.maybeShowInitialReviewPermissionsNotification(); verify(mMockNm, never()).notify(anyString(), anyInt(), any(Notification.class)); } @Test public void testMaybeShowReviewPermissionsNotification_unknown() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // Set up various possible states of the settings int and confirm whether or not the Loading @@ -9588,6 +9601,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_shouldShow() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // If state is SHOULD_SHOW, it ... should show Loading @@ -9602,6 +9616,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_alreadyShown() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // If state is either USER_INTERACTED or DISMISSED, we should not show this on boot Loading @@ -9620,6 +9635,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testMaybeShowReviewPermissionsNotification_reshown() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // If we have re-shown the notification and the user did not subsequently interacted with Loading @@ -9635,6 +9651,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { @Test public void testRescheduledReviewPermissionsNotification() { mService.setShowReviewPermissionsNotification(true); reset(mMockNm); // when rescheduled, the notification goes through the NotificationManagerInternal service Loading @@ -9653,4 +9670,14 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { Settings.Global.REVIEW_PERMISSIONS_NOTIFICATION_STATE, NotificationManagerService.REVIEW_NOTIF_STATE_UNKNOWN)); } @Test public void testRescheduledReviewPermissionsNotification_flagOff() { mService.setShowReviewPermissionsNotification(false); reset(mMockNm); // no notification should be sent if the flag is off mInternalService.sendReviewPermissionsNotification(); verify(mMockNm, never()).notify(anyString(), anyInt(), any(Notification.class)); } }