From 30377db99546eca15c60a168c770fa7c60d4ccea Mon Sep 17 00:00:00 2001 From: Caitlin Cassidy Date: Tue, 3 Aug 2021 21:09:48 +0000 Subject: [PATCH 1/2] [View Controllers] Move KeyguardStatusBarView#setKeyguardUserSwitcherEnabled to the controller. Test: manual Bug: 195442899 Change-Id: I770c45728618f07a27be0b83d8a1194cd9ef1dd1 --- .../systemui/statusbar/phone/KeyguardStatusBarView.java | 2 +- .../statusbar/phone/KeyguardStatusBarViewController.java | 5 +++++ .../statusbar/phone/NotificationPanelViewController.java | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index a73cad7d2c6d6..647df589316d1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -321,7 +321,7 @@ public class KeyguardStatusBarView extends RelativeLayout { } } - public void setKeyguardUserSwitcherEnabled(boolean enabled) { + void setKeyguardUserSwitcherEnabled(boolean enabled) { mKeyguardUserSwitcherEnabled = enabled; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java index 8770e86df7351..f11664c0482bc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java @@ -183,6 +183,11 @@ public class KeyguardStatusBarViewController extends ViewController Date: Fri, 6 Aug 2021 18:00:19 +0000 Subject: [PATCH 2/2] [View Controllers] Move KeyguardStatusBarView#setTopClipping calls out of NotificationPanelViewController. Test: atest (+ new unit tests) and manual (ensure status bar gets cut off when the notification shade is pulled down from lockscreen) Bug: 195442899 Change-Id: I9a7abce32870a026043fef0c551d784c0d2d7076 --- .../phone/KeyguardStatusBarView.java | 4 +- .../KeyguardStatusBarViewController.java | 15 +++++ .../NotificationPanelViewController.java | 9 ++- .../KeyguardStatusBarViewControllerTest.java | 47 ++++++++++++--- .../phone/KeyguardStatusBarViewTest.java | 59 +++++++++++++++++++ 5 files changed, 121 insertions(+), 13 deletions(-) create mode 100644 packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewTest.java diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java index 647df589316d1..df4bbcfc46bb4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java @@ -475,8 +475,10 @@ public class KeyguardStatusBarView extends RelativeLayout { /** * Set the clipping on the top of the view. + * + * Should only be called from {@link KeyguardStatusBarViewController}. */ - public void setTopClipping(int topClipping) { + void setTopClipping(int topClipping) { if (topClipping != mTopClipping) { mTopClipping = topClipping; updateClipping(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java index f11664c0482bc..25294165b3756 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewController.java @@ -201,6 +201,21 @@ public class KeyguardStatusBarViewController extends ViewController { + mKeyguardStatusBarView = + (KeyguardStatusBarView) LayoutInflater.from(mContext) + .inflate(R.layout.keyguard_status_bar, null); + }); mController = new KeyguardStatusBarViewController( mKeyguardStatusBarView, @@ -133,4 +139,27 @@ public class KeyguardStatusBarViewControllerTest extends SysuiTestCase { verify(mBatteryController).addCallback(any()); } + + @Test + public void updateTopClipping_viewClippingUpdated() { + int viewTop = 20; + mKeyguardStatusBarView.setTop(viewTop); + int notificationPanelTop = 30; + + mController.updateTopClipping(notificationPanelTop); + + assertThat(mKeyguardStatusBarView.getClipBounds().top).isEqualTo( + notificationPanelTop - viewTop); + } + + @Test + public void setNotTopClipping_viewClippingUpdatedToZero() { + // Start out with some amount of top clipping. + mController.updateTopClipping(50); + assertThat(mKeyguardStatusBarView.getClipBounds().top).isGreaterThan(0); + + mController.setNoTopClipping(); + + assertThat(mKeyguardStatusBarView.getClipBounds().top).isEqualTo(0); + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewTest.java new file mode 100644 index 0000000000000..3108ed9e7b98d --- /dev/null +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardStatusBarViewTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2021 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 com.google.common.truth.Truth.assertThat; + +import android.testing.AndroidTestingRunner; +import android.testing.TestableLooper; +import android.view.LayoutInflater; + +import androidx.test.filters.SmallTest; + +import com.android.systemui.R; +import com.android.systemui.SysuiTestCase; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +@SmallTest +@RunWith(AndroidTestingRunner.class) +@TestableLooper.RunWithLooper +public class KeyguardStatusBarViewTest extends SysuiTestCase { + + private KeyguardStatusBarView mKeyguardStatusBarView; + + @Before + public void setup() throws Exception { + allowTestableLooperAsMainThread(); + TestableLooper.get(this).runWithLooper(() -> { + mKeyguardStatusBarView = + (KeyguardStatusBarView) LayoutInflater.from(mContext) + .inflate(R.layout.keyguard_status_bar, null); + }); + } + + @Test + public void setTopClipping_clippingUpdated() { + int topClipping = 40; + + mKeyguardStatusBarView.setTopClipping(topClipping); + + assertThat(mKeyguardStatusBarView.getClipBounds().top).isEqualTo(topClipping); + } +}