diff --git a/packages/SystemUI/res/values/ids.xml b/packages/SystemUI/res/values/ids.xml index 15ca9d48c62a5..d2cb475ad2b01 100644 --- a/packages/SystemUI/res/values/ids.xml +++ b/packages/SystemUI/res/values/ids.xml @@ -212,6 +212,7 @@ + diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index 4d196aa5466d3..a9531cffd6310 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -243,24 +243,8 @@ public class KeyguardClockSwitchController extends ViewController= 0) { - mStatusArea.removeView(mDateWeatherView); - addDateWeatherView(index); - } + addDateWeatherView(); setDateWeatherVisibility(); setWeatherVisibility(); } - int index = mStatusArea.indexOfChild(mSmartspaceView); - if (index >= 0) { - mStatusArea.removeView(mSmartspaceView); - addSmartspaceView(index); - } } } - private void addDateWeatherView(int index) { + private void addDateWeatherView() { mDateWeatherView = (ViewGroup) mSmartspaceController.buildAndConnectDateView(mView); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( MATCH_PARENT, WRAP_CONTENT); - mStatusArea.addView(mDateWeatherView, index, lp); + mStatusArea.addView(mDateWeatherView, 0, lp); int startPadding = getContext().getResources().getDimensionPixelSize( R.dimen.below_clock_padding_start); int endPadding = getContext().getResources().getDimensionPixelSize( @@ -343,11 +334,11 @@ public class KeyguardClockSwitchController extends ViewController(R.id.keyguard_status_view)?.let { + legacyParent.removeView(it) + } + + val keyguardStatusView = keyguardRootView.addStatusView() + val statusViewComponent = keyguardStatusViewComponentFactory.build(keyguardStatusView) + val controller = statusViewComponent.getKeyguardStatusViewController() + controller.init() + keyguardStatusViewController = controller + } else { + keyguardRootView.findViewById(R.id.keyguard_status_view)?.let { + keyguardRootView.removeView(it) + } + } + } + + /** + * Temporary, to allow NotificationPanelViewController to use the same instance while code is + * migrated: b/288242803 + */ + fun getKeyguardStatusViewController() = keyguardStatusViewController + fun getKeyguardRootView() = keyguardRootView } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt index f1b3441995168..e35c3699aabf9 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt @@ -199,13 +199,16 @@ interface KeyguardRepository { fun setAnimateDozingTransitions(animate: Boolean) /** Sets the current amount of alpha that should be used for rendering the bottom area. */ - @Deprecated("Deprecated as part of b/278057014") - fun setBottomAreaAlpha(alpha: Float) + @Deprecated("Deprecated as part of b/278057014") fun setBottomAreaAlpha(alpha: Float) /** Sets the current amount of alpha that should be used for rendering the keyguard. */ fun setKeyguardAlpha(alpha: Float) - fun setKeyguardVisibility(statusBarState: Int, goingToFullShade: Boolean, occlusionTransitionRunning: Boolean) + fun setKeyguardVisibility( + statusBarState: Int, + goingToFullShade: Boolean, + occlusionTransitionRunning: Boolean + ) /** * Sets the relative offset of the lock-screen clock from its natural position on the screen. diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/KeyguardRootView.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/KeyguardRootView.kt index e60901f922c32..a94874176a346 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/KeyguardRootView.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/KeyguardRootView.kt @@ -24,6 +24,7 @@ import android.view.View import android.widget.ImageView import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.content.res.ResourcesCompat +import com.android.keyguard.KeyguardStatusView import com.android.keyguard.LockIconView import com.android.systemui.R import com.android.systemui.animation.view.LaunchableImageView @@ -38,6 +39,8 @@ class KeyguardRootView( attrs, ) { + private var statusView: KeyguardStatusView? = null + init { addIndicationTextArea() addLockIconView() @@ -45,6 +48,7 @@ class KeyguardRootView( addLeftShortcut() addRightShortcut() addSettingsPopupMenu() + addStatusView() } private fun addIndicationTextArea() { @@ -119,4 +123,19 @@ class KeyguardRootView( } addView(view) } + + fun addStatusView(): KeyguardStatusView { + // StatusView may need to be rebuilt on config changes. Remove and reinflate + statusView?.let { removeView(it) } + val view = + (LayoutInflater.from(context).inflate(R.layout.keyguard_status_view, this, false) + as KeyguardStatusView) + .apply { + setClipChildren(false) + statusView = this + } + + addView(view) + return view + } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt index 5538fe7e70068..518df0719aaa0 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprint.kt @@ -25,6 +25,8 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultIndicationAr import com.android.systemui.keyguard.ui.view.layout.sections.DefaultLockIconSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultSettingsPopupMenuSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultShortcutsSection +import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection +import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeGuidelines import javax.inject.Inject /** @@ -42,6 +44,8 @@ constructor( private val defaultShortcutsSection: DefaultShortcutsSection, private val defaultAmbientIndicationAreaSection: DefaultAmbientIndicationAreaSection, private val defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection, + private val defaultStatusViewSection: DefaultStatusViewSection, + private val splitShadeGuidelines: SplitShadeGuidelines, ) : KeyguardBlueprint { override val id: String = DEFAULT @@ -51,6 +55,8 @@ constructor( defaultShortcutsSection.apply(constraintSet) defaultAmbientIndicationAreaSection.apply(constraintSet) defaultSettingsPopupMenuSection.apply(constraintSet) + defaultStatusViewSection.apply(constraintSet) + splitShadeGuidelines.apply(constraintSet) } companion object { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/ShortcutsBesideUdfpsKeyguardBlueprint.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/ShortcutsBesideUdfpsKeyguardBlueprint.kt index 19410e4ba89d0..54c27960db3c9 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/ShortcutsBesideUdfpsKeyguardBlueprint.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/ShortcutsBesideUdfpsKeyguardBlueprint.kt @@ -27,6 +27,8 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultIndicationAr import com.android.systemui.keyguard.ui.view.layout.sections.DefaultLockIconSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultSettingsPopupMenuSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultShortcutsSection +import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection +import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeGuidelines import javax.inject.Inject /** Vertically aligns the shortcuts with the udfps. */ @@ -41,6 +43,8 @@ constructor( private val defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection, private val alignShortcutsToUdfpsSection: AlignShortcutsToUdfpsSection, private val defaultShortcutsSection: DefaultShortcutsSection, + private val defaultStatusViewSection: DefaultStatusViewSection, + private val splitShadeGuidelines: SplitShadeGuidelines, ) : KeyguardBlueprint { override val id: String = SHORTCUTS_BESIDE_UDFPS @@ -54,6 +58,8 @@ constructor( } else { defaultShortcutsSection.apply(constraintSet) } + defaultStatusViewSection.apply(constraintSet) + splitShadeGuidelines.apply(constraintSet) } companion object { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt new file mode 100644 index 0000000000000..3f319ba2d0e42 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2023 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.keyguard.ui.view.layout.sections + +import android.content.Context +import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintSet +import com.android.systemui.R +import com.android.systemui.keyguard.data.repository.KeyguardSection +import javax.inject.Inject +import android.view.ViewGroup.LayoutParams.WRAP_CONTENT +import androidx.constraintlayout.widget.ConstraintSet.MATCH_CONSTRAINT +import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID +import androidx.constraintlayout.widget.ConstraintSet.START +import androidx.constraintlayout.widget.ConstraintSet.TOP +import androidx.constraintlayout.widget.ConstraintSet.END + +class DefaultStatusViewSection @Inject constructor(private val context: Context) : + KeyguardSection { + private val statusViewId = R.id.keyguard_status_view + + override fun apply(constraintSet: ConstraintSet) { + constraintSet.apply { + constrainWidth(statusViewId, MATCH_CONSTRAINT) + constrainHeight(statusViewId, WRAP_CONTENT) + connect(statusViewId, TOP, PARENT_ID, TOP) + connect(statusViewId, START, PARENT_ID, START) + connect(statusViewId, END, PARENT_ID, END) + } + } +} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeGuidelines.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeGuidelines.kt new file mode 100644 index 0000000000000..668b17ffeba06 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeGuidelines.kt @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2023 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.keyguard.ui.view.layout.sections + +import android.content.Context +import android.view.ViewGroup +import androidx.constraintlayout.widget.ConstraintSet +import com.android.systemui.R +import com.android.systemui.keyguard.data.repository.KeyguardSection +import javax.inject.Inject +import android.view.ViewGroup.LayoutParams.WRAP_CONTENT +import androidx.constraintlayout.widget.ConstraintSet.MATCH_CONSTRAINT +import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID +import androidx.constraintlayout.widget.ConstraintSet.START +import androidx.constraintlayout.widget.ConstraintSet.TOP +import androidx.constraintlayout.widget.ConstraintSet.END +import androidx.constraintlayout.widget.ConstraintSet.VERTICAL + +class SplitShadeGuidelines @Inject constructor(private val context: Context) : + KeyguardSection { + + override fun apply(constraintSet: ConstraintSet) { + constraintSet.apply { + // For use on large screens, it will provide a guideline vertically in the center to + // enable items to be aligned on the left or right sides + create(R.id.split_shade_guideline, VERTICAL) + setGuidelinePercent(R.id.split_shade_guideline, 0.5f) + } + } +} diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 416f147b74296..35fd98cf34c69 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -90,6 +90,8 @@ import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.Interpolator; import android.widget.FrameLayout; +import androidx.constraintlayout.widget.ConstraintLayout; + import com.android.app.animation.Interpolators; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.MetricsLogger; @@ -1053,10 +1055,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mKeyguardStatusBarViewController.init(); mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent); - updateViewControllers( - mView.findViewById(R.id.keyguard_status_view), - userAvatarContainer, - keyguardUserSwitcherView); + updateViewControllers(userAvatarContainer, keyguardUserSwitcherView); mNotificationStackScrollLayoutController.setOnHeightChangedListener( new NsslHeightChangedListener()); @@ -1218,18 +1217,31 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mQsController.loadDimens(); } - private void updateViewControllers(KeyguardStatusView keyguardStatusView, + private void updateViewControllers( FrameLayout userAvatarView, KeyguardUserSwitcherView keyguardUserSwitcherView) { + // Re-associate the KeyguardStatusViewController if (mKeyguardStatusViewController != null) { mKeyguardStatusViewController.onDestroy(); } - // Re-associate the KeyguardStatusViewController - KeyguardStatusViewComponent statusViewComponent = + + if (mFeatureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_VIEW)) { + // Need a shared controller until mKeyguardStatusViewController can be removed from + // here, due to important state being set in that controller. Rebind in order to pick + // up config changes + mKeyguardViewConfigurator.bindKeyguardStatusView(mView); + mKeyguardStatusViewController = + mKeyguardViewConfigurator.getKeyguardStatusViewController(); + } else { + KeyguardStatusView keyguardStatusView = mView.getRootView().findViewById( + R.id.keyguard_status_view); + KeyguardStatusViewComponent statusViewComponent = mKeyguardStatusViewComponentFactory.build(keyguardStatusView); - mKeyguardStatusViewController = statusViewComponent.getKeyguardStatusViewController(); - mKeyguardStatusViewController.init(); + mKeyguardStatusViewController = statusViewComponent.getKeyguardStatusViewController(); + mKeyguardStatusViewController.init(); + } mKeyguardStatusViewController.setSplitShadeEnabled(mSplitShadeEnabled); + updateClockAppearance(); if (mKeyguardUserSwitcherController != null) { @@ -1335,15 +1347,22 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump void reInflateViews() { debugLog("reInflateViews"); // Re-inflate the status view group. - KeyguardStatusView keyguardStatusView = - mNotificationContainerParent.findViewById(R.id.keyguard_status_view); - int statusIndex = mNotificationContainerParent.indexOfChild(keyguardStatusView); - mNotificationContainerParent.removeView(keyguardStatusView); - keyguardStatusView = (KeyguardStatusView) mLayoutInflater.inflate( - R.layout.keyguard_status_view, mNotificationContainerParent, false); - mNotificationContainerParent.addView(keyguardStatusView, statusIndex); - attachSplitShadeMediaPlayerContainer( - keyguardStatusView.findViewById(R.id.status_view_media_container)); + if (!mFeatureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_VIEW)) { + KeyguardStatusView keyguardStatusView = + mNotificationContainerParent.findViewById(R.id.keyguard_status_view); + int statusIndex = mNotificationContainerParent.indexOfChild(keyguardStatusView); + mNotificationContainerParent.removeView(keyguardStatusView); + keyguardStatusView = (KeyguardStatusView) mLayoutInflater.inflate( + R.layout.keyguard_status_view, mNotificationContainerParent, false); + mNotificationContainerParent.addView(keyguardStatusView, statusIndex); + + attachSplitShadeMediaPlayerContainer( + keyguardStatusView.findViewById(R.id.status_view_media_container)); + } else { + attachSplitShadeMediaPlayerContainer( + mKeyguardViewConfigurator.getKeyguardRootView() + .findViewById(R.id.status_view_media_container)); + } // we need to update KeyguardStatusView constraints after reinflating it updateResources(); @@ -1369,8 +1388,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump R.layout.keyguard_user_switcher /* layoutId */, showKeyguardUserSwitcher /* enabled */); - updateViewControllers(mView.findViewById(R.id.keyguard_status_view), userAvatarView, - keyguardUserSwitcherView); + updateViewControllers(userAvatarView, keyguardUserSwitcherView); if (!mFeatureFlags.isEnabled(Flags.MIGRATE_SPLIT_KEYGUARD_BOTTOM_AREA)) { // Update keyguard bottom area @@ -1666,8 +1684,14 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private void updateKeyguardStatusViewAlignment(boolean animate) { boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered(); + ConstraintLayout layout; + if (mFeatureFlags.isEnabled(Flags.MIGRATE_KEYGUARD_STATUS_VIEW)) { + layout = mKeyguardViewConfigurator.getKeyguardRootView(); + } else { + layout = mNotificationContainerParent; + } mKeyguardStatusViewController.updateAlignment( - mNotificationContainerParent, mSplitShadeEnabled, shouldBeCentered, animate); + layout, mSplitShadeEnabled, shouldBeCentered, animate); mKeyguardUnfoldTransition.ifPresent(t -> t.setStatusViewCentered(shouldBeCentered)); } @@ -3390,7 +3414,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump ipw.print("mPanelFlingOvershootAmount="); ipw.println(mPanelFlingOvershootAmount); ipw.print("mLastGesturedOverExpansion="); ipw.println(mLastGesturedOverExpansion); ipw.print("mIsSpringBackAnimation="); ipw.println(mIsSpringBackAnimation); - ipw.print("mSplitShadeEnabled="); ipw.println(mSplitShadeEnabled); ipw.print("mHintDistance="); ipw.println(mHintDistance); ipw.print("mInitialOffsetOnTouch="); ipw.println(mInitialOffsetOnTouch); ipw.print("mCollapsedAndHeadsUpOnDown="); ipw.println(mCollapsedAndHeadsUpOnDown); @@ -3423,7 +3446,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump ipw.print("mGestureWaitForTouchSlop="); ipw.println(mGestureWaitForTouchSlop); ipw.print("mIgnoreXTouchSlop="); ipw.println(mIgnoreXTouchSlop); ipw.print("mExpandLatencyTracking="); ipw.println(mExpandLatencyTracking); - ipw.print("mExpandLatencyTracking="); ipw.println(mExpandLatencyTracking); ipw.println("gestureExclusionRect:" + calculateGestureExclusionRect()); new DumpsysTableLogger( TAG, 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 11b1053f35b3d..903d485369466 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt @@ -445,6 +445,12 @@ constructor( session?.requestSmartspaceUpdate() } + fun removeViewsFromParent(viewGroup: ViewGroup) { + smartspaceViews.toList().forEach { + viewGroup.removeView(it as View) + } + } + /** * Disconnects the smartspace view from the smartspace service and cleans up any resources. */ diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java index ac04bc4356ac1..98d4d22d59b4b 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java @@ -23,6 +23,7 @@ import static com.android.systemui.flags.Flags.LOCKSCREEN_WALLPAPER_DREAM_ENABLE import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -157,6 +158,12 @@ public class KeyguardClockSwitchControllerBaseTest extends SysuiTestCase { when(mSmartspaceController.buildAndConnectDateView(any())).thenReturn(mFakeDateView); when(mSmartspaceController.buildAndConnectWeatherView(any())).thenReturn(mFakeWeatherView); when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView); + doAnswer(invocation -> { + removeView(mFakeDateView); + removeView(mFakeWeatherView); + removeView(mFakeSmartspaceView); + return null; + }).when(mSmartspaceController).removeViewsFromParent(any()); mExecutor = new FakeExecutor(new FakeSystemClock()); mFakeFeatureFlags = new FakeFeatureFlags(); mFakeFeatureFlags.set(FACE_AUTH_REFACTOR, false); @@ -201,6 +208,13 @@ public class KeyguardClockSwitchControllerBaseTest extends SysuiTestCase { when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea); } + private void removeView(View v) { + ViewGroup group = ((ViewGroup) v.getParent()); + if (group != null) { + group.removeView(v); + } + } + protected void init() { mController.init(); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java index 20d9ef1e86b19..7d23c800321a1 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java @@ -16,6 +16,7 @@ package com.android.keyguard; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -119,8 +120,8 @@ public class KeyguardStatusViewControllerTest extends KeyguardStatusViewControll @Test public void correctlyDump() { mController.onInit(); - verify(mDumpManager).registerDumpable(mController); + verify(mDumpManager).registerDumpable(eq(mController.getInstanceName()), eq(mController)); mController.onDestroy(); - verify(mDumpManager, times(1)).unregisterDumpable(KeyguardStatusViewController.TAG); + verify(mDumpManager, times(1)).unregisterDumpable(eq(mController.getInstanceName())); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt index 66631dc9977ba..addb1815ceadb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt @@ -17,6 +17,8 @@ package com.android.systemui.keyguard.ui.view.layout.blueprints +import android.testing.AndroidTestingRunner +import android.testing.TestableLooper.RunWithLooper import androidx.constraintlayout.widget.ConstraintSet import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase @@ -26,15 +28,17 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultIndicationAr import com.android.systemui.keyguard.ui.view.layout.sections.DefaultLockIconSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultSettingsPopupMenuSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultShortcutsSection +import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection +import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeGuidelines import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import org.junit.runners.JUnit4 import org.mockito.Mock import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations -@RunWith(JUnit4::class) +@RunWith(AndroidTestingRunner::class) +@RunWithLooper(setAsMainLooper = true) @SmallTest class DefaultKeyguardBlueprintTest : SysuiTestCase() { private lateinit var underTest: DefaultKeyguardBlueprint @@ -45,6 +49,8 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() { @Mock private lateinit var defaultAmbientIndicationAreaSection: DefaultAmbientIndicationAreaSection @Mock private lateinit var defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection + @Mock private lateinit var defaultStatusViewSection: DefaultStatusViewSection + @Mock private lateinit var splitShadeGuidelines: SplitShadeGuidelines @Before fun setup() { @@ -57,6 +63,8 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() { defaultShortcutsSection, defaultAmbientIndicationAreaSection, defaultSettingsPopupMenuSection, + defaultStatusViewSection, + splitShadeGuidelines, ) } @@ -69,5 +77,7 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() { verify(defaultShortcutsSection).apply(cs) verify(defaultAmbientIndicationAreaSection).apply(cs) verify(defaultSettingsPopupMenuSection).apply(cs) + verify(defaultStatusViewSection).apply(cs) + verify(splitShadeGuidelines).apply(cs) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultLockIconSectionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultLockIconSectionTest.kt index 1444f8df4e4cf..379c03c4353db 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultLockIconSectionTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultLockIconSectionTest.kt @@ -25,6 +25,7 @@ import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.AuthController +import com.android.systemui.keyguard.ui.view.KeyguardRootView import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index c3540cfec72db..981e44bea846c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -424,6 +424,10 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { when(mView.findViewById(R.id.qs_frame)).thenReturn(mQsFrame); when(mView.findViewById(R.id.keyguard_status_view)) .thenReturn(mock(KeyguardStatusView.class)); + View rootView = mock(View.class); + when(mView.getRootView()).thenReturn(rootView); + when(rootView.findViewById(R.id.keyguard_status_view)) + .thenReturn(mock(KeyguardStatusView.class)); mNotificationContainerParent = new NotificationsQuickSettingsContainer(getContext(), null); mNotificationContainerParent.addView(keyguardStatusView); mNotificationContainerParent.onFinishInflate(); diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt index 15ce055bcc63e..faebcaac1be31 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt @@ -146,7 +146,6 @@ class FakeKeyguardRepository : KeyguardRepository { _animateBottomAreaDozingTransitions.tryEmit(animate) } - @Deprecated("Deprecated as part of b/278057014") override fun setBottomAreaAlpha(alpha: Float) { _bottomAreaAlpha.value = alpha @@ -257,8 +256,11 @@ class FakeKeyguardRepository : KeyguardRepository { goingToFullShade: Boolean, occlusionTransitionRunning: Boolean ) { - _keyguardRootViewVisibility.value = KeyguardRootViewVisibilityState( - statusBarState, goingToFullShade, occlusionTransitionRunning - ) + _keyguardRootViewVisibility.value = + KeyguardRootViewVisibilityState( + statusBarState, + goingToFullShade, + occlusionTransitionRunning + ) } }