Merge "Revert "Moving smartspace to the right on the lockscreen for split shade"" into sc-v2-dev

This commit is contained in:
Android Build Prod User
2021-08-25 11:40:59 +00:00
committed by Android (Google) Code Review
10 changed files with 164 additions and 203 deletions

View File

@@ -68,16 +68,6 @@
lockScreenWeight="400"
/>
</FrameLayout>
<FrameLayout
android:id="@+id/keyguard_smartspace_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/below_clock_padding_start"
android:paddingEnd="@dimen/below_clock_padding_end"
android:layout_alignParentStart="true"
android:layout_below="@id/lockscreen_clock_view"
/>
<!-- either keyguard_status_area or keyguard_smartspace_container is visible -->
<include layout="@layout/keyguard_status_area"
android:id="@+id/keyguard_status_area"
android:layout_width="match_parent"

View File

@@ -86,19 +86,7 @@
layout="@layout/keyguard_status_view"
android:visibility="gone"/>
<FrameLayout
android:id="@+id/split_shade_smartspace_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="@dimen/notification_side_paddings"
android:paddingEnd="@dimen/notification_side_paddings"
systemui:layout_constraintStart_toStartOf="@id/qs_edge_guideline"
systemui:layout_constraintEnd_toEndOf="parent"
systemui:layout_constraintTop_toTopOf="parent"
android:visibility="gone">
</FrameLayout>
<include layout="@layout/dock_info_overlay" />
<include layout="@layout/dock_info_overlay"/>
<FrameLayout
android:id="@+id/qs_frame"

View File

