Fixed an issue about notification icons on AOD

Previously this was tied to the removed statusbar setting.
We're making them consistent with the setting of the appearnace
on the lockscreen.

Bug: 135627468
Test: atest SystemUITests
Change-Id: Ia64238f30620d9906aa50c2469121c2653875e8d
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
index 73b8c94..6c60d77 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
@@ -150,10 +150,9 @@
             StatusBar statusBar,
             NotificationWakeUpCoordinator wakeUpCoordinator,
             KeyguardBypassController keyguardBypassController,
-            StatusBarStateController statusBarStateController,
-            NotificationListener listener) {
+            StatusBarStateController statusBarStateController) {
         return new NotificationIconAreaController(context, statusBar, statusBarStateController,
-                wakeUpCoordinator, keyguardBypassController, listener,
+                wakeUpCoordinator, keyguardBypassController,
                 Dependency.get(NotificationMediaManager.class));
     }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
index 3b41689..6f9a6ec 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
@@ -4,6 +4,7 @@
 import android.content.res.Resources;
 import android.graphics.Color;
 import android.graphics.Rect;
+import android.provider.Settings;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -33,6 +34,7 @@
 import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
 import com.android.systemui.statusbar.notification.collection.NotificationEntry;
 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
+import com.android.systemui.tuner.TunerService;
 
 import java.util.ArrayList;
 import java.util.Objects;
@@ -57,20 +59,8 @@
     private final NotificationWakeUpCoordinator mWakeUpCoordinator;
     private final KeyguardBypassController mBypassController;
     private final DozeParameters mDozeParameters;
-    @VisibleForTesting
-    final NotificationListener.NotificationSettingsListener mSettingsListener =
-            new NotificationListener.NotificationSettingsListener() {
-                @Override
-                public void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) {
-                    if (NotificationUtils.useNewInterruptionModel(mContext)) {
-                        mShowLowPriority = !hideSilentStatusIcons;
-                        if (mNotificationScrollLayout != null) {
-                            updateStatusBarIcons();
-                        }
-                    }
-                }
-            };
 
+    private boolean mShowSilentOnLockscreen = true;
     private int mIconSize;
     private int mIconHPadding;
     private int mIconTint = Color.WHITE;
@@ -87,7 +77,6 @@
     private final Rect mTintArea = new Rect();
     private ViewGroup mNotificationScrollLayout;
     private Context mContext;
-    private boolean mShowLowPriority = true;
     private int mAodIconAppearTranslation;
 
     private boolean mAnimationsEnabled;
@@ -99,7 +88,6 @@
             StatusBarStateController statusBarStateController,
             NotificationWakeUpCoordinator wakeUpCoordinator,
             KeyguardBypassController keyguardBypassController,
