Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e64f9ef7 authored by Yuri Lin's avatar Yuri Lin
Browse files

Disable review permissions notification with config flag

Setting a flag will make it easy to turn back on if we eventually need to, but it is no longer set to roll out for T

Bug: 225373531
Test: NotificationManagerServiceTest, PreferencesHelperTest, manual
Change-Id: I896f0448d2ca9adbfbf50fb44718674ac13dd739
parent 811e3c9d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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>

+1 −0
Original line number Diff line number Diff line
@@ -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" />
+18 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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,
@@ -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),
@@ -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.
@@ -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);
+6 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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;

@@ -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;
@@ -207,6 +208,7 @@ public class PreferencesHelper implements RankingConfig {
        mNotificationChannelLogger = notificationChannelLogger;
        mAppOps = appOpsManager;
        mStatsEventBuilderFactory = statsEventBuilderFactory;
        mShowReviewPermissionsNotification = showReviewPermissionsNotification;

        XML_VERSION = 4;

@@ -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.
+28 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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