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

Commit 0d5b325b authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Cleanup attention helper refactor flag" into main

parents 2da80532 40c66cff
Loading
Loading
Loading
Loading
+21 −859

File changed.

Preview size limit exceeded, changes collapsed.

+0 −1969

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −1
Original line number Diff line number Diff line
@@ -210,7 +210,6 @@ public class NotificationAttentionHelperTest extends UiServiceTestCase {
        assertTrue(mAccessibilityManager.isEnabled());

        // TODO (b/291907312): remove feature flag
        mSetFlagsRule.enableFlags(Flags.FLAG_REFACTOR_ATTENTION_HELPER);
        // Disable feature flags by default. Tests should enable as needed.
        mSetFlagsRule.disableFlags(Flags.FLAG_POLITE_NOTIFICATIONS,
                Flags.FLAG_CROSS_APP_POLITE_NOTIFICATIONS, Flags.FLAG_VIBRATE_WHILE_UNLOCKED);
+7 −52
Original line number Diff line number Diff line
@@ -494,6 +494,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    @Mock
    StatusBarManagerInternal mStatusBar;
    @Mock
    NotificationAttentionHelper mAttentionHelper;
    private NotificationManagerService.WorkerHandler mWorkerHandler;
    private class TestableToastCallback extends ITransientNotification.Stub {
@@ -661,7 +664,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        // TODO (b/291907312): remove feature flag
        // NOTE: Prefer using the @EnableFlag annotation where possible. Do not add any android.app
        //  flags here.
        mSetFlagsRule.disableFlags(Flags.FLAG_REFACTOR_ATTENTION_HELPER,
        mSetFlagsRule.disableFlags(
                Flags.FLAG_POLITE_NOTIFICATIONS, Flags.FLAG_AUTOGROUP_SUMMARY_ICON_UPDATE);
        initNMS();
@@ -695,11 +698,12 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                mSnoozeHelper, mUsageStats, mPolicyFile, mActivityManager, mGroupHelper, mAm, mAtm,
                mAppUsageStats, mDevicePolicyManager, mUgm, mUgmInternal,
                mAppOpsManager, mUm, mHistoryManager, mStatsManager,
                mock(TelephonyManager.class),
                mAmi, mToastRateLimiter, mPermissionHelper, mock(UsageStatsManagerInternal.class),
                mTelecomManager, mLogger, mTestFlagResolver, mPermissionManager,
                mPowerManager, mPostNotificationTrackerFactory);
        mService.setAttentionHelper(mAttentionHelper);
        // Return first true for RoleObserver main-thread check
        when(mMainLooper.isCurrentThread()).thenReturn(true).thenReturn(false);
@@ -715,13 +719,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
            verify(mHistoryManager).onBootPhaseAppsCanStart();
        }
        // TODO b/291907312: remove feature flag
        if (Flags.refactorAttentionHelper()) {
            mService.mAttentionHelper.setAudioManager(mAudioManager);
        } else {
            mService.setAudioManager(mAudioManager);
        }
        mStrongAuthTracker = mService.new StrongAuthTrackerFake(mContext);
        mService.setStrongAuthTracker(mStrongAuthTracker);
@@ -1810,23 +1807,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        assertThat(call.postDurationMillisLogged).isGreaterThan(0);
    }
    @Test
    public void testEnqueueNotificationWithTag_WritesExpectedLogs_NAHRefactor() throws Exception {
        // TODO b/291907312: remove feature flag
        mSetFlagsRule.enableFlags(Flags.FLAG_REFACTOR_ATTENTION_HELPER);
        // Cleanup NMS before re-initializing
        if (mService != null) {
            try {
                mService.onDestroy();
            } catch (IllegalStateException | IllegalArgumentException e) {
                // can throw if a broadcast receiver was never registered
            }
        }
        initNMS();
        testEnqueueNotificationWithTag_WritesExpectedLogs();
    }
    @Test
    public void testEnqueueNotificationWithTag_LogsOnMajorUpdates() throws Exception {
        final String tag = "testEnqueueNotificationWithTag_LogsOnMajorUpdates";
@@ -10105,13 +10085,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    @Test
    public void testOnBubbleMetadataChangedToSuppressNotification_soundStopped()
            throws RemoteException {
        IRingtonePlayer mockPlayer = mock(IRingtonePlayer.class);
        when(mAudioManager.getRingtonePlayer()).thenReturn(mockPlayer);
        // Set up volume to be above 0, and for AudioManager to signal playback should happen,
        // for the sound to actually play
        when(mAudioManager.getStreamVolume(anyInt())).thenReturn(10);
        when(mAudioManager.shouldNotificationSoundPlay(any(android.media.AudioAttributes.class)))
                .thenReturn(true);
        setUpPrefsForBubbles(PKG, mUid,
                true /* global */,
@@ -10130,25 +10103,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        waitForIdle();
        // Check audio is stopped
        verify(mockPlayer).stopAsync();
    }
    @Test
    public void testOnBubbleMetadataChangedToSuppressNotification_soundStopped_NAHRefactor()
        throws Exception {
        // TODO b/291907312: remove feature flag
        mSetFlagsRule.enableFlags(Flags.FLAG_REFACTOR_ATTENTION_HELPER);
        // Cleanup NMS before re-initializing
        if (mService != null) {
            try {
                mService.onDestroy();
            } catch (IllegalStateException | IllegalArgumentException e) {
                // can throw if a broadcast receiver was never registered
            }
        }
        initNMS();
        testOnBubbleMetadataChangedToSuppressNotification_soundStopped();
        verify(mAttentionHelper).clearEffectsLocked(nr.getKey());
    }
    @Test
+1 −1
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ public class RoleObserverTest extends UiServiceTestCase {
                    mock(DevicePolicyManagerInternal.class), mock(IUriGrantsManager.class),
                    mock(UriGrantsManagerInternal.class),
                    mock(AppOpsManager.class), mUm, mock(NotificationHistoryManager.class),
                    mock(StatsManager.class), mock(TelephonyManager.class),
                    mock(StatsManager.class),
                    mock(ActivityManagerInternal.class),
                    mock(MultiRateLimiter.class), mock(PermissionHelper.class),
                    mock(UsageStatsManagerInternal.class), mock(TelecomManager.class),