Do not show keyguard clock when communal mode is active.

This changelist hides the clock (part of the KeyguardStatusView)
when communal mode is shown on the keyguard.

Bug: 196885298
Test: atest KeyguardVisibilityHelperTest
Test: atest NotificationPanelViewTest#testKeyguardStatusViewUpdatedWithCommunalPresence
Change-Id: I488f51526babb5bc404a1dea1572ed43cd28372c
This commit is contained in:
Bryce Lee
2021-08-16 16:44:11 -07:00
parent 248e431587
commit aad7248b33
8 changed files with 188 additions and 7 deletions

View File

@@ -20,6 +20,7 @@ import android.graphics.Rect;
import android.util.Slog;
import com.android.keyguard.KeyguardClockSwitch.ClockSize;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.SmartspaceTransitionController;
import com.android.systemui.statusbar.notification.AnimatableProperty;
@@ -64,6 +65,7 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
KeyguardClockSwitchController keyguardClockSwitchController,
KeyguardStateController keyguardStateController,
KeyguardUpdateMonitor keyguardUpdateMonitor,
CommunalStateController communalStateController,
ConfigurationController configurationController,
DozeParameters dozeParameters,
KeyguardUnlockAnimationController keyguardUnlockAnimationController,
@@ -76,8 +78,9 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV
mConfigurationController = configurationController;
mDozeParameters = dozeParameters;
mKeyguardStateController = keyguardStateController;
mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, keyguardStateController,
dozeParameters, unlockedScreenOffAnimationController, /* animateYPos= */ true);
mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, communalStateController,
keyguardStateController, dozeParameters, unlockedScreenOffAnimationController,
/* animateYPos= */ true);
mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
mSmartspaceTransitionController = smartspaceTransitionController;
}

View File