-            NotificationListener notificationListener,
             NotificationMediaManager notificationMediaManager) {
         mStatusBar = statusBar;
         mContrastColorUtil = ContrastColorUtil.getInstance(context);
@@ -108,7 +96,6 @@
         mStatusBarStateController = statusBarStateController;
         mStatusBarStateController.addCallback(this);
         mMediaManager = notificationMediaManager;
-        notificationListener.addNotificationSettingsListener(mSettingsListener);
         mDozeParameters = DozeParameters.getInstance(mContext);
         mWakeUpCoordinator = wakeUpCoordinator;
         wakeUpCoordinator.addListener(this);
@@ -116,6 +103,11 @@
 
         initializeNotificationAreaViews(context);
         reloadAodColor();
+
+        TunerService tunerService = Dependency.get(TunerService.class);
+        tunerService.addTunable((key, newValue) -> {
+            mShowSilentOnLockscreen = "1".equals(newValue);
+        }, Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS);
     }
 
     protected View inflateIconArea(LayoutInflater inflater) {
@@ -314,7 +306,7 @@
     public void updateStatusBarIcons() {
         updateIconsForLayout(entry -> entry.icon, mNotificationIcons,
                 false /* showAmbient */,
-                mShowLowPriority /* showLowPriority */,
+                true /* showLowPriority */,
                 true /* hideDismissed */,
                 true /* hideRepliedMessages */,
                 false /* hideCurrentMedia */,
@@ -336,7 +328,7 @@
     public void updateAodNotificationIcons() {
         updateIconsForLayout(entry -> entry.aodIcon, mAodIcons,
                 false /* showAmbient */,
-                mShowLowPriority /* showLowPriority */,
+                mShowSilentOnLockscreen /* showLowPriority */,
                 true /* hideDismissed */,
                 true /* hideRepliedMessages */,
                 true /* hideCurrentMedia */,
@@ -344,11 +336,6 @@
                 mBypassController.getBypassEnabled() /* hidePulsing */);
     }
 
-    @VisibleForTesting
-    boolean shouldShouldLowPriorityIcons() {
-        return mShowLowPriority;
-    }
-
     /**
      * Updates the notification icons for a host layout. This will ensure that the notification
      * host layout will have the same icons like the ones in here.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 96e7efe..2804580 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -800,7 +800,7 @@
         mNotificationIconAreaController = SystemUIFactory.getInstance()
                 .createNotificationIconAreaController(context, this,
                         mWakeUpCoordinator, mKeyguardBypassController,
-                        mStatusBarStateController, mNotificationListener);
+                        mStatusBarStateController);
         mWakeUpCoordinator.setIconAreaController(mNotificationIconAreaController);
         inflateShelf();
         mNotificationIconAreaController.setupShelf(mNotificationShelf);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerTest.java
deleted file mode 100644
index b1d5d26..0000000
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.statusbar.phone;
-
-import static android.provider.Settings.Secure.NOTIFICATION_NEW_INTERRUPTION_MODEL;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
-import android.provider.Settings;
-import android.testing.AndroidTestingRunner;
-import android.testing.TestableLooper;
-
-import androidx.test.filters.SmallTest;
-
-import com.android.systemui.R;
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.plugins.statusbar.StatusBarStateController;
-import com.android.systemui.statusbar.NotificationListener;
-import com.android.systemui.statusbar.NotificationMediaManager;
-import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-@SmallTest
-@RunWith(AndroidTestingRunner.class)
-@TestableLooper.RunWithLooper
-public class NotificationIconAreaControllerTest extends SysuiTestCase {
-
-    @Mock
-    private NotificationListener mListener;
-    @Mock
-    StatusBar mStatusBar;
-    @Mock
-    StatusBarWindowView mStatusBarWindowView;
-    @Mock
-    NotificationIconContainer mIconContainer;
-    @Mock
-    StatusBarStateController mStatusBarStateController;
-    @Mock
-    NotificationWakeUpCoordinator mNotificationWakeUpCoordinator;
-    @Mock
-    KeyguardBypassController mBypassController;
-    @Mock
-    private NotificationMediaManager mMediaManager;
-    private NotificationIconAreaController mController;
-
-    @Before
-    public void setup() {
-        MockitoAnnotations.initMocks(this);
-        when(mStatusBar.getStatusBarWindow()).thenReturn(mStatusBarWindowView);
-        when(mStatusBarWindowView.findViewById(R.id.clock_notification_icon_container)).thenReturn(
-                mIconContainer);
-        mController = new NotificationIconAreaController(mContext, mStatusBar,
-                mStatusBarStateController, mNotificationWakeUpCoordinator, mBypassController,
-                mListener, mMediaManager);
-    }
-
-    @Test
-    public void testNotificationIcons_featureOff() {
-        Settings.Secure.putInt(
-                mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 0);
-        assertTrue(mController.shouldShouldLowPriorityIcons());
-    }
-
-    @Test
-    public void testNotificationIcons_featureOn_settingHideIcons() {
-        Settings.Secure.putInt(
-                mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
-        mController.mSettingsListener.onStatusBarIconsBehaviorChanged(true);
-
-        assertFalse(mController.shouldShouldLowPriorityIcons());
-    }
-
-    @Test
-    public void testNotificationIcons_featureOn_settingShowIcons() {
-        Settings.Secure.putInt(
-                mContext.getContentResolver(), NOTIFICATION_NEW_INTERRUPTION_MODEL, 1);
-        mController.mSettingsListener.onStatusBarIconsBehaviorChanged(false);
-
-        assertTrue(mController.shouldShouldLowPriorityIcons());
-    }
-}