Merge changes Ia64238f3,I45056904 into qt-r1-dev
am: a7719614c6
Change-Id: I3c82386f43d19b0b273c5b19279eff38a114e73e
diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
index a354cd4..15812ba 100644
--- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java
@@ -152,10 +152,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/CrossFadeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/CrossFadeHelper.java
index 04534ba..164215b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CrossFadeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CrossFadeHelper.java
@@ -28,6 +28,10 @@
public class CrossFadeHelper {
public static final long ANIMATION_DURATION_LENGTH = 210;
+ public static void fadeOut(final View view) {
+ fadeOut(view, null);
+ }
+
public static void fadeOut(final View view, final Runnable endRunnable) {
fadeOut(view, ANIMATION_DURATION_LENGTH, 0, endRunnable);
}
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 5310a54..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;
@@ -22,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;
@@ -32,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;
@@ -56,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;
@@ -86,18 +77,17 @@
private final Rect mTintArea = new Rect();
private ViewGroup mNotificationScrollLayout;
private Context mContext;
- private boolean mShowLowPriority = true;
private int mAodIconAppearTranslation;
private boolean mAnimationsEnabled;
private int mAodIconTint;
private boolean mFullyHidden;
+ private boolean mAodIconsVisible;
public NotificationIconAreaController(Context context, StatusBar statusBar,
StatusBarStateController statusBarStateController,
NotificationWakeUpCoordinator wakeUpCoordinator,
KeyguardBypassController keyguardBypassController,
- NotificationListener notificationListener,
NotificationMediaManager notificationMediaManager) {
mStatusBar = statusBar;
mContrastColorUtil = ContrastColorUtil.getInstance(context);
@@ -106,7 +96,6 @@
mStatusBarStateController = statusBarStateController;
mStatusBarStateController.addCallback(this);
mMediaManager = notificationMediaManager;
- notificationListener.addNotificationSettingsListener(mSettingsListener);
mDozeParameters = DozeParameters.getInstance(mContext);
mWakeUpCoordinator = wakeUpCoordinator;
wakeUpCoordinator.addListener(this);
@@ -114,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) {
@@ -147,10 +141,10 @@
mAodIcons = mStatusBar.getStatusBarWindow().findViewById(
R.id.clock_notification_icon_container);
mAodIcons.setOnLockScreen(true);
- updateAodIconsVisibility();
+ updateAodIconsVisibility(false /* animate */);
updateAnimations();
if (changed) {
- updateAodIcons();
+ updateAodNotificationIcons();
}
}
@@ -293,7 +287,7 @@
updateStatusBarIcons();
updateShelfIcons();
updateCenterIcon();
- updateAodIcons();
+ updateAodNotificationIcons();
applyNotificationIconsTint();
}
@@ -312,7 +306,7 @@
public void updateStatusBarIcons() {
updateIconsForLayout(entry -> entry.icon, mNotificationIcons,
false /* showAmbient */,
- mShowLowPriority /* showLowPriority */,
+ true /* showLowPriority */,
true /* hideDismissed */,
true /* hideRepliedMessages */,
false /* hideCurrentMedia */,
@@ -331,10 +325,10 @@
false /* hidePulsing */);
}
- public void updateAodIcons() {
+ public void updateAodNotificationIcons() {
updateIconsForLayout(entry -> entry.aodIcon, mAodIcons,
false /* showAmbient */,
- mShowLowPriority /* showLowPriority */,
+ mShowSilentOnLockscreen /* showLowPriority */,
true /* hideDismissed */,
true /* hideRepliedMessages */,
true /* hideCurrentMedia */,
@@ -342,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.
@@ -532,7 +521,7 @@
@Override
public void onStateChanged(int newState) {
- updateAodIconsVisibility();
+ updateAodIconsVisibility(false /* animate */);
updateAnimations();
}
@@ -583,21 +572,25 @@
@Override
public void onFullyHiddenChanged(boolean fullyHidden) {
- if (fullyHidden && !mBypassController.getBypassEnabled()) {
- appearAodIcons();
+ boolean animate = true;
+ if (!mBypassController.getBypassEnabled()) {
+ animate = mDozeParameters.getAlwaysOn() && !mDozeParameters.getDisplayNeedsBlanking();
+ // We only want the appear animations to happen when the notifications get fully hidden,
+ // since otherwise the unhide animation overlaps
+ animate &= fullyHidden;
}
- updateAodIconsVisibility();
- updateAodIcons();
+ updateAodIconsVisibility(animate);
+ updateAodNotificationIcons();
}
@Override
public void onPulseExpansionChanged(boolean expandingChanged) {
if (expandingChanged) {
- updateAodIconsVisibility();
+ updateAodIconsVisibility(true /* animate */);
}
}
- private void updateAodIconsVisibility() {
+ private void updateAodIconsVisibility(boolean animate) {
boolean visible = mBypassController.getBypassEnabled()
|| mWakeUpCoordinator.getNotificationsFullyHidden();
if (mStatusBarStateController.getState() != StatusBarState.KEYGUARD) {
@@ -606,6 +599,28 @@
if (visible && mWakeUpCoordinator.isPulseExpanding()) {
visible = false;
}
- mAodIcons.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
+ if (mAodIconsVisible != visible) {
+ mAodIconsVisible = visible;
+ mAodIcons.animate().cancel();
+ if (animate) {
+ boolean wasFullyInvisible = mAodIcons.getVisibility() != View.VISIBLE;
+ if (mAodIconsVisible) {
+ if (wasFullyInvisible) {
+ // No fading here, let's just appear the icons instead!
+ mAodIcons.setVisibility(View.VISIBLE);
+ mAodIcons.setAlpha(1.0f);
+ appearAodIcons();
+ } else {
+ // We were fading out, let's fade in instead
+ CrossFadeHelper.fadeIn(mAodIcons);
+ }
+ } else {
+ CrossFadeHelper.fadeOut(mAodIcons);
+ }
+ } else {
+ mAodIcons.setAlpha(1.0f);
+ mAodIcons.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
+ }
+ }
}
}
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 3888fc5..abf6c07 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -801,7 +801,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());
- }
-}