summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java7
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayoutTest.java64
2 files changed, 71 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index dcf7439b4a12..7eebdfa4963c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -40,6 +40,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.service.notification.StatusBarNotification;
import android.support.annotation.NonNull;
+import android.support.annotation.VisibleForTesting;
import android.util.AttributeSet;
import android.util.FloatProperty;
import android.util.Log;
@@ -3543,6 +3544,7 @@ public class NotificationStackScrollLayout extends ViewGroup
* See {@link AmbientState#setDimmed}.
*/
public void setDimmed(boolean dimmed, boolean animate) {
+ dimmed &= onKeyguard();
mAmbientState.setDimmed(dimmed);
if (animate && mAnimationsEnabled) {
mDimmedNeedsAnimation = true;
@@ -3554,6 +3556,11 @@ public class NotificationStackScrollLayout extends ViewGroup
requestChildrenUpdate();
}
+ @VisibleForTesting
+ boolean isDimmed() {
+ return mAmbientState.isDimmed();
+ }
+
private void setDimAmount(float dimAmount) {
mDimAmount = dimAmount;
updateBackgroundDimming();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayoutTest.java
new file mode 100644
index 000000000000..1c010b66056a
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayoutTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 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.stack;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.annotation.UiThread;
+import android.support.test.annotation.UiThreadTest;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+import android.view.NotificationHeaderView;
+import android.view.View;
+
+import com.android.systemui.SysuiTestCase;
+import com.android.systemui.statusbar.NotificationTestHelper;
+import com.android.systemui.statusbar.StatusBarState;
+import com.android.systemui.statusbar.phone.ScrimController;
+import com.android.systemui.statusbar.phone.StatusBar;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class NotificationStackScrollLayoutTest extends SysuiTestCase {
+
+ private NotificationStackScrollLayout mStackScroller;
+ private StatusBar mBar;
+
+ @Before
+ @UiThreadTest
+ public void setUp() throws Exception {
+ mStackScroller = new NotificationStackScrollLayout(getContext());
+ mBar = mock(StatusBar.class);
+ mStackScroller.setStatusBar(mBar);
+ mStackScroller.setScrimController(mock(ScrimController.class));
+ }
+
+ @Test
+ public void testNotDimmedOnKeyguard() {
+ when(mBar.getBarState()).thenReturn(StatusBarState.SHADE);
+ mStackScroller.setDimmed(true /* dimmed */, false /* animate */);
+ mStackScroller.setDimmed(true /* dimmed */, true /* animate */);
+ Assert.assertFalse(mStackScroller.isDimmed());
+ }
+
+}