diff options
74 files changed, 196 insertions, 6403 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java deleted file mode 100644 index b937db6bd76d..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - */ - -package com.android.keyguard; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import android.text.TextUtils; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; -import android.widget.TextView; - -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.filters.SmallTest; - -import com.android.systemui.SysuiTestCase; -import com.android.systemui.res.R; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.util.List; - -@SmallTest -@RunWith(AndroidJUnit4.class) -public class KeyguardClockAccessibilityDelegateTest extends SysuiTestCase { - - private TextView mView; - private String m12HoursFormat; - private String m24HoursFormat; - - @Before - public void setUp() throws Exception { - m12HoursFormat = mContext.getString(R.string.keyguard_widget_12_hours_format); - m24HoursFormat = mContext.getString(R.string.keyguard_widget_24_hours_format); - - mView = new TextView(mContext); - mView.setText(m12HoursFormat); - mView.setContentDescription(m12HoursFormat); - mView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext)); - } - - @Test - public void onInitializeAccessibilityEvent_producesNonEmptyAsciiContentDesc() throws Exception { - AccessibilityEvent ev = AccessibilityEvent.obtain(); - mView.onInitializeAccessibilityEvent(ev); - - assertFalse(TextUtils.isEmpty(ev.getContentDescription())); - assertTrue(isAscii(ev.getContentDescription())); - } - - @Test - public void onPopulateAccessibilityEvent_producesNonEmptyAsciiText() throws Exception { - AccessibilityEvent ev = AccessibilityEvent.obtain(); - mView.onPopulateAccessibilityEvent(ev); - - assertFalse(isEmpty(ev.getText())); - assertTrue(isAscii(ev.getText())); - } - - @Test - public void onInitializeAccessibilityNodeInfo_producesNonEmptyAsciiText() throws Exception { - AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(); - // Usually done in View.onInitializeAccessibilityNodeInfoInternal, but only when attached. - info.setContentDescription(mView.getContentDescription()); - mView.onInitializeAccessibilityNodeInfo(info); - - assertFalse(TextUtils.isEmpty(info.getText())); - assertTrue(isAscii(info.getText())); - - assertFalse(TextUtils.isEmpty(info.getContentDescription())); - assertTrue(isAscii(info.getContentDescription())); - } - - @Test - public void isNeeded_returnsTrueIfDateFormatsContainNonAscii() { - if (!isAscii(m12HoursFormat) || !isAscii(m24HoursFormat)) { - assertTrue(KeyguardClockAccessibilityDelegate.isNeeded(mContext)); - } - } - - @Test - public void isNeeded_returnsWhetherFancyColonExists() { - boolean hasFancyColon = !TextUtils.isEmpty(mContext.getString( - R.string.keyguard_fancy_colon)); - - assertEquals(hasFancyColon, KeyguardClockAccessibilityDelegate.isNeeded(mContext)); - } - - private boolean isAscii(CharSequence text) { - return text.chars().allMatch((i) -> i < 128); - } - - private boolean isAscii(List<CharSequence> texts) { - return texts.stream().allMatch(this::isAscii); - } - - private boolean isEmpty(List<CharSequence> texts) { - return texts.stream().allMatch(TextUtils::isEmpty); - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java index 8b5372a1f035..9d10011159c7 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardSliceViewControllerTest.java @@ -17,7 +17,6 @@ package com.android.keyguard; import static org.junit.Assume.assumeFalse; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -36,7 +35,6 @@ import com.android.systemui.keyguard.KeyguardSliceProvider; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.settings.FakeDisplayTracker; import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.tuner.TunerService; import org.junit.After; import org.junit.Before; @@ -53,8 +51,6 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase { @Mock private KeyguardSliceView mView; @Mock - private TunerService mTunerService; - @Mock private ConfigurationController mConfigurationController; @Mock private ActivityStarter mActivityStarter; @@ -74,7 +70,7 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase { when(mView.isAttachedToWindow()).thenReturn(true); when(mView.getContext()).thenReturn(mContext); mController = new KeyguardSliceViewController(mHandler, mBgHandler, mView, - mActivityStarter, mConfigurationController, mTunerService, mDumpManager, + mActivityStarter, mConfigurationController, mDumpManager, mDisplayTracker); mController.setupUri(KeyguardSliceProvider.KEYGUARD_SLICE_URI); } @@ -101,7 +97,6 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase { assumeFalse(isWatch()); mController.init(); - verify(mTunerService).addTunable(any(TunerService.Tunable.class), anyString()); verify(mConfigurationController).addCallback( any(ConfigurationController.ConfigurationListener.class)); } @@ -120,7 +115,6 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase { attachListenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView); - verify(mTunerService).removeTunable(any(TunerService.Tunable.class)); verify(mConfigurationController).removeCallback( any(ConfigurationController.ConfigurationListener.class)); } diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusAreaViewTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusAreaViewTest.kt deleted file mode 100644 index 64e499674d9f..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusAreaViewTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -package com.android.keyguard - -import android.testing.TestableLooper.RunWithLooper -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import com.android.systemui.SysuiTestCase -import org.junit.Assert.assertEquals -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -@SmallTest -@RunWith(AndroidJUnit4::class) -@RunWithLooper(setAsMainLooper = true) -class KeyguardStatusAreaViewTest : SysuiTestCase() { - - private lateinit var view: KeyguardStatusAreaView - - @Before - fun setUp() { - view = KeyguardStatusAreaView(context) - } - - @Test - fun checkTranslationX_AddedTotals() { - view.translateXFromClockDesign = 10f - assertEquals(10f, view.translationX) - - view.translateXFromAod = 20f - assertEquals(30f, view.translationX) - - view.translateXFromUnfold = 30f - assertEquals(60f, view.translationX) - } - - @Test - fun checkTranslationY_AddedTotals() { - view.translateYFromClockSize = 10f - assertEquals(10f, view.translationY) - - view.translateYFromClockDesign = 20f - assertEquals(30f, view.translationY) - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerBaseTest.java deleted file mode 100644 index 2b4fc5bd5cc5..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerBaseTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static org.mockito.Mockito.atLeast; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.view.View; -import android.view.ViewTreeObserver; -import android.widget.FrameLayout; - -import com.android.keyguard.logging.KeyguardLogger; -import com.android.systemui.SysuiTestCase; -import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository; -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory; -import com.android.systemui.kosmos.KosmosJavaAdapter; -import com.android.systemui.power.data.repository.FakePowerRepository; -import com.android.systemui.power.domain.interactor.PowerInteractorFactory; -import com.android.systemui.res.R; -import com.android.systemui.statusbar.notification.AnimatableProperty; -import com.android.systemui.statusbar.phone.DozeParameters; -import com.android.systemui.statusbar.phone.ScreenOffAnimationController; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.KeyguardStateController; - -import org.junit.Before; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -public class KeyguardStatusViewControllerBaseTest extends SysuiTestCase { - - private KosmosJavaAdapter mKosmos; - @Mock protected KeyguardStatusView mKeyguardStatusView; - - @Mock protected KeyguardSliceViewController mKeyguardSliceViewController; - @Mock protected KeyguardClockSwitchController mKeyguardClockSwitchController; - @Mock protected KeyguardStateController mKeyguardStateController; - @Mock protected KeyguardUpdateMonitor mKeyguardUpdateMonitor; - @Mock protected ConfigurationController mConfigurationController; - @Mock protected DozeParameters mDozeParameters; - @Mock protected ScreenOffAnimationController mScreenOffAnimationController; - @Mock protected KeyguardLogger mKeyguardLogger; - @Mock protected KeyguardStatusViewController mControllerMock; - @Mock protected ViewTreeObserver mViewTreeObserver; - protected FakeKeyguardRepository mFakeKeyguardRepository; - protected FakePowerRepository mFakePowerRepository; - - protected KeyguardStatusViewController mController; - - @Mock protected KeyguardClockSwitch mKeyguardClockSwitch; - @Mock protected FrameLayout mMediaHostContainer; - @Mock protected KeyguardStatusAreaView mKeyguardStatusAreaView; - - @Before - public void setup() { - mKosmos = new KosmosJavaAdapter(this); - MockitoAnnotations.initMocks(this); - - KeyguardInteractorFactory.WithDependencies deps = KeyguardInteractorFactory.create(); - mFakeKeyguardRepository = deps.getRepository(); - mFakePowerRepository = new FakePowerRepository(); - - mController = new KeyguardStatusViewController( - mKeyguardStatusView, - mKeyguardSliceViewController, - mKeyguardClockSwitchController, - mKeyguardStateController, - mKeyguardUpdateMonitor, - mConfigurationController, - mDozeParameters, - mScreenOffAnimationController, - mKeyguardLogger, - mKosmos.getInteractionJankMonitor(), - deps.getKeyguardInteractor(), - PowerInteractorFactory.create( - mFakePowerRepository - ).getPowerInteractor()) { - @Override - void setProperty( - AnimatableProperty property, - float value, - boolean animate) { - // Route into the mock version for verification - mControllerMock.setProperty(property, value, animate); - } - }; - - when(mKeyguardStatusView.getViewTreeObserver()).thenReturn(mViewTreeObserver); - when(mKeyguardClockSwitchController.getView()).thenReturn(mKeyguardClockSwitch); - when(mKeyguardStatusView.findViewById(R.id.keyguard_status_area)) - .thenReturn(mKeyguardStatusAreaView); - } - - protected void givenViewAttached() { - ArgumentCaptor<View.OnAttachStateChangeListener> captor = - ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class); - verify(mKeyguardStatusView, atLeast(1)).addOnAttachStateChangeListener(captor.capture()); - - for (View.OnAttachStateChangeListener listener : captor.getAllValues()) { - listener.onViewAttachedToWindow(mKeyguardStatusView); - } - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerWithCoroutinesTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerWithCoroutinesTest.kt deleted file mode 100644 index c29439d89753..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewControllerWithCoroutinesTest.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.keyguard - -import android.testing.TestableLooper -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import com.android.systemui.power.shared.model.ScreenPowerState -import kotlinx.coroutines.cancelChildren -import kotlinx.coroutines.test.runCurrent -import kotlinx.coroutines.test.runTest -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mockito.clearInvocations -import org.mockito.Mockito.never -import org.mockito.Mockito.verify - -@RunWith(AndroidJUnit4::class) -@TestableLooper.RunWithLooper(setAsMainLooper = true) -@SmallTest -class KeyguardStatusViewControllerWithCoroutinesTest : KeyguardStatusViewControllerBaseTest() { - - @Test - fun dozeTimeTickUpdatesSlices() = runTest { - mController.startCoroutines(coroutineContext) - givenViewAttached() - runCurrent() - clearInvocations(mKeyguardSliceViewController) - - mFakeKeyguardRepository.dozeTimeTick() - runCurrent() - verify(mKeyguardSliceViewController).refresh() - - coroutineContext.cancelChildren() - } - - @Test - fun onScreenTurningOnUpdatesSlices() = runTest { - mController.startCoroutines(coroutineContext) - givenViewAttached() - runCurrent() - clearInvocations(mKeyguardSliceViewController) - - mFakePowerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON) - runCurrent() - verify(mKeyguardSliceViewController, never()).refresh() - - // Should only be called during a 'turning on' event - mFakePowerRepository.setScreenPowerState(ScreenPowerState.SCREEN_TURNING_ON) - runCurrent() - verify(mKeyguardSliceViewController).refresh() - - coroutineContext.cancelChildren() - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewTest.kt deleted file mode 100644 index 16d2f0205c84..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardStatusViewTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -package com.android.keyguard - -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import android.testing.TestableLooper.RunWithLooper -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import com.android.systemui.res.R -import com.android.systemui.SysuiTestCase -import com.android.systemui.util.children -import com.google.common.truth.Truth.assertThat -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith - -@SmallTest -@RunWith(AndroidJUnit4::class) -@RunWithLooper(setAsMainLooper = true) -class KeyguardStatusViewTest : SysuiTestCase() { - - private lateinit var keyguardStatusView: KeyguardStatusView - private val mediaView: View - get() = keyguardStatusView.requireViewById(R.id.status_view_media_container) - private val statusViewContainer: ViewGroup - get() = keyguardStatusView.requireViewById(R.id.status_view_container) - private val childrenExcludingMedia - get() = statusViewContainer.children.filter { it != mediaView } - - @Before - fun setUp() { - keyguardStatusView = - LayoutInflater.from(context).inflate(R.layout.keyguard_status_view, /* root= */ null) - as KeyguardStatusView - } - - @Test - fun setChildrenTranslationYExcludingMediaView_mediaViewIsNotTranslated() { - val translationY = 1234f - - keyguardStatusView.setChildrenTranslationY(translationY, /* excludeMedia= */ true) - - assertThat(mediaView.translationY).isEqualTo(0) - - childrenExcludingMedia.forEach { assertThat(it.translationY).isEqualTo(translationY) } - } - - @Test - fun setChildrenTranslationYIncludeMediaView() { - val translationY = 1234f - - keyguardStatusView.setChildrenTranslationY(translationY, /* excludeMedia= */ false) - - statusViewContainer.children.forEach { assertThat(it.translationY).isEqualTo(translationY) } - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/SplitShadeTransitionAdapterTest.kt b/packages/SystemUI/multivalentTests/src/com/android/keyguard/SplitShadeTransitionAdapterTest.kt deleted file mode 100644 index c7d11ef16100..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/SplitShadeTransitionAdapterTest.kt +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.keyguard - -import android.animation.Animator -import android.transition.TransitionValues -import android.view.View -import android.view.ViewGroup -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import com.android.keyguard.KeyguardStatusViewController.SplitShadeTransitionAdapter -import com.android.systemui.SysuiTestCase -import com.android.systemui.util.mockito.mock -import com.google.common.truth.Truth.assertThat -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mock -import org.mockito.MockitoAnnotations - -@SmallTest -@RunWith(AndroidJUnit4::class) -class SplitShadeTransitionAdapterTest : SysuiTestCase() { - - @Mock private lateinit var KeyguardClockSwitchController: KeyguardClockSwitchController - - private lateinit var adapter: SplitShadeTransitionAdapter - - @Before - fun setUp() { - MockitoAnnotations.initMocks(this) - adapter = SplitShadeTransitionAdapter(KeyguardClockSwitchController) - } - - @Test - fun createAnimator_nullStartValues_returnsNull() { - val endValues = createEndValues() - - val animator = adapter.createAnimator(startValues = null, endValues = endValues) - - assertThat(animator).isNull() - } - - @Test - fun createAnimator_nullEndValues_returnsNull() { - val animator = adapter.createAnimator(startValues = createStartValues(), endValues = null) - - assertThat(animator).isNull() - } - - @Test - fun createAnimator_nonNullStartAndEndValues_returnsAnimator() { - val animator = - adapter.createAnimator(startValues = createStartValues(), endValues = createEndValues()) - - assertThat(animator).isNotNull() - } - - private fun createStartValues() = - TransitionValues().also { values -> - values.view = View(context) - adapter.captureStartValues(values) - } - - private fun createEndValues() = - TransitionValues().also { values -> - values.view = View(context) - adapter.captureEndValues(values) - } -} - -private fun SplitShadeTransitionAdapter.createAnimator( - startValues: TransitionValues?, - endValues: TransitionValues? -): Animator? { - return createAnimator(/* sceneRoot= */ mock(), startValues, endValues) -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt index 040d3b8f09cb..4e3d18c80a4f 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinderTest.kt @@ -21,8 +21,6 @@ import androidx.constraintlayout.helper.widget.Layer import androidx.constraintlayout.widget.ConstraintLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.keyguard.KeyguardClockSwitch.LARGE -import com.android.keyguard.KeyguardClockSwitch.SMALL import com.android.systemui.SysuiTestCase import com.android.systemui.keyguard.shared.model.ClockSize import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel @@ -80,6 +78,7 @@ class KeyguardClockViewBinderTest : SysuiTestCase() { verify(rootView).addView(smallClockView) verify(rootView).addView(largeClockView) } + @Test fun addClockViewsToBurnInLayer_LargeWeatherClock() { setupWeatherClock() @@ -110,7 +109,7 @@ class KeyguardClockViewBinderTest : SysuiTestCase() { name = "", description = "", useAlternateSmartspaceAODTransition = true, - useCustomClockScene = true + useCustomClockScene = true, ) whenever(clock.config).thenReturn(clockConfig) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt index 9fab0d9065b6..67a43327efc2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/blueprints/DefaultKeyguardBlueprintTest.kt @@ -37,7 +37,6 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultNotification 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.DefaultStatusBarSection -import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultUdfpsAccessibilityOverlaySection import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSliceViewSection import com.android.systemui.keyguard.ui.view.layout.sections.SmartspaceSection @@ -67,7 +66,6 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() { @Mock private lateinit var defaultShortcutsSection: DefaultShortcutsSection @Mock private lateinit var defaultAmbientIndicationAreaSection: Optional<KeyguardSection> @Mock private lateinit var defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection - @Mock private lateinit var defaultStatusViewSection: DefaultStatusViewSection @Mock private lateinit var defaultStatusBarViewSection: DefaultStatusBarSection @Mock private lateinit var defaultNSSLSection: DefaultNotificationStackScrollLayoutSection @Mock private lateinit var splitShadeGuidelines: SplitShadeGuidelines @@ -79,6 +77,7 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() { @Mock private lateinit var keyguardSliceViewSection: KeyguardSliceViewSection @Mock private lateinit var udfpsAccessibilityOverlaySection: DefaultUdfpsAccessibilityOverlaySection + @Before fun setup() { MockitoAnnotations.initMocks(this) @@ -91,7 +90,6 @@ class DefaultKeyguardBlueprintTest : SysuiTestCase() { defaultShortcutsSection, defaultAmbientIndicationAreaSection, defaultSettingsPopupMenuSection, - defaultStatusViewSection, defaultStatusBarViewSection, defaultNSSLSection, aodNotificationIconsSection, diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt index c0db95f9e5d2..7706c500c52b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/view/layout/sections/SmartspaceSectionTest.kt @@ -17,7 +17,6 @@ package com.android.systemui.keyguard.ui.view.layout.sections -import android.platform.test.annotations.EnableFlags import android.view.View import android.widget.LinearLayout import androidx.constraintlayout.widget.ConstraintLayout @@ -26,7 +25,6 @@ import androidx.constraintlayout.widget.ConstraintSet.GONE import androidx.constraintlayout.widget.ConstraintSet.VISIBLE import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.customization.R as customR import com.android.systemui.keyguard.KeyguardUnlockAnimationController @@ -50,7 +48,6 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidJUnit4::class) @SmallTest -@EnableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) class SmartspaceSectionTest : SysuiTestCase() { private lateinit var underTest: SmartspaceSection @Mock private lateinit var keyguardClockViewModel: KeyguardClockViewModel diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelTest.kt deleted file mode 100644 index 9e696011e285..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelTest.kt +++ /dev/null @@ -1,269 +0,0 @@ -/* - * 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. - */ - -@file:OptIn(ExperimentalCoroutinesApi::class) - -package com.android.systemui.keyguard.ui.viewmodel - -import android.platform.test.annotations.DisableFlags -import android.platform.test.annotations.EnableFlags -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import com.android.systemui.Flags -import com.android.systemui.Flags as AConfigFlags -import com.android.systemui.SysuiTestCase -import com.android.systemui.coroutines.collectLastValue -import com.android.systemui.flags.DisableSceneContainer -import com.android.systemui.flags.EnableSceneContainer -import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository -import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository -import com.android.systemui.keyguard.shared.model.KeyguardState -import com.android.systemui.keyguard.shared.model.TransitionState -import com.android.systemui.keyguard.shared.model.TransitionStep -import com.android.systemui.kosmos.testScope -import com.android.systemui.scene.data.repository.Idle -import com.android.systemui.scene.data.repository.Transition -import com.android.systemui.scene.data.repository.setSceneTransition -import com.android.systemui.scene.shared.model.Scenes -import com.android.systemui.testKosmos -import com.android.systemui.util.mockito.whenever -import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.test.runTest -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.Mock -import org.mockito.MockitoAnnotations - -@SmallTest -@RunWith(AndroidJUnit4::class) -class AodAlphaViewModelTest : SysuiTestCase() { - - @Mock private lateinit var goneToAodTransitionViewModel: GoneToAodTransitionViewModel - - private val kosmos = testKosmos() - private val testScope = kosmos.testScope - private val keyguardRepository = kosmos.fakeKeyguardRepository - private val keyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository - - private lateinit var underTest: AodAlphaViewModel - - private val enterFromTopAnimationAlpha = MutableStateFlow(0f) - - @Before - fun setUp() { - MockitoAnnotations.initMocks(this) - whenever(goneToAodTransitionViewModel.enterFromTopAnimationAlpha) - .thenReturn(enterFromTopAnimationAlpha) - kosmos.goneToAodTransitionViewModel = goneToAodTransitionViewModel - - underTest = kosmos.aodAlphaViewModel - } - - @Test - @DisableSceneContainer - @DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - fun alpha_WhenNotGone_clockMigrationFlagIsOff_emitsKeyguardAlpha() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.AOD, - to = KeyguardState.LOCKSCREEN, - testScope = testScope, - ) - - keyguardRepository.setKeyguardAlpha(0.5f) - assertThat(alpha).isEqualTo(0.5f) - - keyguardRepository.setKeyguardAlpha(0.8f) - assertThat(alpha).isEqualTo(0.8f) - } - - @Test - @DisableSceneContainer - fun alpha_WhenGoneToAod() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.AOD, - to = KeyguardState.GONE, - testScope = testScope, - ) - assertThat(alpha).isEqualTo(0f) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.GONE, - to = KeyguardState.AOD, - testScope = testScope, - ) - enterFromTopAnimationAlpha.value = 0.5f - assertThat(alpha).isEqualTo(0.5f) - - enterFromTopAnimationAlpha.value = 1f - assertThat(alpha).isEqualTo(1f) - } - - @Test - @EnableSceneContainer - fun alpha_WhenGoneToAod_scene_container() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - kosmos.setSceneTransition(Transition(from = Scenes.Lockscreen, to = Scenes.Gone)) - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.AOD, - to = KeyguardState.UNDEFINED, - testScope = testScope, - ) - kosmos.setSceneTransition(Idle(Scenes.Gone)) - assertThat(alpha).isEqualTo(0f) - - kosmos.setSceneTransition(Transition(from = Scenes.Gone, to = Scenes.Lockscreen)) - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.UNDEFINED, - to = KeyguardState.AOD, - testScope = testScope, - ) - enterFromTopAnimationAlpha.value = 0.5f - assertThat(alpha).isEqualTo(0.5f) - - enterFromTopAnimationAlpha.value = 1f - assertThat(alpha).isEqualTo(1f) - } - - @Test - @DisableSceneContainer - fun alpha_WhenGoneToDozing() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.AOD, - to = KeyguardState.GONE, - testScope = testScope, - ) - assertThat(alpha).isEqualTo(0f) - - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.GONE, - to = KeyguardState.DOZING, - testScope = testScope, - ) - assertThat(alpha).isEqualTo(1f) - } - - @Test - @EnableSceneContainer - fun alpha_WhenGoneToDozing_scene_container() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - kosmos.setSceneTransition(Idle(Scenes.Gone)) - assertThat(alpha).isEqualTo(0f) - - kosmos.setSceneTransition(Transition(from = Scenes.Gone, to = Scenes.Lockscreen)) - keyguardTransitionRepository.sendTransitionSteps( - from = KeyguardState.UNDEFINED, - to = KeyguardState.DOZING, - testScope = testScope, - ) - assertThat(alpha).isEqualTo(1f) - } - - @Test - @DisableSceneContainer - @EnableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - fun alpha_whenGone_equalsZero() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.LOCKSCREEN, - to = KeyguardState.GONE, - transitionState = TransitionState.STARTED, - ) - ) - assertThat(alpha).isNull() - - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.LOCKSCREEN, - to = KeyguardState.GONE, - transitionState = TransitionState.RUNNING, - value = 0.5f, - ) - ) - assertThat(alpha).isNull() - - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.LOCKSCREEN, - to = KeyguardState.GONE, - transitionState = TransitionState.RUNNING, - value = 1f, - ) - ) - assertThat(alpha).isEqualTo(0f) - } - - @Test - @DisableSceneContainer - fun enterFromTopAlpha() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.GONE, - to = KeyguardState.AOD, - transitionState = TransitionState.STARTED, - ) - ) - - enterFromTopAnimationAlpha.value = 0.2f - assertThat(alpha).isEqualTo(0.2f) - - enterFromTopAnimationAlpha.value = 1f - assertThat(alpha).isEqualTo(1f) - } - - @Test - @EnableSceneContainer - fun enterFromTopAlpha_scene_container() = - testScope.runTest { - val alpha by collectLastValue(underTest.alpha) - - kosmos.setSceneTransition(Transition(from = Scenes.Gone, to = Scenes.Lockscreen)) - keyguardTransitionRepository.sendTransitionStep( - TransitionStep( - from = KeyguardState.UNDEFINED, - to = KeyguardState.AOD, - transitionState = TransitionState.STARTED, - ) - ) - - enterFromTopAnimationAlpha.value = 0.2f - assertThat(alpha).isEqualTo(0.2f) - - enterFromTopAnimationAlpha.value = 1f - assertThat(alpha).isEqualTo(1f) - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModelTest.kt index 242ee3a783f2..bd892d588d8b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardIndicationAreaViewModelTest.kt @@ -16,11 +16,8 @@ package com.android.systemui.keyguard.ui.viewmodel -import android.platform.test.annotations.DisableFlags -import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState -import com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT import com.android.systemui.SysuiTestCase import com.android.systemui.common.ui.domain.interactor.configurationInteractor import com.android.systemui.communal.data.repository.fakeCommunalSceneRepository @@ -45,18 +42,14 @@ import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest import org.junit.Before import org.junit.Test -import org.junit.runner.RunWith import org.mockito.ArgumentMatchers.anyInt import org.mockito.kotlin.any import org.mockito.kotlin.doReturn import org.mockito.kotlin.mock -import platform.test.runner.parameterized.ParameterizedAndroidJunit4 -import platform.test.runner.parameterized.Parameters @OptIn(ExperimentalCoroutinesApi::class) @SmallTest -@RunWith(ParameterizedAndroidJunit4::class) -class KeyguardIndicationAreaViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { +class KeyguardIndicationAreaViewModelTest() : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope private lateinit var underTest: KeyguardIndicationAreaViewModel @@ -75,11 +68,6 @@ class KeyguardIndicationAreaViewModelTest(flags: FlagsParameterization) : SysuiT slotId = KeyguardQuickAffordancePosition.BOTTOM_END.toSlotId() ) ) - private val alphaFlow = MutableStateFlow(1f) - - init { - mSetFlagsRule.setFlagsParameterization(flags) - } @Before fun setUp() { @@ -106,47 +94,11 @@ class KeyguardIndicationAreaViewModelTest(flags: FlagsParameterization) : SysuiT keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor, backgroundDispatcher = kosmos.testDispatcher, communalSceneInteractor = kosmos.communalSceneInteractor, - mainDispatcher = kosmos.testDispatcher + mainDispatcher = kosmos.testDispatcher, ) } @Test - fun isIndicationAreaPadded() = - testScope.runTest { - keyguardRepository.setKeyguardShowing(true) - val isIndicationAreaPadded by collectLastValue(underTest.isIndicationAreaPadded) - - assertThat(isIndicationAreaPadded).isFalse() - startButtonFlow.value = startButtonFlow.value.copy(isVisible = true) - assertThat(isIndicationAreaPadded).isTrue() - endButtonFlow.value = endButtonFlow.value.copy(isVisible = true) - assertThat(isIndicationAreaPadded).isTrue() - startButtonFlow.value = startButtonFlow.value.copy(isVisible = false) - assertThat(isIndicationAreaPadded).isTrue() - endButtonFlow.value = endButtonFlow.value.copy(isVisible = false) - assertThat(isIndicationAreaPadded).isFalse() - } - - @Test - @DisableFlags(FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - fun indicationAreaTranslationY() = - testScope.runTest { - val translationY by - collectLastValue(underTest.indicationAreaTranslationY(DEFAULT_BURN_IN_OFFSET)) - - // Negative 0 - apparently there's a difference in floating point arithmetic - FML - assertThat(translationY).isEqualTo(-0f) - val expected1 = setDozeAmountAndCalculateExpectedTranslationY(0.1f) - assertThat(translationY).isEqualTo(expected1) - val expected2 = setDozeAmountAndCalculateExpectedTranslationY(0.2f) - assertThat(translationY).isEqualTo(expected2) - val expected3 = setDozeAmountAndCalculateExpectedTranslationY(0.5f) - assertThat(translationY).isEqualTo(expected3) - val expected4 = setDozeAmountAndCalculateExpectedTranslationY(1f) - assertThat(translationY).isEqualTo(expected4) - } - - @Test fun visibilityWhenCommunalNotShowing() = testScope.runTest { keyguardRepository.setStatusBarState(StatusBarState.KEYGUARD) @@ -185,13 +137,5 @@ class KeyguardIndicationAreaViewModelTest(flags: FlagsParameterization) : SysuiT companion object { private const val DEFAULT_BURN_IN_OFFSET = 5 private const val RETURNED_BURN_IN_OFFSET = 3 - - @JvmStatic - @Parameters(name = "{0}") - fun getParams(): List<FlagsParameterization> { - return FlagsParameterization.allCombinationsOf( - FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT, - ) - } } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index 07a408b9a4d7..619874f77e9d 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -28,15 +28,12 @@ import static kotlinx.coroutines.flow.StateFlowKt.MutableStateFlow; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -55,7 +52,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; -import android.view.ViewPropertyAnimator; import android.view.ViewTreeObserver; import android.view.accessibility.AccessibilityManager; @@ -66,17 +62,11 @@ import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.testing.UiEventLoggerFake; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.util.LatencyTracker; -import com.android.keyguard.KeyguardClockSwitch; -import com.android.keyguard.KeyguardClockSwitchController; import com.android.keyguard.KeyguardSliceViewController; -import com.android.keyguard.KeyguardStatusView; -import com.android.keyguard.KeyguardStatusViewController; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.dagger.KeyguardStatusBarViewComponent; -import com.android.keyguard.dagger.KeyguardStatusViewComponent; import com.android.keyguard.logging.KeyguardLogger; import com.android.systemui.SysuiTestCase; -import com.android.systemui.biometrics.AuthController; import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor; import com.android.systemui.classifier.FalsingCollectorFake; import com.android.systemui.classifier.FalsingManagerFake; @@ -101,12 +91,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac import com.android.systemui.keyguard.domain.interactor.NaturalScrollingSettingObserver; import com.android.systemui.keyguard.ui.view.KeyguardRootView; import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.GoneToDreamingTransitionViewModel; import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel; -import com.android.systemui.keyguard.ui.viewmodel.LockscreenToDreamingTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.LockscreenToOccludedTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.OccludedToLockscreenTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.PrimaryBouncerToGoneTransitionViewModel; import com.android.systemui.kosmos.KosmosJavaAdapter; import com.android.systemui.media.controls.domain.pipeline.MediaDataManager; import com.android.systemui.media.controls.ui.controller.KeyguardMediaController; @@ -216,7 +201,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected CentralSurfaces mCentralSurfaces; @Mock protected NotificationStackScrollLayout mNotificationStackScrollLayout; - @Mock protected ViewPropertyAnimator mViewPropertyAnimator; @Mock protected HeadsUpManager mHeadsUpManager; @Mock protected NotificationGutsManager mGutsManager; @Mock protected KeyguardStatusBarView mKeyguardStatusBar; @@ -240,22 +224,17 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected MetricsLogger mMetricsLogger; @Mock protected Resources mResources; @Mock protected Configuration mConfiguration; - @Mock protected KeyguardClockSwitch mKeyguardClockSwitch; @Mock protected MediaHierarchyManager mMediaHierarchyManager; @Mock protected ConversationNotificationManager mConversationNotificationManager; @Mock protected StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - @Mock protected KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory; - @Mock protected KeyguardStatusViewComponent mKeyguardStatusViewComponent; @Mock protected KeyguardStatusBarViewComponent.Factory mKeyguardStatusBarViewComponentFactory; @Mock protected KeyguardStatusBarViewComponent mKeyguardStatusBarViewComponent; - @Mock protected KeyguardClockSwitchController mKeyguardClockSwitchController; @Mock protected KeyguardStatusBarViewController mKeyguardStatusBarViewController; @Mock protected LightBarController mLightBarController; @Mock protected NotificationStackScrollLayoutController mNotificationStackScrollLayoutController; @Mock protected NotificationShadeDepthController mNotificationShadeDepthController; @Mock protected LockscreenShadeTransitionController mLockscreenShadeTransitionController; - @Mock protected AuthController mAuthController; @Mock protected ScrimController mScrimController; @Mock protected MediaDataManager mMediaDataManager; @Mock protected AmbientState mAmbientState; @@ -295,15 +274,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected ViewTreeObserver mViewTreeObserver; @Mock protected DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel; - @Mock protected OccludedToLockscreenTransitionViewModel - mOccludedToLockscreenTransitionViewModel; - @Mock protected LockscreenToDreamingTransitionViewModel - mLockscreenToDreamingTransitionViewModel; - @Mock protected LockscreenToOccludedTransitionViewModel - mLockscreenToOccludedTransitionViewModel; - @Mock protected GoneToDreamingTransitionViewModel mGoneToDreamingTransitionViewModel; - @Mock protected PrimaryBouncerToGoneTransitionViewModel - mPrimaryBouncerToGoneTransitionViewModel; @Mock protected KeyguardTransitionInteractor mKeyguardTransitionInteractor; @Mock protected KeyguardTouchHandlingViewModel mKeyuardTouchHandlingViewModel; @Mock protected AlternateBouncerInteractor mAlternateBouncerInteractor; @@ -311,7 +281,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { @Mock protected CoroutineDispatcher mMainDispatcher; @Mock protected KeyguardSliceViewController mKeyguardSliceViewController; private final KeyguardLogger mKeyguardLogger = new KeyguardLogger(logcatLogBuffer()); - @Mock protected KeyguardStatusView mKeyguardStatusView; @Captor protected ArgumentCaptor<NotificationStackScrollLayout.OnEmptySpaceClickListener> mEmptySpaceClickListenerCaptor; @@ -345,7 +314,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { protected List<View.OnAttachStateChangeListener> mOnAttachStateChangeListeners; protected Handler mMainHandler; protected View.OnLayoutChangeListener mLayoutChangeListener; - protected KeyguardStatusViewController mKeyguardStatusViewController; protected ShadeRepository mShadeRepository; protected FakeMSDLPlayer mMSDLPlayer = mKosmos.getMsdlPlayer(); @@ -427,23 +395,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { () -> mKosmos.getSceneBackInteractor(), () -> mKosmos.getAlternateBouncerInteractor()); - KeyguardStatusView keyguardStatusView = new KeyguardStatusView(mContext); - keyguardStatusView.setId(R.id.keyguard_status_view); - mKeyguardStatusViewController = spy(new KeyguardStatusViewController( - mKeyguardStatusView, - mKeyguardSliceViewController, - mKeyguardClockSwitchController, - mKeyguardStateController, - mUpdateMonitor, - mConfigurationController, - mDozeParameters, - mScreenOffAnimationController, - mKeyguardLogger, - mKosmos.getInteractionJankMonitor(), - mKeyguardInteractor, - mPowerInteractor)); - - when(mAuthController.isUdfpsEnrolled(anyInt())).thenReturn(false); when(mHeadsUpCallback.getContext()).thenReturn(mContext); when(mView.getResources()).thenReturn(mResources); when(mView.getWidth()).thenReturn(PANEL_WIDTH); @@ -462,31 +413,15 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { .thenReturn(SPLIT_SHADE_FULL_TRANSITION_DISTANCE); when(mView.getContext()).thenReturn(getContext()); when(mView.findViewById(R.id.keyguard_header)).thenReturn(mKeyguardStatusBar); - when(mView.findViewById(R.id.keyguard_clock_container)).thenReturn(mKeyguardClockSwitch); when(mView.findViewById(R.id.notification_stack_scroller)) .thenReturn(mNotificationStackScrollLayout); when(mNotificationStackScrollLayoutController.getHeight()).thenReturn(1000); when(mNotificationStackScrollLayoutController.getHeadsUpCallback()) .thenReturn(mHeadsUpCallback); - when(mView.animate()).thenReturn(mViewPropertyAnimator); - when(mKeyguardStatusView.animate()).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.translationX(anyFloat())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.alpha(anyFloat())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setDuration(anyLong())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setStartDelay(anyLong())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setInterpolator(any())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setListener(any())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.setUpdateListener(any())).thenReturn(mViewPropertyAnimator); - when(mViewPropertyAnimator.withEndAction(any())).thenReturn(mViewPropertyAnimator); - when(mView.findViewById(R.id.keyguard_status_view)) - .thenReturn(mock(KeyguardStatusView.class)); ViewGroup rootView = mock(ViewGroup.class); when(rootView.isVisibleToUser()).thenReturn(true); 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(); when(mView.findViewById(R.id.notification_container_parent)) .thenReturn(mNotificationContainerParent); @@ -518,36 +453,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { when(mDreamingToLockscreenTransitionViewModel.lockscreenTranslationY(anyInt())) .thenReturn(emptyFlow()); - // Occluded->Lockscreen - when(mOccludedToLockscreenTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mOccludedToLockscreenTransitionViewModel.getLockscreenTranslationY()) - .thenReturn(emptyFlow()); - - // Lockscreen->Dreaming - when(mLockscreenToDreamingTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mLockscreenToDreamingTransitionViewModel.lockscreenTranslationY(anyInt())) - .thenReturn(emptyFlow()); - - // Gone->Dreaming - when(mGoneToDreamingTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mGoneToDreamingTransitionViewModel.lockscreenTranslationY(anyInt())) - .thenReturn(emptyFlow()); - - // Lockscreen->Occluded - when(mLockscreenToOccludedTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mLockscreenToOccludedTransitionViewModel.getLockscreenTranslationY()) - .thenReturn(emptyFlow()); - - // Primary Bouncer->Gone - when(mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha()) - .thenReturn(emptyFlow()); - when(mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha()) - .thenReturn(emptyFlow()); - NotificationsKeyguardViewStateRepository notifsKeyguardViewStateRepository = new NotificationsKeyguardViewStateRepository(); NotificationsKeyguardInteractor notifsKeyguardInteractor = @@ -589,18 +494,10 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mShadeInteractor, mLockscreenShadeTransitionController, mDumpManager); - when(mKeyguardStatusViewComponentFactory.build(any(), any())) - .thenReturn(mKeyguardStatusViewComponent); - when(mKeyguardStatusViewComponent.getKeyguardClockSwitchController()) - .thenReturn(mKeyguardClockSwitchController); - when(mKeyguardStatusViewComponent.getKeyguardStatusViewController()) - .thenReturn(mKeyguardStatusViewController); when(mKeyguardStatusBarViewComponentFactory.build(any(), any())) .thenReturn(mKeyguardStatusBarViewComponent); when(mKeyguardStatusBarViewComponent.getKeyguardStatusBarViewController()) .thenReturn(mKeyguardStatusBarViewController); - when(mLayoutInflater.inflate(eq(R.layout.keyguard_status_view), any(), anyBoolean())) - .thenReturn(keyguardStatusView); when(mNotificationRemoteInputManager.isRemoteInputActive()) .thenReturn(false); doAnswer(invocation -> { @@ -661,10 +558,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mGutsManager, mNotificationsQSContainerController, mNotificationStackScrollLayoutController, - mKeyguardStatusViewComponentFactory, mKeyguardStatusBarViewComponentFactory, mLockscreenShadeTransitionController, - mAuthController, mScrimController, mUserManager, mMediaDataManager, @@ -694,11 +589,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mKeyguardClockInteractor, mAlternateBouncerInteractor, mDreamingToLockscreenTransitionViewModel, - mOccludedToLockscreenTransitionViewModel, - mLockscreenToDreamingTransitionViewModel, - mGoneToDreamingTransitionViewModel, - mLockscreenToOccludedTransitionViewModel, - mPrimaryBouncerToGoneTransitionViewModel, mMainDispatcher, mKeyguardTransitionInteractor, mDumpManager, @@ -749,7 +639,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { .setHeadsUpAppearanceController(mock(HeadsUpAppearanceController.class)); verify(mNotificationStackScrollLayoutController) .setOnEmptySpaceClickListener(mEmptySpaceClickListenerCaptor.capture()); - reset(mKeyguardStatusViewController); when(mNotificationPanelViewControllerLazy.get()) .thenReturn(mNotificationPanelViewController); @@ -797,7 +686,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { public void tearDown() { List<Animator> leakedAnimators = null; if (mNotificationPanelViewController != null) { - mNotificationPanelViewController.mBottomAreaShadeAlphaAnimator.cancel(); mNotificationPanelViewController.cancelHeightAnimator(); leakedAnimators = mNotificationPanelViewController.mTestSetOfAnimatorsUsed.stream() .filter(Animator::isRunning).toList(); @@ -871,18 +759,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { ); } - protected void assertKeyguardStatusViewCentered() { - mNotificationPanelViewController.updateResources(); - assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd).isAnyOf( - ConstraintSet.PARENT_ID, ConstraintSet.UNSET); - } - - protected void assertKeyguardStatusViewNotCentered() { - mNotificationPanelViewController.updateResources(); - assertThat(getConstraintSetLayout(R.id.keyguard_status_view).endToEnd).isEqualTo( - R.id.qs_edge_guideline); - } - protected void setIsFullWidth(boolean fullWidth) { float nsslWidth = fullWidth ? PANEL_WIDTH : PANEL_WIDTH / 2f; when(mNotificationStackScrollLayoutController.getWidth()).thenReturn(nsslWidth); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index 51f00a09ff43..ba989dbd0e73 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -57,42 +57,6 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo } @Test - @Ignore("b/261472011 - Test appears inconsistent across environments") - public void getVerticalSpaceForLockscreenNotifications_useLockIconBottomPadding_returnsSpaceAvailable() { - setBottomPadding(/* stackScrollLayoutBottom= */ 180, - /* lockIconPadding= */ 20, - /* indicationPadding= */ 0, - /* ambientPadding= */ 0); - - assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenNotifications()) - .isEqualTo(80); - } - - @Test - @Ignore("b/261472011 - Test appears inconsistent across environments") - public void getVerticalSpaceForLockscreenNotifications_useIndicationBottomPadding_returnsSpaceAvailable() { - setBottomPadding(/* stackScrollLayoutBottom= */ 180, - /* lockIconPadding= */ 0, - /* indicationPadding= */ 30, - /* ambientPadding= */ 0); - - assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenNotifications()) - .isEqualTo(70); - } - - @Test - @Ignore("b/261472011 - Test appears inconsistent across environments") - public void getVerticalSpaceForLockscreenNotifications_useAmbientBottomPadding_returnsSpaceAvailable() { - setBottomPadding(/* stackScrollLayoutBottom= */ 180, - /* lockIconPadding= */ 0, - /* indicationPadding= */ 0, - /* ambientPadding= */ 40); - - assertThat(mNotificationPanelViewController.getVerticalSpaceForLockscreenNotifications()) - .isEqualTo(60); - } - - @Test @EnableFlags(com.android.systemui.Flags.FLAG_SHADE_EXPANDS_ON_STATUS_BAR_LONG_PRESS) public void onStatusBarLongPress_shadeExpands() { long downTime = 42L; diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt index 0361ffe475a2..3d3d666825ad 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/NotificationShadeWindowViewTest.kt @@ -16,11 +16,9 @@ package com.android.systemui.shade import android.content.res.Configuration -import android.os.SystemClock import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.testing.TestableLooper.RunWithLooper -import android.view.MotionEvent import android.widget.FrameLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java index b58c13c34505..7433267ab3b0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java @@ -32,7 +32,6 @@ import android.view.accessibility.AccessibilityManager; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.UiEventLogger; -import com.android.keyguard.KeyguardStatusView; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.SysuiTestCase; import com.android.systemui.deviceentry.domain.interactor.DeviceEntryFaceAuthInteractor; @@ -200,9 +199,6 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase { ), mKosmos.getShadeModeInteractor()); - KeyguardStatusView keyguardStatusView = new KeyguardStatusView(mContext); - keyguardStatusView.setId(R.id.keyguard_status_view); - when(mResources.getDimensionPixelSize( R.dimen.lockscreen_shade_qs_transition_distance)).thenReturn(DEFAULT_HEIGHT); when(mPanelView.getResources()).thenReturn(mResources); @@ -218,8 +214,6 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase { when(mQs.getHeaderBottom()).thenReturn(QS_FRAME_BOTTOM); when(mPanelView.getY()).thenReturn((float) QS_FRAME_TOP); when(mPanelView.getHeight()).thenReturn(QS_FRAME_BOTTOM); - when(mPanelView.findViewById(R.id.keyguard_status_view)) - .thenReturn(mock(KeyguardStatusView.class)); when(mQs.getView()).thenReturn(mPanelView); when(mQSFragment.getView()).thenReturn(mPanelView); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt index 6bdd86efa8c0..459778868ccd 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt @@ -24,7 +24,6 @@ import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.compose.animation.scene.ObservableTransitionState -import com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository import com.android.systemui.common.shared.model.NotificationContainerBounds @@ -91,8 +90,6 @@ import platform.test.runner.parameterized.Parameters @SmallTest @RunWith(ParameterizedAndroidJunit4::class) -// SharedNotificationContainerViewModel is only bound when FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT is on -@EnableFlags(FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { companion object { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchControllerTest.kt index b7a35158fdf6..abfd64adab22 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchControllerTest.kt @@ -24,11 +24,10 @@ import android.widget.FrameLayout import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.logging.UiEventLogger -import com.android.systemui.res.R import com.android.systemui.SysuiTestCase import com.android.systemui.plugins.FalsingManager import com.android.systemui.qs.user.UserSwitchDialogController -import com.android.systemui.statusbar.SysuiStatusBarStateController +import com.android.systemui.res.R import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.LockscreenGestureLogger import com.android.systemui.statusbar.phone.ScreenOffAnimationController @@ -47,32 +46,21 @@ import org.mockito.MockitoAnnotations @TestableLooper.RunWithLooper @RunWith(AndroidJUnit4::class) class KeyguardQsUserSwitchControllerTest : SysuiTestCase() { - @Mock - private lateinit var userSwitcherController: UserSwitcherController - - @Mock - private lateinit var keyguardStateController: KeyguardStateController + @Mock private lateinit var userSwitcherController: UserSwitcherController - @Mock - private lateinit var falsingManager: FalsingManager + @Mock private lateinit var keyguardStateController: KeyguardStateController - @Mock - private lateinit var configurationController: ConfigurationController + @Mock private lateinit var falsingManager: FalsingManager - @Mock - private lateinit var statusBarStateController: SysuiStatusBarStateController + @Mock private lateinit var configurationController: ConfigurationController - @Mock - private lateinit var dozeParameters: DozeParameters + @Mock private lateinit var dozeParameters: DozeParameters - @Mock - private lateinit var screenOffAnimationController: ScreenOffAnimationController + @Mock private lateinit var screenOffAnimationController: ScreenOffAnimationController - @Mock - private lateinit var userSwitchDialogController: UserSwitchDialogController + @Mock private lateinit var userSwitchDialogController: UserSwitchDialogController - @Mock - private lateinit var uiEventLogger: UiEventLogger + @Mock private lateinit var uiEventLogger: UiEventLogger private lateinit var view: FrameLayout private lateinit var testableLooper: TestableLooper @@ -83,10 +71,12 @@ class KeyguardQsUserSwitchControllerTest : SysuiTestCase() { MockitoAnnotations.initMocks(this) testableLooper = TestableLooper.get(this) - view = LayoutInflater.from(context) - .inflate(R.layout.keyguard_qs_user_switch, null) as FrameLayout + view = + LayoutInflater.from(context).inflate(R.layout.keyguard_qs_user_switch, null) + as FrameLayout - keyguardQsUserSwitchController = KeyguardQsUserSwitchController( + keyguardQsUserSwitchController = + KeyguardQsUserSwitchController( view, context, context.resources, @@ -94,11 +84,11 @@ class KeyguardQsUserSwitchControllerTest : SysuiTestCase() { keyguardStateController, falsingManager, configurationController, - statusBarStateController, dozeParameters, screenOffAnimationController, userSwitchDialogController, - uiEventLogger) + uiEventLogger, + ) ViewUtils.attachView(view) testableLooper.processAllMessages() @@ -117,7 +107,7 @@ class KeyguardQsUserSwitchControllerTest : SysuiTestCase() { fun testUiEventLogged() { view.findViewById<View>(R.id.kg_multi_user_avatar)?.performClick() verify(uiEventLogger, times(1)) - .log(LockscreenGestureLogger.LockscreenUiEvent.LOCKSCREEN_SWITCH_USER_TAP) + .log(LockscreenGestureLogger.LockscreenUiEvent.LOCKSCREEN_SWITCH_USER_TAP) } @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt index c29b86c1fa37..1135a5f86952 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt @@ -19,8 +19,6 @@ package com.android.systemui.unfold import android.hardware.devicestate.DeviceStateManager import android.hardware.devicestate.DeviceStateManager.FoldStateListener import android.os.PowerManager -import android.view.ViewGroup -import android.view.ViewTreeObserver import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.util.LatencyTracker @@ -74,10 +72,6 @@ class FoldAodAnimationControllerTest : SysuiTestCase() { @Mock lateinit var shadeViewController: ShadeViewController - @Mock lateinit var viewGroup: ViewGroup - - @Mock lateinit var viewTreeObserver: ViewTreeObserver - @Mock lateinit var shadeFoldAnimator: ShadeFoldAnimator @Mock lateinit var foldTransitionInteractor: ToAodFoldTransitionInteractor @@ -97,11 +91,8 @@ class FoldAodAnimationControllerTest : SysuiTestCase() { deviceStates = FoldableTestUtils.findDeviceStates(context) - // TODO(b/254878364): remove this call to NPVC.getView() whenever(shadeViewController.shadeFoldAnimator).thenReturn(shadeFoldAnimator) whenever(foldTransitionInteractor.foldAnimator).thenReturn(shadeFoldAnimator) - whenever(shadeFoldAnimator.view).thenReturn(viewGroup) - whenever(viewGroup.viewTreeObserver).thenReturn(viewTreeObserver) whenever(wakefulnessLifecycle.lastSleepReason) .thenReturn(PowerManager.GO_TO_SLEEP_REASON_DEVICE_FOLD) whenever(shadeFoldAnimator.startFoldToAodAnimation(any(), any(), any())).then { diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_presentation.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_presentation.xml deleted file mode 100644 index f68ab8110b6d..000000000000 --- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_presentation.xml +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?><!-- -** -** Copyright 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. -*/ ---> - -<androidx.constraintlayout.widget.ConstraintLayout - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - android:id="@+id/presentation" - android:layout_width="match_parent" - android:layout_height="match_parent"> - <com.android.keyguard.KeyguardStatusView - android:id="@+id/clock" - android:layout_width="0dp" - android:layout_height="0dp" - android:layout_gravity="center" - android:orientation="vertical" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintDimensionRatio="1:1" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent"> - - - <include - android:id="@+id/keyguard_clock_container" - layout="@layout/keyguard_clock_switch" - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - </com.android.keyguard.KeyguardStatusView> - -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml deleted file mode 100644 index 8bef4759c55d..000000000000 --- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -** -** Copyright 2018, 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. -*/ ---> - -<!-- This is a view that shows clock information in Keyguard. --> -<com.android.keyguard.KeyguardClockSwitch - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/keyguard_clock_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:clipChildren="false" - android:layout_gravity="center_horizontal|top"> - <com.android.keyguard.KeyguardClockFrame - android:id="@id/lockscreen_clock_view" - android:layout_width="wrap_content" - android:layout_height="@dimen/small_clock_height" - android:layout_alignParentStart="true" - android:layout_alignParentTop="true" - android:clipChildren="false" - android:paddingStart="@dimen/clock_padding_start" - android:visibility="invisible" /> - <com.android.keyguard.KeyguardClockFrame - android:id="@id/lockscreen_clock_view_large" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:clipChildren="false" - android:visibility="gone" /> - - <!-- Not quite optimal but needed to translate these items as a group. The - NotificationIconContainer has its own logic for translation. --> - <com.android.keyguard.KeyguardStatusAreaView - android:id="@+id/keyguard_status_area" - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_alignParentStart="true" - android:layout_below="@id/lockscreen_clock_view"> - - <include layout="@layout/keyguard_slice_view" - android:id="@+id/keyguard_slice_view" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <com.android.systemui.statusbar.phone.NotificationIconContainer - android:id="@+id/left_aligned_notification_icon_container" - android:layout_width="match_parent" - android:layout_height="@dimen/notification_shelf_height" - android:paddingStart="@dimen/below_clock_padding_start_icons" - android:visibility="invisible" - /> - </com.android.keyguard.KeyguardStatusAreaView> -</com.android.keyguard.KeyguardClockSwitch> diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml b/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml deleted file mode 100644 index 8a0dd125d88b..000000000000 --- a/packages/SystemUI/res-keyguard/layout/keyguard_presentation.xml +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -** -** Copyright 2013, 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. -*/ ---> - -<!-- This is a view that shows general status information in Keyguard. --> -<FrameLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/presentation" - android:layout_width="match_parent" - android:layout_height="match_parent"> - <!-- This is mostly keyguard_status_view.xml with minor modifications --> - <com.android.keyguard.KeyguardStatusView - android:id="@+id/clock" - android:orientation="vertical" - android:layout_width="@dimen/keyguard_presentation_width" - android:layout_height="wrap_content"> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> - <include - layout="@layout/keyguard_clock_switch" - android:id="@+id/keyguard_clock_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - <ImageView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="24dp" - android:layout_gravity="center_horizontal" - android:src="@drawable/kg_security_lock_normal" /> - </LinearLayout> - </com.android.keyguard.KeyguardStatusView> - -</FrameLayout> diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml index 7c5dbc247428..99b98dd2cdb7 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_slice_view.xml @@ -20,6 +20,7 @@ <!-- This is a view that shows general status information in Keyguard. --> <com.android.keyguard.KeyguardSliceView xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/keyguard_slice_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="start" diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml deleted file mode 100644 index e6122a094707..000000000000 --- a/packages/SystemUI/res-keyguard/layout/keyguard_status_view.xml +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -** -** Copyright 2009, 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. -*/ ---> - -<!-- This is a view that shows general status information in Keyguard. --> -<com.android.keyguard.KeyguardStatusView - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:systemui="http://schemas.android.com/apk/res-auto" - android:id="@+id/keyguard_status_view" - android:orientation="vertical" - systemui:layout_constraintStart_toStartOf="parent" - systemui:layout_constraintEnd_toEndOf="parent" - systemui:layout_constraintTop_toTopOf="parent" - android:layout_marginHorizontal="@dimen/status_view_margin_horizontal" - android:clipChildren="false" - android:layout_width="0dp" - android:layout_height="wrap_content"> - <com.android.keyguard.KeyguardStatusContainer - android:id="@+id/status_view_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:clipChildren="false" - android:clipToPadding="false" - android:orientation="vertical"> - <include - layout="@layout/keyguard_clock_switch" - android:id="@+id/keyguard_clock_container" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - <FrameLayout - android:id="@id/status_view_media_container" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:padding="@dimen/qs_media_padding" - /> - </com.android.keyguard.KeyguardStatusContainer> -</com.android.keyguard.KeyguardStatusView> diff --git a/packages/SystemUI/res/layout/status_bar_expanded.xml b/packages/SystemUI/res/layout/status_bar_expanded.xml index 46a9d475cbb6..b106ad55fb3c 100644 --- a/packages/SystemUI/res/layout/status_bar_expanded.xml +++ b/packages/SystemUI/res/layout/status_bar_expanded.xml @@ -41,10 +41,6 @@ android:clipToPadding="false" android:clipChildren="false"> - <include - layout="@layout/keyguard_status_view" - android:visibility="gone"/> - <include layout="@layout/dock_info_overlay"/> <FrameLayout diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java deleted file mode 100644 index f7db48aefdaf..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockAccessibilityDelegate.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2017 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.content.Context; -import android.text.TextUtils; -import android.view.View; -import android.view.accessibility.AccessibilityEvent; -import android.view.accessibility.AccessibilityNodeInfo; -import android.widget.TextView; - -import com.android.systemui.res.R; - -/** - * Replaces fancy colons with regular colons. Only works on TextViews. - */ -class KeyguardClockAccessibilityDelegate extends View.AccessibilityDelegate { - private final String mFancyColon; - - public KeyguardClockAccessibilityDelegate(Context context) { - mFancyColon = context.getString(R.string.keyguard_fancy_colon); - } - - @Override - public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { - super.onInitializeAccessibilityEvent(host, event); - if (TextUtils.isEmpty(mFancyColon)) { - return; - } - CharSequence text = event.getContentDescription(); - if (!TextUtils.isEmpty(text)) { - event.setContentDescription(replaceFancyColon(text)); - } - } - - @Override - public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) { - if (TextUtils.isEmpty(mFancyColon)) { - super.onPopulateAccessibilityEvent(host, event); - } else { - CharSequence text = ((TextView) host).getText(); - if (!TextUtils.isEmpty(text)) { - event.getText().add(replaceFancyColon(text)); - } - } - } - - @Override - public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { - super.onInitializeAccessibilityNodeInfo(host, info); - if (TextUtils.isEmpty(mFancyColon)) { - return; - } - if (!TextUtils.isEmpty(info.getText())) { - info.setText(replaceFancyColon(info.getText())); - } - if (!TextUtils.isEmpty(info.getContentDescription())) { - info.setContentDescription(replaceFancyColon(info.getContentDescription())); - } - } - - private CharSequence replaceFancyColon(CharSequence text) { - if (TextUtils.isEmpty(mFancyColon)) { - return text; - } - return text.toString().replace(mFancyColon, ":"); - } - - public static boolean isNeeded(Context context) { - return !TextUtils.isEmpty(context.getString(R.string.keyguard_fancy_colon)); - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockFrame.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardClockFrame.kt deleted file mode 100644 index 1cb8e43cf2c8..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockFrame.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.android.keyguard - -import android.content.Context -import android.graphics.Canvas -import android.util.AttributeSet -import android.view.View -import android.widget.FrameLayout - -class KeyguardClockFrame( - context: Context, - attrs: AttributeSet, -) : FrameLayout(context, attrs) { - private var drawAlpha: Int = 255 - - protected override fun onSetAlpha(alpha: Int): Boolean { - // Ignore alpha passed from View, prefer to compute it from set values - drawAlpha = (255 * this.alpha * transitionAlpha).toInt() - return true - } - - protected override fun dispatchDraw(canvas: Canvas) { - saveCanvasAlpha(this, canvas, drawAlpha) { super.dispatchDraw(it) } - } - - companion object { - @JvmStatic - fun saveCanvasAlpha(view: View, canvas: Canvas, alpha: Int, drawFunc: (Canvas) -> Unit) { - if (alpha <= 0) { - // Zero Alpha -> skip drawing phase - return - } - - if (alpha >= 255) { - // Max alpha -> no need for layer - drawFunc(canvas) - return - } - - // Find x & y of view on screen - var (x, y) = - run { - val locationOnScreen = IntArray(2) - view.getLocationOnScreen(locationOnScreen) - Pair(locationOnScreen[0].toFloat(), locationOnScreen[1].toFloat()) - } - - val restoreTo = - canvas.saveLayerAlpha(-1f * x, -1f * y, x + view.width, y + view.height, alpha) - drawFunc(canvas) - canvas.restoreToCount(restoreTo) - } - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java deleted file mode 100644 index 71d4e9af6f55..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ /dev/null @@ -1,501 +0,0 @@ -package com.android.keyguard; - -import static com.android.keyguard.KeyguardStatusAreaView.TRANSLATE_X_CLOCK_DESIGN; -import static com.android.keyguard.KeyguardStatusAreaView.TRANSLATE_Y_CLOCK_DESIGN; -import static com.android.keyguard.KeyguardStatusAreaView.TRANSLATE_Y_CLOCK_SIZE; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.AnimatorSet; -import android.animation.ObjectAnimator; -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.view.View; -import android.view.ViewGroup; -import android.widget.RelativeLayout; - -import androidx.annotation.IntDef; -import androidx.annotation.VisibleForTesting; -import androidx.core.content.res.ResourcesCompat; - -import com.android.app.animation.Interpolators; -import com.android.keyguard.dagger.KeyguardStatusViewScope; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; -import com.android.systemui.log.LogBuffer; -import com.android.systemui.log.core.LogLevel; -import com.android.systemui.plugins.clocks.ClockController; -import com.android.systemui.res.R; -import com.android.systemui.shared.clocks.DefaultClockController; - -import java.io.PrintWriter; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Switch to show plugin clock when plugin is connected, otherwise it will show default clock. - */ -@KeyguardStatusViewScope -public class KeyguardClockSwitch extends RelativeLayout { - - private static final String TAG = "KeyguardClockSwitch"; - public static final String MISSING_CLOCK_ID = "CLOCK_MISSING"; - - private static final long CLOCK_OUT_MILLIS = 133; - private static final long CLOCK_IN_MILLIS = 167; - public static final long CLOCK_IN_START_DELAY_MILLIS = 133; - private static final long STATUS_AREA_START_DELAY_MILLIS = 0; - private static final long STATUS_AREA_MOVE_UP_MILLIS = 967; - private static final long STATUS_AREA_MOVE_DOWN_MILLIS = 467; - private static final float SMARTSPACE_TRANSLATION_CENTER_MULTIPLIER = 1.4f; - private static final float SMARTSPACE_TOP_PADDING_MULTIPLIER = 2.625f; - - @IntDef({LARGE, SMALL}) - @Retention(RetentionPolicy.SOURCE) - public @interface ClockSize { } - - public static final int LARGE = 0; - public static final int SMALL = 1; - // compensate for translation of parents subject to device screen - // In this case, the translation comes from KeyguardStatusView - public int screenOffsetYPadding = 0; - - /** Returns a region for the large clock to position itself, based on the given parent. */ - public static Rect getLargeClockRegion(ViewGroup parent) { - int largeClockTopMargin = parent.getResources() - .getDimensionPixelSize( - com.android.systemui.customization.R.dimen.keyguard_large_clock_top_margin); - int targetHeight = parent.getResources() - .getDimensionPixelSize( - com.android.systemui.customization.R.dimen.large_clock_text_size) - * 2; - int top = parent.getHeight() / 2 - targetHeight / 2 - + largeClockTopMargin / 2; - return new Rect( - parent.getLeft(), - top, - parent.getRight(), - top + targetHeight); - } - - /** Returns a region for the small clock to position itself, based on the given parent. */ - public static Rect getSmallClockRegion(ViewGroup parent) { - int targetHeight = parent.getResources() - .getDimensionPixelSize( - com.android.systemui.customization.R.dimen.small_clock_text_size); - return new Rect( - parent.getLeft(), - parent.getTop(), - parent.getRight(), - parent.getTop() + targetHeight); - } - - /** - * Frame for small/large clocks - */ - private KeyguardClockFrame mSmallClockFrame; - private KeyguardClockFrame mLargeClockFrame; - private ClockController mClock; - - // It's bc_smartspace_view, assigned by KeyguardClockSwitchController - // to get the top padding for translating smartspace for weather clock - private View mSmartspace; - - // Smartspace in weather clock is translated by this value - // to compensate for the position invisible dateWeatherView - private int mSmartspaceTop = -1; - - private KeyguardStatusAreaView mStatusArea; - private int mSmartspaceTopOffset; - private float mWeatherClockSmartspaceScaling = 1f; - private int mWeatherClockSmartspaceTranslateX = 0; - private int mWeatherClockSmartspaceTranslateY = 0; - private int mDrawAlpha = 255; - - private int mStatusBarHeight = 0; - - /** - * Maintain state so that a newly connected plugin can be initialized. - */ - private float mDarkAmount; - private boolean mSplitShadeCentered = false; - - /** - * Indicates which clock is currently displayed - should be one of {@link ClockSize}. - * Use null to signify it is uninitialized. - */ - @ClockSize private Integer mDisplayedClockSize = null; - - @VisibleForTesting AnimatorSet mClockInAnim = null; - @VisibleForTesting AnimatorSet mClockOutAnim = null; - @VisibleForTesting AnimatorSet mStatusAreaAnim = null; - - private int mClockSwitchYAmount; - @VisibleForTesting boolean mChildrenAreLaidOut = false; - @VisibleForTesting boolean mAnimateOnLayout = true; - private LogBuffer mLogBuffer = null; - - public KeyguardClockSwitch(Context context, AttributeSet attrs) { - super(context, attrs); - } - - /** - * Apply dp changes on configuration change - */ - public void onConfigChanged() { - mClockSwitchYAmount = mContext.getResources().getDimensionPixelSize( - R.dimen.keyguard_clock_switch_y_shift); - mSmartspaceTopOffset = (int) (mContext.getResources().getDimensionPixelSize( - com.android.systemui.customization.R.dimen.keyguard_smartspace_top_offset) - * mContext.getResources().getConfiguration().fontScale - / mContext.getResources().getDisplayMetrics().density - * SMARTSPACE_TOP_PADDING_MULTIPLIER); - mWeatherClockSmartspaceScaling = ResourcesCompat.getFloat( - mContext.getResources(), R.dimen.weather_clock_smartspace_scale); - mWeatherClockSmartspaceTranslateX = mContext.getResources().getDimensionPixelSize( - R.dimen.weather_clock_smartspace_translateX); - mWeatherClockSmartspaceTranslateY = mContext.getResources().getDimensionPixelSize( - R.dimen.weather_clock_smartspace_translateY); - mStatusBarHeight = mContext.getResources().getDimensionPixelSize( - R.dimen.status_bar_height); - updateStatusArea(/* animate= */false); - } - - /** Get bc_smartspace_view from KeyguardClockSwitchController - * Use its top to decide the translation value */ - public void setSmartspace(View smartspace) { - mSmartspace = smartspace; - } - - /** Sets whether the large clock is being shown on a connected display. */ - public void setLargeClockOnSecondaryDisplay(boolean onSecondaryDisplay) { - if (mClock != null) { - mClock.getLargeClock().getEvents().onSecondaryDisplayChanged(onSecondaryDisplay); - } - } - - /** - * Enable or disable split shade specific positioning - */ - public void setSplitShadeCentered(boolean splitShadeCentered) { - if (mSplitShadeCentered != splitShadeCentered) { - mSplitShadeCentered = splitShadeCentered; - updateStatusArea(/* animate= */true); - } - } - - public boolean getSplitShadeCentered() { - return mSplitShadeCentered; - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - if (!MigrateClocksToBlueprint.isEnabled()) { - mSmallClockFrame = findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view); - mLargeClockFrame = findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view_large); - mStatusArea = findViewById(R.id.keyguard_status_area); - } else { - removeView(findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view)); - removeView(findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view_large)); - } - onConfigChanged(); - } - - @Override - protected boolean onSetAlpha(int alpha) { - mDrawAlpha = alpha; - return true; - } - - @Override - protected void dispatchDraw(Canvas canvas) { - KeyguardClockFrame.saveCanvasAlpha( - this, canvas, mDrawAlpha, - c -> { - super.dispatchDraw(c); - return kotlin.Unit.INSTANCE; - }); - } - - public void setLogBuffer(LogBuffer logBuffer) { - mLogBuffer = logBuffer; - } - - public LogBuffer getLogBuffer() { - return mLogBuffer; - } - - /** Returns the id of the currently rendering clock */ - public String getClockId() { - if (mClock == null) { - return MISSING_CLOCK_ID; - } - return mClock.getConfig().getId(); - } - - void setClock(ClockController clock, int statusBarState) { - mClock = clock; - - // Disconnect from existing plugin. - mSmallClockFrame.removeAllViews(); - mLargeClockFrame.removeAllViews(); - - if (clock == null) { - if (mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.ERROR, "No clock being shown"); - } - return; - } - - // Attach small and big clock views to hierarchy. - if (mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.INFO, "Attached new clock views to switch"); - } - mSmallClockFrame.addView(clock.getSmallClock().getView()); - mLargeClockFrame.addView(clock.getLargeClock().getView()); - updateClockTargetRegions(); - updateStatusArea(/* animate= */false); - } - - private void updateStatusArea(boolean animate) { - if (mDisplayedClockSize != null && mChildrenAreLaidOut) { - updateClockViews(mDisplayedClockSize == LARGE, animate); - } - } - - void updateClockTargetRegions() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - if (mClock != null) { - if (mSmallClockFrame.isLaidOut()) { - Rect targetRegion = getSmallClockRegion(mSmallClockFrame); - mClock.getSmallClock().getEvents().onTargetRegionChanged(targetRegion); - } - - if (mLargeClockFrame.isLaidOut()) { - Rect targetRegion = getLargeClockRegion(mLargeClockFrame); - if (mClock instanceof DefaultClockController) { - mClock.getLargeClock().getEvents().onTargetRegionChanged( - targetRegion); - } else { - mClock.getLargeClock().getEvents().onTargetRegionChanged( - new Rect( - targetRegion.left, - targetRegion.top - screenOffsetYPadding, - targetRegion.right, - targetRegion.bottom - screenOffsetYPadding)); - } - } - } - } - - private void updateClockViews(boolean useLargeClock, boolean animate) { - if (mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.DEBUG, (msg) -> { - msg.setBool1(useLargeClock); - msg.setBool2(animate); - msg.setBool3(mChildrenAreLaidOut); - return kotlin.Unit.INSTANCE; - }, (msg) -> "updateClockViews" - + "; useLargeClock=" + msg.getBool1() - + "; animate=" + msg.getBool2() - + "; mChildrenAreLaidOut=" + msg.getBool3()); - } - - if (mClockInAnim != null) mClockInAnim.cancel(); - if (mClockOutAnim != null) mClockOutAnim.cancel(); - if (mStatusAreaAnim != null) mStatusAreaAnim.cancel(); - - mClockInAnim = null; - mClockOutAnim = null; - mStatusAreaAnim = null; - - View in, out; - // statusAreaYTranslation uses for the translation for both mStatusArea and mSmallClockFrame - // statusAreaClockTranslateY only uses for mStatusArea - float statusAreaYTranslation, statusAreaClockScale = 1f; - float statusAreaClockTranslateX = 0f, statusAreaClockTranslateY = 0f; - float clockInYTranslation, clockOutYTranslation; - if (useLargeClock) { - out = mSmallClockFrame; - in = mLargeClockFrame; - if (indexOfChild(in) == -1) addView(in, 0); - statusAreaYTranslation = mSmallClockFrame.getTop() - mStatusArea.getTop() - + mSmartspaceTopOffset; - // TODO: Load from clock config when less risky - if (mClock != null - && mClock.getLargeClock().getConfig().getHasCustomWeatherDataDisplay()) { - statusAreaClockScale = mWeatherClockSmartspaceScaling; - statusAreaClockTranslateX = mWeatherClockSmartspaceTranslateX; - if (mSplitShadeCentered) { - statusAreaClockTranslateX *= SMARTSPACE_TRANSLATION_CENTER_MULTIPLIER; - } - - // On large weather clock, - // top padding for time is status bar height from top of the screen. - // On small one, - // it's screenOffsetYPadding (translationY for KeyguardStatusView), - // Cause smartspace is positioned according to the smallClockFrame - // we need to translate the difference between bottom of large clock and small clock - // Also, we need to counter offset the empty date weather view, mSmartspaceTop - // mWeatherClockSmartspaceTranslateY is only for Felix - statusAreaClockTranslateY = mStatusBarHeight - 0.6F * mSmallClockFrame.getHeight() - - mSmartspaceTop - screenOffsetYPadding - - statusAreaYTranslation + mWeatherClockSmartspaceTranslateY; - } - clockInYTranslation = 0; - clockOutYTranslation = 0; // Small clock translation is handled with statusArea - } else { - in = mSmallClockFrame; - out = mLargeClockFrame; - statusAreaYTranslation = 0f; - clockInYTranslation = 0f; - clockOutYTranslation = mClockSwitchYAmount * -1f; - - // Must remove in order for notifications to appear in the proper place, ideally this - // would happen after the out animation runs, but we can't guarantee that the - // nofications won't enter only after the out animation runs. - removeView(out); - } - - if (!animate) { - out.setAlpha(0f); - out.setTranslationY(clockOutYTranslation); - out.setVisibility(INVISIBLE); - in.setAlpha(1f); - in.setTranslationY(clockInYTranslation); - in.setVisibility(VISIBLE); - mStatusArea.setScaleX(statusAreaClockScale); - mStatusArea.setScaleY(statusAreaClockScale); - mStatusArea.setTranslateXFromClockDesign(statusAreaClockTranslateX); - mStatusArea.setTranslateYFromClockDesign(statusAreaClockTranslateY); - mStatusArea.setTranslateYFromClockSize(statusAreaYTranslation); - mSmallClockFrame.setTranslationY(statusAreaYTranslation); - return; - } - - mClockOutAnim = new AnimatorSet(); - mClockOutAnim.setDuration(CLOCK_OUT_MILLIS); - mClockOutAnim.setInterpolator(Interpolators.LINEAR); - mClockOutAnim.playTogether( - ObjectAnimator.ofFloat(out, ALPHA, 0f), - ObjectAnimator.ofFloat(out, TRANSLATION_Y, clockOutYTranslation)); - mClockOutAnim.addListener(new AnimatorListenerAdapter() { - public void onAnimationEnd(Animator animation) { - if (mClockOutAnim == animation) { - out.setVisibility(INVISIBLE); - mClockOutAnim = null; - } - } - }); - - in.setVisibility(View.VISIBLE); - mClockInAnim = new AnimatorSet(); - mClockInAnim.setDuration(CLOCK_IN_MILLIS); - mClockInAnim.setInterpolator(Interpolators.LINEAR_OUT_SLOW_IN); - mClockInAnim.playTogether( - ObjectAnimator.ofFloat(in, ALPHA, 1f), - ObjectAnimator.ofFloat(in, TRANSLATION_Y, clockInYTranslation)); - mClockInAnim.setStartDelay(CLOCK_IN_START_DELAY_MILLIS); - mClockInAnim.addListener(new AnimatorListenerAdapter() { - public void onAnimationEnd(Animator animation) { - if (mClockInAnim == animation) { - mClockInAnim = null; - } - } - }); - - mStatusAreaAnim = new AnimatorSet(); - mStatusAreaAnim.setStartDelay(STATUS_AREA_START_DELAY_MILLIS); - mStatusAreaAnim.setDuration( - useLargeClock ? STATUS_AREA_MOVE_UP_MILLIS : STATUS_AREA_MOVE_DOWN_MILLIS); - mStatusAreaAnim.setInterpolator(Interpolators.EMPHASIZED); - mStatusAreaAnim.playTogether( - ObjectAnimator.ofFloat(mStatusArea, TRANSLATE_Y_CLOCK_SIZE.getProperty(), - statusAreaYTranslation), - ObjectAnimator.ofFloat(mSmallClockFrame, TRANSLATION_Y, statusAreaYTranslation), - ObjectAnimator.ofFloat(mStatusArea, SCALE_X, statusAreaClockScale), - ObjectAnimator.ofFloat(mStatusArea, SCALE_Y, statusAreaClockScale), - ObjectAnimator.ofFloat(mStatusArea, TRANSLATE_X_CLOCK_DESIGN.getProperty(), - statusAreaClockTranslateX), - ObjectAnimator.ofFloat(mStatusArea, TRANSLATE_Y_CLOCK_DESIGN.getProperty(), - statusAreaClockTranslateY)); - mStatusAreaAnim.addListener(new AnimatorListenerAdapter() { - public void onAnimationEnd(Animator animation) { - if (mStatusAreaAnim == animation) { - mStatusAreaAnim = null; - } - } - }); - - mClockInAnim.start(); - mClockOutAnim.start(); - mStatusAreaAnim.start(); - } - - /** - * Display the desired clock and hide the other one - * - * @return true if desired clock appeared and false if it was already visible - */ - boolean switchToClock(@ClockSize int clockSize, boolean animate) { - if (mDisplayedClockSize != null && clockSize == mDisplayedClockSize) { - return false; - } - - // let's make sure clock is changed only after all views were laid out so we can - // translate them properly - if (mChildrenAreLaidOut) { - updateClockViews(clockSize == LARGE, animate); - } - - mDisplayedClockSize = clockSize; - return true; - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - super.onLayout(changed, l, t, r, b); - // TODO: b/305022530 - if (mClock != null && mClock.getConfig().getId().equals("DIGITAL_CLOCK_METRO")) { - mClock.getSmallClock().getEvents().onThemeChanged(mClock.getSmallClock().getTheme()); - mClock.getLargeClock().getEvents().onThemeChanged(mClock.getLargeClock().getTheme()); - } - - if (changed) { - post(() -> updateClockTargetRegions()); - } - - if (mSmartspace != null && mSmartspaceTop != mSmartspace.getTop() - && mDisplayedClockSize != null) { - mSmartspaceTop = mSmartspace.getTop(); - post(() -> updateClockViews(mDisplayedClockSize == LARGE, mAnimateOnLayout)); - } - - if (mDisplayedClockSize != null && !mChildrenAreLaidOut) { - post(() -> updateClockViews(mDisplayedClockSize == LARGE, mAnimateOnLayout)); - } - mChildrenAreLaidOut = true; - } - - public void dump(PrintWriter pw, String[] args) { - pw.println("KeyguardClockSwitch:"); - pw.println(" mSmallClockFrame = " + mSmallClockFrame); - if (mSmallClockFrame != null) { - pw.println(" mSmallClockFrame.alpha = " + mSmallClockFrame.getAlpha()); - } - pw.println(" mLargeClockFrame = " + mLargeClockFrame); - if (mLargeClockFrame != null) { - pw.println(" mLargeClockFrame.alpha = " + mLargeClockFrame.getAlpha()); - } - pw.println(" mStatusArea = " + mStatusArea); - pw.println(" mDisplayedClockSize = " + mDisplayedClockSize); - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java deleted file mode 100644 index 0e1eccc8231c..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ /dev/null @@ -1,676 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; -import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; - -import static com.android.keyguard.KeyguardClockSwitch.LARGE; -import static com.android.keyguard.KeyguardClockSwitch.SMALL; -import static com.android.systemui.Flags.smartspaceRelocateToBottom; - -import android.annotation.Nullable; -import android.database.ContentObserver; -import android.os.UserHandle; -import android.provider.Settings; -import android.text.TextUtils; -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; -import android.widget.LinearLayout; - -import androidx.annotation.NonNull; - -import com.android.systemui.Dumpable; -import com.android.systemui.dagger.qualifiers.Background; -import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.dump.DumpManager; -import com.android.systemui.keyguard.KeyguardUnlockAnimationController; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; -import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor; -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; -import com.android.systemui.keyguard.ui.view.InWindowLauncherUnlockAnimationManager; -import com.android.systemui.log.LogBuffer; -import com.android.systemui.log.core.LogLevel; -import com.android.systemui.log.dagger.KeyguardClockLog; -import com.android.systemui.plugins.clocks.ClockController; -import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.res.R; -import com.android.systemui.shared.clocks.ClockRegistry; -import com.android.systemui.shared.regionsampling.RegionSampler; -import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController; -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.phone.NotificationIconContainer; -import com.android.systemui.util.ViewController; -import com.android.systemui.util.concurrency.DelayableExecutor; -import com.android.systemui.util.settings.SecureSettings; - -import kotlinx.coroutines.DisposableHandle; - -import java.io.PrintWriter; -import java.util.Locale; -import java.util.concurrent.Executor; - -import javax.inject.Inject; - -/** - * Injectable controller for {@link KeyguardClockSwitch}. - */ -public class KeyguardClockSwitchController extends ViewController<KeyguardClockSwitch> - implements Dumpable { - private static final String TAG = "KeyguardClockSwitchController"; - - private final StatusBarStateController mStatusBarStateController; - private final ClockRegistry mClockRegistry; - private final KeyguardSliceViewController mKeyguardSliceViewController; - private final LockscreenSmartspaceController mSmartspaceController; - private final SecureSettings mSecureSettings; - private final DumpManager mDumpManager; - private final ClockEventController mClockEventController; - private final LogBuffer mLogBuffer; - private FrameLayout mSmallClockFrame; // top aligned clock - private FrameLayout mLargeClockFrame; // centered clock - - @KeyguardClockSwitch.ClockSize - private int mCurrentClockSize = SMALL; - - private int mKeyguardSmallClockTopMargin = 0; - private int mKeyguardLargeClockTopMargin = 0; - private int mKeyguardDateWeatherViewInvisibility = View.INVISIBLE; - private final ClockRegistry.ClockChangeListener mClockChangedListener; - - private ViewGroup mStatusArea; - - // If the SMARTSPACE flag is set, keyguard_slice_view is replaced by the following views. - private ViewGroup mDateWeatherView; - private View mWeatherView; - private View mSmartspaceView; - - private final KeyguardUnlockAnimationController mKeyguardUnlockAnimationController; - private final InWindowLauncherUnlockAnimationManager mInWindowLauncherUnlockAnimationManager; - - private boolean mShownOnSecondaryDisplay = false; - private boolean mOnlyClock = false; - private KeyguardInteractor mKeyguardInteractor; - private KeyguardClockInteractor mKeyguardClockInteractor; - private final DelayableExecutor mUiExecutor; - private final Executor mBgExecutor; - private boolean mCanShowDoubleLineClock = true; - private DisposableHandle mAodIconsBindHandle; - @Nullable private NotificationIconContainer mAodIconContainer; - - private final ContentObserver mDoubleLineClockObserver = new ContentObserver(null) { - @Override - public void onChange(boolean change) { - updateDoubleLineClock(); - } - }; - private final ContentObserver mShowWeatherObserver = new ContentObserver(null) { - @Override - public void onChange(boolean change) { - setWeatherVisibility(); - } - }; - - private final KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener - mKeyguardUnlockAnimationListener = - new KeyguardUnlockAnimationController.KeyguardUnlockAnimationListener() { - @Override - public void onUnlockAnimationFinished() { - // For performance reasons, reset this once the unlock animation ends. - setClipChildrenForUnlock(true); - } - }; - - @Inject - public KeyguardClockSwitchController( - KeyguardClockSwitch keyguardClockSwitch, - StatusBarStateController statusBarStateController, - ClockRegistry clockRegistry, - KeyguardSliceViewController keyguardSliceViewController, - LockscreenSmartspaceController smartspaceController, - KeyguardUnlockAnimationController keyguardUnlockAnimationController, - SecureSettings secureSettings, - @Main DelayableExecutor uiExecutor, - @Background Executor bgExecutor, - DumpManager dumpManager, - ClockEventController clockEventController, - @KeyguardClockLog LogBuffer logBuffer, - KeyguardInteractor keyguardInteractor, - KeyguardClockInteractor keyguardClockInteractor, - InWindowLauncherUnlockAnimationManager inWindowLauncherUnlockAnimationManager) { - super(keyguardClockSwitch); - mStatusBarStateController = statusBarStateController; - mClockRegistry = clockRegistry; - mKeyguardSliceViewController = keyguardSliceViewController; - mSmartspaceController = smartspaceController; - mSecureSettings = secureSettings; - mUiExecutor = uiExecutor; - mBgExecutor = bgExecutor; - mKeyguardUnlockAnimationController = keyguardUnlockAnimationController; - mDumpManager = dumpManager; - mClockEventController = clockEventController; - mLogBuffer = logBuffer; - mView.setLogBuffer(mLogBuffer); - mKeyguardInteractor = keyguardInteractor; - mKeyguardClockInteractor = keyguardClockInteractor; - mInWindowLauncherUnlockAnimationManager = inWindowLauncherUnlockAnimationManager; - - mClockChangedListener = new ClockRegistry.ClockChangeListener() { - @Override - public void onCurrentClockChanged() { - if (!MigrateClocksToBlueprint.isEnabled()) { - setClock(mClockRegistry.createCurrentClock()); - } - } - @Override - public void onAvailableClocksChanged() { } - }; - } - - /** - * When set, limits the information shown in an external display. - */ - public void setShownOnSecondaryDisplay(boolean shownOnSecondaryDisplay) { - mShownOnSecondaryDisplay = shownOnSecondaryDisplay; - } - - /** - * Mostly used for alternate displays, limit the information shown - * - * @deprecated use {@link KeyguardClockSwitchController#setShownOnSecondaryDisplay} - */ - @Deprecated - public void setOnlyClock(boolean onlyClock) { - mOnlyClock = onlyClock; - } - - /** - * Used for status view to pass the screen offset from parent view - */ - public void setLockscreenClockY(int clockY) { - if (mView.screenOffsetYPadding != clockY) { - mView.screenOffsetYPadding = clockY; - mView.post(() -> mView.updateClockTargetRegions()); - } - } - - /** - * Attach the controller to the view it relates to. - */ - @Override - protected void onInit() { - mKeyguardSliceViewController.init(); - - if (!MigrateClocksToBlueprint.isEnabled()) { - mSmallClockFrame = mView - .findViewById(com.android.systemui.customization.R.id.lockscreen_clock_view); - mLargeClockFrame = mView - .findViewById(com.android.systemui.customization.R.id.lockscreen_clock_view_large); - } - - if (!mOnlyClock) { - mDumpManager.unregisterDumpable(getClass().getSimpleName()); // unregister previous - mDumpManager.registerDumpable(getClass().getSimpleName(), this); - } - } - - public KeyguardClockSwitch getView() { - return mView; - } - - private void hideSliceViewAndNotificationIconContainer() { - View ksv = mView.findViewById(R.id.keyguard_slice_view); - ksv.setVisibility(View.GONE); - - View nic = mView.findViewById( - R.id.left_aligned_notification_icon_container); - if (nic != null) { - nic.setVisibility(View.GONE); - } - } - - @Override - protected void onViewAttached() { - mClockRegistry.registerClockChangeListener(mClockChangedListener); - setClock(mClockRegistry.createCurrentClock()); - if (!MigrateClocksToBlueprint.isEnabled()) { - mClockEventController.registerListeners(mView); - } - mKeyguardSmallClockTopMargin = - mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); - mKeyguardLargeClockTopMargin = - mView.getResources().getDimensionPixelSize( - com.android.systemui.customization.R.dimen.keyguard_large_clock_top_margin); - mKeyguardDateWeatherViewInvisibility = - mView.getResources().getInteger(R.integer.keyguard_date_weather_view_invisibility); - - if (mShownOnSecondaryDisplay) { - mView.setLargeClockOnSecondaryDisplay(true); - mClockEventController.setLargeClockOnSecondaryDisplay(true); - displayClock(LARGE, /* animate= */ false); - hideSliceViewAndNotificationIconContainer(); - return; - } - - if (mOnlyClock) { - hideSliceViewAndNotificationIconContainer(); - return; - } - mStatusArea = mView.findViewById(R.id.keyguard_status_area); - - mBgExecutor.execute(() -> { - mSecureSettings.registerContentObserverForUserSync( - Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, - false, /* notifyForDescendants */ - mDoubleLineClockObserver, - UserHandle.USER_ALL - ); - - mSecureSettings.registerContentObserverForUserSync( - Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED, - false, /* notifyForDescendants */ - mShowWeatherObserver, - UserHandle.USER_ALL - ); - }); - - updateDoubleLineClock(); - - mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener( - mKeyguardUnlockAnimationListener); - - if (mSmartspaceController.isEnabled()) { - View ksv = mView.findViewById(R.id.keyguard_slice_view); - int viewIndex = mStatusArea.indexOfChild(ksv); - ksv.setVisibility(View.GONE); - - removeViewsFromStatusArea(); - addSmartspaceView(); - // TODO(b/261757708): add content observer for the Settings toggle and add/remove - // weather according to the Settings. - if (mSmartspaceController.isDateWeatherDecoupled()) { - addDateWeatherView(); - } - } - if (!MigrateClocksToBlueprint.isEnabled()) { - setDateWeatherVisibility(); - setWeatherVisibility(); - } - - } - - int getNotificationIconAreaHeight() { - if (MigrateClocksToBlueprint.isEnabled()) { - return 0; - } else { - return mAodIconContainer != null ? mAodIconContainer.getHeight() : 0; - } - } - - @Nullable - View getAodNotifIconContainer() { - return mAodIconContainer; - } - - @Override - protected void onViewDetached() { - mClockRegistry.unregisterClockChangeListener(mClockChangedListener); - if (!MigrateClocksToBlueprint.isEnabled()) { - mClockEventController.unregisterListeners(); - } - setClock(null); - - mBgExecutor.execute(() -> { - mSecureSettings.unregisterContentObserverSync(mDoubleLineClockObserver); - mSecureSettings.unregisterContentObserverSync(mShowWeatherObserver); - }); - - mKeyguardUnlockAnimationController.removeKeyguardUnlockAnimationListener( - mKeyguardUnlockAnimationListener); - } - - void onLocaleListChanged() { - if (mSmartspaceController.isEnabled()) { - removeViewsFromStatusArea(); - addSmartspaceView(); - if (mSmartspaceController.isDateWeatherDecoupled()) { - mDateWeatherView.removeView(mWeatherView); - addDateWeatherView(); - setDateWeatherVisibility(); - setWeatherVisibility(); - } - } - } - - private void addDateWeatherView() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - mDateWeatherView = (ViewGroup) mSmartspaceController.buildAndConnectDateView(mView); - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - MATCH_PARENT, WRAP_CONTENT); - mStatusArea.addView(mDateWeatherView, 0, lp); - int startPadding = getContext().getResources().getDimensionPixelSize( - R.dimen.below_clock_padding_start); - int endPadding = getContext().getResources().getDimensionPixelSize( - R.dimen.below_clock_padding_end); - mDateWeatherView.setPaddingRelative(startPadding, 0, endPadding, 0); - addWeatherView(); - } - - private void addWeatherView() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - WRAP_CONTENT, WRAP_CONTENT); - mWeatherView = mSmartspaceController.buildAndConnectWeatherView(mView); - // Place weather right after the date, before the extras - final int index = mDateWeatherView.getChildCount() == 0 ? 0 : 1; - mDateWeatherView.addView(mWeatherView, index, lp); - mWeatherView.setPaddingRelative(0, 0, 4, 0); - } - - private void addSmartspaceView() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - - if (smartspaceRelocateToBottom()) { - return; - } - - mSmartspaceView = mSmartspaceController.buildAndConnectView(mView); - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( - MATCH_PARENT, WRAP_CONTENT); - mStatusArea.addView(mSmartspaceView, 0, 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); - - mKeyguardUnlockAnimationController.setLockscreenSmartspace(mSmartspaceView); - mInWindowLauncherUnlockAnimationManager.setLockscreenSmartspace(mSmartspaceView); - - mView.setSmartspace(mSmartspaceView); - } - - /** - * Apply dp changes on configuration change - */ - public void onConfigChanged() { - mView.onConfigChanged(); - mKeyguardSmallClockTopMargin = - mView.getResources().getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); - mKeyguardLargeClockTopMargin = - mView.getResources().getDimensionPixelSize( - com.android.systemui.customization.R.dimen.keyguard_large_clock_top_margin); - mKeyguardDateWeatherViewInvisibility = - mView.getResources().getInteger(R.integer.keyguard_date_weather_view_invisibility); - mView.updateClockTargetRegions(); - setDateWeatherVisibility(); - } - - /** - * Enable or disable split shade center specific positioning - */ - public void setSplitShadeCentered(boolean splitShadeCentered) { - mView.setSplitShadeCentered(splitShadeCentered); - } - - /** - * Set if the split shade is enabled - */ - public void setSplitShadeEnabled(boolean splitShadeEnabled) { - mSmartspaceController.setSplitShadeEnabled(splitShadeEnabled); - } - - /** - * Set which clock should be displayed on the keyguard. The other one will be automatically - * hidden. - */ - public void displayClock(@KeyguardClockSwitch.ClockSize int clockSize, boolean animate) { - if (!mCanShowDoubleLineClock && clockSize == KeyguardClockSwitch.LARGE) { - return; - } - - mCurrentClockSize = clockSize; - setDateWeatherVisibility(); - - ClockController clock = getClock(); - boolean appeared = mView.switchToClock(clockSize, animate); - if (clock != null && animate && appeared && clockSize == LARGE) { - mUiExecutor.executeDelayed(() -> clock.getLargeClock().getAnimations().enter(), - KeyguardClockSwitch.CLOCK_IN_START_DELAY_MILLIS); - } - } - - /** - * Animates the clock view between folded and unfolded states - */ - public void animateFoldToAod(float foldFraction) { - ClockController clock = getClock(); - if (clock != null) { - clock.getSmallClock().getAnimations().fold(foldFraction); - clock.getLargeClock().getAnimations().fold(foldFraction); - } - } - - /** - * Refresh clock. Called in response to TIME_TICK broadcasts. - */ - void refresh() { - mLogBuffer.log(TAG, LogLevel.INFO, "refresh"); - if (mSmartspaceController != null) { - mSmartspaceController.requestSmartspaceUpdate(); - } - ClockController clock = getClock(); - if (clock != null) { - clock.getSmallClock().getEvents().onTimeTick(); - clock.getLargeClock().getEvents().onTimeTick(); - } - } - - /** - * Update position of the view, with optional animation. Move the slice view and the clock - * slightly towards the center in order to prevent burn-in. Y positioning occurs at the - * view parent level. The large clock view will scale instead of using x position offsets, to - * keep the clock centered. - */ - void updatePosition(int x, float scale, AnimationProperties props, boolean animate) { - x = getCurrentLayoutDirection() == View.LAYOUT_DIRECTION_RTL ? -x : x; - if (!MigrateClocksToBlueprint.isEnabled()) { - PropertyAnimator.setProperty(mSmallClockFrame, AnimatableProperty.TRANSLATION_X, - x, props, animate); - PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_X, - scale, props, animate); - PropertyAnimator.setProperty(mLargeClockFrame, AnimatableProperty.SCALE_Y, - scale, props, animate); - - } - - if (mStatusArea != null) { - PropertyAnimator.setProperty(mStatusArea, KeyguardStatusAreaView.TRANSLATE_X_AOD, - x, props, animate); - } - } - - /** - * Get y-bottom position of the currently visible clock on the keyguard. - * We can't directly getBottom() because clock changes positions in AOD for burn-in - */ - int getClockBottom(int statusBarHeaderHeight) { - ClockController clock = getClock(); - if (clock == null) { - return 0; - } - - if (MigrateClocksToBlueprint.isEnabled()) { - return 0; - } - - if (mLargeClockFrame.getVisibility() == View.VISIBLE) { - // This gets the expected clock bottom if mLargeClockFrame had a top margin, but it's - // top margin only contributed to height and didn't move the top of the view (as this - // was the computation previously). As we no longer have a margin, we add this back - // into the computation manually. - int frameHeight = mLargeClockFrame.getHeight(); - int clockHeight = clock.getLargeClock().getView().getHeight(); - return frameHeight / 2 + clockHeight / 2 + mKeyguardLargeClockTopMargin / -2; - } else { - int clockHeight = clock.getSmallClock().getView().getHeight(); - return clockHeight + statusBarHeaderHeight + mKeyguardSmallClockTopMargin; - } - } - - /** - * Get the height of the currently visible clock on the keyguard. - */ - int getClockHeight() { - ClockController clock = getClock(); - if (clock == null) { - return 0; - } - - if (mLargeClockFrame.getVisibility() == View.VISIBLE) { - return clock.getLargeClock().getView().getHeight(); - } else { - return clock.getSmallClock().getView().getHeight(); - } - } - - boolean isClockTopAligned() { - if (MigrateClocksToBlueprint.isEnabled()) { - return mKeyguardClockInteractor.getClockSize().getValue().getLegacyValue() == LARGE; - } - return mLargeClockFrame.getVisibility() != View.VISIBLE; - } - - private void setClock(ClockController clock) { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - if (clock != null && mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.INFO, "New Clock"); - } - - mClockEventController.setClock(clock); - mView.setClock(clock, mStatusBarStateController.getState()); - setDateWeatherVisibility(); - } - - @Nullable - public ClockController getClock() { - if (MigrateClocksToBlueprint.isEnabled()) { - return mKeyguardClockInteractor.getCurrentClock().getValue(); - } else { - return mClockEventController.getClock(); - } - } - - private int getCurrentLayoutDirection() { - return TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()); - } - - private void updateDoubleLineClock() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - mCanShowDoubleLineClock = mSecureSettings.getIntForUser( - Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, mView.getResources() - .getInteger(com.android.internal.R.integer.config_doublelineClockDefault), - UserHandle.USER_CURRENT) != 0; - - if (!mCanShowDoubleLineClock) { - mUiExecutor.execute(() -> displayClock(KeyguardClockSwitch.SMALL, - /* animate */ true)); - } - } - - private void setDateWeatherVisibility() { - if (mDateWeatherView != null) { - mUiExecutor.execute(() -> { - mDateWeatherView.setVisibility(clockHasCustomWeatherDataDisplay() - ? mKeyguardDateWeatherViewInvisibility - : View.VISIBLE); - }); - } - } - - private void setWeatherVisibility() { - if (mWeatherView != null) { - mUiExecutor.execute(() -> { - mWeatherView.setVisibility( - mSmartspaceController.isWeatherEnabled() ? View.VISIBLE : View.GONE); - }); - } - } - - /** - * Sets the clipChildren property on relevant views, to allow the smartspace to draw out of - * bounds during the unlock transition. - */ - private void setClipChildrenForUnlock(boolean clip) { - if (mStatusArea != null) { - mStatusArea.setClipChildren(clip); - } - } - - @Override - public void dump(@NonNull PrintWriter pw, @NonNull String[] args) { - pw.println("currentClockSizeLarge: " + (mCurrentClockSize == LARGE)); - pw.println("mCanShowDoubleLineClock: " + mCanShowDoubleLineClock); - mView.dump(pw, args); - mClockRegistry.dump(pw, args); - ClockController clock = getClock(); - if (clock != null) { - clock.dump(pw); - } - final RegionSampler smallRegionSampler = mClockEventController.getSmallRegionSampler(); - if (smallRegionSampler != null) { - smallRegionSampler.dump(pw); - } - final RegionSampler largeRegionSampler = mClockEventController.getLargeRegionSampler(); - if (largeRegionSampler != null) { - largeRegionSampler.dump(pw); - } - } - - /** Returns true if the clock handles the display of weather information */ - private boolean clockHasCustomWeatherDataDisplay() { - ClockController clock = getClock(); - if (clock == null) { - return false; - } - - return ((mCurrentClockSize == LARGE) ? clock.getLargeClock() : clock.getSmallClock()) - .getConfig().getHasCustomWeatherDataDisplay(); - } - - private void removeViewsFromStatusArea() { - for (int i = mStatusArea.getChildCount() - 1; i >= 0; i--) { - final View childView = mStatusArea.getChildAt(i); - if (childView.getTag(R.id.tag_smartspace_view) != null) { - mStatusArea.removeViewAt(i); - } - } - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java index 63088aaf7ff4..42460617d476 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSliceViewController.java @@ -22,7 +22,6 @@ import android.app.PendingIntent; import android.net.Uri; import android.os.Handler; import android.os.Trace; -import android.provider.Settings; import android.util.Log; import android.view.Display; import android.view.View; @@ -38,7 +37,6 @@ import androidx.slice.widget.RowContent; import androidx.slice.widget.SliceContent; import androidx.slice.widget.SliceLiveData; -import com.android.keyguard.dagger.KeyguardStatusViewScope; import com.android.systemui.Dumpable; import com.android.systemui.Flags; import com.android.systemui.dagger.qualifiers.Background; @@ -48,7 +46,6 @@ import com.android.systemui.keyguard.KeyguardSliceProvider; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.settings.DisplayTracker; import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.tuner.TunerService; import com.android.systemui.util.ViewController; import java.io.PrintWriter; @@ -59,7 +56,6 @@ import java.util.stream.Collectors; import javax.inject.Inject; /** Controller for a {@link KeyguardSliceView}. */ -@KeyguardStatusViewScope public class KeyguardSliceViewController extends ViewController<KeyguardSliceView> implements Dumpable { private static final String TAG = "KeyguardSliceViewCtrl"; @@ -68,7 +64,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie private final Handler mBgHandler; private final ActivityStarter mActivityStarter; private final ConfigurationController mConfigurationController; - private final TunerService mTunerService; private final DumpManager mDumpManager; private final DisplayTracker mDisplayTracker; private int mDisplayId; @@ -77,8 +72,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie private Slice mSlice; private Map<View, PendingIntent> mClickActions; - TunerService.Tunable mTunable = (key, newValue) -> setupUri(newValue); - ConfigurationController.ConfigurationListener mConfigurationListener = new ConfigurationController.ConfigurationListener() { @Override @@ -116,7 +109,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie KeyguardSliceView keyguardSliceView, ActivityStarter activityStarter, ConfigurationController configurationController, - TunerService tunerService, DumpManager dumpManager, DisplayTracker displayTracker) { super(keyguardSliceView); @@ -124,7 +116,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie mBgHandler = bgHandler; mActivityStarter = activityStarter; mConfigurationController = configurationController; - mTunerService = tunerService; mDumpManager = dumpManager; mDisplayTracker = displayTracker; } @@ -135,7 +126,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie if (display != null) { mDisplayId = display.getDisplayId(); } - mTunerService.addTunable(mTunable, Settings.Secure.KEYGUARD_SLICE_URI); // Make sure we always have the most current slice if (mDisplayId == mDisplayTracker.getDefaultDisplayId() && mLiveData != null) { mLiveData.observeForever(mObserver); @@ -153,7 +143,6 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie if (mDisplayId == mDisplayTracker.getDefaultDisplayId()) { mLiveData.removeObserver(mObserver); } - mTunerService.removeTunable(mTunable); mConfigurationController.removeCallback(mConfigurationListener); mDumpManager.unregisterDumpable( TAG + "@" + Integer.toHexString( diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusAreaView.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusAreaView.kt deleted file mode 100644 index 11b1a7d00056..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusAreaView.kt +++ /dev/null @@ -1,118 +0,0 @@ -package com.android.keyguard - -import android.content.Context -import android.util.AttributeSet -import android.util.FloatProperty -import android.widget.LinearLayout -import com.android.systemui.res.R -import com.android.systemui.statusbar.notification.AnimatableProperty - -class KeyguardStatusAreaView( - context: Context, - attrs: AttributeSet? = null, -) : LinearLayout(context, attrs) { - var translateXFromClockDesign = 0f - get() = field - set(value) { - field = value - translationX = translateXFromAod + translateXFromClockDesign + translateXFromUnfold - } - - var translateXFromAod = 0f - get() = field - set(value) { - field = value - translationX = translateXFromAod + translateXFromClockDesign + translateXFromUnfold - } - - var translateXFromUnfold = 0F - get() = field - set(value) { - field = value - translationX = translateXFromAod + translateXFromClockDesign + translateXFromUnfold - } - - var translateYFromClockSize = 0f - get() = field - set(value) { - field = value - translationY = value + translateYFromClockDesign - } - - var translateYFromClockDesign = 0f - get() = field - set(value) { - field = value - translationY = value + translateYFromClockSize - } - - companion object { - @JvmField - val TRANSLATE_X_CLOCK_DESIGN = - AnimatableProperty.from( - object : FloatProperty<KeyguardStatusAreaView>("TranslateXClockDesign") { - override fun setValue(view: KeyguardStatusAreaView, value: Float) { - view.translateXFromClockDesign = value - } - - override fun get(view: KeyguardStatusAreaView): Float { - return view.translateXFromClockDesign - } - }, - R.id.translate_x_clock_design_animator_tag, - R.id.translate_x_clock_design_animator_start_tag, - R.id.translate_x_clock_design_animator_end_tag - ) - - @JvmField - val TRANSLATE_X_AOD = - AnimatableProperty.from( - object : FloatProperty<KeyguardStatusAreaView>("TranslateXAod") { - override fun setValue(view: KeyguardStatusAreaView, value: Float) { - view.translateXFromAod = value - } - - override fun get(view: KeyguardStatusAreaView): Float { - return view.translateXFromAod - } - }, - R.id.translate_x_aod_animator_tag, - R.id.translate_x_aod_animator_start_tag, - R.id.translate_x_aod_animator_end_tag - ) - - @JvmField - val TRANSLATE_Y_CLOCK_SIZE = - AnimatableProperty.from( - object : FloatProperty<KeyguardStatusAreaView>("TranslateYClockSize") { - override fun setValue(view: KeyguardStatusAreaView, value: Float) { - view.translateYFromClockSize = value - } - - override fun get(view: KeyguardStatusAreaView): Float { - return view.translateYFromClockSize - } - }, - R.id.translate_y_clock_size_animator_tag, - R.id.translate_y_clock_size_animator_start_tag, - R.id.translate_y_clock_size_animator_end_tag - ) - - @JvmField - val TRANSLATE_Y_CLOCK_DESIGN = - AnimatableProperty.from( - object : FloatProperty<KeyguardStatusAreaView>("TranslateYClockDesign") { - override fun setValue(view: KeyguardStatusAreaView, value: Float) { - view.translateYFromClockDesign = value - } - - override fun get(view: KeyguardStatusAreaView): Float { - return view.translateYFromClockDesign - } - }, - R.id.translate_y_clock_design_animator_tag, - R.id.translate_y_clock_design_animator_start_tag, - R.id.translate_y_clock_design_animator_end_tag - ) - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusContainer.kt b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusContainer.kt deleted file mode 100644 index 298eff27060b..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusContainer.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.android.keyguard - -import android.content.Context -import android.graphics.Canvas -import android.util.AttributeSet -import android.widget.LinearLayout - -class KeyguardStatusContainer( - context: Context, - attrs: AttributeSet, -) : LinearLayout(context, attrs) { - private var drawAlpha: Int = 255 - - protected override fun onSetAlpha(alpha: Int): Boolean { - drawAlpha = alpha - return true - } - - protected override fun dispatchDraw(canvas: Canvas) { - KeyguardClockFrame.saveCanvasAlpha(this, canvas, drawAlpha) { super.dispatchDraw(canvas) } - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java deleted file mode 100644 index 073f33fe5245..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static java.util.Collections.emptySet; - -import android.content.Context; -import android.graphics.Canvas; -import android.os.Build; -import android.os.Trace; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewPropertyAnimator; -import android.widget.GridLayout; - -import com.android.systemui.res.R; -import com.android.systemui.shade.TouchLogger; -import com.android.systemui.statusbar.CrossFadeHelper; - -import java.util.Set; - -/** - * View consisting of: - * - keyguard clock - * - media player (split shade mode only) - */ -public class KeyguardStatusView extends GridLayout { - private static final boolean DEBUG = KeyguardConstants.DEBUG; - private static final String TAG = "KeyguardStatusView"; - - private ViewGroup mStatusViewContainer; - private KeyguardClockSwitch mClockView; - private KeyguardSliceView mKeyguardSlice; - private View mMediaHostContainer; - - private int mDrawAlpha = 255; - private float mDarkAmount = 0; - - public KeyguardStatusView(Context context) { - this(context, null, 0); - } - - public KeyguardStatusView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public KeyguardStatusView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - mStatusViewContainer = findViewById(R.id.status_view_container); - - mClockView = findViewById(R.id.keyguard_clock_container); - if (KeyguardClockAccessibilityDelegate.isNeeded(mContext)) { - mClockView.setAccessibilityDelegate(new KeyguardClockAccessibilityDelegate(mContext)); - } - - mKeyguardSlice = findViewById(R.id.keyguard_slice_view); - - mMediaHostContainer = findViewById(R.id.status_view_media_container); - - updateDark(); - } - - void setDarkAmount(float darkAmount) { - if (mDarkAmount == darkAmount) { - return; - } - mDarkAmount = darkAmount; - CrossFadeHelper.fadeOut(mMediaHostContainer, darkAmount); - updateDark(); - } - - void updateDark() { - mKeyguardSlice.setDarkAmount(mDarkAmount); - } - - /** Sets a translationY value on every child view except for the media view. */ - public void setChildrenTranslationY(float translationY, boolean excludeMedia) { - setChildrenTranslationYExcluding(translationY, - excludeMedia ? Set.of(mMediaHostContainer) : emptySet()); - } - - /** Sets a translationY value on every view except for the views in the provided set. */ - private void setChildrenTranslationYExcluding(float translationY, Set<View> excludedViews) { - for (int i = 0; i < mStatusViewContainer.getChildCount(); i++) { - final View child = mStatusViewContainer.getChildAt(i); - - if (!excludedViews.contains(child)) { - child.setTranslationY(translationY); - } - } - } - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) { - return TouchLogger.logDispatchTouch(TAG, ev, super.dispatchTouchEvent(ev)); - } - - @Override - public ViewPropertyAnimator animate() { - if (Build.IS_DEBUGGABLE) { - throw new IllegalArgumentException( - "KeyguardStatusView does not support ViewPropertyAnimator. " - + "Use PropertyAnimator instead."); - } - return super.animate(); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - Trace.beginSection("KeyguardStatusView#onMeasure"); - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - Trace.endSection(); - } - - @Override - protected boolean onSetAlpha(int alpha) { - mDrawAlpha = alpha; - return true; - } - - @Override - protected void dispatchDraw(Canvas canvas) { - KeyguardClockFrame.saveCanvasAlpha( - this, canvas, mDrawAlpha, - c -> { - super.dispatchDraw(c); - return kotlin.Unit.INSTANCE; - }); - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java deleted file mode 100644 index 0684824ea0b8..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +++ /dev/null @@ -1,664 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static androidx.constraintlayout.widget.ConstraintSet.END; -import static androidx.constraintlayout.widget.ConstraintSet.PARENT_ID; - -import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION; -import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow; - -import android.animation.Animator; -import android.animation.ValueAnimator; -import android.annotation.Nullable; -import android.content.res.Configuration; -import android.graphics.Rect; -import android.transition.ChangeBounds; -import android.transition.Transition; -import android.transition.TransitionListenerAdapter; -import android.transition.TransitionManager; -import android.transition.TransitionSet; -import android.transition.TransitionValues; -import android.util.Slog; -import android.view.View; -import android.view.ViewGroup; -import android.widget.FrameLayout; - -import androidx.annotation.NonNull; -import androidx.annotation.VisibleForTesting; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.constraintlayout.widget.ConstraintSet; -import androidx.viewpager.widget.ViewPager; - -import com.android.app.animation.Interpolators; -import com.android.internal.jank.InteractionJankMonitor; -import com.android.keyguard.KeyguardClockSwitch.ClockSize; -import com.android.keyguard.logging.KeyguardLogger; -import com.android.systemui.animation.ViewHierarchyAnimator; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; -import com.android.systemui.plugins.clocks.ClockController; -import com.android.systemui.power.domain.interactor.PowerInteractor; -import com.android.systemui.power.shared.model.ScreenPowerState; -import com.android.systemui.res.R; -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.phone.DozeParameters; -import com.android.systemui.statusbar.phone.ScreenOffAnimationController; -import com.android.systemui.statusbar.policy.ConfigurationController; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.util.ViewController; - -import kotlin.coroutines.CoroutineContext; -import kotlin.coroutines.EmptyCoroutineContext; - -import javax.inject.Inject; - -/** - * Injectable controller for {@link KeyguardStatusView}. - */ -public class KeyguardStatusViewController extends ViewController<KeyguardStatusView> { - private static final boolean DEBUG = KeyguardConstants.DEBUG; - @VisibleForTesting static final String TAG = "KeyguardStatusViewController"; - private static final long STATUS_AREA_HEIGHT_ANIMATION_MILLIS = 133; - - /** - * Duration to use for the animator when the keyguard status view alignment changes, and a - * custom clock animation is in use. - */ - private static final int KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION = 1000; - - public static final AnimationProperties CLOCK_ANIMATION_PROPERTIES = - new AnimationProperties().setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); - - private final KeyguardSliceViewController mKeyguardSliceViewController; - private final KeyguardClockSwitchController mKeyguardClockSwitchController; - private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; - private final ConfigurationController mConfigurationController; - private final KeyguardVisibilityHelper mKeyguardVisibilityHelper; - private final InteractionJankMonitor mInteractionJankMonitor; - private final Rect mClipBounds = new Rect(); - private final KeyguardInteractor mKeyguardInteractor; - private final PowerInteractor mPowerInteractor; - private final DozeParameters mDozeParameters; - - private View mStatusArea = null; - private ValueAnimator mStatusAreaHeightAnimator = null; - - private Boolean mSplitShadeEnabled = false; - private Boolean mStatusViewCentered = true; - - private final TransitionListenerAdapter mKeyguardStatusAlignmentTransitionListener = - new TransitionListenerAdapter() { - @Override - public void onTransitionCancel(Transition transition) { - mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION); - } - - @Override - public void onTransitionEnd(Transition transition) { - mInteractionJankMonitor.end(CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION); - } - }; - - private final View.OnLayoutChangeListener mStatusAreaLayoutChangeListener = - new View.OnLayoutChangeListener() { - @Override - public void onLayoutChange(View v, - int left, int top, int right, int bottom, - int oldLeft, int oldTop, int oldRight, int oldBottom - ) { - if (!mDozeParameters.getAlwaysOn()) { - return; - } - - int oldHeight = oldBottom - oldTop; - int diff = v.getHeight() - oldHeight; - if (diff == 0) { - return; - } - - int startValue = -1 * diff; - long duration = STATUS_AREA_HEIGHT_ANIMATION_MILLIS; - if (mStatusAreaHeightAnimator != null - && mStatusAreaHeightAnimator.isRunning()) { - duration += mStatusAreaHeightAnimator.getDuration() - - mStatusAreaHeightAnimator.getCurrentPlayTime(); - startValue += (int) mStatusAreaHeightAnimator.getAnimatedValue(); - mStatusAreaHeightAnimator.cancel(); - mStatusAreaHeightAnimator = null; - } - - mStatusAreaHeightAnimator = ValueAnimator.ofInt(startValue, 0); - mStatusAreaHeightAnimator.setDuration(duration); - final View nic = mKeyguardClockSwitchController.getAodNotifIconContainer(); - if (nic != null) { - mStatusAreaHeightAnimator.addUpdateListener(anim -> { - nic.setTranslationY((int) anim.getAnimatedValue()); - }); - } - mStatusAreaHeightAnimator.start(); - } - }; - - @Inject - public KeyguardStatusViewController( - KeyguardStatusView keyguardStatusView, - KeyguardSliceViewController keyguardSliceViewController, - KeyguardClockSwitchController keyguardClockSwitchController, - KeyguardStateController keyguardStateController, - KeyguardUpdateMonitor keyguardUpdateMonitor, - ConfigurationController configurationController, - DozeParameters dozeParameters, - ScreenOffAnimationController screenOffAnimationController, - KeyguardLogger logger, - InteractionJankMonitor interactionJankMonitor, - KeyguardInteractor keyguardInteractor, - PowerInteractor powerInteractor) { - super(keyguardStatusView); - mKeyguardSliceViewController = keyguardSliceViewController; - mKeyguardClockSwitchController = keyguardClockSwitchController; - mKeyguardUpdateMonitor = keyguardUpdateMonitor; - mConfigurationController = configurationController; - mDozeParameters = dozeParameters; - mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, keyguardStateController, - dozeParameters, screenOffAnimationController, /* animateYPos= */ true, - logger.getBuffer()); - mInteractionJankMonitor = interactionJankMonitor; - mKeyguardInteractor = keyguardInteractor; - mPowerInteractor = powerInteractor; - } - - @Override - public void onInit() { - mKeyguardClockSwitchController.init(); - final View mediaHostContainer = mView.findViewById(R.id.status_view_media_container); - if (mediaHostContainer != null) { - mKeyguardClockSwitchController.getView().addOnLayoutChangeListener( - (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { - if (!mSplitShadeEnabled - || mKeyguardClockSwitchController.getView().getSplitShadeCentered() - // Note: isKeyguardVisible() returns false after Launcher -> AOD. - || !mKeyguardUpdateMonitor.isKeyguardVisible()) { - return; - } - - int oldHeight = oldBottom - oldTop; - if (v.getHeight() == oldHeight) return; - - if (mediaHostContainer.getVisibility() != View.VISIBLE - // If the media is appearing, also don't do the transition. - || mediaHostContainer.getHeight() == 0) { - return; - } - - ViewHierarchyAnimator.Companion.animateNextUpdate(mediaHostContainer, - Interpolators.STANDARD, /* duration= */ 500L, - /* animateChildren= */ false); - }); - } - - if (MigrateClocksToBlueprint.isEnabled()) { - startCoroutines(EmptyCoroutineContext.INSTANCE); - mView.setVisibility(View.GONE); - } - } - - void startCoroutines(CoroutineContext context) { - collectFlow(mView, mKeyguardInteractor.getDozeTimeTick(), - (Long millis) -> { - dozeTimeTick(); - }, context); - - collectFlow(mView, mPowerInteractor.getScreenPowerState(), - (ScreenPowerState powerState) -> { - if (powerState == ScreenPowerState.SCREEN_TURNING_ON) { - dozeTimeTick(); - } - }, context); - } - - public KeyguardStatusView getView() { - return mView; - } - - @Override - protected void onViewAttached() { - mStatusArea = mView.findViewById(R.id.keyguard_status_area); - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - - mStatusArea.addOnLayoutChangeListener(mStatusAreaLayoutChangeListener); - mKeyguardUpdateMonitor.registerCallback(mInfoCallback); - mConfigurationController.addCallback(mConfigurationListener); - } - - @Override - protected void onViewDetached() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - - mStatusArea.removeOnLayoutChangeListener(mStatusAreaLayoutChangeListener); - mKeyguardUpdateMonitor.removeCallback(mInfoCallback); - mConfigurationController.removeCallback(mConfigurationListener); - } - - /** Sets the StatusView as shown on an external display. */ - public void setDisplayedOnSecondaryDisplay() { - mKeyguardClockSwitchController.setShownOnSecondaryDisplay(true); - } - - /** - * Updates views on doze time tick. - */ - public void dozeTimeTick() { - refreshTime(); - mKeyguardSliceViewController.refresh(); - } - - /** - * Set which clock should be displayed on the keyguard. The other one will be automatically - * hidden. - */ - public void displayClock(@ClockSize int clockSize, boolean animate) { - mKeyguardClockSwitchController.displayClock(clockSize, animate); - } - - /** - * Performs fold to aod animation of the clocks (changes font weight from bold to thin). - * This animation is played when AOD is enabled and foldable device is fully folded, it is - * displayed on the outer screen - * @param foldFraction current fraction of fold animation complete - */ - public void animateFoldToAod(float foldFraction) { - mKeyguardClockSwitchController.animateFoldToAod(foldFraction); - } - - /** - * Sets a translationY on the views on the keyguard, except on the media view. - */ - public void setTranslationY(float translationY, boolean excludeMedia) { - mView.setChildrenTranslationY(translationY, excludeMedia); - } - - /** - * Set keyguard status view alpha. - */ - public void setAlpha(float alpha) { - if (!mKeyguardVisibilityHelper.isVisibilityAnimating()) { - mView.setAlpha(alpha); - } - } - - /** - * Update the pivot position based on the parent view - */ - public void updatePivot(float parentWidth, float parentHeight) { - mView.setPivotX(parentWidth / 2f); - mView.setPivotY(mKeyguardClockSwitchController.getClockHeight() / 2f); - } - - /** - * Get the height of the keyguard status view without the notification icon area, as that's - * only visible on AOD. - * - * We internally animate height changes to the status area to prevent discontinuities in the - * doze animation introduced by the height suddenly changing due to smartpace. - */ - public int getLockscreenHeight() { - int heightAnimValue = mStatusAreaHeightAnimator == null ? 0 : - (int) mStatusAreaHeightAnimator.getAnimatedValue(); - return mView.getHeight() + heightAnimValue - - mKeyguardClockSwitchController.getNotificationIconAreaHeight(); - } - - /** - * Get y-bottom position of the currently visible clock. - */ - public int getClockBottom(int statusBarHeaderHeight) { - return mKeyguardClockSwitchController.getClockBottom(statusBarHeaderHeight); - } - - /** - * @return true if the currently displayed clock is top aligned (as opposed to center aligned) - */ - public boolean isClockTopAligned() { - return mKeyguardClockSwitchController.isClockTopAligned(); - } - - /** - * Pass top margin from ClockPositionAlgorithm in NotificationPanelViewController - * Use for clock view in LS to compensate for top margin to align to the screen - * Regardless of translation from AOD and unlock gestures - */ - public void setLockscreenClockY(int clockY) { - mKeyguardClockSwitchController.setLockscreenClockY(clockY); - } - - /** - * Set whether the view accessibility importance mode. - */ - public void setStatusAccessibilityImportance(int mode) { - mView.setImportantForAccessibility(mode); - } - - @VisibleForTesting - void setProperty(AnimatableProperty property, float value, boolean animate) { - PropertyAnimator.setProperty(mView, property, value, CLOCK_ANIMATION_PROPERTIES, animate); - } - - /** - * Update position of the view with an optional animation - */ - public void updatePosition(int x, int y, float scale, boolean animate) { - setProperty(AnimatableProperty.Y, y, animate); - - ClockController clock = mKeyguardClockSwitchController.getClock(); - if (clock != null && clock.getConfig().getUseAlternateSmartspaceAODTransition()) { - // If requested, scale the entire view instead of just the clock view - mKeyguardClockSwitchController.updatePosition(x, 1f /* scale */, - CLOCK_ANIMATION_PROPERTIES, animate); - setProperty(AnimatableProperty.SCALE_X, scale, animate); - setProperty(AnimatableProperty.SCALE_Y, scale, animate); - } else { - mKeyguardClockSwitchController.updatePosition(x, scale, - CLOCK_ANIMATION_PROPERTIES, animate); - setProperty(AnimatableProperty.SCALE_X, 1f, animate); - setProperty(AnimatableProperty.SCALE_Y, 1f, animate); - } - } - - /** - * Set the visibility of the keyguard status view based on some new state. - */ - public void setKeyguardStatusViewVisibility( - int statusBarState, - boolean keyguardFadingAway, - boolean goingToFullShade, - int oldStatusBarState) { - mKeyguardVisibilityHelper.setViewVisibility( - statusBarState, keyguardFadingAway, goingToFullShade, oldStatusBarState); - } - - private void refreshTime() { - mKeyguardClockSwitchController.refresh(); - } - - private final ConfigurationController.ConfigurationListener mConfigurationListener = - new ConfigurationController.ConfigurationListener() { - @Override - public void onLocaleListChanged() { - refreshTime(); - mKeyguardClockSwitchController.onLocaleListChanged(); - } - - @Override - public void onConfigChanged(Configuration newConfig) { - mKeyguardClockSwitchController.onConfigChanged(); - } - }; - - private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { - @Override - public void onTimeChanged() { - Slog.v(TAG, "onTimeChanged"); - refreshTime(); - } - - @Override - public void onKeyguardVisibilityChanged(boolean visible) { - if (visible) { - if (DEBUG) Slog.v(TAG, "refresh statusview visible:true"); - refreshTime(); - } - } - }; - - /** - * Rect that specifies how KSV should be clipped, on its parent's coordinates. - */ - public void setClipBounds(Rect clipBounds) { - if (clipBounds != null) { - mClipBounds.set(clipBounds.left, (int) (clipBounds.top - mView.getY()), - clipBounds.right, (int) (clipBounds.bottom - mView.getY())); - mView.setClipBounds(mClipBounds); - } else { - mView.setClipBounds(null); - } - } - - /** - * Returns true if the large clock will block the notification shelf in AOD - */ - public boolean isLargeClockBlockingNotificationShelf() { - ClockController clock = mKeyguardClockSwitchController.getClock(); - return clock != null && clock.getLargeClock().getConfig().getHasCustomWeatherDataDisplay(); - } - - /** - * Set if the split shade is enabled - */ - public void setSplitShadeEnabled(boolean enabled) { - mKeyguardClockSwitchController.setSplitShadeEnabled(enabled); - mSplitShadeEnabled = enabled; - } - - /** - * Updates the alignment of the KeyguardStatusView and animates the transition if requested. - */ - public void updateAlignment( - ConstraintLayout layout, - boolean splitShadeEnabled, - boolean shouldBeCentered, - boolean animate) { - if (MigrateClocksToBlueprint.isEnabled()) { - mKeyguardInteractor.setClockShouldBeCentered(shouldBeCentered); - } else { - mKeyguardClockSwitchController.setSplitShadeCentered( - splitShadeEnabled && shouldBeCentered); - } - if (mStatusViewCentered == shouldBeCentered) { - return; - } - - mStatusViewCentered = shouldBeCentered; - if (layout == null) { - return; - } - - ConstraintSet constraintSet = new ConstraintSet(); - constraintSet.clone(layout); - int guideline; - if (MigrateClocksToBlueprint.isEnabled()) { - guideline = R.id.split_shade_guideline; - } else { - guideline = R.id.qs_edge_guideline; - } - - int statusConstraint = shouldBeCentered ? PARENT_ID : guideline; - constraintSet.connect(R.id.keyguard_status_view, END, statusConstraint, END); - if (!animate) { - constraintSet.applyTo(layout); - return; - } - - mInteractionJankMonitor.begin(mView, CUJ_LOCKSCREEN_CLOCK_MOVE_ANIMATION); - /* This transition blocks any layout changes while running. For that reason - * special logic with setting visibility was added to {@link BcSmartspaceView#setDozing} - * for split shade to avoid jump of the media object. */ - ChangeBounds transition = new ChangeBounds(); - if (splitShadeEnabled) { - // Excluding media from the transition on split-shade, as it doesn't transition - // horizontally properly. - transition.excludeTarget(R.id.status_view_media_container, true); - - // Exclude smartspace viewpager and its children from the transition. - // - Each step of the transition causes the ViewPager to invoke resize, - // which invokes scrolling to the recalculated position. The scrolling - // actions are congested, resulting in kinky translation, and - // delay in settling to the final position. (http://b/281620564#comment1) - // - Also, the scrolling is unnecessary in the transition. We just want - // the viewpager to stay on the same page. - // - Exclude by Class type instead of resource id, since the resource id - // isn't available for all devices, and probably better to exclude all - // ViewPagers any way. - transition.excludeTarget(ViewPager.class, true); - transition.excludeChildren(ViewPager.class, true); - } - - transition.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); - transition.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); - - ClockController clock = mKeyguardClockSwitchController.getClock(); - boolean customClockAnimation = clock != null - && clock.getLargeClock().getConfig().getHasCustomPositionUpdatedAnimation(); - // When migrateClocksToBlueprint is on, customized clock animation is conducted in - // KeyguardClockViewBinder - if (customClockAnimation && !MigrateClocksToBlueprint.isEnabled()) { - // Find the clock, so we can exclude it from this transition. - FrameLayout clockContainerView = mView.findViewById( - com.android.systemui.customization.R.id.lockscreen_clock_view_large); - - // The clock container can sometimes be null. If it is, just fall back to the - // old animation rather than setting up the custom animations. - if (clockContainerView == null || clockContainerView.getChildCount() == 0) { - transition.addListener(mKeyguardStatusAlignmentTransitionListener); - TransitionManager.beginDelayedTransition(layout, transition); - } else { - View clockView = clockContainerView.getChildAt(0); - - TransitionSet set = new TransitionSet(); - set.addTransition(transition); - - SplitShadeTransitionAdapter adapter = - new SplitShadeTransitionAdapter(mKeyguardClockSwitchController); - - // Use linear here, so the actual clock can pick its own interpolator. - adapter.setInterpolator(Interpolators.LINEAR); - adapter.setDuration(KEYGUARD_STATUS_VIEW_CUSTOM_CLOCK_MOVE_DURATION); - adapter.addTarget(clockView); - set.addTransition(adapter); - - if (splitShadeEnabled) { - // Exclude smartspace viewpager and its children from the transition set. - // - This is necessary in addition to excluding them from the - // ChangeBounds child transition. - // - Without this, the viewpager is scrolled to the new position - // (corresponding to its end size) before the size change is realized. - // Note that the size change is realized at the end of the ChangeBounds - // transition. With the "prescrolling", the viewpager ends up in a weird - // position, then recovers smoothly during the transition, and ends at - // the position for the current page. - // - Exclude by Class type instead of resource id, since the resource id - // isn't available for all devices, and probably better to exclude all - // ViewPagers any way. - set.excludeTarget(ViewPager.class, true); - set.excludeChildren(ViewPager.class, true); - } - - set.addListener(mKeyguardStatusAlignmentTransitionListener); - TransitionManager.beginDelayedTransition(layout, set); - } - } else { - transition.addListener(mKeyguardStatusAlignmentTransitionListener); - TransitionManager.beginDelayedTransition(layout, transition); - } - - constraintSet.applyTo(layout); - } - - public ClockController getClockController() { - return mKeyguardClockSwitchController.getClock(); - } - - String getInstanceName() { - return TAG + "#" + hashCode(); - } - - @VisibleForTesting - static class SplitShadeTransitionAdapter extends Transition { - private static final String PROP_BOUNDS_LEFT = "splitShadeTransitionAdapter:boundsLeft"; - private static final String PROP_BOUNDS_RIGHT = "splitShadeTransitionAdapter:boundsRight"; - private static final String PROP_X_IN_WINDOW = "splitShadeTransitionAdapter:xInWindow"; - private static final String[] TRANSITION_PROPERTIES = { - PROP_BOUNDS_LEFT, PROP_BOUNDS_RIGHT, PROP_X_IN_WINDOW}; - - private final KeyguardClockSwitchController mController; - - @VisibleForTesting - SplitShadeTransitionAdapter(KeyguardClockSwitchController controller) { - mController = controller; - } - - private void captureValues(TransitionValues transitionValues) { - transitionValues.values.put(PROP_BOUNDS_LEFT, transitionValues.view.getLeft()); - transitionValues.values.put(PROP_BOUNDS_RIGHT, transitionValues.view.getRight()); - int[] locationInWindowTmp = new int[2]; - transitionValues.view.getLocationInWindow(locationInWindowTmp); - transitionValues.values.put(PROP_X_IN_WINDOW, locationInWindowTmp[0]); - } - - @Override - public void captureEndValues(TransitionValues transitionValues) { - captureValues(transitionValues); - } - - @Override - public void captureStartValues(TransitionValues transitionValues) { - captureValues(transitionValues); - } - - @Nullable - @Override - public Animator createAnimator(@NonNull ViewGroup sceneRoot, - @Nullable TransitionValues startValues, - @Nullable TransitionValues endValues) { - if (startValues == null || endValues == null) { - return null; - } - ValueAnimator anim = ValueAnimator.ofFloat(0, 1); - - int fromLeft = (int) startValues.values.get(PROP_BOUNDS_LEFT); - int fromWindowX = (int) startValues.values.get(PROP_X_IN_WINDOW); - int toWindowX = (int) endValues.values.get(PROP_X_IN_WINDOW); - // Using windowX, to determine direction, instead of left, as in RTL the difference of - // toLeft - fromLeft is always positive, even when moving left. - int direction = toWindowX - fromWindowX > 0 ? 1 : -1; - - anim.addUpdateListener(animation -> { - ClockController clock = mController.getClock(); - if (clock == null) { - return; - } - - clock.getLargeClock().getAnimations() - .onPositionUpdated(fromLeft, direction, animation.getAnimatedFraction()); - }); - - return anim; - } - - @Override - public String[] getTransitionProperties() { - return TRANSITION_PROPERTIES; - } - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java b/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java deleted file mode 100644 index fd8b6d5f05e1..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardVisibilityHelper.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (C) 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static com.android.systemui.statusbar.StatusBarState.KEYGUARD; -import static com.android.systemui.statusbar.StatusBarState.SHADE; - -import android.util.Property; -import android.view.View; - -import com.android.app.animation.Interpolators; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; -import com.android.systemui.log.LogBuffer; -import com.android.systemui.log.core.LogLevel; -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.phone.DozeParameters; -import com.android.systemui.statusbar.phone.ScreenOffAnimationController; -import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.util.Assert; - -import com.google.errorprone.annotations.CompileTimeConstant; - -import java.util.function.Consumer; - -/** - * Helper class for updating visibility of keyguard views based on keyguard and status bar state. - * This logic is shared by both the keyguard status view and the keyguard user switcher. - */ -public class KeyguardVisibilityHelper { - private static final String TAG = "KeyguardVisibilityHelper"; - - private View mView; - private final KeyguardStateController mKeyguardStateController; - private final DozeParameters mDozeParameters; - private final ScreenOffAnimationController mScreenOffAnimationController; - private boolean mAnimateYPos; - private boolean mKeyguardViewVisibilityAnimating; - private boolean mLastOccludedState = false; - private final AnimationProperties mAnimationProperties = new AnimationProperties(); - private final LogBuffer mLogBuffer; - - public KeyguardVisibilityHelper(View view, - KeyguardStateController keyguardStateController, - DozeParameters dozeParameters, - ScreenOffAnimationController screenOffAnimationController, - boolean animateYPos, - LogBuffer logBuffer) { - mView = view; - mKeyguardStateController = keyguardStateController; - mDozeParameters = dozeParameters; - mScreenOffAnimationController = screenOffAnimationController; - mAnimateYPos = animateYPos; - mLogBuffer = logBuffer; - } - - private void log(@CompileTimeConstant String message) { - if (mLogBuffer != null) { - mLogBuffer.log(TAG, LogLevel.DEBUG, message); - } - } - - public boolean isVisibilityAnimating() { - return mKeyguardViewVisibilityAnimating; - } - - /** - * Set the visibility of a keyguard view based on some new state. - */ - public void setViewVisibility( - int statusBarState, - boolean keyguardFadingAway, - boolean goingToFullShade, - int oldStatusBarState) { - if (MigrateClocksToBlueprint.isEnabled()) { - log("Ignoring KeyguardVisibilityelper, migrateClocksToBlueprint flag on"); - return; - } - Assert.isMainThread(); - PropertyAnimator.cancelAnimation(mView, AnimatableProperty.ALPHA); - boolean isOccluded = mKeyguardStateController.isOccluded(); - mKeyguardViewVisibilityAnimating = false; - - if ((!keyguardFadingAway && oldStatusBarState == KEYGUARD - && statusBarState != KEYGUARD) || goingToFullShade) { - mKeyguardViewVisibilityAnimating = true; - - AnimationProperties animProps = new AnimationProperties() - .setCustomInterpolator(View.ALPHA, Interpolators.ALPHA_OUT) - .setAnimationEndAction(mSetGoneEndAction); - if (keyguardFadingAway) { - animProps - .setDelay(mKeyguardStateController.getKeyguardFadingAwayDelay()) - .setDuration(mKeyguardStateController.getShortenedFadingAwayDuration()); - log("goingToFullShade && keyguardFadingAway"); - } else { - animProps.setDelay(0).setDuration(160); - log("goingToFullShade && !keyguardFadingAway"); - } - if (MigrateClocksToBlueprint.isEnabled()) { - log("Using LockscreenToGoneTransition 1"); - } else { - PropertyAnimator.setProperty( - mView, AnimatableProperty.ALPHA, 0f, animProps, true /* animate */); - } - } else if (oldStatusBarState == StatusBarState.SHADE_LOCKED && statusBarState == KEYGUARD) { - mView.setVisibility(View.VISIBLE); - mKeyguardViewVisibilityAnimating = true; - mView.setAlpha(0f); - PropertyAnimator.setProperty( - mView, AnimatableProperty.ALPHA, 1f, - new AnimationProperties() - .setDelay(0) - .setDuration(320) - .setCustomInterpolator(View.ALPHA, Interpolators.ALPHA_IN) - .setAnimationEndAction( - property -> mSetVisibleEndRunnable.run()), - true /* animate */); - log("keyguardFadingAway transition w/ Y Aniamtion"); - } else if (statusBarState == KEYGUARD) { - // Sometimes, device will be unlocked and then locked very quickly. - // keyguardFadingAway hasn't been set to false cause unlock animation hasn't finished - // So we should not animate keyguard fading away in this case (when oldState is SHADE) - if (oldStatusBarState != SHADE) { - log("statusBarState == KEYGUARD && oldStatusBarState != SHADE"); - } else { - log("statusBarState == KEYGUARD && oldStatusBarState == SHADE"); - } - - if (keyguardFadingAway && oldStatusBarState != SHADE) { - mKeyguardViewVisibilityAnimating = true; - AnimationProperties animProps = new AnimationProperties() - .setDelay(0) - .setCustomInterpolator(View.ALPHA, Interpolators.FAST_OUT_LINEAR_IN) - .setAnimationEndAction(mSetInvisibleEndAction); - if (mAnimateYPos) { - float target = mView.getY() - mView.getHeight() * 0.05f; - int delay = 0; - int duration = 125; - // We animate the Y property separately using the PropertyAnimator, as the panel - // view also needs to update the end position. - mAnimationProperties.setDuration(duration).setDelay(delay); - PropertyAnimator.cancelAnimation(mView, AnimatableProperty.Y); - PropertyAnimator.setProperty(mView, AnimatableProperty.Y, target, - mAnimationProperties, - true /* animate */); - animProps.setDuration(duration) - .setDelay(delay); - log("keyguardFadingAway transition w/ Y Aniamtion"); - } else { - log("keyguardFadingAway transition w/o Y Animation"); - } - PropertyAnimator.setProperty( - mView, AnimatableProperty.ALPHA, 0f, - animProps, - true /* animate */); - } else if (mScreenOffAnimationController.shouldAnimateInKeyguard()) { - if (MigrateClocksToBlueprint.isEnabled()) { - log("Using GoneToAodTransition"); - mKeyguardViewVisibilityAnimating = false; - } else { - log("ScreenOff transition"); - mKeyguardViewVisibilityAnimating = true; - - // Ask the screen off animation controller to animate the keyguard visibility - // for us since it may need to be cancelled due to keyguard lifecycle events. - mScreenOffAnimationController.animateInKeyguard(mView, mSetVisibleEndRunnable); - } - } else { - log("Direct set Visibility to VISIBLE"); - mView.setVisibility(View.VISIBLE); - } - } else { - if (MigrateClocksToBlueprint.isEnabled()) { - log("Using LockscreenToGoneTransition 2"); - } else { - log("Direct set Visibility to GONE"); - mView.setVisibility(View.GONE); - mView.setAlpha(1f); - } - } - - mLastOccludedState = isOccluded; - } - - private final Consumer<Property> mSetInvisibleEndAction = new Consumer<>() { - @Override - public void accept(Property property) { - mKeyguardViewVisibilityAnimating = false; - mView.setVisibility(View.INVISIBLE); - log("Callback Set Visibility to INVISIBLE"); - } - }; - - private final Consumer<Property> mSetGoneEndAction = new Consumer<>() { - @Override - public void accept(Property property) { - mKeyguardViewVisibilityAnimating = false; - mView.setVisibility(View.GONE); - log("CallbackSet Visibility to GONE"); - } - }; - - private final Runnable mSetVisibleEndRunnable = () -> { - mKeyguardViewVisibilityAnimating = false; - mView.setVisibility(View.VISIBLE); - log("Callback Set Visibility to VISIBLE"); - }; -} diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewComponent.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewComponent.java index 91dd1d643c96..9a4717064c56 100644 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewComponent.java +++ b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusBarViewComponent.java @@ -16,7 +16,6 @@ package com.android.keyguard.dagger; -import com.android.keyguard.KeyguardStatusViewController; import com.android.systemui.shade.ShadeViewStateProvider; import com.android.systemui.statusbar.phone.KeyguardStatusBarView; import com.android.systemui.statusbar.phone.KeyguardStatusBarViewController; @@ -25,9 +24,7 @@ import dagger.BindsInstance; import dagger.Subcomponent; /** - * Subcomponent for helping work with KeyguardStatusView and its children. - * - * TODO: unify this with {@link KeyguardStatusViewComponent} + * Subcomponent for helping work with KeyguardStatusBarView and its children. */ @Subcomponent(modules = {KeyguardStatusBarViewModule.class}) @KeyguardStatusBarViewScope @@ -41,6 +38,5 @@ public interface KeyguardStatusBarViewComponent { shadeViewStateProvider); } - /** Builds a {@link KeyguardStatusViewController}. */ KeyguardStatusBarViewController getKeyguardStatusBarViewController(); } diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewComponent.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewComponent.java deleted file mode 100644 index f3014f1ecc58..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewComponent.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2020 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.dagger; - -import android.view.Display; - -import com.android.keyguard.KeyguardClockSwitchController; -import com.android.keyguard.KeyguardStatusView; -import com.android.keyguard.KeyguardStatusViewController; - -import dagger.BindsInstance; -import dagger.Subcomponent; - -/** - * Subcomponent for helping work with KeyguardStatusView and its children. - * - * TODO: unify this with {@link KeyguardStatusBarViewComponent} - */ -@Subcomponent(modules = {KeyguardStatusViewModule.class, KeyguardDisplayModule.class}) -@KeyguardStatusViewScope -public interface KeyguardStatusViewComponent { - /** Simple factory for {@link KeyguardStatusViewComponent}. */ - @Subcomponent.Factory - interface Factory { - /** Creates {@link KeyguardStatusViewComponent} for a given display. */ - KeyguardStatusViewComponent build( - @BindsInstance KeyguardStatusView presentation, - @BindsInstance Display display - ); - } - - /** Builds a {@link com.android.keyguard.KeyguardClockSwitchController}. */ - KeyguardClockSwitchController getKeyguardClockSwitchController(); - - /** Builds a {@link com.android.keyguard.KeyguardStatusViewController}. */ - KeyguardStatusViewController getKeyguardStatusViewController(); -} diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java deleted file mode 100644 index 7575f0e80d1c..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewModule.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2020 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.dagger; - -import com.android.keyguard.KeyguardClockSwitch; -import com.android.keyguard.KeyguardSliceView; -import com.android.keyguard.KeyguardStatusView; -import com.android.systemui.res.R; - -import dagger.Module; -import dagger.Provides; - -/** Dagger module for {@link KeyguardStatusViewComponent}. */ -@Module -public abstract class KeyguardStatusViewModule { - @Provides - static KeyguardClockSwitch getKeyguardClockSwitch(KeyguardStatusView keyguardPresentation) { - return keyguardPresentation.findViewById(R.id.keyguard_clock_container); - } - - @Provides - static KeyguardSliceView getKeyguardSliceView(KeyguardClockSwitch keyguardClockSwitch) { - return keyguardClockSwitch.findViewById(R.id.keyguard_slice_view); - } -} diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewScope.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewScope.java deleted file mode 100644 index 6c2c9f2d8e2f..000000000000 --- a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardStatusViewScope.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2020 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.dagger; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; - -import javax.inject.Scope; - -/** - * Scope annotation for singleton items within the {@link KeyguardStatusViewComponent}. - */ -@Documented -@Retention(RUNTIME) -@Scope -public @interface KeyguardStatusViewScope {} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt index d0065c8b06c6..644deb0d358c 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt @@ -170,7 +170,7 @@ constructor( private val notificationShadeWindowController: NotificationShadeWindowController, private val powerManager: PowerManager, private val wallpaperManager: WallpaperManager, - private val deviceStateManager: DeviceStateManager + private val deviceStateManager: DeviceStateManager, ) : KeyguardStateController.Callback, ISysuiUnlockAnimationController.Stub() { interface KeyguardUnlockAnimationListener { @@ -194,7 +194,7 @@ constructor( playingCannedAnimation: Boolean, isWakeAndUnlockNotFromDream: Boolean, unlockAnimationStartDelay: Long, - unlockAnimationDuration: Long + unlockAnimationDuration: Long, ) {} /** @@ -250,7 +250,7 @@ constructor( */ override fun setLauncherUnlockController( activityClass: String, - callback: ILauncherUnlockAnimationController? + callback: ILauncherUnlockAnimationController?, ) { launcherActivityClass = activityClass launcherUnlockController = callback @@ -370,7 +370,7 @@ constructor( Log.d( TAG, "skip finishSurfaceBehindRemoteAnimation" + - " surfaceBehindAlpha=$surfaceBehindAlpha" + " surfaceBehindAlpha=$surfaceBehindAlpha", ) } } @@ -387,7 +387,7 @@ constructor( addUpdateListener { valueAnimator: ValueAnimator -> setWallpaperAppearAmount( valueAnimator.animatedValue as Float, - openingWallpaperTargets + openingWallpaperTargets, ) } addListener( @@ -418,7 +418,7 @@ constructor( addUpdateListener { valueAnimator: ValueAnimator -> setWallpaperAppearAmount( valueAnimator.animatedValue as Float, - closingWallpaperTargets + closingWallpaperTargets, ) } } @@ -488,7 +488,7 @@ constructor( Log.wtf( TAG, " !notificationShadeWindowController.isLaunchingActivity: " + - "${!notificationShadeWindowController.isLaunchingActivity}" + "${!notificationShadeWindowController.isLaunchingActivity}", ) Log.wtf(TAG, " launcherUnlockController != null: ${launcherUnlockController != null}") Log.wtf(TAG, " !isFoldable(context): ${!isDeviceFoldable(resources, deviceStateManager)}") @@ -516,7 +516,7 @@ constructor( try { launcherUnlockController?.setUnlockAmount( 1f, - biometricUnlockControllerLazy.get().isWakeAndUnlock /* forceIfAnimating */ + biometricUnlockControllerLazy.get().isWakeAndUnlock, /* forceIfAnimating */ ) } catch (e: DeadObjectException) { Log.e( @@ -524,7 +524,7 @@ constructor( "launcherUnlockAnimationController was dead, but non-null in " + "onKeyguardGoingAwayChanged(). Catching exception as this should mean " + "Launcher is in the process of being destroyed, but the IPC to System UI " + - "telling us hasn't arrived yet." + "telling us hasn't arrived yet.", ) } } @@ -569,7 +569,7 @@ constructor( offset( 0, (lockscreenSmartspace as? BcSmartspaceDataPlugin.SmartspaceView) - ?.currentCardTopPadding ?: 0 + ?.currentCardTopPadding ?: 0, ) } } @@ -583,7 +583,7 @@ constructor( launcherUnlockController?.prepareForUnlock( willUnlockWithSmartspaceTransition, /* willAnimateSmartspace */ lockscreenSmartspaceBounds, /* lockscreenSmartspaceBounds */ - selectedPage /* selectedPage */ + selectedPage, /* selectedPage */ ) launcherPreparedForUnlock = true @@ -611,7 +611,7 @@ constructor( openingWallpapers: Array<RemoteAnimationTarget>, closingWallpapers: Array<RemoteAnimationTarget>, startTime: Long, - requestedShowSurfaceBehindKeyguard: Boolean + requestedShowSurfaceBehindKeyguard: Boolean, ) { if (surfaceTransactionApplier == null) { surfaceTransactionApplier = @@ -650,7 +650,7 @@ constructor( launcherUnlockController?.playUnlockAnimation( true, unlockAnimationDurationMs() + cannedUnlockStartDelayMs(), - 0 /* startDelay */ + 0, /* startDelay */ ) } catch (e: DeadObjectException) { // Hello! If you are here investigating a bug where Launcher is blank (no icons) @@ -663,7 +663,7 @@ constructor( "launcherUnlockAnimationController was dead, but non-null. " + "Catching exception as this should mean Launcher is in the process " + "of being destroyed, but the IPC to System UI telling us hasn't " + - "arrived yet." + "arrived yet.", ) } @@ -689,7 +689,7 @@ constructor( playingCannedUnlockAnimation /* playingCannedAnimation */, isWakeAndUnlockNotFromDream /* isWakeAndUnlockNotFromDream */, cannedUnlockStartDelayMs() /* unlockStartDelay */, - LAUNCHER_ICONS_ANIMATION_DURATION_MS /* unlockAnimationDuration */ + LAUNCHER_ICONS_ANIMATION_DURATION_MS, /* unlockAnimationDuration */ ) } @@ -742,7 +742,7 @@ constructor( Log.wtf( TAG, "Launcher is prepared for unlock, so we should have started the " + - "in-window animation, however we apparently did not." + "in-window animation, however we apparently did not.", ) logInWindowAnimationConditions() } @@ -762,7 +762,7 @@ constructor( launcherUnlockController?.playUnlockAnimation( true /* unlocked */, LAUNCHER_ICONS_ANIMATION_DURATION_MS /* duration */, - cannedUnlockStartDelayMs() /* startDelay */ + cannedUnlockStartDelayMs(), /* startDelay */ ) } catch (e: DeadObjectException) { // Hello! If you are here investigating a bug where Launcher is blank (no icons) @@ -775,7 +775,7 @@ constructor( "launcherUnlockAnimationController was dead, but non-null. " + "Catching exception as this should mean Launcher is in the process " + "of being destroyed, but the IPC to System UI telling us hasn't " + - "arrived yet." + "arrived yet.", ) } @@ -805,7 +805,7 @@ constructor( Log.e( TAG, "Finish keyguard exit animation delayed Runnable ran, but we are " + - "showing and not going away." + "showing and not going away.", ) return@postDelayed } @@ -819,7 +819,7 @@ constructor( .exitKeyguardAndFinishSurfaceBehindRemoteAnimation(false /* cancelled */) } }, - cannedUnlockStartDelayMs() + cannedUnlockStartDelayMs(), ) } @@ -998,7 +998,7 @@ constructor( surfaceBehindMatrix.setTranslate( surfaceBehindRemoteAnimationTarget.screenSpaceBounds.left.toFloat(), surfaceBehindRemoteAnimationTarget.screenSpaceBounds.top.toFloat() + - surfaceHeight * SURFACE_BEHIND_START_TRANSLATION_Y * (1f - amount) + surfaceHeight * SURFACE_BEHIND_START_TRANSLATION_Y * (1f - amount), ) // Scale up from a point at the center-bottom of the surface. @@ -1006,7 +1006,7 @@ constructor( scaleFactor, scaleFactor, keyguardViewController.viewRootImpl.width / 2f, - surfaceHeight * SURFACE_BEHIND_SCALE_PIVOT_Y + surfaceHeight * SURFACE_BEHIND_SCALE_PIVOT_Y, ) // SyncRtSurfaceTransactionApplier cannot apply transaction when the target view is @@ -1141,14 +1141,14 @@ constructor( if (!KeyguardWmStateRefactor.isEnabled) { keyguardViewController.hide( surfaceBehindRemoteAnimationStartTime, - 0 /* fadeOutDuration */ + 0, /* fadeOutDuration */ ) } } else { Log.i( TAG, "#hideKeyguardViewAfterRemoteAnimation called when keyguard view is not " + - "showing. Ignoring..." + "showing. Ignoring...", ) } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt index e8eb4976194a..ff06837da4e6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt @@ -18,19 +18,7 @@ package com.android.systemui.keyguard import android.content.Context -import android.view.LayoutInflater -import android.view.View -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.runtime.remember -import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.ComposeView -import com.android.compose.animation.scene.MutableSceneTransitionLayoutState -import com.android.compose.animation.scene.SceneKey -import com.android.compose.animation.scene.SceneTransitionLayout import com.android.internal.jank.InteractionJankMonitor -import com.android.keyguard.KeyguardStatusView -import com.android.keyguard.KeyguardStatusViewController -import com.android.keyguard.dagger.KeyguardStatusViewComponent import com.android.systemui.CoreStartable import com.android.systemui.Flags.lightRevealMigration import com.android.systemui.biometrics.ui.binder.DeviceEntryUnlockTrackerViewBinder @@ -43,8 +31,6 @@ import com.android.systemui.keyguard.shared.model.LockscreenSceneBlueprint import com.android.systemui.keyguard.ui.binder.KeyguardBlueprintViewBinder import com.android.systemui.keyguard.ui.binder.KeyguardRootViewBinder import com.android.systemui.keyguard.ui.binder.LightRevealScrimViewBinder -import com.android.systemui.keyguard.ui.composable.LockscreenContent -import com.android.systemui.keyguard.ui.composable.blueprint.ComposableLockscreenSceneBlueprint import com.android.systemui.keyguard.ui.view.KeyguardIndicationArea import com.android.systemui.keyguard.ui.view.KeyguardRootView import com.android.systemui.keyguard.ui.viewmodel.KeyguardBlueprintViewModel @@ -55,7 +41,6 @@ import com.android.systemui.keyguard.ui.viewmodel.LightRevealScrimViewModel import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel import com.android.systemui.keyguard.ui.viewmodel.OccludingAppDeviceEntryMessageViewModel import com.android.systemui.plugins.FalsingManager -import com.android.systemui.res.R import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.ShadeDisplayAware import com.android.systemui.shade.domain.interactor.ShadeInteractor @@ -87,7 +72,6 @@ constructor( private val occludingAppDeviceEntryMessageViewModel: OccludingAppDeviceEntryMessageViewModel, private val chipbarCoordinator: ChipbarCoordinator, private val keyguardBlueprintViewModel: KeyguardBlueprintViewModel, - private val keyguardStatusViewComponentFactory: KeyguardStatusViewComponent.Factory, @ShadeDisplayAware private val configuration: ConfigurationState, @ShadeDisplayAware private val context: Context, private val keyguardIndicationController: KeyguardIndicationController, @@ -115,23 +99,6 @@ constructor( private var rootViewHandle: DisposableHandle? = null private var indicationAreaHandle: DisposableHandle? = null - var keyguardStatusViewController: KeyguardStatusViewController? = null - get() { - if (field == null) { - val statusViewComponent = - keyguardStatusViewComponentFactory.build( - LayoutInflater.from(context).inflate(R.layout.keyguard_status_view, null) - as KeyguardStatusView, - context.display, - ) - val controller = statusViewComponent.keyguardStatusViewController - controller.init() - field = controller - } - - return field - } - override fun start() { bindKeyguardRootView() initializeViews() @@ -192,42 +159,5 @@ constructor( ) } - private fun createLockscreen( - context: Context, - viewModelFactory: LockscreenContentViewModel.Factory, - notificationScrimViewModelFactory: NotificationLockscreenScrimViewModel.Factory, - blueprints: Set<@JvmSuppressWildcards LockscreenSceneBlueprint>, - ): View { - val sceneBlueprints = - blueprints.mapNotNull { it as? ComposableLockscreenSceneBlueprint }.toSet() - return ComposeView(context).apply { - setContent { - // STL is used solely to provide a SceneScope to enable us to invoke SceneScope - // composables. - val currentScene = remember { SceneKey("root-view-scene-key") } - val state = remember { MutableSceneTransitionLayoutState(currentScene) } - SceneTransitionLayout(state) { - scene(currentScene) { - with( - LockscreenContent( - viewModelFactory = viewModelFactory, - notificationScrimViewModelFactory = - notificationScrimViewModelFactory, - blueprints = sceneBlueprints, - clockInteractor = clockInteractor, - ) - ) { - Content(modifier = Modifier.fillMaxSize()) - } - } - } - } - } - } - - /** - * Temporary, to allow NotificationPanelViewController to use the same instance while code is - * migrated: b/288242803 - */ fun getKeyguardRootView() = keyguardRootView } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java index 496c6fb96b39..d95a126fe4bd 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/dagger/KeyguardModule.java @@ -32,7 +32,6 @@ import com.android.keyguard.ViewMediatorCallback; import com.android.keyguard.dagger.KeyguardDisplayModule; import com.android.keyguard.dagger.KeyguardQsUserSwitchComponent; import com.android.keyguard.dagger.KeyguardStatusBarViewComponent; -import com.android.keyguard.dagger.KeyguardStatusViewComponent; import com.android.keyguard.mediator.ScreenOnCoordinator; import com.android.systemui.CoreStartable; import com.android.systemui.animation.ActivityTransitionAnimator; @@ -106,8 +105,7 @@ import java.util.concurrent.Executor; @ExperimentalCoroutinesApi @Module(subcomponents = { KeyguardQsUserSwitchComponent.class, - KeyguardStatusBarViewComponent.class, - KeyguardStatusViewComponent.class}, + KeyguardStatusBarViewComponent.class}, includes = { DeviceEntryIconTransitionModule.class, FalsingModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt index d18d6dce2e94..f792935e67f3 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardClockInteractor.kt @@ -19,7 +19,6 @@ package com.android.systemui.keyguard.domain.interactor import android.util.Log import com.android.keyguard.ClockEventController -import com.android.keyguard.KeyguardClockSwitch import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.keyguard.data.repository.KeyguardClockRepository @@ -121,9 +120,6 @@ constructor( keyguardInteractor.clockShouldBeCentered } - fun setClockSize(@KeyguardClockSwitch.ClockSize size: Int) = - setClockSize(ClockSize.fromLegacy(size)) - fun setClockSize(size: ClockSize) { SceneContainerFlag.assertInLegacyMode() keyguardClockRepository.setClockSize(size) @@ -134,7 +130,7 @@ constructor( return clock?.let { clock -> clock.config.id } ?: run { Log.e(TAG, "No clock is available") - KeyguardClockSwitch.MISSING_CLOCK_ID + "MISSING_CLOCK_ID" } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index 85306e67994c..0193d7cba616 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -27,7 +27,6 @@ import com.android.systemui.common.shared.model.NotificationContainerBounds import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application -import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.data.repository.KeyguardRepository import com.android.systemui.keyguard.shared.model.BiometricUnlockModel import com.android.systemui.keyguard.shared.model.CameraLaunchSourceModel @@ -122,13 +121,11 @@ constructor( // We offset the placeholder bounds by the configured top margin to account for // legacy placement behavior within notifications for splitshade. emit( - if (MigrateClocksToBlueprint.isEnabled) { - if (useSplitShade) { - bounds.copy(bottom = bounds.bottom - keyguardSplitShadeTopMargin) - } else { - bounds - } - } else bounds + if (useSplitShade) { + bounds.copy(bottom = bounds.bottom - keyguardSplitShadeTopMargin) + } else { + bounds + } ) } .stateIn( @@ -340,9 +337,6 @@ constructor( /** The approximate location on the screen of the face unlock sensor, if one is available. */ val faceSensorLocation: Flow<Point?> = repository.faceSensorLocation - @Deprecated("Use the relevant TransitionViewModel") - val keyguardAlpha: Flow<Float> = repository.keyguardAlpha - /** Temporary shim for fading out content when the brightness slider is used */ @Deprecated("SceneContainer uses NotificationStackAppearanceInteractor") val panelAlpha: StateFlow<Float> = repository.panelAlpha.asStateFlow() @@ -483,10 +477,6 @@ constructor( repository.setQuickSettingsVisible(isVisible) } - fun setAlpha(alpha: Float) { - repository.setKeyguardAlpha(alpha) - } - fun setPanelAlpha(alpha: Float) { repository.setPanelAlpha(alpha) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/ToAodFoldTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/ToAodFoldTransitionInteractor.kt index 21b9e537cc18..24929b60952a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/ToAodFoldTransitionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/ToAodFoldTransitionInteractor.kt @@ -16,7 +16,6 @@ package com.android.systemui.keyguard.domain.interactor -import android.view.ViewGroup import com.android.systemui.dagger.SysUISingleton import com.android.systemui.shade.NotificationPanelViewController import com.android.systemui.shade.ShadeFoldAnimator @@ -25,16 +24,12 @@ import javax.inject.Inject @SysUISingleton class ToAodFoldTransitionInteractor @Inject -constructor( - private val keyguardClockInteractor: KeyguardClockInteractor, -) { +constructor(private val keyguardClockInteractor: KeyguardClockInteractor) { private var parentAnimator: NotificationPanelViewController.ShadeFoldAnimatorImpl? = null // TODO(b/331770313): Migrate to PowerInteractor; Deprecate ShadeFoldAnimator again val foldAnimator = object : ShadeFoldAnimator { - override val view: ViewGroup? - get() = throw NotImplementedError("Deprecated. Do not call.") override fun prepareFoldToAodAnimation() { parentAnimator?.prepareFoldToAodAnimation() @@ -43,7 +38,7 @@ constructor( override fun startFoldToAodAnimation( startAction: Runnable, endAction: Runnable, - cancelAction: Runnable + cancelAction: Runnable, ) { parentAnimator?.let { it.buildViewAnimator(startAction, endAction, cancelAction) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ClockSize.kt b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ClockSize.kt index b66129794477..5003a19614a6 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ClockSize.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/shared/model/ClockSize.kt @@ -18,37 +18,19 @@ package com.android.systemui.keyguard.shared.model import android.util.Log -import com.android.keyguard.KeyguardClockSwitch -enum class ClockSize( - @KeyguardClockSwitch.ClockSize val legacyValue: Int, -) { - SMALL(KeyguardClockSwitch.SMALL), - LARGE(KeyguardClockSwitch.LARGE); - - companion object { - private val TAG = ClockSize::class.simpleName!! - fun fromLegacy(@KeyguardClockSwitch.ClockSize value: Int): ClockSize { - for (enumVal in enumValues<ClockSize>()) { - if (enumVal.legacyValue == value) { - return enumVal - } - } - - Log.e(TAG, "Unrecognized legacy clock size value: $value") - return LARGE - } - } +enum class ClockSize { + SMALL, + LARGE, } -enum class ClockSizeSetting( - val settingValue: Int, -) { +enum class ClockSizeSetting(val settingValue: Int) { DYNAMIC(1), SMALL(0); companion object { private val TAG = ClockSizeSetting::class.simpleName!! + fun fromSettingValue(value: Int): ClockSizeSetting { for (enumVal in enumValues<ClockSizeSetting>()) { if (enumVal.settingValue == value) { 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 d5a965569553..6973fecc37b4 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 @@ -31,7 +31,6 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultNotification 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.DefaultStatusBarSection -import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection import com.android.systemui.keyguard.ui.view.layout.sections.DefaultUdfpsAccessibilityOverlaySection import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSectionsModule.Companion.KEYGUARD_AMBIENT_INDICATION_AREA_SECTION import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSliceViewSection @@ -60,7 +59,6 @@ constructor( @Named(KEYGUARD_AMBIENT_INDICATION_AREA_SECTION) defaultAmbientIndicationAreaSection: Optional<KeyguardSection>, defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection, - defaultStatusViewSection: DefaultStatusViewSection, defaultStatusBarSection: DefaultStatusBarSection, defaultNotificationStackScrollLayoutSection: DefaultNotificationStackScrollLayoutSection, aodNotificationIconsSection: AodNotificationIconsSection, @@ -80,7 +78,6 @@ constructor( defaultShortcutsSection, defaultAmbientIndicationAreaSection.getOrNull(), defaultSettingsPopupMenuSection, - defaultStatusViewSection, defaultStatusBarSection, defaultNotificationStackScrollLayoutSection, aodNotificationIconsSection, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt index 34471771c79b..1eed224be3b5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/blueprints/SplitShadeKeyguardBlueprint.kt @@ -30,7 +30,6 @@ import com.android.systemui.keyguard.ui.view.layout.sections.DefaultIndicationAr 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.DefaultStatusBarSection -import com.android.systemui.keyguard.ui.view.layout.sections.DefaultStatusViewSection import com.android.systemui.keyguard.ui.view.layout.sections.KeyguardSectionsModule import com.android.systemui.keyguard.ui.view.layout.sections.SmartspaceSection import com.android.systemui.keyguard.ui.view.layout.sections.SplitShadeGuidelines @@ -57,7 +56,6 @@ constructor( @Named(KeyguardSectionsModule.KEYGUARD_AMBIENT_INDICATION_AREA_SECTION) defaultAmbientIndicationAreaSection: Optional<KeyguardSection>, defaultSettingsPopupMenuSection: DefaultSettingsPopupMenuSection, - defaultStatusViewSection: DefaultStatusViewSection, defaultStatusBarSection: DefaultStatusBarSection, splitShadeNotificationStackScrollLayoutSection: SplitShadeNotificationStackScrollLayoutSection, splitShadeGuidelines: SplitShadeGuidelines, @@ -77,7 +75,6 @@ constructor( defaultShortcutsSection, defaultAmbientIndicationAreaSection.getOrNull(), defaultSettingsPopupMenuSection, - defaultStatusViewSection, defaultStatusBarSection, splitShadeNotificationStackScrollLayoutSection, splitShadeGuidelines, 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 deleted file mode 100644 index 57ea1ad5575d..000000000000 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/DefaultStatusViewSection.kt +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.view.ViewGroup.LayoutParams.WRAP_CONTENT -import androidx.constraintlayout.widget.ConstraintLayout -import androidx.constraintlayout.widget.ConstraintSet -import androidx.constraintlayout.widget.ConstraintSet.END -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 com.android.keyguard.KeyguardStatusView -import com.android.keyguard.dagger.KeyguardStatusViewComponent -import com.android.systemui.keyguard.KeyguardViewConfigurator -import com.android.systemui.keyguard.MigrateClocksToBlueprint -import com.android.systemui.keyguard.shared.model.KeyguardSection -import com.android.systemui.media.controls.ui.controller.KeyguardMediaController -import com.android.systemui.res.R -import com.android.systemui.shade.NotificationPanelView -import com.android.systemui.shade.NotificationPanelViewController -import com.android.systemui.shade.ShadeDisplayAware -import com.android.systemui.statusbar.policy.SplitShadeStateController -import com.android.systemui.util.Utils -import dagger.Lazy -import javax.inject.Inject -import kotlinx.coroutines.ExperimentalCoroutinesApi - -class DefaultStatusViewSection -@Inject -constructor( - @ShadeDisplayAware private val context: Context, - private val notificationPanelView: NotificationPanelView, - private val keyguardStatusViewComponentFactory: KeyguardStatusViewComponent.Factory, - private val keyguardViewConfigurator: Lazy<KeyguardViewConfigurator>, - private val notificationPanelViewController: Lazy<NotificationPanelViewController>, - private val keyguardMediaController: KeyguardMediaController, - private val splitShadeStateController: SplitShadeStateController, -) : KeyguardSection() { - private val statusViewId = R.id.keyguard_status_view - - override fun addViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) { - return - } - // At startup, 2 views with the ID `R.id.keyguard_status_view` will be available. - // Disable one of them - notificationPanelView.findViewById<View>(statusViewId)?.let { - notificationPanelView.removeView(it) - } - val keyguardStatusView = - (LayoutInflater.from(context) - .inflate(R.layout.keyguard_status_view, constraintLayout, false) - as KeyguardStatusView) - .apply { clipChildren = false } - - // This is diassembled and moved to [AodNotificationIconsSection] - keyguardStatusView.findViewById<View>(R.id.left_aligned_notification_icon_container)?.let { - it.setVisibility(View.GONE) - } - // Should keep this even if flag, migrating clocks to blueprint, is on - // cause some events in clockEventController rely on keyguardStatusViewController - // TODO(b/313499340): clean up - constraintLayout.addView(keyguardStatusView) - } - - override fun bindData(constraintLayout: ConstraintLayout) { - if (MigrateClocksToBlueprint.isEnabled) { - constraintLayout.findViewById<KeyguardStatusView?>(R.id.keyguard_status_view)?.let { - val statusViewComponent = - keyguardStatusViewComponentFactory.build(it, context.display) - val controller = statusViewComponent.keyguardStatusViewController - controller.init() - keyguardMediaController.attachSplitShadeContainer( - it.requireViewById<ViewGroup>(R.id.status_view_media_container) - ) - keyguardViewConfigurator.get().keyguardStatusViewController = controller - notificationPanelViewController.get().updateStatusViewController() - } - } - } - - override fun applyConstraints(constraintSet: ConstraintSet) { - constraintSet.apply { - constrainWidth(statusViewId, MATCH_CONSTRAINT) - constrainHeight(statusViewId, WRAP_CONTENT) - // TODO(b/296122465): Constrain to the top of [DefaultStatusBarSection] and remove the - // extra margin below. - connect(statusViewId, TOP, PARENT_ID, TOP) - connect(statusViewId, START, PARENT_ID, START) - connect(statusViewId, END, PARENT_ID, END) - - val margin = - if (splitShadeStateController.shouldUseSplitNotificationShade(context.resources)) { - context.resources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin) - } else { - context.resources.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin) + - Utils.getStatusBarHeaderHeightKeyguard(context) - } - setMargin(statusViewId, TOP, margin) - } - } - - @OptIn(ExperimentalCoroutinesApi::class) - override fun removeViews(constraintLayout: ConstraintLayout) { - constraintLayout.removeView(statusViewId) - keyguardViewConfigurator.get().keyguardStatusViewController = null - } -} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/KeyguardSliceViewSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/KeyguardSliceViewSection.kt index 604318a2751c..962e6089dce9 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/KeyguardSliceViewSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/KeyguardSliceViewSection.kt @@ -17,37 +17,64 @@ package com.android.systemui.keyguard.ui.view.layout.sections -import android.view.View -import android.view.ViewGroup +import android.os.Handler +import android.view.LayoutInflater import androidx.constraintlayout.widget.Barrier import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet +import com.android.keyguard.KeyguardSliceView +import com.android.keyguard.KeyguardSliceViewController import com.android.systemui.customization.R as customR -import com.android.systemui.keyguard.MigrateClocksToBlueprint +import com.android.systemui.dagger.qualifiers.Background +import com.android.systemui.dagger.qualifiers.Main +import com.android.systemui.dump.DumpManager import com.android.systemui.keyguard.shared.model.KeyguardSection +import com.android.systemui.plugins.ActivityStarter import com.android.systemui.res.R +import com.android.systemui.settings.DisplayTracker import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController +import com.android.systemui.statusbar.policy.ConfigurationController import javax.inject.Inject class KeyguardSliceViewSection @Inject constructor( val smartspaceController: LockscreenSmartspaceController, + val layoutInflater: LayoutInflater, + @Main val handler: Handler, + @Background val bgHandler: Handler, + val activityStarter: ActivityStarter, + val configurationController: ConfigurationController, + val dumpManager: DumpManager, + val displayTracker: DisplayTracker, ) : KeyguardSection() { + private lateinit var sliceView: KeyguardSliceView + override fun addViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) return if (smartspaceController.isEnabled) return - constraintLayout.findViewById<View?>(R.id.keyguard_slice_view)?.let { - (it.parent as ViewGroup).removeView(it) - constraintLayout.addView(it) - } + sliceView = + layoutInflater.inflate(R.layout.keyguard_slice_view, null, false) as KeyguardSliceView + constraintLayout.addView(sliceView) } - override fun bindData(constraintLayout: ConstraintLayout) {} + override fun bindData(constraintLayout: ConstraintLayout) { + if (smartspaceController.isEnabled) return + + val controller = + KeyguardSliceViewController( + handler, + bgHandler, + sliceView, + activityStarter, + configurationController, + dumpManager, + displayTracker, + ) + controller.init() + } override fun applyConstraints(constraintSet: ConstraintSet) { - if (!MigrateClocksToBlueprint.isEnabled) return if (smartspaceController.isEnabled) return constraintSet.apply { @@ -55,13 +82,13 @@ constructor( R.id.keyguard_slice_view, ConstraintSet.START, ConstraintSet.PARENT_ID, - ConstraintSet.START + ConstraintSet.START, ) connect( R.id.keyguard_slice_view, ConstraintSet.END, ConstraintSet.PARENT_ID, - ConstraintSet.END + ConstraintSet.END, ) constrainHeight(R.id.keyguard_slice_view, ConstraintSet.WRAP_CONTENT) @@ -69,20 +96,19 @@ constructor( R.id.keyguard_slice_view, ConstraintSet.TOP, customR.id.lockscreen_clock_view, - ConstraintSet.BOTTOM + ConstraintSet.BOTTOM, ) createBarrier( R.id.smart_space_barrier_bottom, Barrier.BOTTOM, 0, - *intArrayOf(R.id.keyguard_slice_view) + *intArrayOf(R.id.keyguard_slice_view), ) } } override fun removeViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) return if (smartspaceController.isEnabled) return constraintLayout.removeView(R.id.keyguard_slice_view) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt index f0d21f22c5ee..c91a0072a502 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/SplitShadeMediaSection.kt @@ -17,7 +17,6 @@ package com.android.systemui.keyguard.ui.view.layout.sections import android.content.Context -import android.view.View import android.view.ViewGroup.LayoutParams.WRAP_CONTENT import android.widget.FrameLayout import androidx.constraintlayout.widget.ConstraintLayout @@ -29,11 +28,9 @@ import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID import androidx.constraintlayout.widget.ConstraintSet.START import androidx.constraintlayout.widget.ConstraintSet.TOP import com.android.systemui.customization.R as customR -import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.shared.model.KeyguardSection import com.android.systemui.media.controls.ui.controller.KeyguardMediaController import com.android.systemui.res.R -import com.android.systemui.shade.NotificationPanelView import com.android.systemui.shade.ShadeDisplayAware import javax.inject.Inject @@ -42,20 +39,11 @@ class SplitShadeMediaSection @Inject constructor( @ShadeDisplayAware private val context: Context, - private val notificationPanelView: NotificationPanelView, private val keyguardMediaController: KeyguardMediaController, ) : KeyguardSection() { private val mediaContainerId = R.id.status_view_media_container override fun addViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) { - return - } - - notificationPanelView.findViewById<View>(mediaContainerId)?.let { - notificationPanelView.removeView(it) - } - val mediaFrame = FrameLayout(context, null).apply { id = mediaContainerId @@ -75,10 +63,6 @@ constructor( override fun bindData(constraintLayout: ConstraintLayout) {} override fun applyConstraints(constraintSet: ConstraintSet) { - if (!MigrateClocksToBlueprint.isEnabled) { - return - } - constraintSet.apply { constrainWidth(mediaContainerId, MATCH_CONSTRAINT) constrainHeight(mediaContainerId, WRAP_CONTENT) @@ -89,10 +73,6 @@ constructor( } override fun removeViews(constraintLayout: ConstraintLayout) { - if (!MigrateClocksToBlueprint.isEnabled) { - return - } - constraintLayout.removeView(mediaContainerId) } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModel.kt deleted file mode 100644 index acaa15edde82..000000000000 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModel.kt +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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. - */ - -@file:OptIn(ExperimentalCoroutinesApi::class) - -package com.android.systemui.keyguard.ui.viewmodel - -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.keyguard.MigrateClocksToBlueprint -import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor -import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor -import com.android.systemui.keyguard.shared.model.KeyguardState.AOD -import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING -import com.android.systemui.keyguard.shared.model.KeyguardState.GONE -import com.android.systemui.keyguard.shared.model.KeyguardState.UNDEFINED -import com.android.systemui.scene.domain.interactor.SceneInteractor -import com.android.systemui.scene.shared.flag.SceneContainerFlag -import com.android.systemui.scene.shared.model.Scenes -import javax.inject.Inject -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.combineTransform -import kotlinx.coroutines.flow.onStart - -/** Models UI state for the alpha of the AOD (always-on display). */ -@SysUISingleton -class AodAlphaViewModel -@Inject -constructor( - keyguardTransitionInteractor: KeyguardTransitionInteractor, - goneToAodTransitionViewModel: GoneToAodTransitionViewModel, - goneToDozingTransitionViewModel: GoneToDozingTransitionViewModel, - keyguardInteractor: KeyguardInteractor, - sceneInteractor: SceneInteractor, -) { - - /** The alpha level for the entire lockscreen while in AOD. */ - val alpha: Flow<Float> = - if (SceneContainerFlag.isEnabled) { - combineTransform( - keyguardTransitionInteractor.transitions, - sceneInteractor.transitionState, - goneToAodTransitionViewModel.enterFromTopAnimationAlpha.onStart { emit(0f) }, - goneToDozingTransitionViewModel.lockscreenAlpha.onStart { emit(0f) }, - keyguardInteractor.keyguardAlpha.onStart { emit(1f) }, - ) { step, sceneTransitionState, goneToAodAlpha, goneToDozingAlpha, keyguardAlpha -> - if (sceneTransitionState.isIdle(Scenes.Gone)) { - emit(0f) - } else if ( - step.from == UNDEFINED && - step.to == AOD && - sceneTransitionState.isTransitioning(Scenes.Gone, Scenes.Lockscreen) - ) { - emit(goneToAodAlpha) - } else if ( - step.from == UNDEFINED && - step.to == DOZING && - sceneTransitionState.isTransitioning(Scenes.Gone, Scenes.Lockscreen) - ) { - emit(goneToDozingAlpha) - } else if (!MigrateClocksToBlueprint.isEnabled) { - emit(keyguardAlpha) - } - } - } else { - combineTransform( - keyguardTransitionInteractor.transitions, - goneToAodTransitionViewModel.enterFromTopAnimationAlpha.onStart { emit(0f) }, - goneToDozingTransitionViewModel.lockscreenAlpha.onStart { emit(0f) }, - keyguardInteractor.keyguardAlpha.onStart { emit(1f) }, - ) { step, goneToAodAlpha, goneToDozingAlpha, keyguardAlpha -> - if (step.to == GONE) { - // When transitioning to GONE, only emit a value when complete as other - // transitions may be controlling the alpha fade - if (step.value == 1f) { - emit(0f) - } - } else if (step.from == GONE && step.to == AOD) { - emit(goneToAodAlpha) - } else if (step.from == GONE && step.to == DOZING) { - emit(goneToDozingAlpha) - } else if (!MigrateClocksToBlueprint.isEnabled) { - emit(keyguardAlpha) - } - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java b/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java index d78f4d8238b1..2ca764728054 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/shade/DebugDrawable.java @@ -85,22 +85,6 @@ public class DebugDrawable extends Drawable { mNotificationPanelViewController.getExpandedFraction()), Color.MAGENTA, "calculateNotificationsTopPadding()"); } - drawDebugInfo(canvas, mNotificationPanelViewController.getClockPositionResult().clockY, - Color.GRAY, "mClockPositionResult.clockY"); - - if (mNotificationPanelViewController.isKeyguardShowing()) { - // Notifications have the space between those two lines. - drawDebugInfo(canvas, - mNotificationStackScrollLayoutController.getTop() - + (int) mNotificationPanelViewController - .getKeyguardNotificationTopPadding(), - Color.RED, "NSSL.getTop() + mKeyguardNotificationTopPadding"); - - drawDebugInfo(canvas, mNotificationStackScrollLayoutController.getBottom() - - (int) mNotificationPanelViewController - .getKeyguardNotificationBottomPadding(), - Color.RED, "NSSL.getBottom() - mKeyguardNotificationBottomPadding"); - } mDebugPaint.setColor(Color.CYAN); canvas.drawLine(0, diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index e681c98b10f4..726af013881d 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -19,10 +19,7 @@ package com.android.systemui.shade; import static android.view.View.INVISIBLE; import static android.view.View.VISIBLE; -import static com.android.app.animation.Interpolators.EMPHASIZED_ACCELERATE; import static com.android.app.animation.Interpolators.EMPHASIZED_DECELERATE; -import static com.android.keyguard.KeyguardClockSwitch.LARGE; -import static com.android.keyguard.KeyguardClockSwitch.SMALL; import static com.android.systemui.Flags.msdlFeedback; import static com.android.systemui.Flags.predictiveBackAnimateShade; import static com.android.systemui.classifier.Classifier.BOUNCER_UNLOCK; @@ -30,10 +27,7 @@ import static com.android.systemui.classifier.Classifier.GENERIC; import static com.android.systemui.classifier.Classifier.QUICK_SETTINGS; import static com.android.systemui.classifier.Classifier.UNLOCK; import static com.android.systemui.keyguard.shared.model.KeyguardState.AOD; -import static com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING; -import static com.android.systemui.keyguard.shared.model.KeyguardState.GONE; import static com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN; -import static com.android.systemui.keyguard.shared.model.KeyguardState.OCCLUDED; import static com.android.systemui.navigationbar.gestural.Utilities.isTrackpadThreeFingerSwipe; import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_CLOSED; import static com.android.systemui.shade.ShadeExpansionStateManagerKt.STATE_OPEN; @@ -78,7 +72,6 @@ import android.view.VelocityTracker; import android.view.View; import android.view.View.AccessibilityDelegate; import android.view.ViewConfiguration; -import android.view.ViewGroup; import android.view.ViewPropertyAnimator; import android.view.ViewStub; import android.view.ViewTreeObserver; @@ -87,9 +80,6 @@ import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityManager; 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; @@ -99,19 +89,13 @@ 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.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.dagger.KeyguardStatusBarViewComponent; -import com.android.keyguard.dagger.KeyguardStatusViewComponent; import com.android.systemui.DejankUtils; import com.android.systemui.Dumpable; import com.android.systemui.Gefingerpoken; -import com.android.systemui.biometrics.AuthController; import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor; -import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants; import com.android.systemui.classifier.Classifier; import com.android.systemui.classifier.FalsingCollector; import com.android.systemui.dagger.SysUISingleton; @@ -126,23 +110,18 @@ import com.android.systemui.flags.Flags; import com.android.systemui.fragments.FragmentService; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.keyguard.KeyguardViewConfigurator; -import com.android.systemui.keyguard.MigrateClocksToBlueprint; import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.domain.interactor.NaturalScrollingSettingObserver; +import com.android.systemui.keyguard.shared.model.ClockSize; import com.android.systemui.keyguard.shared.model.Edge; import com.android.systemui.keyguard.shared.model.TransitionState; import com.android.systemui.keyguard.shared.model.TransitionStep; import com.android.systemui.keyguard.ui.binder.KeyguardLongPressViewBinder; import com.android.systemui.keyguard.ui.transitions.PrimaryBouncerTransition; import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.GoneToDreamingTransitionViewModel; import com.android.systemui.keyguard.ui.viewmodel.KeyguardTouchHandlingViewModel; -import com.android.systemui.keyguard.ui.viewmodel.LockscreenToDreamingTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.LockscreenToOccludedTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.OccludedToLockscreenTransitionViewModel; -import com.android.systemui.keyguard.ui.viewmodel.PrimaryBouncerToGoneTransitionViewModel; import com.android.systemui.media.controls.domain.pipeline.MediaDataManager; import com.android.systemui.media.controls.ui.controller.KeyguardMediaController; import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager; @@ -161,7 +140,6 @@ import com.android.systemui.power.shared.model.WakefulnessModel; import com.android.systemui.qs.flags.QSComposeFragment; import com.android.systemui.res.R; import com.android.systemui.scene.shared.flag.SceneContainerFlag; -import com.android.systemui.scene.shared.model.Scenes; import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor; import com.android.systemui.shade.data.repository.FlingInfo; import com.android.systemui.shade.data.repository.ShadeRepository; @@ -251,7 +229,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump public static final String TAG = NotificationPanelView.class.getSimpleName(); private static final boolean DEBUG_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.DEBUG); - private static final boolean SPEW_LOGCAT = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE); private static final boolean DEBUG_DRAWABLE = false; /** The parallax amount of the quick settings translation when dragging down the panel. */ public static final float QS_PARALLAX_AMOUNT = 0.175f; @@ -319,10 +296,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private final KeyguardUpdateMonitor mUpdateMonitor; private final DeviceEntryFaceAuthInteractor mDeviceEntryFaceAuthInteractor; private final ConversationNotificationManager mConversationNotificationManager; - private final AuthController mAuthController; private final MediaHierarchyManager mMediaHierarchyManager; private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; - private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory; private final KeyguardStatusBarViewComponent.Factory mKeyguardStatusBarViewComponentFactory; private final FragmentService mFragmentService; private final IStatusBarService mStatusBarService; @@ -362,17 +337,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private float mCurrentBackProgress = 0.0f; private boolean mExpanding; private boolean mSplitShadeEnabled; - /** The bottom padding reserved for elements of the keyguard measuring notifications. */ - private float mKeyguardNotificationBottomPadding; - /** - * The top padding from where notification should start in lockscreen. - * Should be static also during animations and should match the Y of the first notification. - */ - private float mKeyguardNotificationTopPadding; - /** Current max allowed keyguard notifications determined by measuring the panel. */ - private int mMaxAllowedKeyguardNotifications; private KeyguardStatusBarViewController mKeyguardStatusBarViewController; - private KeyguardStatusViewController mKeyguardStatusViewController; private NotificationsQuickSettingsContainer mNotificationContainerParent; private final NotificationsQSContainerController mNotificationsQSContainerController; private boolean mAnimateNextPositionUpdate; @@ -429,8 +394,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump Set<Animator> mTestSetOfAnimatorsUsed; private boolean mShowIconsWhenExpanded; - private int mIndicationBottomPadding; - private int mAmbientIndicationBottomPadding; /** Whether the notifications are displayed full width (no margins on the side). */ private boolean mIsFullWidth; private boolean mBlockingExpansionForCurrentTouch; @@ -456,8 +419,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private int mPanelAlpha; private Runnable mPanelAlphaEndAction; - private float mBottomAreaShadeAlpha; - final ValueAnimator mBottomAreaShadeAlphaAnimator; private final AnimatableProperty mPanelAlphaAnimator = AnimatableProperty.from("panelAlpha", (view, alpha) -> { setAlphaInternal(alpha); @@ -499,11 +460,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump /** Whether a collapse that started on the panel should allow the panel to intercept. */ private boolean mIsPanelCollapseOnQQS; - /** Alpha of the views which only show on the keyguard but not in shade / shade locked. */ - private float mKeyguardOnlyContentAlpha = 1.0f; - /** Y translation of the views that only show on the keyguard but in shade / shade locked. */ - private int mKeyguardOnlyTransitionTranslationY = 0; - private float mUdfpsMaxYBurnInOffset; /** Are we currently in gesture navigation. */ private boolean mIsGestureNavigation; private int mOldLayoutDirection; @@ -570,11 +526,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private boolean mExpandLatencyTracking; private boolean mUseExternalTouch = false; private final DreamingToLockscreenTransitionViewModel mDreamingToLockscreenTransitionViewModel; - private final OccludedToLockscreenTransitionViewModel mOccludedToLockscreenTransitionViewModel; - private final LockscreenToDreamingTransitionViewModel mLockscreenToDreamingTransitionViewModel; - private final GoneToDreamingTransitionViewModel mGoneToDreamingTransitionViewModel; - private final LockscreenToOccludedTransitionViewModel mLockscreenToOccludedTransitionViewModel; - private final PrimaryBouncerToGoneTransitionViewModel mPrimaryBouncerToGoneTransitionViewModel; private final SharedNotificationContainerInteractor mSharedNotificationContainerInteractor; private final ActiveNotificationsInteractor mActiveNotificationsInteractor; private final KeyguardTransitionInteractor mKeyguardTransitionInteractor; @@ -583,10 +534,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private final KeyguardViewConfigurator mKeyguardViewConfigurator; private final CoroutineDispatcher mMainDispatcher; private boolean mIsAnyMultiShadeExpanded; - private boolean mIsOcclusionTransitionRunning = false; - private int mDreamingToLockscreenTransitionTranslationY; - private int mLockscreenToDreamingTransitionTranslationY; - private int mGoneToDreamingTransitionTranslationY; private boolean mForceFlingAnimationForTest = false; private final SplitShadeStateController mSplitShadeStateController; private final Runnable mFlingCollapseRunnable = () -> fling(0, false /* expand */, @@ -601,37 +548,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } }; - private final Consumer<TransitionStep> mDreamingToLockscreenTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - - private final Consumer<TransitionStep> mOccludedToLockscreenTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - - private final Consumer<TransitionStep> mLockscreenToDreamingTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - - private final Consumer<TransitionStep> mGoneToDreamingTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - - - private final Consumer<TransitionStep> mLockscreenToOccludedTransition = - (TransitionStep step) -> { - mIsOcclusionTransitionRunning = - step.getTransitionState() == TransitionState.RUNNING; - }; - private final ActivityStarter mActivityStarter; private final BrightnessMirrorShowingInteractor mBrightnessMirrorShowingInteractor; @@ -668,10 +584,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump NotificationGutsManager gutsManager, NotificationsQSContainerController notificationsQSContainerController, NotificationStackScrollLayoutController notificationStackScrollLayoutController, - KeyguardStatusViewComponent.Factory keyguardStatusViewComponentFactory, KeyguardStatusBarViewComponent.Factory keyguardStatusBarViewComponentFactory, LockscreenShadeTransitionController lockscreenShadeTransitionController, - AuthController authController, ScrimController scrimController, UserManager userManager, MediaDataManager mediaDataManager, @@ -701,11 +615,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump KeyguardClockInteractor keyguardClockInteractor, AlternateBouncerInteractor alternateBouncerInteractor, DreamingToLockscreenTransitionViewModel dreamingToLockscreenTransitionViewModel, - OccludedToLockscreenTransitionViewModel occludedToLockscreenTransitionViewModel, - LockscreenToDreamingTransitionViewModel lockscreenToDreamingTransitionViewModel, - GoneToDreamingTransitionViewModel goneToDreamingTransitionViewModel, - LockscreenToOccludedTransitionViewModel lockscreenToOccludedTransitionViewModel, - PrimaryBouncerToGoneTransitionViewModel primaryBouncerToGoneTransitionViewModel, @Main CoroutineDispatcher mainDispatcher, KeyguardTransitionInteractor keyguardTransitionInteractor, DumpManager dumpManager, @@ -740,11 +649,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mShadeLog = shadeLogger; mGutsManager = gutsManager; mDreamingToLockscreenTransitionViewModel = dreamingToLockscreenTransitionViewModel; - mOccludedToLockscreenTransitionViewModel = occludedToLockscreenTransitionViewModel; - mLockscreenToDreamingTransitionViewModel = lockscreenToDreamingTransitionViewModel; - mGoneToDreamingTransitionViewModel = goneToDreamingTransitionViewModel; - mLockscreenToOccludedTransitionViewModel = lockscreenToOccludedTransitionViewModel; - mPrimaryBouncerToGoneTransitionViewModel = primaryBouncerToGoneTransitionViewModel; mKeyguardTransitionInteractor = keyguardTransitionInteractor; mSharedNotificationContainerInteractor = sharedNotificationContainerInteractor; mActiveNotificationsInteractor = activeNotificationsInteractor; @@ -813,7 +717,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mNavigationBarController = navigationBarController; mNotificationsQSContainerController.init(); mNotificationStackScrollLayoutController = notificationStackScrollLayoutController; - mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory; mKeyguardStatusBarViewComponentFactory = keyguardStatusBarViewComponentFactory; mDepthController = notificationShadeDepthController; mContentResolver = contentResolver; @@ -852,16 +755,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump quickSettingsController.setFlingQsWithoutClickListener(this::onFlingQsWithoutClick); quickSettingsController.setExpansionHeightSetToMaxListener(this::onExpansionHeightSetToMax); shadeExpansionStateManager.addStateListener(this::onPanelStateChanged); - - mBottomAreaShadeAlphaAnimator = ValueAnimator.ofFloat(1f, 0); - mBottomAreaShadeAlphaAnimator.addUpdateListener(animation -> { - mBottomAreaShadeAlpha = (float) animation.getAnimatedValue(); - updateKeyguardBottomAreaAlpha(); - }); - mBottomAreaShadeAlphaAnimator.setDuration(160); - mBottomAreaShadeAlphaAnimator.setInterpolator(Interpolators.ALPHA_OUT); mConversationNotificationManager = conversationNotificationManager; - mAuthController = authController; mScreenOffAnimationController = screenOffAnimationController; mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; mLastDownEvents = new NPVCDownEventState.Buffer(MAX_DOWN_EVENT_BUFFER_SIZE); @@ -950,28 +844,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump instantCollapse(); } else { mView.animate().cancel(); - if (!MigrateClocksToBlueprint.isEnabled()) { - mView.animate() - .alpha(0f) - .setStartDelay(0) - // Translate up by 4%. - .translationY(mView.getHeight() * -0.04f) - // This start delay is to give us time to animate out before - // the launcher icons animation starts, so use that as our - // duration. - .setDuration(unlockAnimationStartDelay) - .setInterpolator(EMPHASIZED_ACCELERATE) - .withEndAction(() -> { - instantCollapse(); - mView.setAlpha(1f); - mView.setTranslationY(0f); - }) - .start(); - } else { - mView.postDelayed(() -> { - instantCollapse(); - }, unlockAnimationStartDelay); - } + mView.postDelayed(() -> { + instantCollapse(); + }, unlockAnimationStartDelay); } } } @@ -979,7 +854,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @VisibleForTesting void onFinishInflate() { loadDimens(); - mKeyguardStatusBarViewController = mKeyguardStatusBarViewComponentFactory.build( mView.findViewById(R.id.keyguard_header), @@ -987,7 +861,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump .getKeyguardStatusBarViewController(); mKeyguardStatusBarViewController.init(); mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent); - updateStatusViewController(); mNotificationStackScrollLayoutController.setOnHeightChangedListener( new NsslHeightChangedListener()); mNotificationStackScrollLayoutController.setOnEmptySpaceClickListener( @@ -1020,89 +893,17 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump () -> collapse(/* delayed= */ false , /* speedUpFactor= */ 1.0f)); // Dreaming->Lockscreen - collectFlow( - mView, - mKeyguardTransitionInteractor.transition( - Edge.Companion.create(DREAMING, LOCKSCREEN)), - mDreamingToLockscreenTransition, - mMainDispatcher); collectFlow(mView, mDreamingToLockscreenTransitionViewModel.getLockscreenAlpha(), setDreamLockscreenTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); - collectFlow(mView, mDreamingToLockscreenTransitionViewModel.lockscreenTranslationY( - mDreamingToLockscreenTransitionTranslationY), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - // Occluded->Lockscreen - collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(OCCLUDED, LOCKSCREEN)), - mOccludedToLockscreenTransition, mMainDispatcher); - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mOccludedToLockscreenTransitionViewModel.getLockscreenAlpha(), - setTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); - collectFlow(mView, - mOccludedToLockscreenTransitionViewModel.getLockscreenTranslationY(), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - } - - // Lockscreen->Dreaming - collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(LOCKSCREEN, DREAMING)), - mLockscreenToDreamingTransition, mMainDispatcher); - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mLockscreenToDreamingTransitionViewModel.getLockscreenAlpha(), - setDreamLockscreenTransitionAlpha(mNotificationStackScrollLayoutController), - mMainDispatcher); - } - collectFlow(mView, mLockscreenToDreamingTransitionViewModel.lockscreenTranslationY( - mLockscreenToDreamingTransitionTranslationY), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - - // Gone->Dreaming - collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(Scenes.Gone, DREAMING), - Edge.Companion.create(GONE, DREAMING)), - mGoneToDreamingTransition, mMainDispatcher); - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mGoneToDreamingTransitionViewModel.getLockscreenAlpha(), - setTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); - } - collectFlow(mView, mGoneToDreamingTransitionViewModel.lockscreenTranslationY( - mGoneToDreamingTransitionTranslationY), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - - // Lockscreen->Occluded collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(LOCKSCREEN, OCCLUDED)), - mLockscreenToOccludedTransition, mMainDispatcher); - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mLockscreenToOccludedTransitionViewModel.getLockscreenAlpha(), - setTransitionAlpha(mNotificationStackScrollLayoutController), mMainDispatcher); - collectFlow(mView, mLockscreenToOccludedTransitionViewModel.getLockscreenTranslationY(), - setTransitionY(mNotificationStackScrollLayoutController), mMainDispatcher); - } - - // Primary bouncer->Gone (ensures lockscreen content is not visible on successful auth) - if (!MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getLockscreenAlpha(), - setTransitionAlpha(mNotificationStackScrollLayoutController, - /* excludeNotifications=*/ true), mMainDispatcher); - collectFlow(mView, mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha(), - (Float alpha) -> { - mNotificationStackScrollLayoutController.setMaxAlphaForKeyguard(alpha, - "mPrimaryBouncerToGoneTransitionViewModel.getNotificationAlpha()"); - }, mMainDispatcher); - } - - if (MigrateClocksToBlueprint.isEnabled()) { - collectFlow(mView, mKeyguardTransitionInteractor.transition( - Edge.Companion.create(AOD, LOCKSCREEN)), - (TransitionStep step) -> { - if (step.getTransitionState() == TransitionState.FINISHED) { - updateExpandedHeightToMaxHeight(); - } - }, mMainDispatcher); - } + Edge.Companion.create(AOD, LOCKSCREEN)), + (TransitionStep step) -> { + if (step.getTransitionState() == TransitionState.FINISHED) { + updateExpandedHeightToMaxHeight(); + } + }, mMainDispatcher); if (com.android.systemui.Flags.bouncerUiRevamp()) { collectFlow(mView, mKeyguardInteractor.primaryBouncerShowing, @@ -1138,22 +939,13 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mStatusBarMinHeight = SystemBarUtils.getStatusBarHeight(mView.getContext()); mStatusBarHeaderHeightKeyguard = Utils.getStatusBarHeaderHeightKeyguard(mView.getContext()); mClockPositionAlgorithm.loadDimens(mView.getContext(), mResources); - mIndicationBottomPadding = mResources.getDimensionPixelSize( - R.dimen.keyguard_indication_bottom_padding); int statusbarHeight = SystemBarUtils.getStatusBarHeight(mView.getContext()); mHeadsUpInset = statusbarHeight + mResources.getDimensionPixelSize( R.dimen.heads_up_status_bar_padding); mMaxOverscrollAmountForPulse = mResources.getDimensionPixelSize( R.dimen.pulse_expansion_max_top_overshoot); - mUdfpsMaxYBurnInOffset = mResources.getDimensionPixelSize(R.dimen.udfps_burn_in_offset_y); mSplitShadeScrimTransitionDistance = mResources.getDimensionPixelSize( R.dimen.split_shade_scrim_transition_distance); - mDreamingToLockscreenTransitionTranslationY = mResources.getDimensionPixelSize( - R.dimen.dreaming_to_lockscreen_transition_lockscreen_translation_y); - mLockscreenToDreamingTransitionTranslationY = mResources.getDimensionPixelSize( - R.dimen.lockscreen_to_dreaming_transition_lockscreen_translation_y); - mGoneToDreamingTransitionTranslationY = mResources.getDimensionPixelSize( - R.dimen.gone_to_dreaming_transition_lockscreen_translation_y); // TODO (b/265193930): remove this and make QsController listen to NotificationPanelViews mQsController.loadDimens(); } @@ -1174,37 +966,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } } - /** Updates the StatusBarViewController and updates any that depend on it. */ - public void updateStatusViewController() { - // Re-associate the KeyguardStatusViewController - if (MigrateClocksToBlueprint.isEnabled()) { - // 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 - mKeyguardStatusViewController = - mKeyguardViewConfigurator.getKeyguardStatusViewController(); - } else { - KeyguardStatusView keyguardStatusView = mView.getRootView().findViewById( - R.id.keyguard_status_view); - KeyguardStatusViewComponent statusViewComponent = - mKeyguardStatusViewComponentFactory.build(keyguardStatusView, - mView.getContext().getDisplay()); - mKeyguardStatusViewController = statusViewComponent.getKeyguardStatusViewController(); - mKeyguardStatusViewController.init(); - - mKeyguardStatusViewController.setSplitShadeEnabled(mSplitShadeEnabled); - mKeyguardStatusViewController.getView().addOnLayoutChangeListener( - (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> { - int oldHeight = oldBottom - oldTop; - if (v.getHeight() != oldHeight) { - mNotificationStackScrollLayoutController.animateNextTopPaddingChange(); - } - }); - - updateClockAppearance(); - } - } - @Override public void updateResources() { Trace.beginSection("NSSLC#updateResources"); @@ -1233,16 +994,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private void onSplitShadeEnabledChanged() { mShadeLog.logSplitShadeChanged(mSplitShadeEnabled); - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setSplitShadeEnabled(mSplitShadeEnabled); - } // Reset any left over overscroll state. It is a rare corner case but can happen. mQsController.setOverScrollAmount(0); mScrimController.setNotificationsOverScrollAmount(0); - if (!MigrateClocksToBlueprint.isEnabled()) { - mNotificationStackScrollLayoutController.setOverExpansion(0); - mNotificationStackScrollLayoutController.setOverScrollAmount(0); - } // when we switch between split shade and regular shade we want to enforce setting qs to // the default state: expanded for split shade and collapsed otherwise @@ -1260,9 +1014,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } updateClockAppearance(); mQsController.updateQsState(); - if (!MigrateClocksToBlueprint.isEnabled() && !FooterViewRefactor.isEnabled()) { - mNotificationStackScrollLayoutController.updateFooter(); - } } private View reInflateStub(int viewId, int stubId, int layoutId, boolean enabled) { @@ -1291,45 +1042,9 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @VisibleForTesting void reInflateViews() { debugLog("reInflateViews"); - // Re-inflate the status view group. - if (!MigrateClocksToBlueprint.isEnabled()) { - 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)); - } - - // we need to update KeyguardStatusView constraints after reinflating it updateResources(); - updateStatusViewController(); mStatusBarStateListener.onDozeAmountChanged(mStatusBarStateController.getDozeAmount(), mStatusBarStateController.getInterpolatedDozeAmount()); - - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setKeyguardStatusViewVisibility( - mBarState, - false, - false, - mBarState); - } - } - - private void attachSplitShadeMediaPlayerContainer(FrameLayout container) { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - mKeyguardMediaController.attachSplitShadeContainer(container); - } - - @VisibleForTesting - void setMaxDisplayedNotifications(int maxAllowed) { - mMaxAllowedKeyguardNotifications = maxAllowed; } @VisibleForTesting @@ -1337,33 +1052,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mIsFlinging; } - private void updateMaxDisplayedNotifications(boolean recompute) { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - - if (recompute) { - setMaxDisplayedNotifications(Math.max(computeMaxKeyguardNotifications(), 1)); - } else { - if (SPEW_LOGCAT) Log.d(TAG, "Skipping computeMaxKeyguardNotifications() by request"); - } - - if (isKeyguardShowing() && !mKeyguardBypassController.getBypassEnabled()) { - mNotificationStackScrollLayoutController.setMaxDisplayedNotifications( - mMaxAllowedKeyguardNotifications); - mNotificationStackScrollLayoutController.setKeyguardBottomPaddingForDebug( - mKeyguardNotificationBottomPadding); - } else { - // no max when not on the keyguard - mNotificationStackScrollLayoutController.setMaxDisplayedNotifications(-1); - mNotificationStackScrollLayoutController.setKeyguardBottomPaddingForDebug(-1f); - } - } - - private boolean shouldAvoidChangingNotificationsCount() { - return mUnlockedScreenOffAnimationController.isAnimationPlaying(); - } - /** Sets a listener to be notified when the shade starts opening or finishes closing. */ public void setOpenCloseListener(OpenCloseListener openCloseListener) { SceneContainerFlag.assertInLegacyMode(); @@ -1443,68 +1131,28 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } private void updateClockAppearance() { - boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled(); - boolean shouldAnimateClockChange = mScreenOffAnimationController.shouldAnimateClockChange(); - if (MigrateClocksToBlueprint.isEnabled()) { - mKeyguardClockInteractor.setClockSize(computeDesiredClockSize()); - } else { - mKeyguardStatusViewController.displayClock(computeDesiredClockSize(), - shouldAnimateClockChange); - } + mKeyguardClockInteractor.setClockSize(computeDesiredClockSize()); updateKeyguardStatusViewAlignment(/* animate= */true); - float expandedFraction = - mScreenOffAnimationController.shouldExpandNotifications() - ? 1.0f : getExpandedFraction(); + float darkAmount = mScreenOffAnimationController.shouldExpandNotifications() ? 1.0f : mInterpolatedDarkAmount; - float udfpsAodTopLocation = -1f; - if (mUpdateMonitor.isUdfpsEnrolled() && mAuthController.getUdfpsLocation() != null) { - udfpsAodTopLocation = mAuthController.getUdfpsLocation().y - - mAuthController.getUdfpsRadius() - mUdfpsMaxYBurnInOffset; - } - mClockPositionAlgorithm.setup( - mStatusBarHeaderHeightKeyguard, - expandedFraction, - mKeyguardStatusViewController.getLockscreenHeight(), darkAmount, mOverStretchAmount, - bypassEnabled, + mKeyguardBypassController.getBypassEnabled(), mQsController.getHeaderHeight(), - mQsController.computeExpansionFraction(), - mDisplayTopInset, - mSplitShadeEnabled, - udfpsAodTopLocation, - mKeyguardStatusViewController.getClockBottom(mStatusBarHeaderHeightKeyguard), - mKeyguardStatusViewController.isClockTopAligned()); + mSplitShadeEnabled); mClockPositionAlgorithm.run(mClockPositionResult); - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setLockscreenClockY( - mClockPositionAlgorithm.getExpandedPreferredClockY()); - } - - boolean animate = !SceneContainerFlag.isEnabled() - && mNotificationStackScrollLayoutController.isAddOrRemoveAnimationPending(); - boolean animateClock = (animate || mAnimateNextPositionUpdate) && shouldAnimateClockChange; - - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.updatePosition( - mClockPositionResult.clockX, mClockPositionResult.clockY, - mClockPositionResult.clockScale, animateClock); - } - updateNotificationTranslucency(); - updateClock(); } KeyguardClockPositionAlgorithm.Result getClockPositionResult() { return mClockPositionResult; } - @ClockSize - private int computeDesiredClockSize() { + private ClockSize computeDesiredClockSize() { if (shouldForceSmallClock()) { - return SMALL; + return ClockSize.SMALL; } if (mSplitShadeEnabled) { @@ -1513,34 +1161,22 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return computeDesiredClockSizeForSingleShade(); } - @ClockSize - private int computeDesiredClockSizeForSingleShade() { + private ClockSize computeDesiredClockSizeForSingleShade() { if (hasVisibleNotifications()) { - return SMALL; + return ClockSize.SMALL; } - return LARGE; + return ClockSize.LARGE; } - @ClockSize - private int computeDesiredClockSizeForSplitShade() { + private ClockSize computeDesiredClockSizeForSplitShade() { // Media is not visible to the user on AOD. boolean isMediaVisibleToUser = mMediaDataManager.hasActiveMediaOrRecommendation() && !isOnAod(); if (isMediaVisibleToUser) { // When media is visible, it overlaps with the large clock. Use small clock instead. - return SMALL; - } - // To prevent the weather clock from overlapping with the notification shelf on AOD, we use - // the small clock here - // With migrateClocksToBlueprint, weather clock will have behaviors similar to other clocks - if (!MigrateClocksToBlueprint.isEnabled()) { - boolean bypassEnabled = mKeyguardBypassController.getBypassEnabled(); - if (mKeyguardStatusViewController.isLargeClockBlockingNotificationShelf() - && hasVisibleNotifications() && (isOnAod() || bypassEnabled)) { - return SMALL; - } + return ClockSize.SMALL; } - return LARGE; + return ClockSize.LARGE; } private boolean shouldForceSmallClock() { @@ -1553,13 +1189,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump private void updateKeyguardStatusViewAlignment(boolean animate) { boolean shouldBeCentered = shouldKeyguardStatusViewBeCentered(); mKeyguardUnfoldTransition.ifPresent(t -> t.setStatusViewCentered(shouldBeCentered)); - if (MigrateClocksToBlueprint.isEnabled()) { - mKeyguardInteractor.setClockShouldBeCentered(shouldBeCentered); - return; - } - ConstraintLayout layout = mNotificationContainerParent; - mKeyguardStatusViewController.updateAlignment( - layout, mSplitShadeEnabled, shouldBeCentered, animate); + mKeyguardInteractor.setClockShouldBeCentered(shouldBeCentered); } private boolean shouldKeyguardStatusViewBeCentered() { @@ -1588,7 +1218,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mDozing && mDozeParameters.getAlwaysOn(); } - private boolean hasVisibleNotifications() { if (FooterViewRefactor.isEnabled()) { return mActiveNotificationsInteractor.getAreAnyNotificationsPresentValue() @@ -1600,121 +1229,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } } - /** Returns space between top of lock icon and bottom of NotificationStackScrollLayout. */ - private float getLockIconPadding() { - float lockIconPadding = 0f; - View deviceEntryIconView = mKeyguardViewConfigurator.getKeyguardRootView() - .findViewById(R.id.device_entry_icon_view); - if (deviceEntryIconView != null) { - lockIconPadding = mNotificationStackScrollLayoutController.getBottom() - - deviceEntryIconView.getTop(); - } - return lockIconPadding; - } - - /** Returns space available to show notifications on lockscreen. */ - @VisibleForTesting - float getVerticalSpaceForLockscreenNotifications() { - final float lockIconPadding = getLockIconPadding(); - - float bottomPadding = Math.max(lockIconPadding, - Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding)); - mKeyguardNotificationBottomPadding = bottomPadding; - - float staticTopPadding = mClockPositionAlgorithm.getLockscreenNotifPadding( - mNotificationStackScrollLayoutController.getTop()); - - mKeyguardNotificationTopPadding = staticTopPadding; - - // To debug the available space, enable debug lines in this class. If you change how the - // available space is calculated, please also update those lines. - final float verticalSpace = - mNotificationStackScrollLayoutController.getHeight() - - staticTopPadding - - bottomPadding; - - if (SPEW_LOGCAT) { - Log.i(TAG, "\n"); - Log.i(TAG, "staticTopPadding[" + staticTopPadding - + "] = Clock.padding[" - + mClockPositionAlgorithm.getLockscreenNotifPadding( - mNotificationStackScrollLayoutController.getTop()) - + "]" - ); - Log.i(TAG, "bottomPadding[" + bottomPadding - + "] = max(ambientIndicationBottomPadding[" + mAmbientIndicationBottomPadding - + "], mIndicationBottomPadding[" + mIndicationBottomPadding - + "], lockIconPadding[" + lockIconPadding - + "])" - ); - Log.i(TAG, "verticalSpaceForNotifications[" + verticalSpace - + "] = NSSL.height[" + mNotificationStackScrollLayoutController.getHeight() - + "] - staticTopPadding[" + staticTopPadding - + "] - bottomPadding[" + bottomPadding - + "]" - ); - } - return verticalSpace; - } - - /** Returns extra space available to show the shelf on lockscreen */ - @VisibleForTesting - float getVerticalSpaceForLockscreenShelf() { - if (mSplitShadeEnabled) { - return 0f; - } - final float lockIconPadding = getLockIconPadding(); - - final float noShelfOverlapBottomPadding = - Math.max(mIndicationBottomPadding, mAmbientIndicationBottomPadding); - - final float extraSpaceForShelf = lockIconPadding - noShelfOverlapBottomPadding; - - if (extraSpaceForShelf > 0f) { - return Math.min(getShelfHeight(), extraSpaceForShelf); - } - return 0f; - } - - /** - * @return Maximum number of notifications that can fit on keyguard. - */ - @VisibleForTesting - int computeMaxKeyguardNotifications() { - if (mAmbientState.getFractionToShade() > 0) { - if (SPEW_LOGCAT) { - Log.v(TAG, "Internally skipping computeMaxKeyguardNotifications()" - + " fractionToShade=" + mAmbientState.getFractionToShade() - ); - } - return mMaxAllowedKeyguardNotifications; - } - return mNotificationStackSizeCalculator.computeMaxKeyguardNotifications( - mNotificationStackScrollLayoutController.getView(), - getVerticalSpaceForLockscreenNotifications(), - getVerticalSpaceForLockscreenShelf(), - getShelfHeight() - ); - } - - private int getShelfHeight() { - return mNotificationStackScrollLayoutController.getShelfHeight(); - } - - private void updateClock() { - if (mIsOcclusionTransitionRunning) { - return; - } - float alpha = mClockPositionResult.clockAlpha * mKeyguardOnlyContentAlpha; - mKeyguardStatusViewController.setAlpha(alpha); - if (MigrateClocksToBlueprint.isEnabled()) { - // TODO (b/296373478) This is for split shade media movement. - } else { - mKeyguardStatusViewController - .setTranslationY(mKeyguardOnlyTransitionTranslationY, /* excludeMedia= */true); - } - } - @Override public void transitionToExpandedShade(long delay) { mNotificationStackScrollLayoutController.goToFullShade(delay); @@ -2156,17 +1670,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mPowerInteractor.getDetailedWakefulness().getValue(); } - @VisibleForTesting - void maybeAnimateBottomAreaAlpha() { - mBottomAreaShadeAlphaAnimator.cancel(); - if (mBarState == StatusBarState.SHADE_LOCKED) { - mBottomAreaShadeAlphaAnimator.setFloatValues(mBottomAreaShadeAlpha, 0.0f); - mBottomAreaShadeAlphaAnimator.start(); - } else { - mBottomAreaShadeAlpha = 1f; - } - } - /** * When the back gesture triggers a fully-expanded shade --> QQS shade collapse transition, * the expansionFraction goes down from 1.0 --> 0.0 (collapsing), so the current "squish" amount @@ -2246,7 +1749,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } if (!mKeyguardBypassController.getBypassEnabled()) { - if (MigrateClocksToBlueprint.isEnabled() && !mSplitShadeEnabled) { + if (!mSplitShadeEnabled) { return (int) mKeyguardInteractor.getNotificationContainerBounds() .getValue().getTop(); } @@ -2268,23 +1771,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mBarState == KEYGUARD; } - float getKeyguardNotificationTopPadding() { - return mKeyguardNotificationTopPadding; - } - - float getKeyguardNotificationBottomPadding() { - return mKeyguardNotificationBottomPadding; - } - void requestScrollerTopPaddingUpdate(boolean animate) { if (!SceneContainerFlag.isEnabled()) { float padding = mQsController.calculateNotificationsTopPadding(mIsExpandingOrCollapsing, getKeyguardNotificationStaticPadding(), mExpandedFraction); - if (MigrateClocksToBlueprint.isEnabled()) { - mSharedNotificationContainerInteractor.setTopPosition(padding); - } else { - mNotificationStackScrollLayoutController.updateTopPadding(padding, animate); - } + mSharedNotificationContainerInteractor.setTopPosition(padding); } if (isKeyguardShowing() @@ -2295,27 +1786,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } @Override - public void setKeyguardTransitionProgress(float keyguardAlpha, int keyguardTranslationY) { - mKeyguardOnlyContentAlpha = Interpolators.ALPHA_IN.getInterpolation(keyguardAlpha); - mKeyguardOnlyTransitionTranslationY = keyguardTranslationY; - if (mBarState == KEYGUARD) { - // If the animator is running, it's already fading out the content and this is a reset - mBottomAreaShadeAlpha = mKeyguardOnlyContentAlpha; - updateKeyguardBottomAreaAlpha(); - } - updateClock(); - } - - @Override public void setKeyguardStatusBarAlpha(float alpha) { mKeyguardStatusBarViewController.setAlpha(alpha); } - /** */ - float getKeyguardOnlyContentAlpha() { - return mKeyguardOnlyContentAlpha; - } - @VisibleForTesting boolean canCollapsePanelOnTouch() { if (!mQsController.getExpanded() && mBarState == KEYGUARD) { @@ -2416,7 +1890,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } updateExpandedHeight(expandedHeight); updateHeader(); - updateNotificationTranslucency(); updatePanelExpanded(); updateGestureExclusionRect(); if (DEBUG_DRAWABLE) { @@ -2454,35 +1927,14 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump int maxHeight = mNotificationStackScrollLayoutController.getHeight() - emptyBottomMargin; if (mBarState == KEYGUARD) { - int minKeyguardPanelBottom = mClockPositionAlgorithm.getLockscreenStatusViewHeight() - + mNotificationStackScrollLayoutController.getIntrinsicContentHeight(); + int minKeyguardPanelBottom = mNotificationStackScrollLayoutController + .getIntrinsicContentHeight(); return Math.max(maxHeight, minKeyguardPanelBottom); } else { return maxHeight; } } - private void updateNotificationTranslucency() { - if (mIsOcclusionTransitionRunning) { - return; - } - - if (!MigrateClocksToBlueprint.isEnabled()) { - float alpha = 1f; - if (mClosingWithAlphaFadeOut && !mExpandingFromHeadsUp - && !mHeadsUpManager.hasPinnedHeadsUp()) { - alpha = getFadeoutAlpha(); - } - if (mBarState == KEYGUARD - && !mKeyguardBypassController.getBypassEnabled() - && !mQsController.getFullyExpanded()) { - alpha *= mClockPositionResult.clockAlpha; - } - mNotificationStackScrollLayoutController.setMaxAlphaForKeyguard(alpha, - "NPVC.updateNotificationTranslucency()"); - } - } - private float getFadeoutAlpha() { float alpha; if (mQsController.getMinExpansionHeight() == 0) { @@ -2502,28 +1954,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mQsController.updateExpansion(); } - private void updateKeyguardBottomAreaAlpha() { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - if (mIsOcclusionTransitionRunning) { - return; - } - // There are two possible panel expansion behaviors: - // • User dragging up to unlock: we want to fade out as quick as possible - // (ALPHA_EXPANSION_THRESHOLD) to avoid seeing the bouncer over the bottom area. - // • User tapping on lock screen: bouncer won't be visible but panel expansion will - // change due to "unlock hint animation." In this case, fading out the bottom area - // would also hide the message that says "swipe to unlock," we don't want to do that. - float expansionAlpha = MathUtils.constrainedMap(0f, 1f, - KeyguardBouncerConstants.ALPHA_EXPANSION_THRESHOLD, 1f, - getExpandedFraction()); - - float alpha = Math.min(expansionAlpha, 1 - mQsController.computeExpansionFraction()); - alpha *= mBottomAreaShadeAlpha; - mKeyguardInteractor.setAlpha(alpha); - } - private void onExpandingFinished() { if (!SceneContainerFlag.isEnabled()) { mNotificationStackScrollLayoutController.onExpansionStopped(); @@ -2734,13 +2164,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump } } - @Override - public void onScreenTurningOn() { - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.dozeTimeTick(); - } - } - private void onMiddleClicked() { switch (mBarState) { case KEYGUARD: @@ -2846,7 +2269,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump if (!SceneContainerFlag.isEnabled()) { mNotificationStackScrollLayoutController.setExpandedHeight(expandedHeight); } - updateKeyguardBottomAreaAlpha(); updateStatusBarIcons(); } @@ -2973,10 +2395,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mKeyguardStatusBarViewController.setDozing(mDozing); mQsController.setDozing(mDozing); - if (dozing) { - mBottomAreaShadeAlphaAnimator.cancel(); - } - if (mBarState == KEYGUARD || mBarState == StatusBarState.SHADE_LOCKED) { updateDozingVisibilities(animate); } @@ -3006,32 +2424,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump updateKeyguardStatusViewAlignment(/* animate= */ true); } - @Override - public void setAmbientIndicationTop(int ambientIndicationTop, boolean ambientTextVisible) { - int ambientIndicationBottomPadding = 0; - if (ambientTextVisible) { - int stackBottom = mNotificationStackScrollLayoutController.getBottom(); - ambientIndicationBottomPadding = stackBottom - ambientIndicationTop; - } - if (mAmbientIndicationBottomPadding != ambientIndicationBottomPadding) { - mAmbientIndicationBottomPadding = ambientIndicationBottomPadding; - updateMaxDisplayedNotifications(true); - } - } - - public void dozeTimeTick() { - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.dozeTimeTick(); - } - if (mInterpolatedDarkAmount > 0) { - positionClockAndNotifications(); - } - } - - void setStatusAccessibilityImportance(int mode) { - mKeyguardStatusViewController.setStatusAccessibilityImportance(mode); - } - public void performHapticFeedback(int constant) { if (msdlFeedback()) { MSDLToken token; @@ -3095,12 +2487,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump /** Updates the views to the initial state for the fold to AOD animation. */ @Override public void prepareFoldToAodAnimation() { - if (MigrateClocksToBlueprint.isEnabled()) { - setDozing(true /* dozing */, false /* animate */); - } else { - // Force show AOD UI even if we are not locked - showAodUi(); - } + setDozing(true /* dozing */, false /* animate */); // Move the content of the AOD all the way to the left // so we can animate to the initial position @@ -3120,14 +2507,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump @Override public void startFoldToAodAnimation( Runnable startAction, Runnable endAction, Runnable cancelAction) { - if (MigrateClocksToBlueprint.isEnabled()) { - return; - } - buildViewAnimator(startAction, endAction, cancelAction) - .setUpdateListener(anim -> mKeyguardStatusViewController - .animateFoldToAod(anim.getAnimatedFraction())) - .start(); } /** @@ -3173,13 +2553,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump resetAlpha(); resetTranslation(); } - - /** Returns the NotificationPanelView. */ - @Override - public ViewGroup getView() { - // TODO(b/254878364): remove this method, or at least reduce references to it. - return mView; - } } @Override @@ -3207,11 +2580,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump ipw.print("isTracking()="); ipw.println(isTracking()); ipw.print("mExpanding="); ipw.println(mExpanding); ipw.print("mSplitShadeEnabled="); ipw.println(mSplitShadeEnabled); - ipw.print("mKeyguardNotificationBottomPadding="); - ipw.println(mKeyguardNotificationBottomPadding); - ipw.print("mKeyguardNotificationTopPadding="); ipw.println(mKeyguardNotificationTopPadding); - ipw.print("mMaxAllowedKeyguardNotifications="); - ipw.println(mMaxAllowedKeyguardNotifications); ipw.print("mAnimateNextPositionUpdate="); ipw.println(mAnimateNextPositionUpdate); ipw.print("isPanelExpanded()="); ipw.println(isPanelExpanded()); ipw.print("mDozing="); ipw.println(mDozing); @@ -3235,8 +2603,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump ipw.print("mClosingWithAlphaFadeOut="); ipw.println(mClosingWithAlphaFadeOut); ipw.print("mHeadsUpAnimatingAway="); ipw.println(mHeadsUpAnimatingAway); ipw.print("mShowIconsWhenExpanded="); ipw.println(mShowIconsWhenExpanded); - ipw.print("mIndicationBottomPadding="); ipw.println(mIndicationBottomPadding); - ipw.print("mAmbientIndicationBottomPadding="); ipw.println(mAmbientIndicationBottomPadding); ipw.print("mIsFullWidth="); ipw.println(mIsFullWidth); ipw.print("mBlockingExpansionForCurrentTouch="); ipw.println(mBlockingExpansionForCurrentTouch); @@ -3247,16 +2613,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump ipw.print("mPulsing="); ipw.println(mPulsing); ipw.print("mStackScrollerMeasuringPass="); ipw.println(mStackScrollerMeasuringPass); ipw.print("mPanelAlpha="); ipw.println(mPanelAlpha); - ipw.print("mBottomAreaShadeAlpha="); ipw.println(mBottomAreaShadeAlpha); ipw.print("mHeadsUpInset="); ipw.println(mHeadsUpInset); ipw.print("mHeadsUpPinnedMode="); ipw.println(mHeadsUpPinnedMode); ipw.print("mAllowExpandForSmallExpansion="); ipw.println(mAllowExpandForSmallExpansion); ipw.print("mMaxOverscrollAmountForPulse="); ipw.println(mMaxOverscrollAmountForPulse); ipw.print("mIsPanelCollapseOnQQS="); ipw.println(mIsPanelCollapseOnQQS); - ipw.print("mKeyguardOnlyContentAlpha="); ipw.println(mKeyguardOnlyContentAlpha); - ipw.print("mKeyguardOnlyTransitionTranslationY="); - ipw.println(mKeyguardOnlyTransitionTranslationY); - ipw.print("mUdfpsMaxYBurnInOffset="); ipw.println(mUdfpsMaxYBurnInOffset); ipw.print("mIsGestureNavigation="); ipw.println(mIsGestureNavigation); ipw.print("mOldLayoutDirection="); ipw.println(mOldLayoutDirection); ipw.print("mMinFraction="); ipw.println(mMinFraction); @@ -3325,7 +2686,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mGestureRecorder = recorder; mHideExpandedRunnable = hideExpandedRunnable; - updateMaxDisplayedNotifications(true); } @Override @@ -3691,18 +3051,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mExpandLatencyTracking = false; } float maxPanelHeight = getMaxPanelTransitionDistance(); - if (mHeightAnimator == null && !MigrateClocksToBlueprint.isEnabled()) { - // MigrateClocksToBlueprint - There is an edge case where swiping up slightly, - // and then swiping down will trigger overscroll logic. Even without this flag - // enabled, the notifications can then run into UDFPS. At this point it is - // safer to remove overscroll for this one case to prevent overlap. - - // Split shade has its own overscroll logic - if (isTracking()) { - float overExpansionPixels = Math.max(0, h - maxPanelHeight); - setOverExpansionInternal(overExpansionPixels, true /* isFromGesture */); - } - } mExpandedHeight = Math.min(h, maxPanelHeight); // If we are closing the panel and we are almost there due to a slow decelerating // interpolator, abort the animation. @@ -4019,9 +3367,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump void onQsExpansionChanged(boolean expanded) { updateExpandedHeightToMaxHeight(); - setStatusAccessibilityImportance(expanded - ? View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS - : View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); updateSystemUiStateFlags(); NavigationBarView navigationBarView = mNavigationBarController.getNavigationBarView(mDisplayId); @@ -4036,7 +3381,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mKeyguardStatusBarViewController.updateViewState(); int barState = getBarState(); if (barState == SHADE_LOCKED || barState == KEYGUARD) { - updateKeyguardBottomAreaAlpha(); positionClockAndNotifications(); } @@ -4060,10 +3404,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump mKeyguardInteractor.setQuickSettingsVisible(qsVisible); } - // The padding on this area is large enough that - // we can use a cheaper clipping strategy - mKeyguardStatusViewController.setClipBounds( - clipStatusView ? lastQsClipBounds : null); if (mSplitShadeEnabled) { mKeyguardStatusBarViewController.setNoTopClipping(); } else { @@ -4104,9 +3444,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump == firstRow))) { requestScrollerTopPaddingUpdate(false /* animate */); } - if (isKeyguardShowing()) { - updateMaxDisplayedNotifications(true); - } updateExpandedHeightToMaxHeight(); } @@ -4128,7 +3465,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump public void onHeadsUpPinnedModeChanged(final boolean inPinnedMode) { if (inPinnedMode) { mHeadsUpExistenceChangedRunnable.run(); - updateNotificationTranslucency(); } else { setHeadsUpAnimatingAway(true); mNotificationStackScrollLayoutController.runAfterAnimationFinished( @@ -4190,28 +3526,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump int oldState = mBarState; boolean keyguardShowing = statusBarState == KEYGUARD; - if (mDozeParameters.shouldDelayKeyguardShow() - && oldState == StatusBarState.SHADE - && statusBarState == KEYGUARD) { - // This means we're doing the screen off animation - position the keyguard status - // view where it'll be on AOD, so we can animate it in. - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.updatePosition( - mClockPositionResult.clockX, - mClockPositionResult.clockYFullyDozing, - mClockPositionResult.clockScale, - false /* animate */); - } - } - - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setKeyguardStatusViewVisibility( - statusBarState, - keyguardFadingAway, - goingToFullShade, - mBarState); - } - // TODO: maybe add a listener for barstate mBarState = statusBarState; mQsController.setBarState(statusBarState); @@ -4273,10 +3587,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump updateDozingVisibilities(false /* animate */); } - updateMaxDisplayedNotifications(false); // The update needs to happen after the headerSlide in above, otherwise the translation // would reset - maybeAnimateBottomAreaAlpha(); mQsController.updateQsState(); } @@ -4311,12 +3623,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump public void showAodUi() { setDozing(true /* dozing */, false /* animate */); mStatusBarStateController.setUpcomingState(KEYGUARD); - - if (MigrateClocksToBlueprint.isEnabled()) { - mStatusBarStateController.setState(KEYGUARD); - } else { - mStatusBarStateListener.onStateChanged(KEYGUARD); - } + mStatusBarStateController.setState(KEYGUARD); mStatusBarStateListener.onDozeAmountChanged(1f, 1f); setExpandedFraction(1f); } @@ -4370,14 +3677,8 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump fling(mUpdateFlingVelocity); mUpdateFlingOnLayout = false; } - updateMaxDisplayedNotifications(!shouldAvoidChangingNotificationsCount()); setIsFullWidth(mNotificationStackScrollLayoutController.getWidth() == mView.getWidth()); - // Update Clock Pivot (used by anti-burnin transformations) - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.updatePivot(mView.getWidth(), mView.getHeight()); - } - int oldMaxHeight = mQsController.updateHeightsOnShadeLayoutChange(); positionClockAndNotifications(); mQsController.handleShadeLayoutChanged(oldMaxHeight); @@ -4457,36 +3758,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump // Also animate the status bar's alpha during transitions between the lockscreen and // dreams. mKeyguardStatusBarViewController.setAlpha(alpha); - setTransitionAlpha(stackScroller).accept(alpha); - }; - } - - private Consumer<Float> setTransitionAlpha( - NotificationStackScrollLayoutController stackScroller) { - return setTransitionAlpha(stackScroller, /* excludeNotifications= */ false); - } - - private Consumer<Float> setTransitionAlpha( - NotificationStackScrollLayoutController stackScroller, - boolean excludeNotifications) { - return (Float alpha) -> { - mKeyguardStatusViewController.setAlpha(alpha); - if (!excludeNotifications) { - stackScroller.setMaxAlphaForKeyguard(alpha, "NPVC.setTransitionAlpha()"); - } - - mKeyguardInteractor.setAlpha(alpha); - }; - } - - private Consumer<Float> setTransitionY( - NotificationStackScrollLayoutController stackScroller) { - return (Float translationY) -> { - if (!MigrateClocksToBlueprint.isEnabled()) { - mKeyguardStatusViewController.setTranslationY(translationY, - /* excludeMedia= */false); - stackScroller.setTranslationY(translationY); - } }; } @@ -4514,7 +3785,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump */ @Override public boolean onInterceptTouchEvent(MotionEvent event) { - if (MigrateClocksToBlueprint.isEnabled() && !mUseExternalTouch) { + if (!mUseExternalTouch) { return false; } @@ -4583,9 +3854,6 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: - if (!MigrateClocksToBlueprint.isEnabled()) { - mCentralSurfaces.userActivity(); - } mAnimatingOnDown = mHeightAnimator != null && !mIsSpringBackAnimation; mMinExpandHeight = 0.0f; mDownTime = mSystemClock.uptimeMillis(); @@ -4681,7 +3949,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump */ @Override public boolean onTouchEvent(MotionEvent event) { - if (MigrateClocksToBlueprint.isEnabled() && !mUseExternalTouch) { + if (!mUseExternalTouch) { return false; } diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt b/packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt index 58111576574e..7299f092640f 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationsQSContainerController.kt @@ -27,7 +27,6 @@ import androidx.constraintlayout.widget.ConstraintSet.START import androidx.constraintlayout.widget.ConstraintSet.TOP import androidx.lifecycle.lifecycleScope import com.android.app.tracing.coroutines.launchTraced as launch -import com.android.systemui.customization.R as customR import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.fragments.FragmentService @@ -271,7 +270,6 @@ constructor( ensureAllViewsHaveIds(mView) val constraintSet = ConstraintSet() constraintSet.clone(mView) - setKeyguardStatusViewConstraints(constraintSet) setQsConstraints(constraintSet) setLargeScreenShadeHeaderConstraints(constraintSet) mView.applyConstraints(constraintSet) @@ -295,15 +293,6 @@ constructor( } } - private fun setKeyguardStatusViewConstraints(constraintSet: ConstraintSet) { - val statusViewMarginHorizontal = - resources.getDimensionPixelSize(customR.dimen.status_view_margin_horizontal) - constraintSet.apply { - setMargin(R.id.keyguard_status_view, START, statusViewMarginHorizontal) - setMargin(R.id.keyguard_status_view, END, statusViewMarginHorizontal) - } - } - private fun ensureAllViewsHaveIds(parentView: ViewGroup) { for (i in 0 until parentView.childCount) { val childView = parentView.getChildAt(i) diff --git a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java index 4fb43fdcfdae..c88e7b827881 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/QuickSettingsControllerImpl.java @@ -1199,7 +1199,6 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum !mSplitShadeEnabled && qsExpansionFraction == 0 && qsPanelBottomY > 0; final boolean qsVisible = qsExpansionFraction > 0; final boolean qsOrQqsVisible = qqsVisible || qsVisible; - checkCorrectScrimVisibility(qsExpansionFraction); int top = calculateTopClippingBound(qsPanelBottomY); int bottom = calculateBottomClippingBound(top); @@ -1403,21 +1402,6 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum } } - private void checkCorrectScrimVisibility(float expansionFraction) { - // issues with scrims visible on keyguard occur only in split shade - if (mSplitShadeEnabled) { - // TODO (b/265193930): remove dependency on NPVC - boolean keyguardViewsVisible = mBarState == KEYGUARD - && mPanelViewControllerLazy.get().getKeyguardOnlyContentAlpha() == 1; - // expansionFraction == 1 means scrims are fully visible as their size/visibility depend - // on QS expansion - if (expansionFraction == 1 && keyguardViewsVisible) { - Log.wtf(TAG, - "Incorrect state, scrim is visible at the same time when clock is visible"); - } - } - } - @Override public float calculateNotificationsTopPadding(boolean isShadeExpanding, int keyguardNotificationStaticPadding, float expandedFraction) { diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt index 6069705be5fb..6d66a7fc0f3e 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurface.kt @@ -75,9 +75,6 @@ interface ShadeSurface : /** Sets the view's alpha to max. */ fun resetAlpha() - /** @see com.android.systemui.keyguard.ScreenLifecycle.Observer.onScreenTurningOn */ - fun onScreenTurningOn() - /** * Called when the device's theme changes. * diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt index 9b971d7740f2..110100eeec76 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeSurfaceImpl.kt @@ -65,10 +65,6 @@ class ShadeSurfaceImpl @Inject constructor() : ShadeSurface, ShadeViewController // Do nothing } - override fun onScreenTurningOn() { - // Do nothing - } - override fun onThemeChanged() { // Do nothing } diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt index b085aec3de2f..879008325141 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewController.kt @@ -16,7 +16,6 @@ package com.android.systemui.shade import android.view.MotionEvent -import android.view.ViewGroup import com.android.systemui.power.shared.model.WakefulnessModel import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.phone.HeadsUpAppearanceController @@ -53,10 +52,6 @@ interface ShadeViewController { @Deprecated("Does nothing when scene container is enabled.") fun setQsScrimEnabled(qsScrimEnabled: Boolean) - /** Sets the top spacing for the ambient indicator. */ - @Deprecated("Does nothing when scene container is enabled.") - fun setAmbientIndicationTop(ambientIndicationTop: Int, ambientTextVisible: Boolean) - /** Updates notification panel-specific flags on [SysUiState]. */ @Deprecated("Does nothing when scene container is enabled.") fun updateSystemUiStateFlags() @@ -169,9 +164,6 @@ interface ShadeFoldAnimator { /** Cancels fold to AOD transition and resets view state. */ @Deprecated("Used by the Keyguard Fold Transition. Needs flexiglass equivalent.") fun cancelFoldToAodAnimation() - - /** Returns the main view of the shade. */ - @Deprecated("Not used when migrateClocksToBlueprint enabled.") val view: ViewGroup? } /** diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt index f65d3780b21e..2976a1fd1658 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt @@ -17,7 +17,6 @@ package com.android.systemui.shade import android.view.MotionEvent -import android.view.ViewGroup import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor import com.android.systemui.shade.domain.interactor.ShadeBackActionInteractor import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor @@ -55,8 +54,6 @@ open class ShadeViewControllerEmptyImpl @Inject constructor() : override fun startExpandLatencyTracking() {} - override fun dozeTimeTick() {} - override fun resetViews(animate: Boolean) {} override val barState: Int = 0 @@ -74,8 +71,6 @@ open class ShadeViewControllerEmptyImpl @Inject constructor() : override fun setQsScrimEnabled(qsScrimEnabled: Boolean) {} - override fun setAmbientIndicationTop(ambientIndicationTop: Int, ambientTextVisible: Boolean) {} - override fun updateSystemUiStateFlags() {} override fun updateTouchableRegion() {} @@ -84,9 +79,6 @@ open class ShadeViewControllerEmptyImpl @Inject constructor() : @Deprecated("Not supported by scenes") override fun resetViewGroupFade() {} - @Deprecated("Not supported by scenes") - override fun setKeyguardTransitionProgress(keyguardAlpha: Float, keyguardTranslationY: Int) {} - @Deprecated("Not supported by scenes") override fun setOverStretchAmount(amount: Float) {} @Deprecated("TODO(b/325072511) delete this") @@ -146,6 +138,4 @@ class ShadeFoldAnimatorEmptyImpl : ShadeFoldAnimator { ) {} override fun cancelFoldToAodAnimation() {} - - override val view: ViewGroup? = null } diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractor.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractor.kt index f538d7446453..049589d2d251 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractor.kt @@ -38,9 +38,6 @@ interface ShadeLockscreenInteractor { */ @Deprecated("Use ShadeInteractor instead") val isExpanded: Boolean - /** Called once every minute while dozing. */ - fun dozeTimeTick() - /** * Do not let the user drag the shade up and down for the current touch session. This is * necessary to avoid shade expansion while/after the bouncer is dismissed. @@ -59,13 +56,6 @@ interface ShadeLockscreenInteractor { /** @see ViewGroupFadeHelper.reset */ @Deprecated("Not supported by scenes") fun resetViewGroupFade() - /** - * Set the alpha and translationY of the keyguard elements which only show on the lockscreen, - * but not in shade locked / shade. This is used when dragging down to the full shade. - */ - @Deprecated("Not supported by scenes") - fun setKeyguardTransitionProgress(keyguardAlpha: Float, keyguardTranslationY: Int) - /** Sets the overstretch amount in raw pixels when dragging down. */ @Deprecated("Not supported by scenes") fun setOverStretchAmount(amount: Float) diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt index d712ece7f144..14934b31a06f 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeLockscreenInteractorImpl.kt @@ -54,10 +54,6 @@ constructor( override val isExpanded get() = shadeInteractor.isAnyExpanded.value - override fun dozeTimeTick() { - // TODO("b/383591086") Implement replacement or delete - } - @Deprecated("Not supported by scenes") override fun blockExpansionForCurrentTouch() { // TODO("b/324280998") Implement replacement or delete @@ -93,11 +89,6 @@ constructor( } @Deprecated("Not supported by scenes") - override fun setKeyguardTransitionProgress(keyguardAlpha: Float, keyguardTranslationY: Int) { - // Now handled elsewhere. Do nothing. - } - - @Deprecated("Not supported by scenes") override fun setOverStretchAmount(amount: Float) { // Now handled elsewhere. Do nothing. } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeKeyguardTransitionController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeKeyguardTransitionController.kt index 72f2aa5aa10b..31e5df9e668a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeKeyguardTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeKeyguardTransitionController.kt @@ -17,14 +17,19 @@ import dagger.assisted.AssistedInject class LockscreenShadeKeyguardTransitionController @AssistedInject constructor( - private val mediaHierarchyManager: MediaHierarchyManager, - @Assisted private val shadeLockscreenInteractor: ShadeLockscreenInteractor, - context: Context, - configurationController: ConfigurationController, - dumpManager: DumpManager, - splitShadeStateController: SplitShadeStateController -) : AbstractLockscreenShadeTransitionController(context, configurationController, dumpManager, - splitShadeStateController) { + private val mediaHierarchyManager: MediaHierarchyManager, + @Assisted private val shadeLockscreenInteractor: ShadeLockscreenInteractor, + context: Context, + configurationController: ConfigurationController, + dumpManager: DumpManager, + splitShadeStateController: SplitShadeStateController, +) : + AbstractLockscreenShadeTransitionController( + context, + configurationController, + dumpManager, + splitShadeStateController, + ) { /** * Distance that the full shade transition takes in order for the keyguard content on @@ -32,15 +37,6 @@ constructor( */ private var alphaTransitionDistance = 0 - /** - * Distance that the full shade transition takes in order for the keyguard elements to fully - * translate into their final position - */ - private var keyguardTransitionDistance = 0 - - /** The amount of vertical offset for the keyguard during the full shade transition. */ - private var keyguardTransitionOffset = 0 - /** The amount of alpha that was last set on the keyguard elements. */ private var alpha = 0f @@ -50,49 +46,21 @@ constructor( /** The amount of alpha that was last set on the keyguard status bar. */ private var statusBarAlpha = 0f - /** The amount of translationY that was last set on the keyguard elements. */ - private var translationY = 0 - - /** The latest progress [0,1] of the translationY progress. */ - private var translationYProgress = 0f - override fun updateResources() { alphaTransitionDistance = context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_npvc_keyguard_content_alpha_transition_distance) - keyguardTransitionDistance = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_keyguard_transition_distance) - keyguardTransitionOffset = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_keyguard_transition_vertical_offset) + R.dimen.lockscreen_shade_npvc_keyguard_content_alpha_transition_distance + ) } override fun onDragDownAmountChanged(dragDownAmount: Float) { alphaProgress = MathUtils.saturate(dragDownAmount / alphaTransitionDistance) alpha = 1f - alphaProgress - translationY = calculateKeyguardTranslationY(dragDownAmount) - shadeLockscreenInteractor.setKeyguardTransitionProgress(alpha, translationY) statusBarAlpha = if (useSplitShade) alpha else -1f shadeLockscreenInteractor.setKeyguardStatusBarAlpha(statusBarAlpha) } - private fun calculateKeyguardTranslationY(dragDownAmount: Float): Int { - if (!useSplitShade) { - return 0 - } - // On split-shade, the translationY of the keyguard should stay in sync with the - // translation of media. - if (mediaHierarchyManager.isCurrentlyInGuidedTransformation()) { - return mediaHierarchyManager.getGuidedTransformationTranslationY() - } - // When media is not showing, apply the default distance - translationYProgress = MathUtils.saturate(dragDownAmount / keyguardTransitionDistance) - val translationY = translationYProgress * keyguardTransitionOffset - return translationY.toInt() - } - override fun dump(indentingPrintWriter: IndentingPrintWriter) { indentingPrintWriter.let { it.println("LockscreenShadeKeyguardTransitionController:") @@ -100,8 +68,6 @@ constructor( it.println("Resources:") it.increaseIndent() it.println("alphaTransitionDistance: $alphaTransitionDistance") - it.println("keyguardTransitionDistance: $keyguardTransitionDistance") - it.println("keyguardTransitionOffset: $keyguardTransitionOffset") it.decreaseIndent() it.println("State:") it.increaseIndent() @@ -109,8 +75,6 @@ constructor( it.println("alpha: $alpha") it.println("alphaProgress: $alphaProgress") it.println("statusBarAlpha: $statusBarAlpha") - it.println("translationProgress: $translationYProgress") - it.println("translationY: $translationY") } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 233559c7e689..2bc417e4aada 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -2662,7 +2662,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { @Override public void onScreenTurningOn() { mFalsingCollector.onScreenTurningOn(); - mShadeSurface.onScreenTurningOn(); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java index 57e26d708f26..6922de5739ab 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/DozeServiceHost.java @@ -340,7 +340,6 @@ public final class DozeServiceHost implements DozeHost { public void dozeTimeTick() { TraceUtils.trace("DozeServiceHost#dozeTimeTick", () -> { mDozeInteractor.dozeTimeTick(); - mShadeLockscreenInteractor.dozeTimeTick(); mAuthController.dozeTimeTick(); if (mAmbientIndicationContainer instanceof DozeReceiver) { ((DozeReceiver) mAmbientIndicationContainer).dozeTimeTick(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java index 518923eec5ca..656ab0d7c938 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithm.java @@ -16,23 +16,14 @@ package com.android.systemui.statusbar.phone; -import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInOffset; -import static com.android.systemui.doze.util.BurnInHelperKt.getBurnInScale; -import static com.android.systemui.statusbar.notification.NotificationUtils.interpolate; - import android.content.Context; import android.content.res.Resources; -import android.util.MathUtils; -import com.android.app.animation.Interpolators; -import com.android.keyguard.BouncerPanelExpansionCalculator; -import com.android.keyguard.KeyguardStatusView; import com.android.systemui.log.LogBuffer; import com.android.systemui.log.core.Logger; import com.android.systemui.log.dagger.KeyguardClockLog; import com.android.systemui.res.R; import com.android.systemui.shade.LargeScreenHeaderHelper; -import com.android.systemui.shade.ShadeViewController; import javax.inject.Inject; @@ -44,31 +35,6 @@ public class KeyguardClockPositionAlgorithm { private static final boolean DEBUG = false; /** - * Margin between the bottom of the status view and the notification shade. - */ - private int mStatusViewBottomMargin; - - /** - * Height of {@link KeyguardStatusView}. - */ - private int mKeyguardStatusHeight; - - /** - * Minimum top margin to avoid overlap with status bar or multi-user switcher avatar. - */ - private int mMinTopMargin; - - /** - * Minimum top inset (in pixels) to avoid overlap with any display cutouts. - */ - private int mCutoutTopInset = 0; - - /** - * Recommended distance from the status bar. - */ - private int mContainerTopPadding; - - /** * Top margin of notifications introduced by presence of split shade header / status bar */ private int mSplitShadeTopNotificationsMargin; @@ -79,35 +45,10 @@ public class KeyguardClockPositionAlgorithm { private int mSplitShadeTargetTopMargin; /** - * @see ShadeViewController#getExpandedFraction() - */ - private float mPanelExpansion; - - /** - * Max burn-in prevention x translation. - */ - private int mMaxBurnInPreventionOffsetX; - - /** - * Max burn-in prevention y translation for clock layouts. - */ - private int mMaxBurnInPreventionOffsetYClock; - - /** - * Current burn-in prevention y translation. - */ - private float mCurrentBurnInOffsetY; - - /** * Doze/AOD transition amount. */ private float mDarkAmount; - /** - * How visible the quick settings panel is. - */ - private float mQsExpansion; - private float mOverStretchAmount; /** @@ -123,25 +64,6 @@ public class KeyguardClockPositionAlgorithm { private boolean mIsSplitShade; - /** - * Top location of the udfps icon. This includes the worst case (highest) burn-in - * offset that would make the top physically highest on the screen. - * - * Set to -1 if udfps is not enrolled on the device. - */ - private float mUdfpsTop; - - /** - * Bottom y-position of the currently visible clock - */ - private float mClockBottom; - - /** - * If true, try to keep clock aligned to the top of the display. Else, assume the clock - * is center aligned. - */ - private boolean mIsClockTopAligned; - private Logger mLogger; @Inject @@ -151,230 +73,52 @@ public class KeyguardClockPositionAlgorithm { /** Refreshes the dimension values. */ public void loadDimens(Context context, Resources res) { - mStatusViewBottomMargin = - res.getDimensionPixelSize(R.dimen.keyguard_status_view_bottom_margin); mSplitShadeTopNotificationsMargin = LargeScreenHeaderHelper.getLargeScreenHeaderHeight(context); mSplitShadeTargetTopMargin = res.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin); - - mContainerTopPadding = - res.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin); - mMaxBurnInPreventionOffsetX = res.getDimensionPixelSize( - R.dimen.burn_in_prevention_offset_x); - mMaxBurnInPreventionOffsetYClock = res.getDimensionPixelSize( - R.dimen.burn_in_prevention_offset_y_clock); } /** * Sets up algorithm values. */ - public void setup(int keyguardStatusBarHeaderHeight, float panelExpansion, - int keyguardStatusHeight, float dark, float overStretchAmount, boolean bypassEnabled, - int unlockedStackScrollerPadding, float qsExpansion, int cutoutTopInset, - boolean isSplitShade, float udfpsTop, float clockBottom, boolean isClockTopAligned) { - mMinTopMargin = keyguardStatusBarHeaderHeight + mContainerTopPadding; - mPanelExpansion = BouncerPanelExpansionCalculator - .getKeyguardClockScaledExpansion(panelExpansion); - mKeyguardStatusHeight = keyguardStatusHeight + mStatusViewBottomMargin; + public void setup(float dark, float overStretchAmount, boolean bypassEnabled, + int unlockedStackScrollerPadding, boolean isSplitShade) { mDarkAmount = dark; mOverStretchAmount = overStretchAmount; mBypassEnabled = bypassEnabled; mUnlockedStackScrollerPadding = unlockedStackScrollerPadding; - mQsExpansion = qsExpansion; - mCutoutTopInset = cutoutTopInset; mIsSplitShade = isSplitShade; - mUdfpsTop = udfpsTop; - mClockBottom = clockBottom; - mIsClockTopAligned = isClockTopAligned; } public void run(Result result) { - final int y = getClockY(mPanelExpansion, mDarkAmount); - result.clockY = y; - result.clockYFullyDozing = getClockY( - 1.0f /* panelExpansion */, 1.0f /* darkAmount */); - result.clockAlpha = getClockAlpha(y); - result.stackScrollerPadding = getStackScrollerPadding(y); + result.stackScrollerPadding = getStackScrollerPadding(); result.stackScrollerPaddingExpanded = getStackScrollerPaddingExpanded(); - result.clockX = (int) interpolate(0, burnInPreventionOffsetX(), mDarkAmount); - result.clockScale = interpolate(getBurnInScale(), 1.0f, 1.0f - mDarkAmount); } private int getStackScrollerPaddingExpanded() { if (mBypassEnabled) { return mUnlockedStackScrollerPadding; } else if (mIsSplitShade) { - return getClockY(1.0f, mDarkAmount); + return mSplitShadeTargetTopMargin; } else { - return getClockY(1.0f, mDarkAmount) + mKeyguardStatusHeight; + return 0; } } - private int getStackScrollerPadding(int clockYPosition) { + private int getStackScrollerPadding() { if (mBypassEnabled) { return (int) (mUnlockedStackScrollerPadding + mOverStretchAmount); } else if (mIsSplitShade) { // mCurrentBurnInOffsetY is subtracted to make notifications not follow clock adjustment // for burn-in. It can make pulsing notification go too high and it will get clipped - return clockYPosition - mSplitShadeTopNotificationsMargin - - (int) mCurrentBurnInOffsetY; + return mSplitShadeTargetTopMargin - mSplitShadeTopNotificationsMargin; } else { - return clockYPosition + mKeyguardStatusHeight; + return 0; } } - /** - * @param nsslTop NotificationStackScrollLayout top, which is below top of the srceen. - * @return Distance from nsslTop to top of the first view in the lockscreen shade. - */ - public float getLockscreenNotifPadding(float nsslTop) { - if (mBypassEnabled) { - return mUnlockedStackScrollerPadding - nsslTop; - } else if (mIsSplitShade) { - return mSplitShadeTargetTopMargin - nsslTop; - } else { - // Non-bypass portrait shade already uses values from nsslTop - // so we don't need to subtract it here. - return mMinTopMargin + mKeyguardStatusHeight; - } - } - - /** - * give the static topMargin, used for lockscreen clocks to get the initial translationY - * to do counter translation - */ - public int getExpandedPreferredClockY() { - if (mIsSplitShade) { - return mSplitShadeTargetTopMargin; - } else { - return mMinTopMargin; - } - } - - public int getLockscreenStatusViewHeight() { - return mKeyguardStatusHeight; - } - - private int getClockY(float panelExpansion, float darkAmount) { - float clockYRegular = getExpandedPreferredClockY(); - - // Dividing the height creates a smoother transition when the user swipes up to unlock - float clockYBouncer = -mKeyguardStatusHeight / 3.0f; - - // Move clock up while collapsing the shade - float shadeExpansion = Interpolators.FAST_OUT_LINEAR_IN.getInterpolation(panelExpansion); - float clockY = MathUtils.lerp(clockYBouncer, clockYRegular, shadeExpansion); - - // This will keep the clock at the top but out of the cutout area - float shift = 0; - if (clockY - mMaxBurnInPreventionOffsetYClock < mCutoutTopInset) { - shift = mCutoutTopInset - (clockY - mMaxBurnInPreventionOffsetYClock); - } - - int burnInPreventionOffsetY = mMaxBurnInPreventionOffsetYClock; // requested offset - final boolean hasUdfps = mUdfpsTop > -1; - if (hasUdfps && !mIsClockTopAligned) { - // ensure clock doesn't overlap with the udfps icon - if (mUdfpsTop < mClockBottom) { - // sometimes the clock textView extends beyond udfps, so let's just use the - // space above the KeyguardStatusView/clock as our burn-in offset - burnInPreventionOffsetY = (int) (clockY - mCutoutTopInset) / 2; - if (mMaxBurnInPreventionOffsetYClock < burnInPreventionOffsetY) { - burnInPreventionOffsetY = mMaxBurnInPreventionOffsetYClock; - } - shift = -burnInPreventionOffsetY; - } else { - float upperSpace = clockY - mCutoutTopInset; - float lowerSpace = mUdfpsTop - mClockBottom; - // center the burn-in offset within the upper + lower space - burnInPreventionOffsetY = (int) (lowerSpace + upperSpace) / 2; - if (mMaxBurnInPreventionOffsetYClock < burnInPreventionOffsetY) { - burnInPreventionOffsetY = mMaxBurnInPreventionOffsetYClock; - } - shift = (lowerSpace - upperSpace) / 2; - } - } - - float fullyDarkBurnInOffset = burnInPreventionOffsetY(burnInPreventionOffsetY); - float clockYDark = clockY + fullyDarkBurnInOffset + shift; - mCurrentBurnInOffsetY = MathUtils.lerp(0, fullyDarkBurnInOffset, darkAmount); - - if (DEBUG) { - final float finalShift = shift; - final float finalBurnInPreventionOffsetY = burnInPreventionOffsetY; - mLogger.i(msg -> { - final String inputs = "panelExpansion: " + panelExpansion - + " darkAmount: " + darkAmount; - final String outputs = "clockY: " + clockY - + " burnInPreventionOffsetY: " + finalBurnInPreventionOffsetY - + " fullyDarkBurnInOffset: " + fullyDarkBurnInOffset - + " shift: " + finalShift - + " mOverStretchAmount: " + mOverStretchAmount - + " mCurrentBurnInOffsetY: " + mCurrentBurnInOffsetY; - return inputs + " -> " + outputs; - }, msg -> { - return kotlin.Unit.INSTANCE; - }); - } - return (int) (MathUtils.lerp(clockY, clockYDark, darkAmount) + mOverStretchAmount); - } - - /** - * We might want to fade out the clock when the user is swiping up. - * One exception is when the bouncer will become visible, in this cause the clock - * should always persist. - * - * @param y Current clock Y. - * @return Alpha from 0 to 1. - */ - private float getClockAlpha(int y) { - float alphaKeyguard = Math.max(0, y / Math.max(1f, getClockY(1f, mDarkAmount))); - if (!mIsSplitShade) { - // in split shade QS are always expanded so this factor shouldn't apply - float qsAlphaFactor = MathUtils.saturate(mQsExpansion / 0.3f); - qsAlphaFactor = 1f - qsAlphaFactor; - alphaKeyguard *= qsAlphaFactor; - } - alphaKeyguard = Interpolators.ACCELERATE.getInterpolation(alphaKeyguard); - return MathUtils.lerp(alphaKeyguard, 1f, mDarkAmount); - } - - private float burnInPreventionOffsetY(int offset) { - return getBurnInOffset(offset * 2, false /* xAxis */) - offset; - } - - private float burnInPreventionOffsetX() { - return getBurnInOffset(mMaxBurnInPreventionOffsetX, true /* xAxis */); - } - public static class Result { - - /** - * The x translation of the clock. - */ - public int clockX; - - /** - * The y translation of the clock. - */ - public int clockY; - - /** - * The y translation of the clock when we're fully dozing. - */ - public int clockYFullyDozing; - - /** - * The alpha value of the clock. - */ - public float clockAlpha; - - /** - * Amount to scale the large clock (0.0 - 1.0) - */ - public float clockScale; - /** * The top padding of the stack scroller, in pixels. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt index c53558ea7fd2..76f10b1c2a8b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt @@ -21,7 +21,6 @@ import com.android.systemui.DejankUtils import com.android.systemui.Flags.lightRevealMigration import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.KeyguardViewMediator -import com.android.systemui.keyguard.MigrateClocksToBlueprint import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.shade.ShadeViewController import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor @@ -87,7 +86,6 @@ constructor( private var animatorDurationScale = 1f private var shouldAnimateInKeyguard = false private var lightRevealAnimationPlaying = false - private var aodUiAnimationPlaying = false /** * The result of our decision whether to play the screen off animation in @@ -131,7 +129,7 @@ constructor( override fun onAnimationStart(animation: Animator) { interactionJankMonitor.begin( notifShadeWindowControllerLazy.get().windowRootView, - CUJ_SCREEN_OFF + CUJ_SCREEN_OFF, ) } } @@ -155,7 +153,7 @@ constructor( override fun initialize( centralSurfaces: CentralSurfaces, shadeViewController: ShadeViewController, - lightRevealScrim: LightRevealScrim + lightRevealScrim: LightRevealScrim, ) { this.initialized = true this.lightRevealScrim = lightRevealScrim @@ -165,7 +163,7 @@ constructor( globalSettings.registerContentObserverSync( Settings.Global.getUriFor(Settings.Global.ANIMATOR_DURATION_SCALE), /* notify for descendants */ false, - animatorDurationScaleObserver + animatorDurationScaleObserver, ) wakefulnessLifecycle.addObserver(this) } @@ -203,7 +201,7 @@ constructor( AnimatableProperty.Y, currentY, AnimationProperties().setDuration(duration.toLong()), - true /* animate */ + true, /* animate */ ) // Cancel any existing CUJs before starting the animation @@ -217,8 +215,6 @@ constructor( .setDelay(0) .setDuration(duration.toLong()) .setAnimationEndAction { - aodUiAnimationPlaying = false - // Lock the keyguard if it was waiting for the screen off animation to end. keyguardViewMediatorLazy.get().maybeHandlePendingLock() @@ -239,17 +235,16 @@ constructor( // will not be called, which is what we want since that will finish the // screen off animation and show the lockscreen, which we don't want if we // were cancelled. - aodUiAnimationPlaying = false decidedToAnimateGoingToSleep = null interactionJankMonitor.cancel(CUJ_SCREEN_OFF_SHOW_AOD) } .setCustomInterpolator(View.ALPHA, Interpolators.FAST_OUT_SLOW_IN), - true /* animate */ + true, /* animate */ ) val builder = InteractionJankMonitor.Configuration.Builder.withView( InteractionJankMonitor.CUJ_SCREEN_OFF_SHOW_AOD, - checkNotNull(notifShadeWindowControllerLazy.get().windowRootView) + checkNotNull(notifShadeWindowControllerLazy.get().windowRootView), ) .setTag(statusBarStateControllerImpl.getClockId()) @@ -267,11 +262,6 @@ constructor( } override fun onFinishedWakingUp() { - // Set this to false in onFinishedWakingUp rather than onStartedWakingUp so that other - // observers (such as CentralSurfaces) can ask us whether we were playing the screen off - // animation and reset accordingly. - aodUiAnimationPlaying = false - // If we can't control the screen off animation, we shouldn't mess with the // CentralSurfaces's keyguard state unnecessarily. if (dozeParameters.get().canControlUnlockedScreenOff()) { @@ -313,19 +303,12 @@ constructor( !powerManager.isInteractive(Display.DEFAULT_DISPLAY) && shouldAnimateInKeyguard ) { - if (!MigrateClocksToBlueprint.isEnabled) { - // Tracking this state should no longer be relevant, as the - // isInteractive - // check covers it - aodUiAnimationPlaying = true - } - // Show AOD. That'll cause the KeyguardVisibilityHelper to call // #animateInKeyguard. shadeLockscreenInteractorLazy.get().showAodUi() } }, - (ANIMATE_IN_KEYGUARD_DELAY * animatorDurationScale).toLong() + (ANIMATE_IN_KEYGUARD_DELAY * animatorDurationScale).toLong(), ) return true @@ -362,7 +345,7 @@ constructor( if ( Settings.Global.getString( context.contentResolver, - Settings.Global.ANIMATOR_DURATION_SCALE + Settings.Global.ANIMATOR_DURATION_SCALE, ) == "0" ) { return false @@ -408,7 +391,7 @@ constructor( * AOD UI. */ override fun isAnimationPlaying(): Boolean { - return isScreenOffLightRevealAnimationPlaying() || aodUiAnimationPlaying + return isScreenOffLightRevealAnimationPlaying() } override fun shouldAnimateInKeyguard(): Boolean = shouldAnimateInKeyguard diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java index 8b60ee56d5f8..b966005975ff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java @@ -32,16 +32,13 @@ import android.widget.FrameLayout; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.logging.UiEventLogger; import com.android.keyguard.KeyguardConstants; -import com.android.keyguard.KeyguardVisibilityHelper; import com.android.keyguard.dagger.KeyguardUserSwitcherScope; import com.android.settingslib.drawable.CircleFramedDrawable; import com.android.systemui.animation.Expandable; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.FalsingManager; -import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.qs.user.UserSwitchDialogController; import com.android.systemui.res.R; -import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.stack.AnimationProperties; @@ -57,6 +54,7 @@ import javax.inject.Inject; /** * Manages the user switch on the Keyguard that is used for opening the QS user panel. + * TODO: b/384064264 - Move to blueprint sections */ @KeyguardUserSwitcherScope public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> { @@ -73,9 +71,7 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> private BaseUserSwitcherAdapter mAdapter; private final KeyguardStateController mKeyguardStateController; private final FalsingManager mFalsingManager; - protected final SysuiStatusBarStateController mStatusBarStateController; private final ConfigurationController mConfigurationController; - private final KeyguardVisibilityHelper mKeyguardVisibilityHelper; private final UserSwitchDialogController mUserSwitchDialogController; private final UiEventLogger mUiEventLogger; @VisibleForTesting @@ -84,26 +80,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> UserRecord mCurrentUser; private boolean mIsKeyguardShowing; - // State info for the user switch and keyguard - private int mBarState; - - private final StatusBarStateController.StateListener mStatusBarStateListener = - new StatusBarStateController.StateListener() { - @Override - public void onStateChanged(int newState) { - boolean goingToFullShade = mStatusBarStateController.goingToFullShade(); - boolean keyguardFadingAway = mKeyguardStateController.isKeyguardFadingAway(); - int oldState = mBarState; - mBarState = newState; - - setKeyguardQsUserSwitchVisibility( - newState, - keyguardFadingAway, - goingToFullShade, - oldState); - } - }; - private ConfigurationController.ConfigurationListener mConfigurationListener = new ConfigurationController.ConfigurationListener() { @@ -144,7 +120,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> KeyguardStateController keyguardStateController, FalsingManager falsingManager, ConfigurationController configurationController, - SysuiStatusBarStateController statusBarStateController, DozeParameters dozeParameters, ScreenOffAnimationController screenOffAnimationController, UserSwitchDialogController userSwitchDialogController, @@ -157,11 +132,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> mKeyguardStateController = keyguardStateController; mFalsingManager = falsingManager; mConfigurationController = configurationController; - mStatusBarStateController = statusBarStateController; - mKeyguardVisibilityHelper = new KeyguardVisibilityHelper(mView, - keyguardStateController, dozeParameters, - screenOffAnimationController, /* animateYPos= */ false, - /* logBuffer= */ null); mUserSwitchDialogController = userSwitchDialogController; mUiEventLogger = uiEventLogger; } @@ -184,9 +154,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) { return; } - if (isListAnimating()) { - return; - } // Tapping anywhere in the view will open the user switcher mUiEventLogger.log( @@ -212,7 +179,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> if (DEBUG) Log.d(TAG, "onViewAttached"); mAdapter.registerDataSetObserver(mDataSetObserver); mDataSetObserver.onChanged(); - mStatusBarStateController.addCallback(mStatusBarStateListener); mConfigurationController.addCallback(mConfigurationListener); mKeyguardStateController.addCallback(mKeyguardStateCallback); // Force update when view attached in case configuration changed while the view was detached @@ -225,7 +191,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> if (DEBUG) Log.d(TAG, "onViewDetached"); mAdapter.unregisterDataSetObserver(mDataSetObserver); - mStatusBarStateController.removeCallback(mStatusBarStateListener); mConfigurationController.removeCallback(mConfigurationListener); mKeyguardStateController.removeCallback(mKeyguardStateCallback); } @@ -333,18 +298,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> } /** - * Set the visibility of the user avatar view based on some new state. - */ - public void setKeyguardQsUserSwitchVisibility( - int statusBarState, - boolean keyguardFadingAway, - boolean goingToFullShade, - int oldStatusBarState) { - mKeyguardVisibilityHelper.setViewVisibility( - statusBarState, keyguardFadingAway, goingToFullShade, oldStatusBarState); - } - - /** * Update position of the view with an optional animation */ public void updatePosition(int x, int y, boolean animate) { @@ -357,12 +310,6 @@ public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> * Set keyguard user avatar view alpha. */ public void setAlpha(float alpha) { - if (!mKeyguardVisibilityHelper.isVisibilityAnimating()) { - mView.setAlpha(alpha); - } - } - - private boolean isListAnimating() { - return mKeyguardVisibilityHelper.isVisibilityAnimating(); + mView.setAlpha(alpha); } } diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java deleted file mode 100644 index 8e441a3db242..000000000000 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardStatusViewControllerTest.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.keyguard; - -import static junit.framework.Assert.assertEquals; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.animation.AnimatorTestRule; -import android.platform.test.annotations.DisableFlags; -import android.testing.AndroidTestingRunner; -import android.testing.TestableLooper; -import android.view.View; - -import androidx.test.filters.SmallTest; - -import com.android.app.animation.Interpolators; -import com.android.systemui.Flags; -import com.android.systemui.animation.ViewHierarchyAnimator; -import com.android.systemui.plugins.clocks.ClockConfig; -import com.android.systemui.plugins.clocks.ClockController; -import com.android.systemui.res.R; -import com.android.systemui.statusbar.notification.AnimatableProperty; -import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; - -import java.lang.reflect.Field; - -@SmallTest -@TestableLooper.RunWithLooper(setAsMainLooper = true) -@RunWith(AndroidTestingRunner.class) -public class KeyguardStatusViewControllerTest extends KeyguardStatusViewControllerBaseTest { - - @Rule - public final AnimatorTestRule mAnimatorTestRule = new AnimatorTestRule(this); - - @Test - public void dozeTimeTick_updatesSlice() { - mController.dozeTimeTick(); - verify(mKeyguardSliceViewController).refresh(); - } - - @Test - public void dozeTimeTick_updatesClock() { - mController.dozeTimeTick(); - verify(mKeyguardClockSwitchController).refresh(); - } - - @Test - public void setTranslationYExcludingMedia_forwardsCallToView() { - float translationY = 123f; - - mController.setTranslationY(translationY, /* excludeMedia= */true); - - verify(mKeyguardStatusView).setChildrenTranslationY(translationY, /* excludeMedia= */true); - } - - @Test - @DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - public void onLocaleListChangedNotifiesClockSwitchController() { - ArgumentCaptor<ConfigurationListener> configurationListenerArgumentCaptor = - ArgumentCaptor.forClass(ConfigurationListener.class); - - mController.onViewAttached(); - verify(mConfigurationController).addCallback(configurationListenerArgumentCaptor.capture()); - - configurationListenerArgumentCaptor.getValue().onLocaleListChanged(); - verify(mKeyguardClockSwitchController).onLocaleListChanged(); - } - - @Test - public void updatePosition_primaryClockAnimation() { - ClockController mockClock = mock(ClockController.class); - when(mKeyguardClockSwitchController.getClock()).thenReturn(mockClock); - when(mockClock.getConfig()).thenReturn(new ClockConfig("MOCK", "", "", false, true, false)); - - mController.updatePosition(10, 15, 20f, true); - - verify(mControllerMock).setProperty(AnimatableProperty.Y, 15f, true); - verify(mKeyguardClockSwitchController).updatePosition( - 10, 20f, KeyguardStatusViewController.CLOCK_ANIMATION_PROPERTIES, true); - verify(mControllerMock).setProperty(AnimatableProperty.SCALE_X, 1f, true); - verify(mControllerMock).setProperty(AnimatableProperty.SCALE_Y, 1f, true); - } - - @Test - public void updatePosition_alternateClockAnimation() { - ClockController mockClock = mock(ClockController.class); - when(mKeyguardClockSwitchController.getClock()).thenReturn(mockClock); - when(mockClock.getConfig()).thenReturn(new ClockConfig("MOCK", "", "", true, true, false)); - - mController.updatePosition(10, 15, 20f, true); - - verify(mControllerMock).setProperty(AnimatableProperty.Y, 15f, true); - verify(mKeyguardClockSwitchController).updatePosition( - 10, 1f, KeyguardStatusViewController.CLOCK_ANIMATION_PROPERTIES, true); - verify(mControllerMock).setProperty(AnimatableProperty.SCALE_X, 20f, true); - verify(mControllerMock).setProperty(AnimatableProperty.SCALE_Y, 20f, true); - } - - @Test - public void splitShadeEnabledPassedToClockSwitchController() { - mController.setSplitShadeEnabled(true); - verify(mKeyguardClockSwitchController, times(1)).setSplitShadeEnabled(true); - verify(mKeyguardClockSwitchController, times(0)).setSplitShadeEnabled(false); - } - - @Test - public void splitShadeDisabledPassedToClockSwitchController() { - mController.setSplitShadeEnabled(false); - verify(mKeyguardClockSwitchController, times(1)).setSplitShadeEnabled(false); - verify(mKeyguardClockSwitchController, times(0)).setSplitShadeEnabled(true); - } - - @Test - public void onInit_addsOnLayoutChangeListenerToClockSwitch() { - when(mKeyguardStatusView.findViewById(R.id.status_view_media_container)).thenReturn( - mMediaHostContainer); - - mController.onInit(); - - ArgumentCaptor<View.OnLayoutChangeListener> captor = - ArgumentCaptor.forClass(View.OnLayoutChangeListener.class); - verify(mKeyguardClockSwitch).addOnLayoutChangeListener(captor.capture()); - } - - @Test - public void clockSwitchHeightChanged_animatesMediaHostContainer() { - when(mKeyguardStatusView.findViewById(R.id.status_view_media_container)).thenReturn( - mMediaHostContainer); - - mController.onInit(); - - ArgumentCaptor<View.OnLayoutChangeListener> captor = - ArgumentCaptor.forClass(View.OnLayoutChangeListener.class); - verify(mKeyguardClockSwitch).addOnLayoutChangeListener(captor.capture()); - - // Above here is the same as `onInit_addsOnLayoutChangeListenerToClockSwitch`. - // Below here is the actual test. - - ViewHierarchyAnimator.Companion animator = ViewHierarchyAnimator.Companion; - ViewHierarchyAnimator.Companion spiedAnimator = spy(animator); - setCompanion(spiedAnimator); - - View.OnLayoutChangeListener listener = captor.getValue(); - - mController.setSplitShadeEnabled(true); - when(mKeyguardClockSwitch.getSplitShadeCentered()).thenReturn(false); - when(mKeyguardUpdateMonitor.isKeyguardVisible()).thenReturn(true); - when(mMediaHostContainer.getVisibility()).thenReturn(View.VISIBLE); - when(mMediaHostContainer.getHeight()).thenReturn(200); - - when(mKeyguardClockSwitch.getHeight()).thenReturn(0); - listener.onLayoutChange(mKeyguardClockSwitch, /* left= */ 0, /* top= */ 0, /* right= */ - 0, /* bottom= */ 0, /* oldLeft= */ 0, /* oldTop= */ 0, /* oldRight= */ - 0, /* oldBottom = */ 200); - verify(spiedAnimator).animateNextUpdate(mMediaHostContainer, - Interpolators.STANDARD, /* duration= */ 500L, /* animateChildren= */ false); - - // Resets ViewHierarchyAnimator.Companion to its original value - setCompanion(animator); - } - - @Test - public void clockSwitchHeightNotChanged_doesNotAnimateMediaOutputContainer() { - when(mKeyguardStatusView.findViewById(R.id.status_view_media_container)).thenReturn( - mMediaHostContainer); - - mController.onInit(); - - ArgumentCaptor<View.OnLayoutChangeListener> captor = - ArgumentCaptor.forClass(View.OnLayoutChangeListener.class); - verify(mKeyguardClockSwitch).addOnLayoutChangeListener(captor.capture()); - - // Above here is the same as `onInit_addsOnLayoutChangeListenerToClockSwitch`. - // Below here is the actual test. - - ViewHierarchyAnimator.Companion animator = ViewHierarchyAnimator.Companion; - ViewHierarchyAnimator.Companion spiedAnimator = spy(animator); - setCompanion(spiedAnimator); - - View.OnLayoutChangeListener listener = captor.getValue(); - - mController.setSplitShadeEnabled(true); - when(mKeyguardClockSwitch.getSplitShadeCentered()).thenReturn(false); - when(mKeyguardUpdateMonitor.isKeyguardVisible()).thenReturn(true); - when(mMediaHostContainer.getVisibility()).thenReturn(View.VISIBLE); - when(mMediaHostContainer.getHeight()).thenReturn(200); - - when(mKeyguardClockSwitch.getHeight()).thenReturn(200); - listener.onLayoutChange(mKeyguardClockSwitch, /* left= */ 0, /* top= */ 0, /* right= */ - 0, /* bottom= */ 0, /* oldLeft= */ 0, /* oldTop= */ 0, /* oldRight= */ - 0, /* oldBottom = */ 200); - verify(spiedAnimator, never()).animateNextUpdate(any(), any(), anyLong(), anyBoolean()); - - // Resets ViewHierarchyAnimator.Companion to its original value - setCompanion(animator); - } - - private void setCompanion(ViewHierarchyAnimator.Companion companion) { - try { - Field field = ViewHierarchyAnimator.class.getDeclaredField("Companion"); - field.setAccessible(true); - field.set(null, companion); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Test - @DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) - public void statusAreaHeightChange_animatesHeightOutputChange() { - // Init & Capture Layout Listener - mController.onInit(); - mController.onViewAttached(); - - when(mDozeParameters.getAlwaysOn()).thenReturn(true); - ArgumentCaptor<View.OnLayoutChangeListener> captor = - ArgumentCaptor.forClass(View.OnLayoutChangeListener.class); - verify(mKeyguardStatusAreaView).addOnLayoutChangeListener(captor.capture()); - View.OnLayoutChangeListener listener = captor.getValue(); - - // Setup and validate initial height - when(mKeyguardStatusView.getHeight()).thenReturn(200); - when(mKeyguardClockSwitchController.getNotificationIconAreaHeight()).thenReturn(10); - assertEquals(190, mController.getLockscreenHeight()); - - // Trigger Change and validate value unchanged immediately - when(mKeyguardStatusAreaView.getHeight()).thenReturn(100); - when(mKeyguardStatusView.getHeight()).thenReturn(300); // Include child height - listener.onLayoutChange(mKeyguardStatusAreaView, - /* new layout */ 100, 300, 200, 400, - /* old layout */ 100, 300, 200, 300); - assertEquals(190, mController.getLockscreenHeight()); - - // Complete animation, validate height increased - mAnimatorTestRule.advanceTimeBy(200); - assertEquals(290, mController.getLockscreenHeight()); - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationsQSContainerControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationsQSContainerControllerTest.kt index 4850b0f67857..24f8843e935d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationsQSContainerControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationsQSContainerControllerTest.kt @@ -16,7 +16,6 @@ package com.android.systemui.shade -import android.platform.test.annotations.EnableFlags import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.view.View @@ -27,7 +26,6 @@ import androidx.annotation.IdRes import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintSet import androidx.test.filters.SmallTest -import com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT import com.android.systemui.SysuiTestCase import com.android.systemui.fragments.FragmentHostManager import com.android.systemui.fragments.FragmentService @@ -68,7 +66,6 @@ import org.mockito.MockitoAnnotations @RunWith(AndroidTestingRunner::class) @TestableLooper.RunWithLooper(setAsMainLooper = true) @SmallTest -@EnableFlags(FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT) class NotificationsQSContainerControllerTest : SysuiTestCase() { private val view = mock<NotificationsQuickSettingsContainer>() @@ -120,7 +117,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { delayableExecutor, notificationStackScrollLayoutController, ResourcesSplitShadeStateController(), - largeScreenHeaderHelperLazy = { largeScreenHeaderHelper } + largeScreenHeaderHelperLazy = { largeScreenHeaderHelper }, ) overrideResource(R.dimen.split_shade_notifications_scrim_margin_bottom, SCRIM_MARGIN) @@ -205,23 +202,23 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = true, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = 0, // taskbar should disappear when shade is expanded expectedNotificationsMargin = NOTIFICATIONS_MARGIN, - expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) given( taskbarVisible = true, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = STABLE_INSET_BOTTOM, expectedNotificationsMargin = NOTIFICATIONS_MARGIN, - expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) } @@ -233,22 +230,22 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = 0, - expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) given( taskbarVisible = false, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = 0, // qs goes full height as it's not obscuring nav buttons expectedNotificationsMargin = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN, - expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) } @@ -259,22 +256,22 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withCutout() + insets = windowInsets().withCutout(), ) then( expectedContainerPadding = CUTOUT_HEIGHT, - expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) given( taskbarVisible = false, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withCutout().withStableBottom() + insets = windowInsets().withCutout().withStableBottom(), ) then( expectedContainerPadding = 0, expectedNotificationsMargin = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN, - expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET + expectedQsPadding = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN - QS_PADDING_OFFSET, ) } @@ -285,18 +282,18 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = true, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then(expectedContainerPadding = 0, expectedQsPadding = STABLE_INSET_BOTTOM) given( taskbarVisible = true, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = STABLE_INSET_BOTTOM, - expectedQsPadding = STABLE_INSET_BOTTOM + expectedQsPadding = STABLE_INSET_BOTTOM, ) } @@ -310,19 +307,19 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withCutout().withStableBottom() + insets = windowInsets().withCutout().withStableBottom(), ) then(expectedContainerPadding = CUTOUT_HEIGHT, expectedQsPadding = STABLE_INSET_BOTTOM) given( taskbarVisible = false, navigationMode = BUTTONS_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then( expectedContainerPadding = 0, expectedNotificationsMargin = STABLE_INSET_BOTTOM + NOTIFICATIONS_MARGIN, - expectedQsPadding = STABLE_INSET_BOTTOM + expectedQsPadding = STABLE_INSET_BOTTOM, ) } @@ -335,7 +332,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then(expectedContainerPadding = 0, expectedNotificationsMargin = 0) @@ -351,7 +348,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { given( taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, - insets = windowInsets().withStableBottom() + insets = windowInsets().withStableBottom(), ) then(expectedContainerPadding = 0) @@ -467,7 +464,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { delayableExecutor, notificationStackScrollLayoutController, ResourcesSplitShadeStateController(), - largeScreenHeaderHelperLazy = { largeScreenHeaderHelper } + largeScreenHeaderHelperLazy = { largeScreenHeaderHelper }, ) controller.updateConstraints() @@ -483,7 +480,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { taskbarVisible = false, navigationMode = GESTURES_NAVIGATION, insets = emptyInsets(), - applyImmediately = false + applyImmediately = false, ) fakeSystemClock.advanceTime(INSET_DEBOUNCE_MILLIS / 2) windowInsetsCallback.accept(windowInsets().withStableBottom()) @@ -550,7 +547,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { taskbarVisible: Boolean, navigationMode: Int, insets: WindowInsets, - applyImmediately: Boolean = true + applyImmediately: Boolean = true, ) { Mockito.clearInvocations(view) taskbarVisibilityCallback.onTaskbarStatusUpdated(taskbarVisible, false) @@ -565,7 +562,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { fun then( expectedContainerPadding: Int, expectedNotificationsMargin: Int = NOTIFICATIONS_MARGIN, - expectedQsPadding: Int = 0 + expectedQsPadding: Int = 0, ) { verify(view).setPadding(anyInt(), anyInt(), anyInt(), eq(expectedContainerPadding)) verify(view).setNotificationsMarginBottom(expectedNotificationsMargin) @@ -597,7 +594,7 @@ class NotificationsQSContainerControllerTest : SysuiTestCase() { val layoutParams = ConstraintLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT + ViewGroup.LayoutParams.WRAP_CONTENT, ) // required as cloning ConstraintSet fails if view doesn't have layout params view.layoutParams = layoutParams diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt index 3a46d038f946..cfc00a918f61 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt @@ -364,79 +364,6 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { } @Test - fun setDragAmount_setsKeyguardTransitionProgress() = - testScope.runTest { - transitionController.dragDownAmount = 10f - - verify(shadeLockscreenInteractor).setKeyguardTransitionProgress(anyFloat(), anyInt()) - } - - @Test - fun setDragAmount_setsKeyguardAlphaBasedOnDistance() = - testScope.runTest { - val alphaDistance = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_npvc_keyguard_content_alpha_transition_distance - ) - transitionController.dragDownAmount = 10f - - val expectedAlpha = 1 - 10f / alphaDistance - verify(shadeLockscreenInteractor) - .setKeyguardTransitionProgress(eq(expectedAlpha), anyInt()) - } - - @Test - fun setDragAmount_notInSplitShade_setsKeyguardTranslationToZero() = - testScope.runTest { - val mediaTranslationY = 123 - disableSplitShade() - whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(true) - whenever(mediaHierarchyManager.getGuidedTransformationTranslationY()) - .thenReturn(mediaTranslationY) - - transitionController.dragDownAmount = 10f - - verify(shadeLockscreenInteractor).setKeyguardTransitionProgress(anyFloat(), eq(0)) - } - - @Test - fun setDragAmount_inSplitShade_setsKeyguardTranslationBasedOnMediaTranslation() = - testScope.runTest { - val mediaTranslationY = 123 - enableSplitShade() - whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(true) - whenever(mediaHierarchyManager.getGuidedTransformationTranslationY()) - .thenReturn(mediaTranslationY) - - transitionController.dragDownAmount = 10f - - verify(shadeLockscreenInteractor) - .setKeyguardTransitionProgress(anyFloat(), eq(mediaTranslationY)) - } - - @Test - fun setDragAmount_inSplitShade_mediaNotShowing_setsKeyguardTranslationBasedOnDistance() = - testScope.runTest { - enableSplitShade() - whenever(mediaHierarchyManager.isCurrentlyInGuidedTransformation()).thenReturn(false) - whenever(mediaHierarchyManager.getGuidedTransformationTranslationY()).thenReturn(123) - - transitionController.dragDownAmount = 10f - - val distance = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_keyguard_transition_distance - ) - val offset = - context.resources.getDimensionPixelSize( - R.dimen.lockscreen_shade_keyguard_transition_vertical_offset - ) - val expectedTranslation = 10f / distance * offset - verify(shadeLockscreenInteractor) - .setKeyguardTransitionProgress(anyFloat(), eq(expectedTranslation.toInt())) - } - - @Test fun setDragDownAmount_setsValueOnMediaHierarchyManager() = testScope.runTest { transitionController.dragDownAmount = 10f diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java index 9d6eb798df17..b17a58f9d8e3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardClockPositionAlgorithmTest.java @@ -49,11 +49,7 @@ import org.mockito.quality.Strictness; @SmallTest @RunWith(AndroidJUnit4.class) public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { - private static final int SCREEN_HEIGHT = 2000; - private static final int EMPTY_HEIGHT = 0; private static final float ZERO_DRAG = 0.f; - private static final float OPAQUE = 1.f; - private static final float TRANSPARENT = 0.f; @Mock private Resources mResources; @@ -62,18 +58,10 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { private MockitoSession mStaticMockSession; - private float mPanelExpansion; - private int mKeyguardStatusBarHeaderHeight; - private int mKeyguardStatusHeight; private float mDark; - private float mQsExpansion; - private int mCutoutTopInset = 0; private boolean mIsSplitShade = false; private boolean mBypassEnabled = false; private int mUnlockedStackScrollerPadding = 0; - private float mUdfpsTop = -1; - private float mClockBottom = SCREEN_HEIGHT / 2; - private boolean mClockTopAligned; @Before public void setUp() { @@ -98,118 +86,9 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } @Test - public void clockPositionTopOfScreenOnAOD() { - // GIVEN on AOD and clock has 0 height - givenAOD(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position is the top of the screen - assertThat(mClockPosition.clockY).isEqualTo(0); - // AND the clock is opaque and positioned on the left. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isEqualTo(OPAQUE); - } - - @Test - public void clockPositionBelowCutout() { - // GIVEN on AOD and clock has 0 height - givenAOD(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - mCutoutTopInset = 300; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position is below the cutout - assertThat(mClockPosition.clockY).isEqualTo(300); - // AND the clock is opaque and positioned on the left. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isEqualTo(OPAQUE); - } - - @Test - public void clockPositionAdjustsForKeyguardStatusOnAOD() { - // GIVEN on AOD with a clock of height 100 - givenAOD(); - mKeyguardStatusHeight = 100; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position is at the top - assertThat(mClockPosition.clockY).isEqualTo(0); - // AND the clock is opaque and positioned on the left. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isEqualTo(OPAQUE); - } - - @Test - public void clockPositionLargeClockOnAOD() { - // GIVEN on AOD with a full screen clock - givenAOD(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position doesn't overflow the screen. - assertThat(mClockPosition.clockY).isEqualTo(0); - // AND the clock is opaque and positioned on the left. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isEqualTo(OPAQUE); - } - - @Test - public void clockPositionTopOfScreenOnLockScreen() { - // GIVEN on lock screen with clock of 0 height - givenLockScreen(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position is the top of the screen - 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(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - mPanelExpansion = 0.5f; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock Y position adjusts with drag gesture. - assertThat(mClockPosition.clockY).isLessThan(1000); - // AND the clock is positioned on the left and not fully opaque. - assertThat(mClockPosition.clockX).isEqualTo(0); - assertThat(mClockPosition.clockAlpha).isLessThan(OPAQUE); - } - - @Test - public void clockPositionWithFullDragOnLockScreen() { - // GIVEN the lock screen is dragged up - givenLockScreen(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - mPanelExpansion = 0.f; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock is transparent. - assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); - } - - @Test - public void largeClockOnLockScreenIsTransparent() { - // GIVEN on lock screen with a full screen clock - givenLockScreen(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock is transparent - assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); - } - - @Test public void notifPositionTopOfScreenOnAOD() { // GIVEN on AOD and clock has 0 height givenAOD(); - mKeyguardStatusHeight = EMPTY_HEIGHT; // WHEN the position algorithm is run positionClock(); // THEN the notif padding is 0 (top of screen) @@ -217,53 +96,9 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } @Test - public void notifPositionIndependentOfKeyguardStatusHeightOnAOD() { - // GIVEN on AOD and clock has a nonzero height - givenAOD(); - mKeyguardStatusHeight = 100; - // WHEN the position algorithm is run - positionClock(); - // THEN the notif padding adjusts for keyguard status height - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(100); - } - - @Test - public void notifPositionWithLargeClockOnAOD() { - // GIVEN on AOD and clock has a nonzero height - givenAOD(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - // WHEN the position algorithm is run - positionClock(); - // THEN the notif padding is, unfortunately, the entire screen. - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(SCREEN_HEIGHT); - } - - @Test - public void notifPositionMiddleOfScreenOnLockScreen() { - // GIVEN on lock screen and clock has 0 height - givenLockScreen(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - // WHEN the position algorithm is run - positionClock(); - // THEN the notif are placed to the top of the screen - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); - } - - @Test - public void notifPositionAdjustsForClockHeightOnLockScreen() { - // GIVEN on lock screen and stack scroller has a nonzero height - givenLockScreen(); - mKeyguardStatusHeight = 200; - // WHEN the position algorithm is run - positionClock(); - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(200); - } - - @Test public void notifPositionAlignedWithClockInSplitShadeMode() { givenLockScreen(); mIsSplitShade = true; - mKeyguardStatusHeight = 200; // WHEN the position algorithm is run positionClock(); // THEN the notif padding DOESN'T adjust for keyguard status height. @@ -284,17 +119,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } @Test - public void clockPositionedDependingOnMarginInSplitShade() { - setSplitShadeTopMargin(400); - givenLockScreen(); - mIsSplitShade = true; - // WHEN the position algorithm is run - positionClock(); - - assertThat(mClockPosition.clockY).isEqualTo(400); - } - - @Test public void notifPaddingMakesUpToFullMarginInSplitShade_usesHelper() { int keyguardSplitShadeTopMargin = 100; int largeScreenHeaderHeightHelper = 50; @@ -316,259 +140,15 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } @Test - public void notifPaddingExpandedAlignedWithClockInSplitShadeMode() { - givenLockScreen(); - mIsSplitShade = true; - mKeyguardStatusHeight = 200; - // WHEN the position algorithm is run - positionClock(); - // THEN the padding DOESN'T adjust for keyguard status height. - assertThat(mClockPosition.stackScrollerPaddingExpanded) - .isEqualTo(mClockPosition.clockY); - } - - @Test - public void notifPadding_splitShade() { - givenLockScreen(); - mIsSplitShade = true; - mKeyguardStatusHeight = 200; - // WHEN the position algorithm is run - positionClock(); - // THEN the padding DOESN'T adjust for keyguard status height. - assertThat(mClockPositionAlgorithm.getLockscreenNotifPadding(/* nsslTop= */ 10)) - .isEqualTo(mKeyguardStatusBarHeaderHeight - 10); - } - - @Test - public void notifPadding_portraitShade_bypassOff() { - givenLockScreen(); - mIsSplitShade = false; - mBypassEnabled = false; - - mKeyguardStatusBarHeaderHeight = 100; - when(mResources.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin)) - .thenReturn(0); - - mKeyguardStatusHeight = 200; - - // WHEN the position algorithm is run - positionClock(); - - // THEN padding = 300 = mMinTopMargin(100) + mKeyguardStatusHeight(200) - assertThat(mClockPositionAlgorithm.getLockscreenNotifPadding(/* nsslTop= */ 50)) - .isEqualTo(300); - } - - @Test - public void notifPadding_portraitShade_bypassOn() { - givenLockScreen(); - mIsSplitShade = false; - mBypassEnabled = true; - mUnlockedStackScrollerPadding = 200; - - // WHEN the position algorithm is run - positionClock(); - - // THEN padding = 150 = mUnlockedStackScrollerPadding(200) - nsslTop(50) - assertThat(mClockPositionAlgorithm.getLockscreenNotifPadding(/* nsslTop= */ 50)) - .isEqualTo(150); - } - - @Test - public void notifPositionWithLargeClockOnLockScreen() { - // GIVEN on lock screen and clock has a nonzero height - givenLockScreen(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - // WHEN the position algorithm is run - positionClock(); - // THEN the notif padding is below keyguard status area - assertThat(mClockPosition.stackScrollerPadding).isEqualTo(SCREEN_HEIGHT); - } - - @Test public void notifPositionWithFullDragOnLockScreen() { // GIVEN the lock screen is dragged up givenLockScreen(); - mKeyguardStatusHeight = EMPTY_HEIGHT; - mPanelExpansion = 0.f; // WHEN the clock position algorithm is run positionClock(); // THEN the notif padding is zero. assertThat(mClockPosition.stackScrollerPadding).isEqualTo(0); } - @Test - public void notifPositionWithLargeClockFullDragOnLockScreen() { - // GIVEN the lock screen is dragged up and a full screen clock - givenLockScreen(); - mKeyguardStatusHeight = SCREEN_HEIGHT; - mPanelExpansion = 0.f; - // WHEN the clock position algorithm is run - positionClock(); - assertThat(mClockPosition.stackScrollerPadding).isEqualTo( - (int) (mKeyguardStatusHeight * .667f)); - } - - @Test - public void clockHiddenWhenQsIsExpanded() { - // GIVEN on the lock screen with visible notifications - givenLockScreen(); - mQsExpansion = 1; - // WHEN the clock position algorithm is run - positionClock(); - // THEN the clock is transparent. - assertThat(mClockPosition.clockAlpha).isEqualTo(TRANSPARENT); - } - - @Test - public void clockNotHiddenWhenQsIsExpandedInSplitShade() { - // GIVEN on the split lock screen with QS expansion - givenLockScreen(); - mIsSplitShade = true; - setSplitShadeTopMargin(100); - mQsExpansion = 1; - - // WHEN the clock position algorithm is run - positionClock(); - - assertThat(mClockPosition.clockAlpha).isEqualTo(1); - } - - @Test - public void clockPositionMinimizesBurnInMovementToAvoidUdfpsOnAOD() { - // GIVEN a center aligned clock - mClockTopAligned = false; - - // GIVEN the clock + udfps are 100px apart - mClockBottom = SCREEN_HEIGHT - 500; - mUdfpsTop = SCREEN_HEIGHT - 400; - - // GIVEN it's AOD and the burn-in y value is 200 - givenAOD(); - givenMaxBurnInOffset(200); - - // WHEN the clock position algorithm is run with the highest burn in offset - givenHighestBurnInOffset(); - positionClock(); - - // THEN the worst-case clock Y position is shifted only by 100 (not the full 200), - // so that it's at the same location as mUdfpsTop - assertThat(mClockPosition.clockY).isEqualTo(100); - - // WHEN the clock position algorithm is run with the lowest burn in offset - givenLowestBurnInOffset(); - positionClock(); - - // THEN lowest case starts at 0 - assertThat(mClockPosition.clockY).isEqualTo(0); - } - - @Test - public void clockPositionShiftsToAvoidUdfpsOnAOD_usesSpaceAboveClock() { - // GIVEN a center aligned clock - mClockTopAligned = false; - - // GIVEN there's space at the top of the screen on LS (that's available to be used for - // burn-in on AOD) - mKeyguardStatusBarHeaderHeight = 150; - - // GIVEN the bottom of the clock is beyond the top of UDFPS - mClockBottom = SCREEN_HEIGHT - 300; - mUdfpsTop = SCREEN_HEIGHT - 400; - - // GIVEN it's AOD and the burn-in y value is 200 - givenAOD(); - givenMaxBurnInOffset(200); - - // WHEN the clock position algorithm is run with the highest burn in offset - givenHighestBurnInOffset(); - positionClock(); - - // THEN the algo should shift the clock up and use the area above the clock for - // burn-in since the burn in offset > space above clock - assertThat(mClockPosition.clockY).isEqualTo(mKeyguardStatusBarHeaderHeight); - - // WHEN the clock position algorithm is run with the lowest burn in offset - givenLowestBurnInOffset(); - positionClock(); - - // THEN lowest case starts at mCutoutTopInset (0 in this case) - assertThat(mClockPosition.clockY).isEqualTo(mCutoutTopInset); - } - - @Test - public void clockPositionShiftsToAvoidUdfpsOnAOD_usesMaxBurnInOffset() { - // GIVEN a center aligned clock - mClockTopAligned = false; - - // GIVEN there's 200px space at the top of the screen on LS (that's available to be used for - // burn-in on AOD) but 50px are taken up by the cutout - mKeyguardStatusBarHeaderHeight = 200; - mCutoutTopInset = 50; - - // GIVEN the bottom of the clock is beyond the top of UDFPS - mClockBottom = SCREEN_HEIGHT - 300; - mUdfpsTop = SCREEN_HEIGHT - 400; - - // GIVEN it's AOD and the burn-in y value is only 25px (less than space above clock) - givenAOD(); - int maxYBurnInOffset = 25; - givenMaxBurnInOffset(maxYBurnInOffset); - - // WHEN the clock position algorithm is run with the highest burn in offset - givenHighestBurnInOffset(); - positionClock(); - - // THEN the algo should shift the clock up and use the area above the clock for - // burn-in - assertThat(mClockPosition.clockY).isEqualTo(mKeyguardStatusBarHeaderHeight); - - // WHEN the clock position algorithm is run with the lowest burn in offset - givenLowestBurnInOffset(); - positionClock(); - - // THEN lowest case starts above mKeyguardStatusBarHeaderHeight - assertThat(mClockPosition.clockY).isEqualTo( - mKeyguardStatusBarHeaderHeight - 2 * maxYBurnInOffset); - } - - @Test - public void clockPositionShiftsToMaximizeUdfpsBurnInMovement() { - // GIVEN a center aligned clock - mClockTopAligned = false; - - // GIVEN there's 200px space at the top of the screen on LS (that's available to be used for - // burn-in on AOD) but 50px are taken up by the cutout - mKeyguardStatusBarHeaderHeight = 200; - mCutoutTopInset = 50; - int upperSpaceAvailable = mKeyguardStatusBarHeaderHeight - mCutoutTopInset; - - // GIVEN the bottom of the clock and the top of UDFPS are 100px apart - mClockBottom = SCREEN_HEIGHT - 500; - mUdfpsTop = SCREEN_HEIGHT - 400; - float lowerSpaceAvailable = mUdfpsTop - mClockBottom; - - // GIVEN it's AOD and the burn-in y value is 200 - givenAOD(); - givenMaxBurnInOffset(200); - - // WHEN the clock position algorithm is run with the highest burn in offset - givenHighestBurnInOffset(); - positionClock(); - - // THEN the algo should shift the clock up and use both the area above - // the clock and below the clock (vertically centered in its allowed area) - assertThat(mClockPosition.clockY).isEqualTo( - (int) (mCutoutTopInset + upperSpaceAvailable + lowerSpaceAvailable)); - - // WHEN the clock position algorithm is run with the lowest burn in offset - givenLowestBurnInOffset(); - positionClock(); - - // THEN lowest case starts at mCutoutTopInset - assertThat(mClockPosition.clockY).isEqualTo(mCutoutTopInset); - } - private void setSplitShadeTopMargin(int value) { when(mResources.getDimensionPixelSize(R.dimen.keyguard_split_shade_top_margin)) .thenReturn(value); @@ -579,10 +159,6 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { when(BurnInHelperKt.getBurnInOffset(anyInt(), anyBoolean())).then(returnsFirstArg()); } - private void givenLowestBurnInOffset() { - when(BurnInHelperKt.getBurnInOffset(anyInt(), anyBoolean())).thenReturn(0); - } - private void givenMaxBurnInOffset(int offset) { when(mResources.getDimensionPixelSize(R.dimen.burn_in_prevention_offset_y_clock)) .thenReturn(offset); @@ -590,12 +166,10 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { } private void givenAOD() { - mPanelExpansion = 1.f; mDark = 1.f; } private void givenLockScreen() { - mPanelExpansion = 1.f; mDark = 0.f; } @@ -606,19 +180,11 @@ public class KeyguardClockPositionAlgorithmTest extends SysuiTestCase { */ private void positionClock() { mClockPositionAlgorithm.setup( - mKeyguardStatusBarHeaderHeight, - mPanelExpansion, - mKeyguardStatusHeight, mDark, ZERO_DRAG, mBypassEnabled, mUnlockedStackScrollerPadding, - mQsExpansion, - mCutoutTopInset, - mIsSplitShade, - mUdfpsTop, - mClockBottom, - mClockTopAligned); + mIsSplitShade); mClockPositionAlgorithm.run(mClockPosition); } } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepositoryKosmos.kt index 49a8c1866aa2..6df2318c6935 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepositoryKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/KeyguardBlueprintRepositoryKosmos.kt @@ -59,7 +59,6 @@ val Kosmos.defaultKeyguardBlueprint by defaultShortcutsSection = mock(), defaultAmbientIndicationAreaSection = Optional.of(mock()), defaultSettingsPopupMenuSection = mock(), - defaultStatusViewSection = mock(), defaultStatusBarSection = mock(), defaultNotificationStackScrollLayoutSection = mock(), aodNotificationIconsSection = mock(), @@ -81,7 +80,6 @@ val Kosmos.splitShadeBlueprint by defaultShortcutsSection = mock(), defaultAmbientIndicationAreaSection = Optional.of(mock()), defaultSettingsPopupMenuSection = mock(), - defaultStatusViewSection = mock(), defaultStatusBarSection = mock(), splitShadeNotificationStackScrollLayoutSection = mock(), splitShadeGuidelines = mock(), diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelKosmos.kt deleted file mode 100644 index 24201d75424e..000000000000 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/ui/viewmodel/AodAlphaViewModelKosmos.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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. - */ - -@file:OptIn(ExperimentalCoroutinesApi::class) - -package com.android.systemui.keyguard.ui.viewmodel - -import com.android.systemui.keyguard.domain.interactor.keyguardInteractor -import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor -import com.android.systemui.kosmos.Kosmos -import com.android.systemui.kosmos.Kosmos.Fixture -import com.android.systemui.scene.domain.interactor.sceneInteractor -import kotlinx.coroutines.ExperimentalCoroutinesApi - -val Kosmos.aodAlphaViewModel by Fixture { - AodAlphaViewModel( - keyguardTransitionInteractor = keyguardTransitionInteractor, - goneToAodTransitionViewModel = goneToAodTransitionViewModel, - goneToDozingTransitionViewModel = goneToDozingTransitionViewModel, - keyguardInteractor = keyguardInteractor, - sceneInteractor = sceneInteractor, - ) -} |