From b03823f4dc7163f70930bf927e8341adeea055e9 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Tue, 12 Oct 2021 15:51:14 -0400 Subject: [PATCH] AOD - Notif icon location Support a mode where icons are visible on AOD with the large clock. This means shifting both smartspace and icons when switching between large/small clocks. Also: Continue to remove old keyguard flag Also: Add a couple logs for smartspace, let LockscreenSmartspaceController handle disconnect directly Fixes: 201548040 Test: atest KeyguardClockSwitchControllerTest KeyguardSliceViewTest KeyguardUpdateMonitorTest KeyguardStatusViewControllerTest Change-Id: I3697aea0c1a8083e87d446d082d95aab573af83a --- .../layout/keyguard_clock_switch.xml | 31 ++++--- ...tatus_area.xml => keyguard_slice_view.xml} | 7 +- packages/SystemUI/res/values/flags.xml | 3 - .../android/keyguard/KeyguardClockSwitch.java | 53 +++++------ .../KeyguardClockSwitchController.java | 39 ++++---- .../android/keyguard/KeyguardSliceView.java | 89 ++----------------- .../keyguard/KeyguardSliceViewController.java | 11 --- .../android/keyguard/KeyguardStatusView.java | 2 +- .../KeyguardStatusViewController.java | 5 -- .../keyguard/KeyguardUpdateMonitor.java | 31 ------- .../KeyguardUpdateMonitorCallback.java | 5 -- .../dagger/KeyguardStatusViewModule.java | 2 +- .../android/systemui/flags/FeatureFlags.java | 4 - .../KeyguardIndicationController.java | 6 -- .../LockscreenSmartspaceController.kt | 9 ++ .../KeyguardClockSwitchControllerTest.java | 29 ++---- .../keyguard/KeyguardSliceViewTest.java | 2 +- .../keyguard/KeyguardUpdateMonitorTest.java | 2 - .../LockscreenSmartspaceControllerTest.kt | 2 + 19 files changed, 85 insertions(+), 247 deletions(-) rename packages/SystemUI/res-keyguard/layout/{keyguard_status_area.xml => keyguard_slice_view.xml} (89%) diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml index 28c61663bd4d7..87a9825af1cb9 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml @@ -51,7 +51,7 @@ android:id="@+id/lockscreen_clock_view_large" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@id/keyguard_status_area" + android:layout_below="@id/keyguard_slice_view" android:visibility="gone"> - + + android:layout_below="@id/lockscreen_clock_view"> - + + + + diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml b/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml similarity index 89% rename from packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml rename to packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml index 95eb5c1d5f1aa..1863d11129474 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_status_area.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml @@ -22,11 +22,10 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_gravity="center_horizontal" + android:layout_gravity="start" android:clipToPadding="false" android:orientation="vertical" - android:paddingStart="@dimen/below_clock_padding_start" - android:layout_centerHorizontal="true"> + android:paddingStart="@dimen/below_clock_padding_start"> diff --git a/packages/SystemUI/res/values/flags.xml b/packages/SystemUI/res/values/flags.xml index 740e97c4e4437..89614b812d40c 100644 --- a/packages/SystemUI/res/values/flags.xml +++ b/packages/SystemUI/res/values/flags.xml @@ -24,9 +24,6 @@ true - - true - false diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java index f81f0b9ca2c34..6fd0c821bad1e 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java @@ -41,7 +41,7 @@ public class KeyguardClockSwitch extends RelativeLayout { private static final long CLOCK_OUT_MILLIS = 150; private static final long CLOCK_IN_MILLIS = 200; - private static final long SMARTSPACE_MOVE_MILLIS = 350; + private static final long STATUS_AREA_MOVE_MILLIS = 350; @IntDef({LARGE, SMALL}) @Retention(RetentionPolicy.SOURCE) @@ -63,13 +63,7 @@ public class KeyguardClockSwitch extends RelativeLayout { private AnimatableClockView mClockView; private AnimatableClockView mLargeClockView; - /** - * Status area (date and other stuff) shown below the clock. Plugin can decide whether or not to - * show it below the alternate clock. - */ - private View mKeyguardStatusArea; - /** Mutually exclusive with mKeyguardStatusArea */ - private View mSmartspaceView; + private View mStatusArea; private int mSmartspaceTopOffset; /** @@ -85,7 +79,7 @@ public class KeyguardClockSwitch extends RelativeLayout { @VisibleForTesting AnimatorSet mClockInAnim = null; @VisibleForTesting AnimatorSet mClockOutAnim = null; - private ObjectAnimator mSmartspaceAnim = null; + private ObjectAnimator mStatusAreaAnim = null; /** * If the Keyguard Slice has a header (big center-aligned text.) @@ -131,7 +125,7 @@ public class KeyguardClockSwitch extends RelativeLayout { mClockView = findViewById(R.id.animatable_clock_view); mLargeClockFrame = findViewById(R.id.lockscreen_clock_view_large); mLargeClockView = findViewById(R.id.animatable_clock_view_large); - mKeyguardStatusArea = findViewById(R.id.keyguard_status_area); + mStatusArea = findViewById(R.id.keyguard_status_area); onDensityOrFontScaleChanged(); } @@ -200,22 +194,22 @@ public class KeyguardClockSwitch extends RelativeLayout { private void animateClockChange(boolean useLargeClock) { if (mClockInAnim != null) mClockInAnim.cancel(); if (mClockOutAnim != null) mClockOutAnim.cancel(); - if (mSmartspaceAnim != null) mSmartspaceAnim.cancel(); + if (mStatusAreaAnim != null) mStatusAreaAnim.cancel(); View in, out; int direction = 1; - float smartspaceYTranslation; + float statusAreaYTranslation; if (useLargeClock) { out = mClockFrame; in = mLargeClockFrame; if (indexOfChild(in) == -1) addView(in); direction = -1; - smartspaceYTranslation = mSmartspaceView == null ? 0 - : mClockFrame.getTop() - mSmartspaceView.getTop() + mSmartspaceTopOffset; + statusAreaYTranslation = mClockFrame.getTop() - mStatusArea.getTop() + + mSmartspaceTopOffset; } else { in = mClockFrame; out = mLargeClockFrame; - smartspaceYTranslation = 0f; + statusAreaYTranslation = 0f; // Must remove in order for notifications to appear in the proper place removeView(out); @@ -251,18 +245,16 @@ public class KeyguardClockSwitch extends RelativeLayout { mClockInAnim.start(); mClockOutAnim.start(); - if (mSmartspaceView != null) { - mSmartspaceAnim = ObjectAnimator.ofFloat(mSmartspaceView, View.TRANSLATION_Y, - smartspaceYTranslation); - mSmartspaceAnim.setDuration(SMARTSPACE_MOVE_MILLIS); - mSmartspaceAnim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); - mSmartspaceAnim.addListener(new AnimatorListenerAdapter() { - public void onAnimationEnd(Animator animation) { - mSmartspaceAnim = null; - } - }); - mSmartspaceAnim.start(); - } + mStatusAreaAnim = ObjectAnimator.ofFloat(mStatusArea, View.TRANSLATION_Y, + statusAreaYTranslation); + mStatusAreaAnim.setDuration(STATUS_AREA_MOVE_MILLIS); + mStatusAreaAnim.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); + mStatusAreaAnim.addListener(new AnimatorListenerAdapter() { + public void onAnimationEnd(Animator animation) { + mStatusAreaAnim = null; + } + }); + mStatusAreaAnim.start(); } /** @@ -352,10 +344,6 @@ public class KeyguardClockSwitch extends RelativeLayout { } } - void setSmartspaceView(View smartspaceView) { - mSmartspaceView = smartspaceView; - } - void updateColors(ColorExtractor.GradientColors colors) { mSupportsDarkText = colors.supportsDarkText(); mColorPalette = colors.getColorPalette(); @@ -369,8 +357,7 @@ public class KeyguardClockSwitch extends RelativeLayout { pw.println(" mClockPlugin: " + mClockPlugin); pw.println(" mClockFrame: " + mClockFrame); pw.println(" mLargeClockFrame: " + mLargeClockFrame); - pw.println(" mKeyguardStatusArea: " + mKeyguardStatusArea); - pw.println(" mSmartspaceView: " + mSmartspaceView); + pw.println(" mStatusArea: " + mStatusArea); pw.println(" mDarkAmount: " + mDarkAmount); pw.println(" mSupportsDarkText: " + mSupportsDarkText); pw.println(" mColorPalette: " + Arrays.toString(mColorPalette)); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index 4111020afbf59..01976b41a4b29 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -25,7 +25,9 @@ import android.app.WallpaperManager; import android.content.res.Resources; import android.text.TextUtils; import android.view.View; +import android.view.ViewGroup; import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.RelativeLayout; import com.android.internal.colorextraction.ColorExtractor; @@ -99,7 +101,8 @@ public class KeyguardClockSwitchController extends ViewController showSlice(RowContent header, List subItems) { Trace.beginSection("KeyguardSliceView#showSlice"); mHasHeader = header != null; @@ -189,8 +156,7 @@ public class KeyguardSliceView extends LinearLayout { final int startIndex = mHasHeader ? 1 : 0; // First item is header; skip it mRow.setVisibility(subItemsCount > 0 ? VISIBLE : GONE); LinearLayout.LayoutParams layoutParams = (LayoutParams) mRow.getLayoutParams(); - layoutParams.gravity = mLockScreenMode != KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL - ? Gravity.START : Gravity.CENTER; + layoutParams.gravity = Gravity.START; mRow.setLayoutParams(layoutParams); for (int i = startIndex; i < subItemsCount; i++) { @@ -224,8 +190,7 @@ public class KeyguardSliceView extends LinearLayout { final int iconSize = mHasHeader ? mIconSizeWithHeader : mIconSize; iconDrawable = icon.getIcon().loadDrawable(mContext); if (iconDrawable != null) { - if ((iconDrawable instanceof InsetDrawable) - && mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) { + if (iconDrawable instanceof InsetDrawable) { // System icons (DnD) use insets which are fine for centered slice content // but will cause a slight indent for left/right-aligned slice views iconDrawable = ((InsetDrawable) iconDrawable).getDrawable(); @@ -321,7 +286,6 @@ public class KeyguardSliceView extends LinearLayout { pw.println(" mTextColor: " + Integer.toHexString(mTextColor)); pw.println(" mDarkAmount: " + mDarkAmount); pw.println(" mHasHeader: " + mHasHeader); - pw.println(" mLockScreenMode: " + mLockScreenMode); } @Override @@ -332,7 +296,6 @@ public class KeyguardSliceView extends LinearLayout { public static class Row extends LinearLayout { private Set mKeyguardSliceTextViewSet = new HashSet(); - private int mLockScreenModeRow = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL; /** * This view is visible in AOD, which means that the device will sleep if we @@ -407,11 +370,7 @@ public class KeyguardSliceView extends LinearLayout { for (int i = 0; i < childCount; i++) { View child = getChildAt(i); if (child instanceof KeyguardSliceTextView) { - if (mLockScreenModeRow == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) { - ((KeyguardSliceTextView) child).setMaxWidth(Integer.MAX_VALUE); - } else { - ((KeyguardSliceTextView) child).setMaxWidth(width / 3); - } + ((KeyguardSliceTextView) child).setMaxWidth(Integer.MAX_VALUE); } } @@ -443,7 +402,6 @@ public class KeyguardSliceView extends LinearLayout { super.addView(view, index); if (view instanceof KeyguardSliceTextView) { - ((KeyguardSliceTextView) view).setLockScreenMode(mLockScreenModeRow); mKeyguardSliceTextViewSet.add((KeyguardSliceTextView) view); } } @@ -455,24 +413,6 @@ public class KeyguardSliceView extends LinearLayout { mKeyguardSliceTextViewSet.remove((KeyguardSliceTextView) view); } } - - /** - * Updates the lockscreen mode which may change the layout of this view. - */ - public void setLockscreenMode(int mode) { - mLockScreenModeRow = mode; - if (mLockScreenModeRow == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) { - setOrientation(LinearLayout.VERTICAL); - setGravity(Gravity.START); - } else { - setOrientation(LinearLayout.HORIZONTAL); - setGravity(Gravity.CENTER); - } - - for (KeyguardSliceTextView textView : mKeyguardSliceTextViewSet) { - textView.setLockScreenMode(mLockScreenModeRow); - } - } } /** @@ -480,7 +420,6 @@ public class KeyguardSliceView extends LinearLayout { */ @VisibleForTesting static class KeyguardSliceTextView extends TextView { - private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL; @StyleRes private static int sStyleId = R.style.TextAppearance_Keyguard_Secondary; @@ -509,13 +448,8 @@ public class KeyguardSliceView extends LinearLayout { boolean hasText = !TextUtils.isEmpty(getText()); int padding = (int) getContext().getResources() .getDimension(R.dimen.widget_horizontal_padding) / 2; - if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) { - // orientation is vertical, so add padding to top & bottom - setPadding(0, padding, 0, hasText ? padding : 0); - } else { - // orientation is horizontal, so add padding to left & right - setPadding(padding, 0, padding * (hasText ? 1 : -1), 0); - } + // orientation is vertical, so add padding to top & bottom + setPadding(0, padding, 0, hasText ? padding : 0); setCompoundDrawablePadding((int) mContext.getResources() .getDimension(R.dimen.widget_icon_padding)); @@ -543,18 +477,5 @@ public class KeyguardSliceView extends LinearLayout { } } } - - /** - * Updates the lockscreen mode which may change the layout of this view. - */ - public void setLockScreenMode(int mode) { - mLockScreenMode = mode; - if (mLockScreenMode == KeyguardUpdateMonitor.LOCK_SCREEN_MODE_LAYOUT_1) { - setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); - } else { - setTextAlignment(View.TEXT_ALIGNMENT_CENTER); - } - updatePadding(); - } } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java index 4a56773a96d9e..d05cc4ea81010 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java @@ -73,7 +73,6 @@ public class KeyguardSliceViewController extends ViewController mClickActions; - private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL; TunerService.Tunable mTunable = (key, newValue) -> setupUri(newValue); @@ -137,7 +136,6 @@ public class KeyguardSliceViewController extends ViewController data : mSimDatas.entrySet()) { final SimData state = data.getValue(); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index e970a86c65168..12431984c9b92 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -324,11 +324,6 @@ public class KeyguardUpdateMonitorCallback { */ public void onSecondaryLockscreenRequirementChanged(int userId) { } - /** - * Called to switch lock screen layout/clock layouts - */ - public void onLockScreenModeChanged(int mode) { } - /** * Called when notifying user to unlock in order to use NFC. */ diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java index 1d51e5925de89..b8841eda1de43 100644 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java +++ b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java @@ -34,6 +34,6 @@ public abstract class KeyguardStatusViewModule { @Provides static KeyguardSliceView getKeyguardSliceView(KeyguardClockSwitch keyguardClockSwitch) { - return keyguardClockSwitch.findViewById(R.id.keyguard_status_area); + return keyguardClockSwitch.findViewById(R.id.keyguard_slice_view); } } diff --git a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlags.java b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlags.java index 15072a52f5311..e2cef43a2cf8f 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/FeatureFlags.java +++ b/packages/SystemUI/src/com/android/systemui/flags/FeatureFlags.java @@ -132,10 +132,6 @@ public class FeatureFlags { return mFlagReader.isEnabled(R.bool.flag_notification_pipeline2_rendering); } - public boolean isKeyguardLayoutEnabled() { - return mFlagReader.isEnabled(R.bool.flag_keyguard_layout); - } - /** */ public boolean useNewLockscreenAnimations() { return mFlagReader.isEnabled(R.bool.flag_lockscreen_animations); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 4f932a36504c3..9ba846dc052dd 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -147,7 +147,6 @@ public class KeyguardIndicationController { private boolean mBatteryPresent = true; private long mChargingTimeRemaining; private String mMessageToShowOnScreenOn; - protected int mLockScreenMode; private boolean mInited; private KeyguardUpdateMonitorCallback mUpdateMonitorCallback; @@ -862,11 +861,6 @@ public class KeyguardIndicationController { protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback { public static final int HIDE_DELAY_MS = 5000; - @Override - public void onLockScreenModeChanged(int mode) { - mLockScreenMode = mode; - } - @Override public void onRefreshBatteryInfo(BatteryStatus status) { boolean isChargingOrFull = status.status == BatteryManager.BATTERY_STATUS_CHARGING diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt index bdade2c6c2c99..bacb85ae89df3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt @@ -29,6 +29,7 @@ import android.net.Uri import android.os.Handler import android.os.UserHandle import android.provider.Settings +import android.util.Log import android.view.View import android.view.ViewGroup import com.android.settingslib.Utils @@ -73,6 +74,10 @@ class LockscreenSmartspaceController @Inject constructor( @Main private val handler: Handler, optionalPlugin: Optional ) { + companion object { + private const val TAG = "LockscreenSmartspaceController" + } + private var session: SmartspaceSession? = null private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null) @@ -210,6 +215,7 @@ class LockscreenSmartspaceController @Inject constructor( val newSession = smartspaceManager.createSmartspaceSession( SmartspaceConfig.Builder(context, "lockscreen").build()) + Log.d(TAG, "Starting smartspace session for lockscreen") newSession.addOnTargetsAvailableListener(uiExecutor, sessionListener) this.session = newSession @@ -231,6 +237,8 @@ class LockscreenSmartspaceController @Inject constructor( * Disconnects the smartspace view from the smartspace service and cleans up any resources. */ fun disconnect() { + if (!smartspaceViews.isEmpty()) return + execution.assertIsMainThread() if (session == null) { @@ -248,6 +256,7 @@ class LockscreenSmartspaceController @Inject constructor( session = null plugin?.onTargetsAvailable(emptyList()) + Log.d(TAG, "Ending smartspace session for lockscreen") } fun addListener(listener: SmartspaceTargetListener) { diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java index 5c7885f47c593..fe0a2a4bbb145 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java @@ -19,7 +19,6 @@ 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; @@ -30,6 +29,7 @@ import android.content.res.Resources; import android.testing.AndroidTestingRunner; import android.view.View; import android.widget.FrameLayout; +import android.widget.LinearLayout; import android.widget.RelativeLayout; import androidx.test.filters.SmallTest; @@ -108,7 +108,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { private final View mFakeSmartspaceView = new View(mContext); private KeyguardClockSwitchController mController; - private View mStatusArea; + private View mSliceView; @Before public void setup() { @@ -149,8 +149,10 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); when(mColorExtractor.getColors(anyInt())).thenReturn(mGradientColors); - mStatusArea = new View(getContext()); - when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea); + mSliceView = new View(getContext()); + when(mView.findViewById(R.id.keyguard_slice_view)).thenReturn(mSliceView); + when(mView.findViewById(R.id.keyguard_status_area)).thenReturn( + new LinearLayout(getContext())); } @Test @@ -215,7 +217,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView); mController.init(); - assertEquals(View.GONE, mStatusArea.getVisibility()); + assertEquals(View.GONE, mSliceView.getVisibility()); } @Test @@ -223,22 +225,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { when(mSmartspaceController.isEnabled()).thenReturn(false); mController.init(); - assertEquals(View.VISIBLE, mStatusArea.getVisibility()); - } - - @Test - public void testDetachDisconnectsSmartspace() { - when(mSmartspaceController.isEnabled()).thenReturn(true); - when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView); - mController.init(); - verify(mView).addView(eq(mFakeSmartspaceView), anyInt(), any()); - - ArgumentCaptor listenerArgumentCaptor = - ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class); - verify(mView).addOnAttachStateChangeListener(listenerArgumentCaptor.capture()); - - listenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView); - verify(mSmartspaceController).disconnect(); + assertEquals(View.VISIBLE, mSliceView.getVisibility()); } @Test diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java index 1ab08c27088ac..77302ce30f090 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSliceViewTest.java @@ -54,7 +54,7 @@ public class KeyguardSliceViewTest extends SysuiTestCase { MockitoAnnotations.initMocks(this); LayoutInflater layoutInflater = LayoutInflater.from(getContext()); mKeyguardSliceView = (KeyguardSliceView) layoutInflater - .inflate(R.layout.keyguard_status_area, null); + .inflate(R.layout.keyguard_slice_view, null); mSliceUri = Uri.parse(KeyguardSliceProvider.KEYGUARD_SLICE_URI); SliceProvider.setSpecs(new HashSet<>(Collections.singletonList(SliceSpecs.LIST))); } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java index b95a33b2b806f..3edfd03dfc704 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java @@ -239,8 +239,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase { when(mRingerModeTracker.getRingerMode()).thenReturn(mRingerModeLiveData); - when(mFeatureFlags.isKeyguardLayoutEnabled()).thenReturn(false); - mMockitoSession = ExtendedMockito.mockitoSession() .spyStatic(SubscriptionManager.class).startMocking(); ExtendedMockito.doReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt index ee9c2b82c2838..ff91978c54bbc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt @@ -246,6 +246,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { clearInvocations(plugin) // WHEN the session is closed + controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View) controller.disconnect() // THEN the listener receives an empty list of targets @@ -417,6 +418,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { connectSession() // WHEN we are told to cleanup + controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View) controller.disconnect() // THEN we disconnect from the session and unregister any listeners