@@ -17,13 +17,13 @@
package com.android.keyguard;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.android.keyguard.KeyguardClockSwitch.LARGE;
import android.app.WallpaperManager;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
@@ -93,7 +93,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private final ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin;
private ViewGroup mSmartspaceContainer;
// If set, will replace keyguard_status_area
private View mSmartspaceView;
private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
private SmartspaceTransitionController mSmartspaceTransitionController;
@@ -147,8 +148,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mClockFrame = mView.findViewById(R.id.lockscreen_clock_view);
mLargeClockFrame = mView.findViewById(R.id.lockscreen_clock_view_large);
mSmartspaceContainer = mView.findViewById(R.id.keyguard_smartspace_container);
mSmartspaceController.setKeyguardStatusContainer(mSmartspaceContainer);
mClockViewController =
new AnimatableClockController(
@@ -190,25 +189,35 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
}
updateAodIcons();
if (mSmartspaceController.isSmartspaceEnabled()) {
// "Enabled" doesn't mean smartspace is displayed here - inside mSmartspaceContainer -
// it might be a part of another view when in split shade. But it means that it CAN be
// displayed here, so we want to hide keyguard_status_area and set views relations
// accordingly.
if (mSmartspaceController.isEnabled()) {
mSmartspaceView = mSmartspaceController.buildAndConnectView(mView);
View ksa = mView.findViewById(R.id.keyguard_status_area);
// we show either keyguard_status_area or smartspace, so when smartspace can be visible,
// keyguard_status_area should be hidden
int ksaIndex = mView.indexOfChild(ksa);
ksa.setVisibility(View.GONE);
// Place smartspace view below normal clock...
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
MATCH_PARENT, WRAP_CONTENT);
lp.addRule(RelativeLayout.BELOW, R.id.lockscreen_clock_view);
mView.addView(mSmartspaceView, ksaIndex, lp);
int startPadding = getContext().getResources()
.getDimensionPixelSize(R.dimen.below_clock_padding_start);
int endPadding = getContext().getResources()
.getDimensionPixelSize(R.dimen.below_clock_padding_end);
mSmartspaceView.setPaddingRelative(startPadding, 0, endPadding, 0);
updateClockLayout();
View nic = mView.findViewById(R.id.left_aligned_notification_icon_container);
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) nic.getLayoutParams();
lp.addRule(RelativeLayout.BELOW, mSmartspaceContainer.getId());
View nic = mView.findViewById(
R.id.left_aligned_notification_icon_container);
lp = (RelativeLayout.LayoutParams) nic.getLayoutParams();
lp.addRule(RelativeLayout.BELOW, mSmartspaceView.getId());
nic.setLayoutParams(lp);
mView.setSmartspaceView(mSmartspaceContainer);
mSmartspaceTransitionController.setLockscreenSmartspace(mSmartspaceContainer);
mView.setSmartspaceView(mSmartspaceView);
mSmartspaceTransitionController.setLockscreenSmartspace(mSmartspaceView);
}
}
@@ -231,7 +240,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
// instance of this class. In order to fix this, we need to modify the plugin so that
// (a) we get a new view each time and (b) we can properly clean up an old view by making
// it unregister itself as a plugin listener.
mSmartspaceContainer.removeAllViews();
if (mSmartspaceView != null) {
mView.removeView(mSmartspaceView);
mSmartspaceView = null;
}
}
/**
@@ -244,7 +256,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
}
private void updateClockLayout() {
if (mSmartspaceController.isSmartspaceEnabled()) {
if (mSmartspaceController.isEnabled()) {
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(MATCH_PARENT,
MATCH_PARENT);
lp.topMargin = getContext().getResources().getDimensionPixelSize(
@@ -309,8 +321,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y,
scale, props, animate);
if (mSmartspaceContainer != null) {
PropertyAnimator.setProperty(mSmartspaceContainer, AnimatableProperty.TRANSLATION_X,
if (mSmartspaceView != null) {
PropertyAnimator.setProperty(mSmartspaceView, AnimatableProperty.TRANSLATION_X,
x, props, animate);
// If we're unlocking with the SmartSpace shared element transition, let the controller
@@ -328,8 +340,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
public void setChildrenAlphaExcludingSmartspace(float alpha) {
final Set<View> excludedViews = new HashSet<>();
if (mSmartspaceContainer != null) {
excludedViews.add(mSmartspaceContainer);
if (mSmartspaceView != null) {
excludedViews.add(mSmartspaceView);
}
setChildrenAlphaExcluding(alpha, excludedViews);

View File

@@ -31,8 +31,6 @@ import android.os.Handler
import android.os.UserHandle
import android.provider.Settings
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import com.android.settingslib.Utils
import com.android.systemui.R
@@ -46,21 +44,14 @@ import com.android.systemui.plugins.FalsingManager
import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.settings.UserTracker
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.notification.AnimatableProperty
import com.android.systemui.statusbar.notification.PropertyAnimator
import com.android.systemui.statusbar.notification.stack.AnimationProperties
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.util.concurrency.Execution
import com.android.systemui.util.settings.SecureSettings
import java.lang.RuntimeException
import java.util.Optional
import java.util.concurrent.Executor
import javax.inject.Inject
private val ANIMATION_PROPERTIES = AnimationProperties()
.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD.toLong())
/**
* Controller for managing the smartspace view on the lockscreen
*/
@@ -81,15 +72,10 @@ class LockscreenSmartspaceController @Inject constructor(
@Main private val handler: Handler,
optionalPlugin: Optional<BcSmartspaceDataPlugin>
) {
var splitShadeContainer: ViewGroup? = null
private var singlePaneContainer: ViewGroup? = null
private var session: SmartspaceSession? = null
private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null)
private lateinit var smartspaceView: SmartspaceView
// smartspace casted to View
lateinit var view: View
private set
@@ -97,60 +83,12 @@ class LockscreenSmartspaceController @Inject constructor(
private var showSensitiveContentForManagedUser = false
private var managedUserHandle: UserHandle? = null
private var isAod = false
private var isSplitShade = false
fun isSmartspaceEnabled(): Boolean {
fun isEnabled(): Boolean {
execution.assertIsMainThread()
return featureFlags.isSmartspaceEnabled && plugin != null
}
fun setKeyguardStatusContainer(container: ViewGroup) {
singlePaneContainer = container
// reattach smartspace if necessary as this might be a new container
updateSmartSpaceContainer()
}
fun onSplitShadeChanged(splitShade: Boolean) {
isSplitShade = splitShade
updateSmartSpaceContainer()
}
private fun updateSmartSpaceContainer() {
if (!isSmartspaceEnabled()) return
// in AOD we always want to show smartspace on the left i.e. in singlePaneContainer
if (isSplitShade && !isAod) {
switchContainerVisibility(
newParent = splitShadeContainer,
oldParent = singlePaneContainer)
} else {
switchContainerVisibility(
newParent = singlePaneContainer,
oldParent = splitShadeContainer)
}
requestSmartspaceUpdate()
}
private fun switchContainerVisibility(newParent: ViewGroup?, oldParent: ViewGroup?) {
// it might be the case that smartspace was already attached and we just needed to update
// visibility, e.g. going from lockscreen -> unlocked -> lockscreen
if (newParent?.childCount == 0) {
oldParent?.removeAllViews()
newParent.addView(buildAndConnectView(newParent))
}
oldParent?.visibility = GONE
newParent?.visibility = VISIBLE
}
fun setSplitShadeSmartspaceAlpha(alpha: Float) {
// the other container's alpha is modified as a part of keyguard status view, so we don't
// have to do that here
if (splitShadeContainer?.visibility == VISIBLE) {
splitShadeContainer?.alpha = alpha
}
}
/**
* Constructs the smartspace view and connects it to the smartspace service. Subsequent calls
* are idempotent until [disconnect] is called.
@@ -158,7 +96,7 @@ class LockscreenSmartspaceController @Inject constructor(
fun buildAndConnectView(parent: ViewGroup): View {
execution.assertIsMainThread()
if (!isSmartspaceEnabled()) {
if (!isEnabled()) {
throw RuntimeException("Cannot build view when not enabled")
}
@@ -244,6 +182,7 @@ class LockscreenSmartspaceController @Inject constructor(
userTracker.removeCallback(userTrackerCallback)
contentResolver.unregisterContentObserver(settingsObserver)
configurationController.removeCallback(configChangeListener)
statusBarStateController.removeCallback(statusBarStateListener)
session = null
plugin?.onTargetsAvailable(emptyList())
@@ -259,13 +198,6 @@ class LockscreenSmartspaceController @Inject constructor(
plugin?.unregisterListener(listener)
}
fun shiftSplitShadeSmartspace(y: Int, animate: Boolean) {
if (splitShadeContainer?.visibility == VISIBLE) {
PropertyAnimator.setProperty(splitShadeContainer, AnimatableProperty.Y, y.toFloat(),
ANIMATION_PROPERTIES, animate)
}
}
private val sessionListener = SmartspaceSession.OnTargetsAvailableListener { targets ->
execution.assertIsMainThread()
val filteredTargets = targets.filter(::filterSmartspaceTarget)
@@ -301,23 +233,6 @@ class LockscreenSmartspaceController @Inject constructor(
execution.assertIsMainThread()
smartspaceView.setDozeAmount(eased)
}
override fun onDozingChanged(isDozing: Boolean) {
isAod = isDozing
updateSmartSpaceContainer()
}
override fun onStateChanged(newState: Int) {
if (newState == StatusBarState.KEYGUARD) {
if (isSmartspaceEnabled()) {
updateSmartSpaceContainer()
}
} else {
splitShadeContainer?.visibility = GONE
singlePaneContainer?.visibility = GONE
disconnect()
}
}
}
private fun filterSmartspaceTarget(t: SmartspaceTarget): Boolean {

View File

@@ -32,11 +32,23 @@ import com.android.systemui.statusbar.policy.KeyguardUserSwitcherListView;
* Utility class to calculate the clock position and top padding of notifications on Keyguard.
*/
public class KeyguardClockPositionAlgorithm {
/**
* How much the clock height influences the shade position.
* 0 means nothing, 1 means move the shade up by the height of the clock
* 0.5f means move the shade up by half of the size of the clock.
*/
private static float CLOCK_HEIGHT_WEIGHT = 0.7f;
/**
* Margin between the bottom of the status view and the notification shade.
*/
private int mStatusViewBottomMargin;
/**
* Height of the parent view - display size in px.
*/
private int mHeight;
/**
* Height of {@link KeyguardStatusView}.
*/
@@ -55,6 +67,21 @@ public class KeyguardClockPositionAlgorithm {
*/
private int mUserSwitchPreferredY;
/**
* Whether or not there is a custom clock face on keyguard.
*/
private boolean mHasCustomClock;
/**
* Whether or not the NSSL contains any visible notifications.
*/
private boolean mHasVisibleNotifs;
/**
* Height of notification stack: Sum of height of each notification.
*/
private int mNotificationStackHeight;
/**
* Minimum top margin to avoid overlap with status bar, lock icon, or multi-user switcher
* avatar.
@@ -121,7 +148,6 @@ public class KeyguardClockPositionAlgorithm {
private int mUnlockedStackScrollerPadding;
private boolean mIsSplitShade;
private int mSplitShadeSmartspaceHeight;
/**
* Refreshes the dimension values.
@@ -144,25 +170,28 @@ public class KeyguardClockPositionAlgorithm {
* Sets up algorithm values.
*/
public void setup(int keyguardStatusBarHeaderHeight, int maxShadeBottom,
float panelExpansion,
int keyguardStatusHeight, int userSwitchHeight, int userSwitchPreferredY, float dark,
int notificationStackHeight, float panelExpansion, int parentHeight,
int keyguardStatusHeight, int userSwitchHeight, int userSwitchPreferredY,
boolean hasCustomClock, boolean hasVisibleNotifs, float dark,
float overStrechAmount, boolean bypassEnabled, int unlockedStackScrollerPadding,
float qsExpansion, int cutoutTopInset, int splitShadeSmartspaceHeight,
boolean isSplitShade) {
float qsExpansion, int cutoutTopInset, boolean isSplitShade) {
mMinTopMargin = keyguardStatusBarHeaderHeight + Math.max(mContainerTopPadding,
userSwitchHeight);
mMaxShadeBottom = maxShadeBottom;
mNotificationStackHeight = notificationStackHeight;
mPanelExpansion = panelExpansion;
mHeight = parentHeight;
mKeyguardStatusHeight = keyguardStatusHeight + mStatusViewBottomMargin;
mUserSwitchHeight = userSwitchHeight;
mUserSwitchPreferredY = userSwitchPreferredY;
mHasCustomClock = hasCustomClock;
mHasVisibleNotifs = hasVisibleNotifs;
mDarkAmount = dark;
mOverStretchAmount = overStrechAmount;
mBypassEnabled = bypassEnabled;
mUnlockedStackScrollerPadding = unlockedStackScrollerPadding;
mQsExpansion = qsExpansion;
mCutoutTopInset = cutoutTopInset;
mSplitShadeSmartspaceHeight = splitShadeSmartspaceHeight;
mIsSplitShade = isSplitShade;
}
@@ -184,7 +213,7 @@ public class KeyguardClockPositionAlgorithm {
if (mBypassEnabled) {
return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount);
} else if (mIsSplitShade) {
return clockYPosition + mSplitShadeSmartspaceHeight;
return clockYPosition;
} else {
return clockYPosition + mKeyguardStatusHeight;
}

View File

@@ -138,7 +138,6 @@ import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.events.PrivacyDotViewController;
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController;
import com.android.systemui.statusbar.notification.AnimatableProperty;
import com.android.systemui.statusbar.notification.ConversationNotificationManager;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
@@ -230,7 +229,6 @@ public class NotificationPanelViewController extends PanelViewController {
private final HeightListener mHeightListener = new HeightListener();
private final ConfigurationListener mConfigurationListener = new ConfigurationListener();
private final SettingsChangeObserver mSettingsChangeObserver;
private final LockscreenSmartspaceController mLockscreenSmartspaceController;
@VisibleForTesting final StatusBarStateListener mStatusBarStateListener =
new StatusBarStateListener();
@@ -357,8 +355,6 @@ public class NotificationPanelViewController extends PanelViewController {
private KeyguardStatusViewController mKeyguardStatusViewController;
private LockIconViewController mLockIconViewController;
private NotificationsQuickSettingsContainer mNotificationContainerParent;
private FrameLayout mSplitShadeSmartspaceContainer;
private boolean mAnimateNextPositionUpdate;
private float mQuickQsOffsetHeight;
private UnlockedScreenOffAnimationController mUnlockedScreenOffAnimationController;
@@ -739,7 +735,6 @@ public class NotificationPanelViewController extends PanelViewController {
@Main Executor uiExecutor,
SecureSettings secureSettings,
SplitShadeHeaderController splitShadeHeaderController,
LockscreenSmartspaceController lockscreenSmartspaceController,
UnlockedScreenOffAnimationController unlockedScreenOffAnimationController,
LockscreenGestureLogger lockscreenGestureLogger,
NotificationRemoteInputManager remoteInputManager,
@@ -780,7 +775,6 @@ public class NotificationPanelViewController extends PanelViewController {
mQSDetailDisplayer = qsDetailDisplayer;
mFragmentService = fragmentService;
mSettingsChangeObserver = new SettingsChangeObserver(handler);
mLockscreenSmartspaceController = lockscreenSmartspaceController;
mShouldUseSplitNotificationShade =
Utils.shouldUseSplitNotificationShade(mResources);
mView.setWillNotDraw(!DEBUG);
@@ -875,9 +869,6 @@ public class NotificationPanelViewController extends PanelViewController {
loadDimens();
mKeyguardStatusBar = mView.findViewById(R.id.keyguard_header);
mBigClockContainer = mView.findViewById(R.id.big_clock_container);
mSplitShadeSmartspaceContainer = mView.findViewById(R.id.split_shade_smartspace_container);
mLockscreenSmartspaceController.setSplitShadeContainer(mSplitShadeSmartspaceContainer);
mLockscreenSmartspaceController.onSplitShadeChanged(mShouldUseSplitNotificationShade);
UserAvatarView userAvatarView = null;
KeyguardUserSwitcherView keyguardUserSwitcherView = null;
@@ -1083,7 +1074,7 @@ public class NotificationPanelViewController extends PanelViewController {
mNotificationContainerParent.setSplitShadeEnabled(mShouldUseSplitNotificationShade);
updateKeyguardStatusViewAlignment(/* animate= */false);
mLockscreenSmartspaceController.onSplitShadeChanged(mShouldUseSplitNotificationShade);
mKeyguardMediaController.refreshMediaPosition();
}
@@ -1349,15 +1340,16 @@ public class NotificationPanelViewController extends PanelViewController {
? 1.0f : mInterpolatedDarkAmount;
mClockPositionAlgorithm.setup(mStatusBarHeaderHeightKeyguard,
totalHeight - bottomPadding,
mNotificationStackScrollLayoutController.getIntrinsicContentHeight(),
expandedFraction,
totalHeight,
mKeyguardStatusViewController.getLockscreenHeight(),
userIconHeight,
userSwitcherPreferredY,
darkamount, mOverStretchAmount,
userSwitcherPreferredY, hasCustomClock(),
hasVisibleNotifications, darkamount, mOverStretchAmount,
bypassEnabled, getUnlockedStackScrollerPadding(),
computeQsExpansionFraction(),
mDisplayTopInset,
mSplitShadeSmartspaceContainer.getHeight(),
mShouldUseSplitNotificationShade);
mClockPositionAlgorithm.run(mClockPositionResult);
boolean animate = mNotificationStackScrollLayoutController.isAddOrRemoveAnimationPending();
@@ -1377,9 +1369,6 @@ public class NotificationPanelViewController extends PanelViewController {
mClockPositionResult.userSwitchY,
animateClock);
}
// no need to translate in X axis - horizontal position is determined by constraints
mLockscreenSmartspaceController
.shiftSplitShadeSmartspace(mClockPositionResult.clockY, animateClock);
updateNotificationTranslucency();
updateClock();
}
@@ -1547,7 +1536,6 @@ public class NotificationPanelViewController extends PanelViewController {
if (mKeyguardUserSwitcherController != null) {
mKeyguardUserSwitcherController.setAlpha(alpha);
}
mLockscreenSmartspaceController.setSplitShadeSmartspaceAlpha(alpha);
}
public void animateToFullShade(long delay) {
@@ -3732,7 +3720,6 @@ public class NotificationPanelViewController extends PanelViewController {
public void dozeTimeTick() {
mKeyguardBottomArea.dozeTimeTick();
mKeyguardStatusViewController.dozeTimeTick();
mLockscreenSmartspaceController.requestSmartspaceUpdate();
if (mInterpolatedDarkAmount > 0) {
positionClockAndNotifications();
}

View File

@@ -19,6 +19,7 @@ package com.android.keyguard;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
@@ -28,7 +29,6 @@ import static org.mockito.Mockito.when;
import android.content.res.Resources;
import android.testing.AndroidTestingRunner;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
@@ -104,8 +104,6 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
private AnimatableClockView mLargeClockView;
@Mock
private FrameLayout mLargeClockFrame;
@Mock
private ViewGroup mSmartspaceContainer;
private final View mFakeSmartspaceView = new View(mContext);
@@ -125,8 +123,6 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
when(mView.findViewById(R.id.animatable_clock_view)).thenReturn(mClockView);
when(mView.findViewById(R.id.animatable_clock_view_large)).thenReturn(mLargeClockView);
when(mView.findViewById(R.id.lockscreen_clock_view_large)).thenReturn(mLargeClockFrame);
when(mView.findViewById(R.id.keyguard_smartspace_container))
.thenReturn(mSmartspaceContainer);
when(mClockView.getContext()).thenReturn(getContext());
when(mLargeClockView.getContext()).thenReturn(getContext());
@@ -214,7 +210,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
@Test
public void testSmartspaceEnabledRemovesKeyguardStatusArea() {
when(mSmartspaceController.isSmartspaceEnabled()).thenReturn(true);
when(mSmartspaceController.isEnabled()).thenReturn(true);
when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
mController.init();
@@ -223,7 +219,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
@Test
public void testSmartspaceDisabledShowsKeyguardStatusArea() {
when(mSmartspaceController.isSmartspaceEnabled()).thenReturn(false);
when(mSmartspaceController.isEnabled()).thenReturn(false);
mController.init();
assertEquals(View.VISIBLE, mStatusArea.getVisibility());
@@ -231,16 +227,17 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
@Test
public void testDetachRemovesSmartspaceView() {
when(mSmartspaceController.isSmartspaceEnabled()).thenReturn(true);
when(mSmartspaceController.isEnabled()).thenReturn(true);
when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
mController.init();
verify(mView).addView(eq(mFakeSmartspaceView), anyInt(), any());
ArgumentCaptor<View.OnAttachStateChangeListener> listenerArgumentCaptor =
ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class);
verify(mView).addOnAttachStateChangeListener(listenerArgumentCaptor.capture());
listenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView);
verify(mSmartspaceContainer).removeAllViews();
verify(mView).removeView(mFakeSmartspaceView);
}
@Test

View File

@@ -389,6 +389,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
verify(userTracker).removeCallback(userListener)
verify(contentResolver).unregisterContentObserver(settingsObserver)
verify(configurationController).removeCallback(configChangeListener)
verify(statusBarStateController).removeCallback(statusBarStateListener)
}
@Test

View File

@@ -38,27 +38,35 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
private static final float ZERO_DRAG = 0.f;
private static final float OPAQUE = 1.f;
private static final float TRANSPARENT = 0.f;
private static final boolean HAS_CUSTOM_CLOCK = false;
private static final boolean HAS_VISIBLE_NOTIFS = false;
private KeyguardClockPositionAlgorithm mClockPositionAlgorithm;
private KeyguardClockPositionAlgorithm.Result mClockPosition;
private int mNotificationStackHeight;
private float mPanelExpansion;
private int mKeyguardStatusHeight;
private float mDark;
private boolean mHasCustomClock;
private boolean mHasVisibleNotifs;
private float mQsExpansion;
private int mCutoutTopInsetPx = 0;
private int mSplitShadeSmartspaceHeightPx = 0;
private int mCutoutTopInset = 0; // in pixels
private boolean mIsSplitShade = false;
@Before
public void setUp() {
mClockPositionAlgorithm = new KeyguardClockPositionAlgorithm();
mClockPosition = new KeyguardClockPositionAlgorithm.Result();
mHasCustomClock = HAS_CUSTOM_CLOCK;
mHasVisibleNotifs = HAS_VISIBLE_NOTIFS;
}
@Test
public void clockPositionTopOfScreenOnAOD() {
// GIVEN on AOD and clock has 0 height
// GIVEN on AOD and both stack scroll and clock have 0 height
givenAOD();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = EMPTY_HEIGHT;
// WHEN the clock position algorithm is run
positionClock();
@@ -71,10 +79,11 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
@Test
public void clockPositionBelowCutout() {
// GIVEN on AOD and clock has 0 height
// GIVEN on AOD and both stack scroll and clock have 0 height
givenAOD();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = EMPTY_HEIGHT;
mCutoutTopInsetPx = 300;
mCutoutTopInset = 300;
// WHEN the clock position algorithm is run
positionClock();
// THEN the clock Y position is below the cutout
@@ -88,6 +97,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
public void clockPositionAdjustsForKeyguardStatusOnAOD() {
// GIVEN on AOD with a clock of height 100
givenAOD();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = 100;
// WHEN the clock position algorithm is run
positionClock();
@@ -102,6 +112,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
public void clockPositionLargeClockOnAOD() {
// GIVEN on AOD with a full screen clock
givenAOD();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = SCREEN_HEIGHT;
// WHEN the clock position algorithm is run
positionClock();
@@ -114,8 +125,9 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
@Test
public void clockPositionTopOfScreenOnLockScreen() {
// GIVEN on lock screen with clock of 0 height
// GIVEN on lock screen with stack scroll and clock of 0 height
givenLockScreen();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = EMPTY_HEIGHT;
// WHEN the clock position algorithm is run
positionClock();
@@ -125,10 +137,25 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
assertThat(mClockPosition.clockX).isEqualTo(0);
}
@Test
public void clockPositionWithStackScrollExpandOnLockScreen() {
// GIVEN on lock screen with stack scroll of height 500
givenLockScreen();
mNotificationStackHeight = 500;
mKeyguardStatusHeight = EMPTY_HEIGHT;
// WHEN the clock position algorithm is run
positionClock();
// THEN the clock Y position stays to the top
assertThat(mClockPosition.clockY).isEqualTo(0);
// AND the clock is positioned on the left.
assertThat(mClockPosition.clockX).isEqualTo(0);
}
@Test
public void clockPositionWithPartialDragOnLockScreen() {
// GIVEN dragging up on lock screen
givenLockScreen();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = EMPTY_HEIGHT;
mPanelExpansion = 0.5f;
// WHEN the clock position algorithm is run
@@ -144,6 +171,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
public void clockPositionWithFullDragOnLockScreen() {
// GIVEN the lock screen is dragged up
givenLockScreen();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = EMPTY_HEIGHT;
mPanelExpansion = 0.f;
// WHEN the clock position algorithm is run
@@ -156,6 +184,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
public void largeClockOnLockScreenIsTransparent() {
// GIVEN on lock screen with a full screen clock
givenLockScreen();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = SCREEN_HEIGHT;
// WHEN the clock position algorithm is run
positionClock();
@@ -165,8 +194,9 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
@Test
public void notifPositionTopOfScreenOnAOD() {
// GIVEN on AOD and clock has 0 height
// GIVEN on AOD and both stack scroll and clock have 0 height
givenAOD();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = EMPTY_HEIGHT;
// WHEN the position algorithm is run
positionClock();
@@ -178,6 +208,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
public void notifPositionIndependentOfKeyguardStatusHeightOnAOD() {
// GIVEN on AOD and clock has a nonzero height
givenAOD();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = 100;
// WHEN the position algorithm is run
positionClock();
@@ -189,6 +220,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
public void notifPositionWithLargeClockOnAOD() {
// GIVEN on AOD and clock has a nonzero height
givenAOD();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = SCREEN_HEIGHT;
// WHEN the position algorithm is run
positionClock();
@@ -198,8 +230,9 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
@Test
public void notifPositionMiddleOfScreenOnLockScreen() {
// GIVEN on lock screen and clock has 0 height
// GIVEN on lock screen and both stack scroll and clock have 0 height
givenLockScreen();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = EMPTY_HEIGHT;
// WHEN the position algorithm is run
positionClock();
@@ -207,43 +240,59 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0);
}
@Test
public void notifPositionAdjustsForStackHeightOnLockScreen() {
// GIVEN on lock screen and stack scroller has a nonzero height
givenLockScreen();
mNotificationStackHeight = 500;
mKeyguardStatusHeight = EMPTY_HEIGHT;
// WHEN the position algorithm is run
positionClock();
// THEN the notif padding adjusts for keyguard status height
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0);
}
@Test
public void notifPositionAdjustsForClockHeightOnLockScreen() {
// GIVEN on lock screen and stack scroller has a nonzero height
givenLockScreen();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = 200;
// WHEN the position algorithm is run
positionClock();
// THEN the notif padding adjusts for both clock and notif stack.
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(200);
}
@Test
public void notifPositionAdjustsForStackHeightAndClockHeightOnLockScreen() {
// GIVEN on lock screen and stack scroller has a nonzero height
givenLockScreen();
mNotificationStackHeight = 500;
mKeyguardStatusHeight = 200;
// WHEN the position algorithm is run
positionClock();
// THEN the notifs are placed below the statusview
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(200);
}
@Test
public void notifPositionAlignedWithClockInSplitShadeMode() {
// GIVEN on lock screen and split shade mode
givenLockScreen();
mIsSplitShade = true;
mKeyguardStatusHeight = 200;
mHasCustomClock = true;
// WHEN the position algorithm is run
positionClock();
// THEN the notif padding DOESN'T adjust for keyguard status height.
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0);
}
@Test
public void notifPositionAdjustedBySmartspaceHeightInSplitShadeMode() {
givenLockScreen();
mSplitShadeSmartspaceHeightPx = 200;
mIsSplitShade = true;
// WHEN the position algorithm is run
positionClock();
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(200);
}
@Test
public void notifPositionWithLargeClockOnLockScreen() {
// GIVEN on lock screen and clock has a nonzero height
givenLockScreen();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = SCREEN_HEIGHT;
// WHEN the position algorithm is run
positionClock();
@@ -255,6 +304,7 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
public void notifPositionWithFullDragOnLockScreen() {
// GIVEN the lock screen is dragged up
givenLockScreen();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = EMPTY_HEIGHT;
mPanelExpansion = 0.f;
// WHEN the clock position algorithm is run
@@ -267,18 +317,19 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
public void notifPositionWithLargeClockFullDragOnLockScreen() {
// GIVEN the lock screen is dragged up and a full screen clock
givenLockScreen();
mNotificationStackHeight = EMPTY_HEIGHT;
mKeyguardStatusHeight = SCREEN_HEIGHT;
mPanelExpansion = 0.f;
// WHEN the clock position algorithm is run
positionClock();
// THEN the notif padding is zero.
assertThat(mClockPosition.stackScrollerPadding).isEqualTo(
(int) (mKeyguardStatusHeight * .667f));
}
@Test
public void clockHiddenWhenQsIsExpanded() {
// GIVEN on the lock screen with visible notifications
// GIVEN on the lock screen with a custom clock and visible notifications
givenLockScreen();
mQsExpansion = 1;
// WHEN the clock position algorithm is run
@@ -298,12 +349,12 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase {
}
private void positionClock() {
mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT,
mPanelExpansion, mKeyguardStatusHeight,
mClockPositionAlgorithm.setup(EMPTY_MARGIN, SCREEN_HEIGHT, mNotificationStackHeight,
mPanelExpansion, SCREEN_HEIGHT, mKeyguardStatusHeight,
0 /* userSwitchHeight */, 0 /* userSwitchPreferredY */,
mDark, ZERO_DRAG, false /* bypassEnabled */,
mHasCustomClock, mHasVisibleNotifs, mDark, ZERO_DRAG, false /* bypassEnabled */,
0 /* unlockedStackScrollerPadding */, mQsExpansion,
mCutoutTopInsetPx, mSplitShadeSmartspaceHeightPx, mIsSplitShade);
mCutoutTopInset, mIsSplitShade);
mClockPositionAlgorithm.run(mClockPosition);
}
}

View File

@@ -63,7 +63,6 @@ import android.view.ViewPropertyAnimator;
import android.view.ViewStub;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;
@@ -113,7 +112,6 @@ import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.events.PrivacyDotViewController;
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController;
import com.android.systemui.statusbar.notification.ConversationNotificationManager;
import com.android.systemui.statusbar.notification.DynamicPrivacyController;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
@@ -303,10 +301,6 @@ public class NotificationPanelViewTest extends SysuiTestCase {
@Mock
private ControlsComponent mControlsComponent;
@Mock
private LockscreenSmartspaceController mLockscreenSmartspaceController;
@Mock
private FrameLayout mSplitShadeSmartspaceContainer;
@Mock
private LockscreenGestureLogger mLockscreenGestureLogger;
private SysuiStatusBarStateController mStatusBarStateController;
@@ -357,8 +351,6 @@ public class NotificationPanelViewTest extends SysuiTestCase {
when(mView.findViewById(R.id.qs_frame)).thenReturn(mQsFrame);
when(mView.findViewById(R.id.keyguard_status_view))
.thenReturn(mock(KeyguardStatusView.class));
when(mView.findViewById(R.id.split_shade_smartspace_container))
.thenReturn(mSplitShadeSmartspaceContainer);
mNotificationContainerParent = new NotificationsQuickSettingsContainer(getContext(), null);
mNotificationContainerParent.addView(newViewWithId(R.id.qs_frame));
mNotificationContainerParent.addView(newViewWithId(R.id.notification_stack_scroller));
@@ -452,7 +444,6 @@ public class NotificationPanelViewTest extends SysuiTestCase {
new FakeExecutor(new FakeSystemClock()),
mSecureSettings,
mSplitShadeHeaderController,
mLockscreenSmartspaceController,
mUnlockedScreenOffAnimationController,
mLockscreenGestureLogger,
mNotificationRemoteInputManager,