diff options
15 files changed, 158 insertions, 23 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java index 781a9a85edb3..7e5205b56d57 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/DozeServiceHostTest.java @@ -36,7 +36,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.keyguard.LockIconViewController; import com.android.systemui.SysuiTestCase; import com.android.systemui.assist.AssistManager; import com.android.systemui.biometrics.AuthController; @@ -93,7 +92,6 @@ public class DozeServiceHostTest extends SysuiTestCase { @Mock private NotificationShadeWindowViewController mNotificationShadeWindowViewController; @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @Mock private ShadeLockscreenInteractor mShadeLockscreenInteractor; - @Mock private LockIconViewController mLockIconViewController; @Mock private View mAmbientIndicationContainer; @Mock private BiometricUnlockController mBiometricUnlockController; @Mock private AuthController mAuthController; diff --git a/packages/SystemUI/src/com/android/keyguard/EmptyLockIconViewController.kt b/packages/SystemUI/src/com/android/keyguard/EmptyLockIconViewController.kt new file mode 100644 index 000000000000..b792db354b36 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/EmptyLockIconViewController.kt @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.keyguard + +import android.view.MotionEvent +import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.keyguard.ui.view.KeyguardRootView +import com.android.systemui.res.R +import dagger.Lazy +import javax.inject.Inject + +/** + * Lock icon view logic now lives in DeviceEntryIconViewBinder and ViewModels. Icon is positioned in + * [com.android.systemui.keyguard.ui.view.layout.sections.DefaultDeviceEntrySection]. + * + * This class is to bridge the gap between the logic when the DeviceEntryUdfpsRefactor is enabled + * and the KeyguardBottomAreaRefactor is NOT enabled. This class can and should be removed when both + * flags are enabled. + */ +@SysUISingleton +class EmptyLockIconViewController +@Inject +constructor( + private val keyguardRootView: Lazy<KeyguardRootView>, +) : LockIconViewController { + private val deviceEntryIconViewId = R.id.device_entry_icon_view + override fun setLockIconView(lockIconView: LockIconView) { + // no-op + } + + override fun getTop(): Float { + return keyguardRootView.get().getViewById(deviceEntryIconViewId)?.top?.toFloat() ?: 0f + } + + override fun getBottom(): Float { + return keyguardRootView.get().getViewById(deviceEntryIconViewId)?.bottom?.toFloat() ?: 0f + } + + override fun dozeTimeTick() { + // no-op + } + + override fun setAlpha(alpha: Float) { + // no-op + } + + override fun willHandleTouchWhileDozing(event: MotionEvent): Boolean { + return false + } +} diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LegacyLockIconViewController.java index 985f6c8bc59f..4e5df3543451 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LegacyLockIconViewController.java @@ -98,7 +98,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi; * icon will show a set distance from the bottom of the device. */ @SysUISingleton -public class LockIconViewController implements Dumpable { +public class LegacyLockIconViewController implements Dumpable, LockIconViewController { private static final String TAG = "LockIconViewController"; private static final float sDefaultDensity = (float) DisplayMetrics.DENSITY_DEVICE_STABLE / (float) DisplayMetrics.DENSITY_DEFAULT; @@ -189,7 +189,7 @@ public class LockIconViewController implements Dumpable { }; @Inject - public LockIconViewController( + public LegacyLockIconViewController( @NonNull StatusBarStateController statusBarStateController, @NonNull KeyguardUpdateMonitor keyguardUpdateMonitor, @NonNull KeyguardViewController keyguardViewController, @@ -262,6 +262,7 @@ public class LockIconViewController implements Dumpable { /** Sets the LockIconView to the controller and rebinds any that depend on it. */ @SuppressLint("ClickableViewAccessibility") + @Override public void setLockIconView(LockIconView lockIconView) { mView = lockIconView; mView.setAccessibilityDelegate(mAccessibilityDelegate); @@ -344,10 +345,12 @@ public class LockIconViewController implements Dumpable { } } + @Override public float getTop() { return mView.getLocationTop(); } + @Override public float getBottom() { return mView.getLocationBottom(); } @@ -499,6 +502,7 @@ public class LockIconViewController implements Dumpable { } /** Every minute, update the aod icon's burn in offset */ + @Override public void dozeTimeTick() { updateBurnInOffsets(); } @@ -774,6 +778,7 @@ public class LockIconViewController implements Dumpable { /** * Set the alpha of this view. */ + @Override public void setAlpha(float alpha) { mView.setAlpha(alpha); } @@ -823,6 +828,7 @@ public class LockIconViewController implements Dumpable { /** * Whether the lock icon will handle a touch while dozing. */ + @Override public boolean willHandleTouchWhileDozing(MotionEvent event) { // is in lock icon area mView.getHitRect(mSensorTouchLocation); diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.kt b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.kt new file mode 100644 index 000000000000..10d5a0cc3dd5 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.kt @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.keyguard + +import android.view.MotionEvent + +/** Controls the [LockIconView]. */ +interface LockIconViewController { + fun setLockIconView(lockIconView: LockIconView) + fun getTop(): Float + fun getBottom(): Float + fun dozeTimeTick() + fun setAlpha(alpha: Float) + fun willHandleTouchWhileDozing(event: MotionEvent): Boolean +} diff --git a/packages/SystemUI/src/com/android/systemui/deviceentry/DeviceEntryModule.kt b/packages/SystemUI/src/com/android/systemui/deviceentry/DeviceEntryModule.kt index 71b5ab2d61ed..b8c03c071572 100644 --- a/packages/SystemUI/src/com/android/systemui/deviceentry/DeviceEntryModule.kt +++ b/packages/SystemUI/src/com/android/systemui/deviceentry/DeviceEntryModule.kt @@ -1,9 +1,32 @@ +/* + * Copyright (C) 2024 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.deviceentry +import com.android.keyguard.EmptyLockIconViewController +import com.android.keyguard.LegacyLockIconViewController +import com.android.keyguard.LockIconViewController +import com.android.systemui.dagger.SysUISingleton import com.android.systemui.deviceentry.data.repository.DeviceEntryRepositoryModule import com.android.systemui.deviceentry.data.repository.FaceWakeUpTriggersConfigModule +import com.android.systemui.deviceentry.shared.DeviceEntryUdfpsRefactor import com.android.systemui.keyguard.ui.transitions.DeviceEntryIconTransition +import dagger.Lazy import dagger.Module +import dagger.Provides import dagger.multibindings.Multibinds @Module( @@ -18,4 +41,19 @@ abstract class DeviceEntryModule { * A set of DeviceEntryIconTransitions. Ensures that this can be injected even if it's empty. */ @Multibinds abstract fun deviceEntryIconTransitionSet(): Set<DeviceEntryIconTransition> + + companion object { + @Provides + @SysUISingleton + fun provideLockIconViewController( + legacyLockIconViewController: Lazy<LegacyLockIconViewController>, + emptyLockIconViewController: Lazy<EmptyLockIconViewController>, + ): LockIconViewController { + return if (DeviceEntryUdfpsRefactor.isEnabled) { + emptyLockIconViewController.get() + } else { + legacyLockIconViewController.get() + } + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt index fa845c7cf784..560fe32e954e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt @@ -32,8 +32,8 @@ import androidx.constraintlayout.widget.ConstraintSet.TOP import com.android.internal.jank.InteractionJankMonitor import com.android.keyguard.KeyguardStatusView import com.android.keyguard.KeyguardStatusViewController +import com.android.keyguard.LegacyLockIconViewController import com.android.keyguard.LockIconView -import com.android.keyguard.LockIconViewController import com.android.keyguard.dagger.KeyguardStatusViewComponent import com.android.systemui.CoreStartable import com.android.systemui.common.ui.ConfigurationState @@ -92,7 +92,7 @@ constructor( private val configuration: ConfigurationState, private val context: Context, private val keyguardIndicationController: KeyguardIndicationController, - private val lockIconViewController: Lazy<LockIconViewController>, + private val lockIconViewController: Lazy<LegacyLockIconViewController>, private val shadeInteractor: ShadeInteractor, private val interactionJankMonitor: InteractionJankMonitor, private val deviceEntryHapticsInteractor: DeviceEntryHapticsInteractor, diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index e4f5aeb5028c..2f89b459303d 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -96,12 +96,12 @@ import com.android.internal.policy.SystemBarUtils; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.util.LatencyTracker; import com.android.keyguard.ActiveUnlockConfig; +import com.android.keyguard.LockIconViewController; import com.android.keyguard.KeyguardClockSwitch.ClockSize; import com.android.keyguard.KeyguardStatusView; import com.android.keyguard.KeyguardStatusViewController; import com.android.keyguard.KeyguardUnfoldTransition; import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.keyguard.LockIconViewController; import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent; import com.android.keyguard.dagger.KeyguardStatusBarViewComponent; import com.android.keyguard.dagger.KeyguardStatusViewComponent; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt index 82b10bc11cc1..eadb7f5a1684 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.kt @@ -23,12 +23,12 @@ import android.view.ViewGroup import android.widget.FrameLayout import androidx.annotation.StringRes import com.android.keyguard.LockIconViewController -import com.android.systemui.res.R import com.android.systemui.keyguard.ui.binder.KeyguardBottomAreaViewBinder import com.android.systemui.keyguard.ui.binder.KeyguardBottomAreaViewBinder.bind import com.android.systemui.keyguard.ui.viewmodel.KeyguardBottomAreaViewModel import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.FalsingManager +import com.android.systemui.res.R import com.android.systemui.statusbar.VibratorHelper /** @@ -155,13 +155,13 @@ constructor( // make top of ambient indication view the bottom of the lock icon it.layout( ambientLeft, - lockIconViewController?.bottom?.toInt() ?: 0, + lockIconViewController?.getBottom()?.toInt() ?: 0, right - ambientLeft, ambientTop + it.measuredHeight ) } else { // make bottom of ambient indication view the top of the lock icon - val lockLocationTop = lockIconViewController?.top ?: 0 + val lockLocationTop = lockIconViewController?.getTop() ?: 0 it.layout( ambientLeft, lockLocationTop.toInt() - it.measuredHeight, diff --git a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/keyguard/LegacyLockIconViewControllerBaseTest.java index 1c773512e590..f924ab4a4617 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/LegacyLockIconViewControllerBaseTest.java @@ -68,7 +68,7 @@ import org.mockito.MockitoAnnotations; import org.mockito.MockitoSession; import org.mockito.quality.Strictness; -public class LockIconViewControllerBaseTest extends SysuiTestCase { +public class LegacyLockIconViewControllerBaseTest extends SysuiTestCase { protected static final String UNLOCKED_LABEL = "unlocked"; protected static final String LOCKED_LABEL = "locked"; protected static final int PADDING = 10; @@ -98,7 +98,7 @@ public class LockIconViewControllerBaseTest extends SysuiTestCase { protected @Mock PrimaryBouncerInteractor mPrimaryBouncerInteractor; - protected LockIconViewController mUnderTest; + protected LegacyLockIconViewController mUnderTest; // Capture listeners so that they can be used to send events @Captor protected ArgumentCaptor<View.OnAttachStateChangeListener> mAttachCaptor = @@ -153,7 +153,7 @@ public class LockIconViewControllerBaseTest extends SysuiTestCase { mFeatureFlags.set(LOCKSCREEN_WALLPAPER_DREAM_ENABLED, false); mFeatureFlags.set(LOCKSCREEN_ENABLE_LANDSCAPE, false); - mUnderTest = new LockIconViewController( + mUnderTest = new LegacyLockIconViewController( mStatusBarStateController, mKeyguardUpdateMonitor, mKeyguardViewController, diff --git a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/LegacyLockIconViewControllerTest.java index b0887efed4d7..868984233816 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/LegacyLockIconViewControllerTest.java @@ -51,7 +51,7 @@ import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper -public class LockIconViewControllerTest extends LockIconViewControllerBaseTest { +public class LegacyLockIconViewControllerTest extends LegacyLockIconViewControllerBaseTest { @Override public void setUp() throws Exception { diff --git a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerWithCoroutinesTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/LegacyLockIconViewControllerWithCoroutinesTest.kt index 12135182ac15..25a87b8aaf60 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerWithCoroutinesTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/LegacyLockIconViewControllerWithCoroutinesTest.kt @@ -39,7 +39,7 @@ import org.mockito.Mockito.verify @RunWith(AndroidTestingRunner::class) @SmallTest -class LockIconViewControllerWithCoroutinesTest : LockIconViewControllerBaseTest() { +class LegacyLockIconViewControllerWithCoroutinesTest : LegacyLockIconViewControllerBaseTest() { /** After migration, replaces LockIconViewControllerTest version */ @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySectionTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySectionTest.kt index 58273d6805b9..4f2b690f9fcd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySectionTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultDeviceEntrySectionTest.kt @@ -22,7 +22,7 @@ import android.view.WindowManager import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.test.filters.SmallTest -import com.android.keyguard.LockIconViewController +import com.android.keyguard.LegacyLockIconViewController import com.android.systemui.Flags as AConfigFlags import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.AuthController @@ -58,7 +58,7 @@ class DefaultDeviceEntrySectionTest : SysuiTestCase() { @Mock(answer = Answers.RETURNS_DEEP_STUBS) private lateinit var windowManager: WindowManager @Mock private lateinit var notificationPanelView: NotificationPanelView private lateinit var featureFlags: FakeFeatureFlags - @Mock private lateinit var lockIconViewController: LockIconViewController + @Mock private lateinit var lockIconViewController: LegacyLockIconViewController @Mock private lateinit var falsingManager: FalsingManager @Mock private lateinit var deviceEntryIconViewModel: DeviceEntryIconViewModel private lateinit var underTest: DefaultDeviceEntrySection 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 e957ca2eca3a..3cc42117c9cc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -73,7 +73,7 @@ import com.android.keyguard.KeyguardSliceViewController; import com.android.keyguard.KeyguardStatusView; import com.android.keyguard.KeyguardStatusViewController; import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.keyguard.LockIconViewController; +import com.android.keyguard.LegacyLockIconViewController; import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent; import com.android.keyguard.dagger.KeyguardStatusBarViewComponent; import com.android.keyguard.dagger.KeyguardStatusViewComponent; @@ -278,7 +278,7 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected AmbientState mAmbientState; @Mock protected UserManager mUserManager; @Mock protected UiEventLogger mUiEventLogger; - @Mock protected LockIconViewController mLockIconViewController; + @Mock protected LegacyLockIconViewController mLockIconViewController; @Mock protected KeyguardViewConfigurator mKeyguardViewConfigurator; @Mock protected KeyguardRootView mKeyguardRootView; @Mock protected View mKeyguardRootViewChild; diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt index b6996131ea09..03d28d1f788d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt @@ -25,7 +25,7 @@ import android.view.View import android.view.ViewGroup import androidx.test.filters.SmallTest import com.android.keyguard.KeyguardSecurityContainerController -import com.android.keyguard.LockIconViewController +import com.android.keyguard.LegacyLockIconViewController import com.android.keyguard.dagger.KeyguardBouncerComponent import com.android.systemui.Flags import com.android.systemui.SysuiTestCase @@ -113,7 +113,7 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { @Mock private lateinit var quickSettingsController: QuickSettingsControllerImpl @Mock private lateinit var lockscreenShadeTransitionController: LockscreenShadeTransitionController - @Mock private lateinit var lockIconViewController: LockIconViewController + @Mock private lateinit var lockIconViewController: LegacyLockIconViewController @Mock private lateinit var phoneStatusBarViewController: PhoneStatusBarViewController @Mock private lateinit var pulsingGestureListener: PulsingGestureListener @Mock diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt index 2ecca2e5c4ca..5272fb12b5af 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt @@ -22,7 +22,7 @@ import android.view.MotionEvent import android.widget.FrameLayout import androidx.test.filters.SmallTest import com.android.keyguard.KeyguardSecurityContainerController -import com.android.keyguard.LockIconViewController +import com.android.keyguard.LegacyLockIconViewController import com.android.keyguard.dagger.KeyguardBouncerComponent import com.android.systemui.Flags as AConfigFlags import com.android.systemui.SysuiTestCase @@ -101,7 +101,7 @@ class NotificationShadeWindowViewTest : SysuiTestCase() { @Mock private lateinit var statusBarWindowStateController: StatusBarWindowStateController @Mock private lateinit var lockscreenShadeTransitionController: LockscreenShadeTransitionController - @Mock private lateinit var lockIconViewController: LockIconViewController + @Mock private lateinit var lockIconViewController: LegacyLockIconViewController @Mock private lateinit var keyguardUnlockAnimationController: KeyguardUnlockAnimationController @Mock private lateinit var ambientState: AmbientState @Mock private lateinit var shadeLogger: ShadeLogger |