DO NOT MERGE: Fixed an issue about notification icons on AOD
Previously low priority notifications were hidden on AOD unconditionally which is wrong. Bug: 135627468 Test: atest SystemUITests Merged-in: Ia64238f30620d9906aa50c2469121c2653875e8d Change-Id: Ia64238f30620d9906aa50c2469121c2653875e8d
This commit is contained in:
@@ -144,10 +144,9 @@ public class SystemUIFactory {
|
||||
}
|
||||
|
||||
public NotificationIconAreaController createNotificationIconAreaController(Context context,
|
||||
StatusBar statusBar, StatusBarStateController statusBarStateController,
|
||||
NotificationListener listener) {
|
||||
StatusBar statusBar, StatusBarStateController statusBarStateController) {
|
||||
return new NotificationIconAreaController(context, statusBar, statusBarStateController,
|
||||
listener, Dependency.get(NotificationMediaManager.class));
|
||||
Dependency.get(NotificationMediaManager.class));
|
||||
}
|
||||
|
||||
public KeyguardIndicationController createKeyguardIndicationController(Context context,
|
||||
|
||||
@@ -48,19 +48,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
private final Runnable mUpdateStatusBarIcons = this::updateStatusBarIcons;
|
||||
private final StatusBarStateController mStatusBarStateController;
|
||||
private final NotificationMediaManager mMediaManager;
|
||||
@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 int mIconSize;
|
||||
private int mIconHPadding;
|
||||
@@ -78,7 +65,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
private ViewGroup mNotificationScrollLayout;
|
||||
private Context mContext;
|
||||
private boolean mFullyDark;
|
||||
private boolean mShowLowPriority = true;
|
||||
private boolean mAnimationsEnabled;
|
||||
|
||||
/**
|
||||
@@ -88,7 +74,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
|
||||
public NotificationIconAreaController(Context context, StatusBar statusBar,
|
||||
StatusBarStateController statusBarStateController,
|
||||
NotificationListener notificationListener,
|
||||
NotificationMediaManager notificationMediaManager) {
|
||||
mStatusBar = statusBar;
|
||||
mContrastColorUtil = ContrastColorUtil.getInstance(context);
|
||||
@@ -97,7 +82,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
mStatusBarStateController = statusBarStateController;
|
||||
mStatusBarStateController.addCallback(this);
|
||||
mMediaManager = notificationMediaManager;
|
||||
notificationListener.addNotificationSettingsListener(mSettingsListener);
|
||||
|
||||
initializeNotificationAreaViews(context);
|
||||
}
|
||||
@@ -258,7 +242,7 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
private void updateShelfIcons() {
|
||||
updateIconsForLayout(entry -> entry.expandedIcon, mShelfIcons,
|
||||
true /* showAmbient */,
|
||||
!mFullyDark /* showLowPriority */,
|
||||
true /* showLowPriority */,
|
||||
false /* hideDismissed */,
|
||||
mFullyDark /* hideRepliedMessages */,
|
||||
mFullyDark /* hideCurrentMedia */,
|
||||
@@ -268,7 +252,7 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
public void updateStatusBarIcons() {
|
||||
updateIconsForLayout(entry -> entry.icon, mNotificationIcons,
|
||||
false /* showAmbient */,
|
||||
mShowLowPriority /* showLowPriority */,
|
||||
true /* showLowPriority */,
|
||||
true /* hideDismissed */,
|
||||
true /* hideRepliedMessages */,
|
||||
false /* hideCurrentMedia */,
|
||||
@@ -278,7 +262,7 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
private void updateCenterIcon() {
|
||||
updateIconsForLayout(entry -> entry.centeredIcon, mCenteredIcon,
|
||||
false /* showAmbient */,
|
||||
!mFullyDark /* showLowPriority */,
|
||||
true /* showLowPriority */,
|
||||
false /* hideDismissed */,
|
||||
false /* hideRepliedMessages */,
|
||||
mFullyDark /* hideCurrentMedia */,
|
||||
@@ -304,11 +288,6 @@ public class NotificationIconAreaController implements DarkReceiver,
|
||||
mNotificationIcons.setAnimationsEnabled(mAnimationsEnabled && inShade);
|
||||
}
|
||||
|
||||
@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.
|
||||
|
||||
@@ -795,8 +795,7 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
mNotificationLogger.setUpWithContainer(notifListContainer);
|
||||
|
||||
mNotificationIconAreaController = SystemUIFactory.getInstance()
|
||||
.createNotificationIconAreaController(context, this,
|
||||
mStatusBarStateController, mNotificationListener);
|
||||
.createNotificationIconAreaController(context, this, mStatusBarStateController);
|
||||
inflateShelf();
|
||||
mNotificationIconAreaController.setupShelf(mNotificationShelf);
|
||||
|
||||
|
||||
@@ -1,88 +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 android.provider.Settings;
|
||||
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 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
|
||||
private NotificationMediaManager mMediaManager;
|
||||
private NotificationIconAreaController mController;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mController = new NotificationIconAreaController(mContext, mStatusBar,
|
||||
mStatusBarStateController, 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user