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

Commit 786625c1 authored by Iavor-Valentin Iftime's avatar Iavor-Valentin Iftime
Browse files

Revert "Revert "Use aconfig flag for NAH refactoring""

This reverts commit fe27605d.

Reason for revert: resubmit

Change-Id: I88998285923a05f1252849e6732ccd5223000af3
parent 108e3329
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -81,11 +81,6 @@ public class SystemUiSystemPropertiesFlags {
        public static final Flag PROPAGATE_CHANNEL_UPDATES_TO_CONVERSATIONS = releasedFlag(
                "persist.sysui.notification.propagate_channel_updates_to_conversations");

        // TODO: b/291907312 - remove feature flags
        /** Gating the NMS->NotificationAttentionHelper buzzBeepBlink refactor */
        public static final Flag ENABLE_ATTENTION_HELPER_REFACTOR = devFlag(
                "persist.debug.sysui.notification.enable_attention_helper_refactor");

        // TODO b/291899544: for released flags, use resource config values
        /** Value used by polite notif. feature */
        public static final Flag NOTIF_COOLDOWN_T1 = devFlag(
+16 −18
Original line number Diff line number Diff line
@@ -290,7 +290,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.compat.IPlatformCompat;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags;
import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags;
import com.android.internal.logging.InstanceId;
import com.android.internal.logging.InstanceIdSequence;
import com.android.internal.logging.MetricsLogger;
@@ -1180,7 +1179,7 @@ public class NotificationManagerService extends SystemService {
        @Override
        public void onSetDisabled(int status) {
            synchronized (mNotificationLock) {
                if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
                if (Flags.refactorAttentionHelper()) {
                    mAttentionHelper.updateDisableNotificationEffectsLocked(status);
                } else {
                    mDisableNotificationEffects =
@@ -1326,7 +1325,7 @@ public class NotificationManagerService extends SystemService {
        public void clearEffects() {
            synchronized (mNotificationLock) {
                if (DBG) Slog.d(TAG, "clearEffects");
                if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
                if (Flags.refactorAttentionHelper()) {
                    mAttentionHelper.clearAttentionEffects();
                } else {
                    clearSoundLocked();
@@ -1555,8 +1554,7 @@ public class NotificationManagerService extends SystemService {
                        int changedFlags = data.getFlags() ^ flags;
                        if ((changedFlags & FLAG_SUPPRESS_NOTIFICATION) != 0) {
                            // Suppress notification flag changed, clear any effects
                            if (mFlagResolver.isEnabled(
                                    NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
                            if (Flags.refactorAttentionHelper()) {
                                mAttentionHelper.clearEffectsLocked(key);
                            } else {
                                clearEffectsLocked(key);
@@ -1905,7 +1903,7 @@ public class NotificationManagerService extends SystemService {
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (!mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
            if (!Flags.refactorAttentionHelper()) {
                if (action.equals(Intent.ACTION_SCREEN_ON)) {
                    // Keep track of screen on/off state, but do not turn off the notification light
                    // until user passes through the lock screen or views the notification.
@@ -2019,7 +2017,7 @@ public class NotificationManagerService extends SystemService {
            ContentResolver resolver = getContext().getContentResolver();
            resolver.registerContentObserver(NOTIFICATION_BADGING_URI,
                    false, this, UserHandle.USER_ALL);
            if (!mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
            if (!Flags.refactorAttentionHelper()) {
                resolver.registerContentObserver(NOTIFICATION_LIGHT_PULSE_URI,
                    false, this, UserHandle.USER_ALL);
            }
@@ -2045,7 +2043,7 @@ public class NotificationManagerService extends SystemService {
        public void update(Uri uri) {
            ContentResolver resolver = getContext().getContentResolver();
            if (!mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
            if (!Flags.refactorAttentionHelper()) {
                if (uri == null || NOTIFICATION_LIGHT_PULSE_URI.equals(uri)) {
                    boolean pulseEnabled = Settings.System.getIntForUser(resolver,
                        Settings.System.NOTIFICATION_LIGHT_PULSE, 0, UserHandle.USER_CURRENT)
@@ -2538,7 +2536,7 @@ public class NotificationManagerService extends SystemService {
        mToastRateLimiter = toastRateLimiter;
        if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
        if (Flags.refactorAttentionHelper()) {
            mAttentionHelper = new NotificationAttentionHelper(getContext(), lightsManager,
                mAccessibilityManager, mPackageManagerClient, userManager, usageStats,
                mNotificationManagerPrivate, mZenModeHelper, flagResolver);
@@ -2548,7 +2546,7 @@ public class NotificationManagerService extends SystemService {
        // If this is called within a test, make sure to unregister the intent receivers by
        // calling onDestroy()
        IntentFilter filter = new IntentFilter();
        if (!mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
        if (!Flags.refactorAttentionHelper()) {
            filter.addAction(Intent.ACTION_SCREEN_ON);
            filter.addAction(Intent.ACTION_SCREEN_OFF);
            filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
@@ -2876,7 +2874,7 @@ public class NotificationManagerService extends SystemService {
            }
            registerNotificationPreferencesPullers();
            new LockPatternUtils(getContext()).registerStrongAuthTracker(mStrongAuthTracker);
            if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
            if (Flags.refactorAttentionHelper()) {
                mAttentionHelper.onSystemReady();
            }
        } else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
@@ -6501,7 +6499,7 @@ public class NotificationManagerService extends SystemService {
                    pw.println("  mMaxPackageEnqueueRate=" + mMaxPackageEnqueueRate);
                    pw.println("  hideSilentStatusBar="
                            + mPreferencesHelper.shouldHideSilentStatusIcons());
                    if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
                    if (Flags.refactorAttentionHelper()) {
                        mAttentionHelper.dump(pw, "    ", filter);
                    }
                }
@@ -7767,7 +7765,7 @@ public class NotificationManagerService extends SystemService {
            boolean wasPosted = removeFromNotificationListsLocked(r);
            cancelNotificationLocked(r, false, REASON_SNOOZED, wasPosted, null,
                    SystemClock.elapsedRealtime());
            if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
            if (Flags.refactorAttentionHelper()) {
                mAttentionHelper.updateLightsLocked();
            } else {
                updateLightsLocked();
@@ -7900,7 +7898,7 @@ public class NotificationManagerService extends SystemService {
                    cancelGroupChildrenLocked(r, mCallingUid, mCallingPid, listenerName,
                            mSendDelete, childrenFlagChecker, mReason,
                            mCancellationElapsedTimeMs);
                    if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
                    if (Flags.refactorAttentionHelper()) {
                        mAttentionHelper.updateLightsLocked();
                    } else {
                        updateLightsLocked();
@@ -8197,7 +8195,7 @@ public class NotificationManagerService extends SystemService {
                    int buzzBeepBlinkLoggingCode = 0;
                    if (!r.isHidden()) {
                        if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
                        if (Flags.refactorAttentionHelper()) {
                            buzzBeepBlinkLoggingCode = mAttentionHelper.buzzBeepBlinkLocked(r,
                                new NotificationAttentionHelper.Signals(
                                    mUserProfiles.isCurrentProfile(r.getUserId()),
@@ -9184,7 +9182,7 @@ public class NotificationManagerService extends SystemService {
                    || interruptiveChanged;
            if (interceptBefore && !record.isIntercepted()
                    && record.isNewEnoughForAlerting(System.currentTimeMillis())) {
                if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
                if (Flags.refactorAttentionHelper()) {
                    mAttentionHelper.buzzBeepBlinkLocked(record,
                        new NotificationAttentionHelper.Signals(
                            mUserProfiles.isCurrentProfile(record.getUserId()), mListenerHints));
@@ -9564,7 +9562,7 @@ public class NotificationManagerService extends SystemService {
                });
            }
            if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
            if (Flags.refactorAttentionHelper()) {
                mAttentionHelper.clearEffectsLocked(canceledKey);
            } else {
                // sound
@@ -9928,7 +9926,7 @@ public class NotificationManagerService extends SystemService {
                            cancellationElapsedTimeMs);
                }
            }
            if (mFlagResolver.isEnabled(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR)) {
            if (Flags.refactorAttentionHelper()) {
                mAttentionHelper.updateLightsLocked();
            } else {
                updateLightsLocked();
+4 −1
Original line number Diff line number Diff line
@@ -80,7 +80,9 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.IAccessibilityManager;
import android.view.accessibility.IAccessibilityManagerClient;

import androidx.test.runner.AndroidJUnit4;

import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags;
import com.android.internal.config.sysui.TestableFlagResolver;
import com.android.internal.logging.InstanceIdSequence;
@@ -93,6 +95,7 @@ import com.android.server.pm.PackageManagerService;

import java.util.List;
import java.util.Objects;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -190,7 +193,7 @@ public class NotificationAttentionHelperTest extends UiServiceTestCase {
        assertTrue(mAccessibilityManager.isEnabled());

        // TODO (b/291907312): remove feature flag
        mTestFlagResolver.setFlagOverride(NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR, true);
        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_EXPIRE_BITMAPS);

+5 −5
Original line number Diff line number Diff line
@@ -85,7 +85,6 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.ENABLE_ATTENTION_HELPER_REFACTOR;
import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.FSI_FORCE_DEMOTE;
import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.NotificationFlags.SHOW_STICKY_HUN_FOR_DENIED_FSI;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN;
@@ -614,7 +613,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
                });
        // TODO (b/291907312): remove feature flag
        mTestFlagResolver.setFlagOverride(ENABLE_ATTENTION_HELPER_REFACTOR, false);
        mSetFlagsRule.disableFlags(Flags.FLAG_REFACTOR_ATTENTION_HELPER,
                Flags.FLAG_POLITE_NOTIFICATIONS);
        initNMS();
    }
@@ -655,7 +655,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        verify(mHistoryManager).onBootPhaseAppsCanStart();
        // TODO b/291907312: remove feature flag
        if (mTestFlagResolver.isEnabled(ENABLE_ATTENTION_HELPER_REFACTOR)) {
        if (Flags.refactorAttentionHelper()) {
            mService.mAttentionHelper.setAudioManager(mAudioManager);
        } else {
            mService.setAudioManager(mAudioManager);
@@ -1692,7 +1692,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    @Test
    public void testEnqueueNotificationWithTag_WritesExpectedLogs_NAHRefactor() throws Exception {
        // TODO b/291907312: remove feature flag
        mTestFlagResolver.setFlagOverride(ENABLE_ATTENTION_HELPER_REFACTOR, true);
        mSetFlagsRule.enableFlags(Flags.FLAG_REFACTOR_ATTENTION_HELPER);
        // Cleanup NMS before re-initializing
        if (mService != null) {
            try {
@@ -9155,7 +9155,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    public void testOnBubbleMetadataChangedToSuppressNotification_soundStopped_NAHRefactor()
        throws Exception {
        // TODO b/291907312: remove feature flag
        mTestFlagResolver.setFlagOverride(ENABLE_ATTENTION_HELPER_REFACTOR, true);
        mSetFlagsRule.enableFlags(Flags.FLAG_REFACTOR_ATTENTION_HELPER);
        // Cleanup NMS before re-initializing
        if (mService != null) {
            try {