Loading packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +2 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.screenshot.ScreenshotNotificationSmartActionsProvider; import com.android.systemui.statusbar.KeyguardIndicationController; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; import com.android.systemui.statusbar.phone.DozeParameters; Loading Loading @@ -153,6 +154,7 @@ public class SystemUIFactory { return new NotificationIconAreaController(context, statusBar, statusBarStateController, wakeUpCoordinator, keyguardBypassController, Dependency.get(NotificationMediaManager.class), Dependency.get(NotificationListener.class), Dependency.get(DozeParameters.class)); } Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java +34 −3 Original line number Diff line number Diff line package com.android.systemui.statusbar.phone; import android.app.NotificationManager; import android.content.Context; import android.content.res.Resources; import android.graphics.Color; Loading @@ -10,6 +11,7 @@ import android.view.ViewGroup; import android.widget.FrameLayout; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import androidx.collection.ArrayMap; import com.android.internal.statusbar.StatusBarIcon; Loading @@ -21,6 +23,7 @@ import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.CrossFadeHelper; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationShelf; import com.android.systemui.statusbar.StatusBarIconView; Loading Loading @@ -76,6 +79,19 @@ public class NotificationIconAreaController implements DarkReceiver, private boolean mFullyHidden; private boolean mAodIconsVisible; private boolean mIsPulsing; private boolean mShowLowPriority = true; @VisibleForTesting final NotificationListener.NotificationSettingsListener mSettingsListener = new NotificationListener.NotificationSettingsListener() { @Override public void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) { mShowLowPriority = !hideSilentStatusIcons; if (mNotificationScrollLayout != null) { updateStatusBarIcons(); } } }; public NotificationIconAreaController( Context context, Loading @@ -84,6 +100,7 @@ public class NotificationIconAreaController implements DarkReceiver, NotificationWakeUpCoordinator wakeUpCoordinator, KeyguardBypassController keyguardBypassController, NotificationMediaManager notificationMediaManager, NotificationListener notificationListener, DozeParameters dozeParameters) { mStatusBar = statusBar; mContrastColorUtil = ContrastColorUtil.getInstance(context); Loading @@ -95,6 +112,7 @@ public class NotificationIconAreaController implements DarkReceiver, mWakeUpCoordinator = wakeUpCoordinator; wakeUpCoordinator.addListener(this); mBypassController = keyguardBypassController; notificationListener.addNotificationSettingsListener(mSettingsListener); initializeNotificationAreaViews(context); reloadAodColor(); Loading Loading @@ -230,7 +248,7 @@ public class NotificationIconAreaController implements DarkReceiver, } protected boolean shouldShowNotificationIcon(NotificationEntry entry, boolean showAmbient, boolean hideDismissed, boolean showAmbient, boolean showLowPriority, boolean hideDismissed, boolean hideRepliedMessages, boolean hideCurrentMedia, boolean hideCenteredIcon, boolean hidePulsing, boolean onlyShowCenteredIcon) { Loading @@ -249,6 +267,9 @@ public class NotificationIconAreaController implements DarkReceiver, if (hideCurrentMedia && entry.getKey().equals(mMediaManager.getMediaNotificationKey())) { return false; } if (!showLowPriority && entry.getImportance() < NotificationManager.IMPORTANCE_DEFAULT) { return false; } if (!entry.isTopLevelChild()) { return false; } Loading Loading @@ -288,6 +309,7 @@ public class NotificationIconAreaController implements DarkReceiver, private void updateShelfIcons() { updateIconsForLayout(entry -> entry.expandedIcon, mShelfIcons, true /* showAmbient */, true /* showLowPriority */, false /* hideDismissed */, false /* hideRepliedMessages */, false /* hideCurrentMedia */, Loading @@ -299,6 +321,7 @@ public class NotificationIconAreaController implements DarkReceiver, public void updateStatusBarIcons() { updateIconsForLayout(entry -> entry.icon, mNotificationIcons, false /* showAmbient */, mShowLowPriority, true /* hideDismissed */, true /* hideRepliedMessages */, false /* hideCurrentMedia */, Loading @@ -310,6 +333,7 @@ public class NotificationIconAreaController implements DarkReceiver, private void updateCenterIcon() { updateIconsForLayout(entry -> entry.centeredIcon, mCenteredIcon, false /* showAmbient */, true /* showLowPriority */, false /* hideDismissed */, false /* hideRepliedMessages */, false /* hideCurrentMedia */, Loading @@ -321,6 +345,7 @@ public class NotificationIconAreaController implements DarkReceiver, public void updateAodNotificationIcons() { updateIconsForLayout(entry -> entry.aodIcon, mAodIcons, false /* showAmbient */, true /* showLowPriority */, true /* hideDismissed */, true /* hideRepliedMessages */, true /* hideCurrentMedia */, Loading @@ -329,18 +354,24 @@ public class NotificationIconAreaController implements DarkReceiver, false /* onlyShowCenteredIcon */); } @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. * @param function A function to look up an icon view based on an entry * @param hostLayout which layout should be updated * @param showAmbient should ambient notification icons be shown * @param showLowPriority should icons from silent notifications be shown * @param hideDismissed should dismissed icons be hidden * @param hideRepliedMessages should messages that have been replied to be hidden * @param hidePulsing should pulsing notifications be hidden */ private void updateIconsForLayout(Function<NotificationEntry, StatusBarIconView> function, NotificationIconContainer hostLayout, boolean showAmbient, NotificationIconContainer hostLayout, boolean showAmbient, boolean showLowPriority, boolean hideDismissed, boolean hideRepliedMessages, boolean hideCurrentMedia, boolean hideCenteredIcon, boolean hidePulsing, boolean onlyShowCenteredIcon) { ArrayList<StatusBarIconView> toShow = new ArrayList<>( Loading @@ -351,7 +382,7 @@ public class NotificationIconAreaController implements DarkReceiver, View view = mNotificationScrollLayout.getChildAt(i); if (view instanceof ExpandableNotificationRow) { NotificationEntry ent = ((ExpandableNotificationRow) view).getEntry(); if (shouldShowNotificationIcon(ent, showAmbient, hideDismissed, if (shouldShowNotificationIcon(ent, showAmbient, showLowPriority, hideDismissed, hideRepliedMessages, hideCurrentMedia, hideCenteredIcon, hidePulsing, onlyShowCenteredIcon)) { StatusBarIconView iconView = function.apply(ent); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerTest.java 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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 org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import androidx.test.filters.SmallTest; 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 StatusBarStateController mStatusBarStateController; @Mock NotificationWakeUpCoordinator mWakeUpCoordinator; @Mock KeyguardBypassController mKeyguardBypassController; @Mock NotificationMediaManager mNotificationMediaManager; @Mock DozeParameters mDozeParameters; @Mock NotificationShadeWindowView mNotificationShadeWindowView; private NotificationIconAreaController mController; @Before public void setup() { MockitoAnnotations.initMocks(this); when(mStatusBar.getNotificationShadeWindowView()).thenReturn(mNotificationShadeWindowView); when(mNotificationShadeWindowView.findViewById(anyInt())).thenReturn( mock(NotificationIconContainer.class)); mController = new NotificationIconAreaController(mContext, mStatusBar, mStatusBarStateController, mWakeUpCoordinator, mKeyguardBypassController, mNotificationMediaManager, mListener, mDozeParameters); } @Test public void testNotificationIcons_settingHideIcons() { mController.mSettingsListener.onStatusBarIconsBehaviorChanged(true); assertFalse(mController.shouldShouldLowPriorityIcons()); } @Test public void testNotificationIcons_settingShowIcons() { mController.mSettingsListener.onStatusBarIconsBehaviorChanged(false); assertTrue(mController.shouldShouldLowPriorityIcons()); } } Loading
packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +2 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.screenshot.ScreenshotNotificationSmartActionsProvider; import com.android.systemui.statusbar.KeyguardIndicationController; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator; import com.android.systemui.statusbar.phone.DozeParameters; Loading Loading @@ -153,6 +154,7 @@ public class SystemUIFactory { return new NotificationIconAreaController(context, statusBar, statusBarStateController, wakeUpCoordinator, keyguardBypassController, Dependency.get(NotificationMediaManager.class), Dependency.get(NotificationListener.class), Dependency.get(DozeParameters.class)); } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java +34 −3 Original line number Diff line number Diff line package com.android.systemui.statusbar.phone; import android.app.NotificationManager; import android.content.Context; import android.content.res.Resources; import android.graphics.Color; Loading @@ -10,6 +11,7 @@ import android.view.ViewGroup; import android.widget.FrameLayout; import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import androidx.collection.ArrayMap; import com.android.internal.statusbar.StatusBarIcon; Loading @@ -21,6 +23,7 @@ import com.android.systemui.plugins.DarkIconDispatcher; import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.CrossFadeHelper; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationShelf; import com.android.systemui.statusbar.StatusBarIconView; Loading Loading @@ -76,6 +79,19 @@ public class NotificationIconAreaController implements DarkReceiver, private boolean mFullyHidden; private boolean mAodIconsVisible; private boolean mIsPulsing; private boolean mShowLowPriority = true; @VisibleForTesting final NotificationListener.NotificationSettingsListener mSettingsListener = new NotificationListener.NotificationSettingsListener() { @Override public void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) { mShowLowPriority = !hideSilentStatusIcons; if (mNotificationScrollLayout != null) { updateStatusBarIcons(); } } }; public NotificationIconAreaController( Context context, Loading @@ -84,6 +100,7 @@ public class NotificationIconAreaController implements DarkReceiver, NotificationWakeUpCoordinator wakeUpCoordinator, KeyguardBypassController keyguardBypassController, NotificationMediaManager notificationMediaManager, NotificationListener notificationListener, DozeParameters dozeParameters) { mStatusBar = statusBar; mContrastColorUtil = ContrastColorUtil.getInstance(context); Loading @@ -95,6 +112,7 @@ public class NotificationIconAreaController implements DarkReceiver, mWakeUpCoordinator = wakeUpCoordinator; wakeUpCoordinator.addListener(this); mBypassController = keyguardBypassController; notificationListener.addNotificationSettingsListener(mSettingsListener); initializeNotificationAreaViews(context); reloadAodColor(); Loading Loading @@ -230,7 +248,7 @@ public class NotificationIconAreaController implements DarkReceiver, } protected boolean shouldShowNotificationIcon(NotificationEntry entry, boolean showAmbient, boolean hideDismissed, boolean showAmbient, boolean showLowPriority, boolean hideDismissed, boolean hideRepliedMessages, boolean hideCurrentMedia, boolean hideCenteredIcon, boolean hidePulsing, boolean onlyShowCenteredIcon) { Loading @@ -249,6 +267,9 @@ public class NotificationIconAreaController implements DarkReceiver, if (hideCurrentMedia && entry.getKey().equals(mMediaManager.getMediaNotificationKey())) { return false; } if (!showLowPriority && entry.getImportance() < NotificationManager.IMPORTANCE_DEFAULT) { return false; } if (!entry.isTopLevelChild()) { return false; } Loading Loading @@ -288,6 +309,7 @@ public class NotificationIconAreaController implements DarkReceiver, private void updateShelfIcons() { updateIconsForLayout(entry -> entry.expandedIcon, mShelfIcons, true /* showAmbient */, true /* showLowPriority */, false /* hideDismissed */, false /* hideRepliedMessages */, false /* hideCurrentMedia */, Loading @@ -299,6 +321,7 @@ public class NotificationIconAreaController implements DarkReceiver, public void updateStatusBarIcons() { updateIconsForLayout(entry -> entry.icon, mNotificationIcons, false /* showAmbient */, mShowLowPriority, true /* hideDismissed */, true /* hideRepliedMessages */, false /* hideCurrentMedia */, Loading @@ -310,6 +333,7 @@ public class NotificationIconAreaController implements DarkReceiver, private void updateCenterIcon() { updateIconsForLayout(entry -> entry.centeredIcon, mCenteredIcon, false /* showAmbient */, true /* showLowPriority */, false /* hideDismissed */, false /* hideRepliedMessages */, false /* hideCurrentMedia */, Loading @@ -321,6 +345,7 @@ public class NotificationIconAreaController implements DarkReceiver, public void updateAodNotificationIcons() { updateIconsForLayout(entry -> entry.aodIcon, mAodIcons, false /* showAmbient */, true /* showLowPriority */, true /* hideDismissed */, true /* hideRepliedMessages */, true /* hideCurrentMedia */, Loading @@ -329,18 +354,24 @@ public class NotificationIconAreaController implements DarkReceiver, false /* onlyShowCenteredIcon */); } @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. * @param function A function to look up an icon view based on an entry * @param hostLayout which layout should be updated * @param showAmbient should ambient notification icons be shown * @param showLowPriority should icons from silent notifications be shown * @param hideDismissed should dismissed icons be hidden * @param hideRepliedMessages should messages that have been replied to be hidden * @param hidePulsing should pulsing notifications be hidden */ private void updateIconsForLayout(Function<NotificationEntry, StatusBarIconView> function, NotificationIconContainer hostLayout, boolean showAmbient, NotificationIconContainer hostLayout, boolean showAmbient, boolean showLowPriority, boolean hideDismissed, boolean hideRepliedMessages, boolean hideCurrentMedia, boolean hideCenteredIcon, boolean hidePulsing, boolean onlyShowCenteredIcon) { ArrayList<StatusBarIconView> toShow = new ArrayList<>( Loading @@ -351,7 +382,7 @@ public class NotificationIconAreaController implements DarkReceiver, View view = mNotificationScrollLayout.getChildAt(i); if (view instanceof ExpandableNotificationRow) { NotificationEntry ent = ((ExpandableNotificationRow) view).getEntry(); if (shouldShowNotificationIcon(ent, showAmbient, hideDismissed, if (shouldShowNotificationIcon(ent, showAmbient, showLowPriority, hideDismissed, hideRepliedMessages, hideCurrentMedia, hideCenteredIcon, hidePulsing, onlyShowCenteredIcon)) { StatusBarIconView iconView = function.apply(ent); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationIconAreaControllerTest.java 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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 org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import androidx.test.filters.SmallTest; 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 StatusBarStateController mStatusBarStateController; @Mock NotificationWakeUpCoordinator mWakeUpCoordinator; @Mock KeyguardBypassController mKeyguardBypassController; @Mock NotificationMediaManager mNotificationMediaManager; @Mock DozeParameters mDozeParameters; @Mock NotificationShadeWindowView mNotificationShadeWindowView; private NotificationIconAreaController mController; @Before public void setup() { MockitoAnnotations.initMocks(this); when(mStatusBar.getNotificationShadeWindowView()).thenReturn(mNotificationShadeWindowView); when(mNotificationShadeWindowView.findViewById(anyInt())).thenReturn( mock(NotificationIconContainer.class)); mController = new NotificationIconAreaController(mContext, mStatusBar, mStatusBarStateController, mWakeUpCoordinator, mKeyguardBypassController, mNotificationMediaManager, mListener, mDozeParameters); } @Test public void testNotificationIcons_settingHideIcons() { mController.mSettingsListener.onStatusBarIconsBehaviorChanged(true); assertFalse(mController.shouldShouldLowPriorityIcons()); } @Test public void testNotificationIcons_settingShowIcons() { mController.mSettingsListener.onStatusBarIconsBehaviorChanged(false); assertTrue(mController.shouldShouldLowPriorityIcons()); } }