@@ -22,6 +22,7 @@ import android.view.View;
import android.view.ViewPropertyAnimator;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.PropertyAnimator;
@@ -38,6 +39,7 @@ import com.android.systemui.statusbar.policy.KeyguardStateController;
public class KeyguardVisibilityHelper {
private View mView;
private final CommunalStateController mCommunalStateController;
private final KeyguardStateController mKeyguardStateController;
private final DozeParameters mDozeParameters;
private final UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
@@ -47,11 +49,13 @@ public class KeyguardVisibilityHelper {
private final AnimationProperties mAnimationProperties = new AnimationProperties();
public KeyguardVisibilityHelper(View view,
CommunalStateController communalStateController,
KeyguardStateController keyguardStateController,
DozeParameters dozeParameters,
UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
boolean animateYPos) {
mView = view;
mCommunalStateController = communalStateController;
mKeyguardStateController = keyguardStateController;
mDozeParameters = dozeParameters;
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
@@ -73,6 +77,14 @@ public class KeyguardVisibilityHelper {
mView.animate().cancel();
boolean isOccluded = mKeyguardStateController.isOccluded();
mKeyguardViewVisibilityAnimating = false;
// If the communal view is showing, hide immediately
if (mCommunalStateController.getCommunalViewShowing()) {
mView.setVisibility(View.GONE);
mView.setAlpha(1f);
return;
}
if ((!keyguardFadingAway && oldStatusBarState == KEYGUARD
&& statusBarState != KEYGUARD) || goingToFullShade) {
mKeyguardViewVisibilityAnimating = true;

View File

@@ -109,6 +109,7 @@ import com.android.systemui.communal.CommunalHostView;
import com.android.systemui.communal.CommunalHostViewController;
import com.android.systemui.communal.CommunalSource;
import com.android.systemui.communal.CommunalSourceMonitor;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.communal.dagger.CommunalViewComponent;
import com.android.systemui.controls.dagger.ControlsComponent;
import com.android.systemui.dagger.qualifiers.DisplayId;
@@ -327,6 +328,7 @@ public class NotificationPanelViewController extends PanelViewController {
private final KeyguardBypassController mKeyguardBypassController;
private final KeyguardUpdateMonitor mUpdateMonitor;
private final CommunalSourceMonitor mCommunalSourceMonitor;
private final CommunalStateController mCommunalStateController;
private final ConversationNotificationManager mConversationNotificationManager;
private final AuthController mAuthController;
private final MediaHierarchyManager mMediaHierarchyManager;
@@ -711,6 +713,32 @@ public class NotificationPanelViewController extends PanelViewController {
}
};
private final CommunalStateController.Callback mCommunalStateCallback =
new CommunalStateController.Callback() {
@Override
public void onCommunalViewShowingChanged() {
mKeyguardStatusViewController.setKeyguardStatusViewVisibility(
mBarState,
mKeyguardStateController.isKeyguardFadingAway(),
mStatusBarStateController.goingToFullShade(),
mBarState);
if (mKeyguardUserSwitcherController != null) {
mKeyguardUserSwitcherController.setKeyguardUserSwitcherVisibility(
mBarState,
mKeyguardStateController.isKeyguardFadingAway(),
mStatusBarStateController.goingToFullShade(),
mBarState);
}
if (mKeyguardQsUserSwitchController != null) {
mKeyguardQsUserSwitchController.setKeyguardQsUserSwitchVisibility(
mBarState,
mKeyguardStateController.isKeyguardFadingAway(),
mStatusBarStateController.goingToFullShade(),
mBarState);
}
}
};
private final FalsingTapListener mFalsingTapListener = new FalsingTapListener() {
@Override
public void onDoubleTapRequired() {
@@ -735,6 +763,7 @@ public class NotificationPanelViewController extends PanelViewController {
FalsingCollector falsingCollector,
NotificationLockscreenUserManager notificationLockscreenUserManager,
NotificationEntryManager notificationEntryManager,
CommunalStateController communalStateController,
KeyguardStateController keyguardStateController,
StatusBarStateController statusBarStateController, DozeLog dozeLog,
DozeParameters dozeParameters, CommandQueue commandQueue, VibratorHelper vibratorHelper,
@@ -811,6 +840,7 @@ public class NotificationPanelViewController extends PanelViewController {
mNotificationStackScrollLayoutController = notificationStackScrollLayoutController;
mGroupManager = groupManager;
mNotificationIconAreaController = notificationIconAreaController;
mCommunalStateController = communalStateController;
mCommunalViewComponentFactory = communalViewComponentFactory;
mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory;
mKeyguardStatusBarViewComponentFactory = keyguardStatusBarViewComponentFactory;
@@ -4660,6 +4690,7 @@ public class NotificationPanelViewController extends PanelViewController {
mFalsingManager.addTapListener(mFalsingTapListener);
mKeyguardIndicationController.init();
registerSettingsChangeListener();
mCommunalStateController.addCallback(mCommunalStateCallback);
}
@Override
@@ -4674,6 +4705,7 @@ public class NotificationPanelViewController extends PanelViewController {
// Clear source when detached.
setCommunalSource(null /*source*/);
mFalsingManager.removeTapListener(mFalsingTapListener);
mCommunalStateController.removeCallback(mCommunalStateCallback);
}
}

View File

@@ -33,6 +33,7 @@ import com.android.keyguard.KeyguardVisibilityHelper;
import com.android.keyguard.dagger.KeyguardUserSwitcherScope;
import com.android.settingslib.drawable.CircleFramedDrawable;
import com.android.systemui.R;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.plugins.FalsingManager;
@@ -116,6 +117,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
@Main Resources resources,
ScreenLifecycle screenLifecycle,
UserSwitcherController userSwitcherController,
CommunalStateController communalStateController,
KeyguardStateController keyguardStateController,
FalsingManager falsingManager,
ConfigurationController configurationController,
@@ -133,7 +135,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
mFalsingManager = falsingManager;
mConfigurationController = configurationController;
mStatusBarStateController = statusBarStateController;
mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView,
mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, communalStateController,
keyguardStateController, dozeParameters,
unlockedScreenOffAnimationController, /* animateYPos= */ false);
mUserDetailAdapter = new KeyguardUserDetailAdapter(context, userDetailViewAdapterProvider);

View File

@@ -42,6 +42,7 @@ import com.android.keyguard.dagger.KeyguardUserSwitcherScope;
import com.android.settingslib.drawable.CircleFramedDrawable;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -157,6 +158,7 @@ public class KeyguardUserSwitcherController extends ViewController<KeyguardUserS
LayoutInflater layoutInflater,
ScreenLifecycle screenLifecycle,
UserSwitcherController userSwitcherController,
CommunalStateController communalStateController,
KeyguardStateController keyguardStateController,
SysuiStatusBarStateController statusBarStateController,
KeyguardUpdateMonitor keyguardUpdateMonitor,
@@ -172,7 +174,7 @@ public class KeyguardUserSwitcherController extends ViewController<KeyguardUserS
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mAdapter = new KeyguardUserAdapter(mContext, resources, layoutInflater,
mUserSwitcherController, this);
mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView,
mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, communalStateController,
keyguardStateController, dozeParameters,
unlockedScreenOffAnimationController, /* animateYPos= */ false);
mBackground = new KeyguardUserSwitcherScrim(context);

View File

@@ -22,6 +22,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.testing.AndroidTestingRunner;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.shared.system.smartspace.SmartspaceTransitionController;
import com.android.systemui.statusbar.phone.DozeParameters;
@@ -50,6 +51,8 @@ public class KeyguardStatusViewControllerTest extends SysuiTestCase {
@Mock
private KeyguardStateController mKeyguardStateController;
@Mock
private CommunalStateController mCommunalStateController;
@Mock
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock
ConfigurationController mConfigurationController;
@@ -76,6 +79,7 @@ public class KeyguardStatusViewControllerTest extends SysuiTestCase {
mKeyguardClockSwitchController,
mKeyguardStateController,
mKeyguardUpdateMonitor,
mCommunalStateController,
mConfigurationController,
mDozeParameters,
mKeyguardUnlockAnimationController,

View File

@@ -0,0 +1,77 @@
/*
* 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.keyguard;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.test.suitebuilder.annotation.SmallTest;
import android.view.View;
import android.view.ViewPropertyAnimator;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@SmallTest
public class KeyguardVisibilityHelperTest extends SysuiTestCase {
@Mock
private CommunalStateController mCommunalStateController;
@Mock
private KeyguardStateController mKeyguardStateController;
@Mock
com.android.systemui.statusbar.phone.DozeParameters mDozeParameters;
@Mock
UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
@Mock
ViewPropertyAnimator mViewPropertyAnimator;
@Mock
View mTargetView;
private KeyguardVisibilityHelper mKeyguardVisibilityHelper;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
when(mTargetView.animate()).thenReturn(mViewPropertyAnimator);
mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mTargetView,
mCommunalStateController, mKeyguardStateController, mDozeParameters,
mUnlockedScreenOffAnimationController, false);
}
@Test
public void testHideOnCommunal() {
// Verify view is hidden when communal is visible.
when(mCommunalStateController.getCommunalViewShowing()).thenReturn(true);
mKeyguardVisibilityHelper.setViewVisibility(StatusBarState.KEYGUARD, false,
false, StatusBarState.KEYGUARD);
verify(mTargetView).setVisibility(View.GONE);
verify(mTargetView).setAlpha(1.0f);
// Verify view is shown when communal is not visible.
when(mCommunalStateController.getCommunalViewShowing()).thenReturn(false);
mKeyguardVisibilityHelper.setViewVisibility(StatusBarState.KEYGUARD, false,
false, StatusBarState.KEYGUARD);
verify(mTargetView).setVisibility(View.VISIBLE);
}
}

View File

@@ -93,6 +93,7 @@ import com.android.systemui.communal.CommunalHostView;
import com.android.systemui.communal.CommunalHostViewController;
import com.android.systemui.communal.CommunalSource;
import com.android.systemui.communal.CommunalSourceMonitor;
import com.android.systemui.communal.CommunalStateController;
import com.android.systemui.communal.dagger.CommunalViewComponent;
import com.android.systemui.controls.dagger.ControlsComponent;
import com.android.systemui.doze.DozeLog;
@@ -131,7 +132,10 @@ import com.android.systemui.statusbar.notification.stack.NotificationRoundnessMa
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardQsUserSwitchController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcherController;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcherView;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.util.time.FakeSystemClock;
@@ -178,7 +182,7 @@ public class NotificationPanelViewTest extends SysuiTestCase {
@Mock
private KeyguardStatusBarView mKeyguardStatusBar;
@Mock
private View mUserSwitcherView;
private KeyguardUserSwitcherView mUserSwitcherView;
@Mock
private ViewStub mUserSwitcherStubView;
@Mock
@@ -247,8 +251,16 @@ public class NotificationPanelViewTest extends SysuiTestCase {
@Mock
private KeyguardQsUserSwitchComponent.Factory mKeyguardQsUserSwitchComponentFactory;
@Mock
private KeyguardQsUserSwitchComponent mKeyguardQsUserSwitchComponent;
@Mock
private KeyguardQsUserSwitchController mKeyguardQsUserSwitchController;
@Mock
private KeyguardUserSwitcherComponent.Factory mKeyguardUserSwitcherComponentFactory;
@Mock
private KeyguardUserSwitcherComponent mKeyguardUserSwitcherComponent;
@Mock
private KeyguardUserSwitcherController mKeyguardUserSwitcherController;
@Mock
private IdleViewComponent.Factory mIdleViewComponentFactory;
@Mock
private IdleViewComponent mIdleViewComponent;
@@ -275,6 +287,9 @@ public class NotificationPanelViewTest extends SysuiTestCase {
@Mock
private CommunalHostView mCommunalHostView;
@Mock
private CommunalStateController mCommunalStateController;
private CommunalStateController.Callback mCommunalStateControllerCallback;
@Mock
private KeyguardClockSwitchController mKeyguardClockSwitchController;
@Mock
private KeyguardStatusViewController mKeyguardStatusViewController;
@@ -396,6 +411,14 @@ public class NotificationPanelViewTest extends SysuiTestCase {
when(mFragmentService.getFragmentHostManager(mView)).thenReturn(mFragmentHostManager);
FlingAnimationUtils.Builder flingAnimationUtilsBuilder = new FlingAnimationUtils.Builder(
mDisplayMetrics);
when(mKeyguardQsUserSwitchComponentFactory.build(any()))
.thenReturn(mKeyguardQsUserSwitchComponent);
when(mKeyguardQsUserSwitchComponent.getKeyguardQsUserSwitchController())
.thenReturn(mKeyguardQsUserSwitchController);
when(mKeyguardUserSwitcherComponentFactory.build(any()))
.thenReturn(mKeyguardUserSwitcherComponent);
when(mKeyguardUserSwitcherComponent.getKeyguardUserSwitcherController())
.thenReturn(mKeyguardUserSwitcherController);
doAnswer((Answer<Void>) invocation -> {
mTouchHandler = invocation.getArgument(0);
@@ -440,6 +463,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
.thenReturn(mIdleHostViewController);
when(mLayoutInflater.inflate(eq(R.layout.keyguard_status_view), any(), anyBoolean()))
.thenReturn(mKeyguardStatusView);
when(mLayoutInflater.inflate(eq(R.layout.keyguard_user_switcher), any(), anyBoolean()))
.thenReturn(mUserSwitcherView);
when(mLayoutInflater.inflate(eq(R.layout.keyguard_bottom_area), any(), anyBoolean()))
.thenReturn(mKeyguardBottomArea);
when(mNotificationRemoteInputManager.isRemoteInputActive()).thenReturn(false);
@@ -453,8 +478,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
coordinator, expansionHandler, mDynamicPrivacyController, mKeyguardBypassController,
mFalsingManager, new FalsingCollectorFake(),
mNotificationLockscreenUserManager, mNotificationEntryManager,
mKeyguardStateController, mStatusBarStateController, mDozeLog,
mDozeParameters, mCommandQueue, mVibratorHelper,
mCommunalStateController, mKeyguardStateController, mStatusBarStateController,
mDozeLog, mDozeParameters, mCommandQueue, mVibratorHelper,
mLatencyTracker, mPowerManager, mAccessibilityManager, 0, mUpdateMonitor,
mCommunalSourceMonitor, mMetricsLogger, mActivityManager, mConfigurationController,
() -> flingAnimationUtilsBuilder, mStatusBarTouchableRegionManager,
@@ -878,6 +903,30 @@ public class NotificationPanelViewTest extends SysuiTestCase {
assertThat(sourceCapture.getValue()).isEqualTo(null);
}
@Test
public void testKeyguardStatusViewUpdatedWithCommunalPresence() {
givenViewAttached();
when(mResources.getBoolean(
com.android.internal.R.bool.config_keyguardUserSwitcher)).thenReturn(true);
updateMultiUserSetting(true);
ArgumentCaptor<CommunalStateController.Callback> communalCallbackCapture =
ArgumentCaptor.forClass(CommunalStateController.Callback.class);
verify(mCommunalStateController).addCallback(communalCallbackCapture.capture());
final CommunalStateController.Callback communalStateControllerCallback =
communalCallbackCapture.getValue();
clearInvocations(mKeyguardStatusViewController, mKeyguardUserSwitcherController);
// Ensure changes in communal visibility leads to setting the keyguard status view
// visibility.
communalStateControllerCallback.onCommunalViewShowingChanged();
verify(mKeyguardStatusViewController).setKeyguardStatusViewVisibility(anyInt(),
anyBoolean(), anyBoolean(), anyInt());
verify(mKeyguardUserSwitcherController).setKeyguardUserSwitcherVisibility(anyInt(),
anyBoolean(), anyBoolean(), anyInt());
}
private void triggerPositionClockAndNotifications() {
mNotificationPanelViewController.closeQs();
}