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

Commit 814ac929 authored by Valentin Iftime's avatar Valentin Iftime
Browse files

Cache aconfig flag for NAH refactoring

 Prevent NPE in NMS to allow advancing to trunkfood
 Proper fix in: cl/579845063 for GMSCore

Test: atest NotificationAttentionHelperTest
Test: atest NotificationManagerServiceTest

Bug: 291907312
Bug: 270456865
Bug: 308456356
Change-Id: I73f89c4a2df4c35093cfb5d24b38e96385268a8f
parent 82e25a93
Loading
Loading
Loading
Loading
+19 −16
Original line number Diff line number Diff line
@@ -705,6 +705,7 @@ public class NotificationManagerService extends SystemService {
    private boolean mNotificationEffectsEnabledForAutomotive;
    private DeviceConfig.OnPropertiesChangedListener mDeviceConfigChangedListener;
    protected NotificationAttentionHelper mAttentionHelper;
    private boolean mFlagRefactorAttentionHelper;
    private int mWarnRemoteViewsSizeBytes;
    private int mStripRemoteViewsSizeBytes;
@@ -1188,7 +1189,7 @@ public class NotificationManagerService extends SystemService {
        @Override
        public void onSetDisabled(int status) {
            synchronized (mNotificationLock) {
                if (Flags.refactorAttentionHelper()) {
                if (mFlagRefactorAttentionHelper) {
                    mAttentionHelper.updateDisableNotificationEffectsLocked(status);
                } else {
                    mDisableNotificationEffects =
@@ -1334,7 +1335,7 @@ public class NotificationManagerService extends SystemService {
        public void clearEffects() {
            synchronized (mNotificationLock) {
                if (DBG) Slog.d(TAG, "clearEffects");
                if (Flags.refactorAttentionHelper()) {
                if (mFlagRefactorAttentionHelper) {
                    mAttentionHelper.clearAttentionEffects();
                } else {
                    clearSoundLocked();
@@ -1563,7 +1564,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 (Flags.refactorAttentionHelper()) {
                            if (mFlagRefactorAttentionHelper) {
                                mAttentionHelper.clearEffectsLocked(key);
                            } else {
                                clearEffectsLocked(key);
@@ -1912,7 +1913,7 @@ public class NotificationManagerService extends SystemService {
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (!Flags.refactorAttentionHelper()) {
            if (!mFlagRefactorAttentionHelper) {
                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.
@@ -2028,7 +2029,7 @@ public class NotificationManagerService extends SystemService {
            ContentResolver resolver = getContext().getContentResolver();
            resolver.registerContentObserver(NOTIFICATION_BADGING_URI,
                    false, this, UserHandle.USER_ALL);
            if (!Flags.refactorAttentionHelper()) {
            if (!mFlagRefactorAttentionHelper) {
                resolver.registerContentObserver(NOTIFICATION_LIGHT_PULSE_URI,
                    false, this, UserHandle.USER_ALL);
            }
@@ -2058,7 +2059,7 @@ public class NotificationManagerService extends SystemService {
        public void update(Uri uri) {
            ContentResolver resolver = getContext().getContentResolver();
            if (!Flags.refactorAttentionHelper()) {
            if (!mFlagRefactorAttentionHelper) {
                if (uri == null || NOTIFICATION_LIGHT_PULSE_URI.equals(uri)) {
                    boolean pulseEnabled = Settings.System.getIntForUser(resolver,
                        Settings.System.NOTIFICATION_LIGHT_PULSE, 0, UserHandle.USER_CURRENT)
@@ -2559,7 +2560,9 @@ public class NotificationManagerService extends SystemService {
        mToastRateLimiter = toastRateLimiter;
        if (Flags.refactorAttentionHelper()) {
        //Cache aconfig flag value
        mFlagRefactorAttentionHelper = Flags.refactorAttentionHelper();
        if (mFlagRefactorAttentionHelper) {
            mAttentionHelper = new NotificationAttentionHelper(getContext(), lightsManager,
                mAccessibilityManager, mPackageManagerClient, userManager, usageStats,
                mNotificationManagerPrivate, mZenModeHelper, flagResolver);
@@ -2569,7 +2572,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 (!Flags.refactorAttentionHelper()) {
        if (!mFlagRefactorAttentionHelper) {
            filter.addAction(Intent.ACTION_SCREEN_ON);
            filter.addAction(Intent.ACTION_SCREEN_OFF);
            filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
@@ -2897,7 +2900,7 @@ public class NotificationManagerService extends SystemService {
            }
            registerNotificationPreferencesPullers();
            new LockPatternUtils(getContext()).registerStrongAuthTracker(mStrongAuthTracker);
            if (Flags.refactorAttentionHelper()) {
            if (mFlagRefactorAttentionHelper) {
                mAttentionHelper.onSystemReady();
            }
        } else if (phase == SystemService.PHASE_THIRD_PARTY_APPS_CAN_START) {
@@ -6560,7 +6563,7 @@ public class NotificationManagerService extends SystemService {
                    pw.println("  mMaxPackageEnqueueRate=" + mMaxPackageEnqueueRate);
                    pw.println("  hideSilentStatusBar="
                            + mPreferencesHelper.shouldHideSilentStatusIcons());
                    if (Flags.refactorAttentionHelper()) {
                    if (mFlagRefactorAttentionHelper) {
                        mAttentionHelper.dump(pw, "    ", filter);
                    }
                }
@@ -7833,7 +7836,7 @@ public class NotificationManagerService extends SystemService {
            boolean wasPosted = removeFromNotificationListsLocked(r);
            cancelNotificationLocked(r, false, REASON_SNOOZED, wasPosted, null,
                    SystemClock.elapsedRealtime());
            if (Flags.refactorAttentionHelper()) {
            if (mFlagRefactorAttentionHelper) {
                mAttentionHelper.updateLightsLocked();
            } else {
                updateLightsLocked();
@@ -7973,7 +7976,7 @@ public class NotificationManagerService extends SystemService {
                    cancelGroupChildrenLocked(r, mCallingUid, mCallingPid, listenerName,
                            mSendDelete, childrenFlagChecker, mReason,
                            mCancellationElapsedTimeMs);
                    if (Flags.refactorAttentionHelper()) {
                    if (mFlagRefactorAttentionHelper) {
                        mAttentionHelper.updateLightsLocked();
                    } else {
                        updateLightsLocked();
@@ -8270,7 +8273,7 @@ public class NotificationManagerService extends SystemService {
                    int buzzBeepBlinkLoggingCode = 0;
                    if (!r.isHidden()) {
                        if (Flags.refactorAttentionHelper()) {
                        if (mFlagRefactorAttentionHelper) {
                            buzzBeepBlinkLoggingCode = mAttentionHelper.buzzBeepBlinkLocked(r,
                                new NotificationAttentionHelper.Signals(
                                    mUserProfiles.isCurrentProfile(r.getUserId()),
@@ -9257,7 +9260,7 @@ public class NotificationManagerService extends SystemService {
                    || interruptiveChanged;
            if (interceptBefore && !record.isIntercepted()
                    && record.isNewEnoughForAlerting(System.currentTimeMillis())) {
                if (Flags.refactorAttentionHelper()) {
                if (mFlagRefactorAttentionHelper) {
                    mAttentionHelper.buzzBeepBlinkLocked(record,
                        new NotificationAttentionHelper.Signals(
                            mUserProfiles.isCurrentProfile(record.getUserId()), mListenerHints));
@@ -9637,7 +9640,7 @@ public class NotificationManagerService extends SystemService {
                });
            }
            if (Flags.refactorAttentionHelper()) {
            if (mFlagRefactorAttentionHelper) {
                mAttentionHelper.clearEffectsLocked(canceledKey);
            } else {
                // sound
@@ -10001,7 +10004,7 @@ public class NotificationManagerService extends SystemService {
                            cancellationElapsedTimeMs);
                }
            }
            if (Flags.refactorAttentionHelper()) {
            if (mFlagRefactorAttentionHelper) {
                mAttentionHelper.updateLightsLocked();
            } else {
                updateLightsLocked();