summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java227
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java278
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchTest.java273
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java20
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt300
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt11
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt12
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerAlwaysOnDisplayViewBinder.kt53
9 files changed, 126 insertions, 1055 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java
deleted file mode 100644
index ce57fe256798..000000000000
--- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchControllerBaseTest.java
+++ /dev/null
@@ -1,227 +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 static android.view.View.INVISIBLE;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.atLeast;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.res.Resources;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.dump.DumpManager;
-import com.android.systemui.flags.FakeFeatureFlags;
-import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
-import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor;
-import com.android.systemui.keyguard.domain.interactor.KeyguardInteractorFactory;
-import com.android.systemui.keyguard.ui.view.InWindowLauncherUnlockAnimationManager;
-import com.android.systemui.log.LogBuffer;
-import com.android.systemui.plugins.clocks.ClockAnimations;
-import com.android.systemui.plugins.clocks.ClockController;
-import com.android.systemui.plugins.clocks.ClockEvents;
-import com.android.systemui.plugins.clocks.ClockFaceConfig;
-import com.android.systemui.plugins.clocks.ClockFaceController;
-import com.android.systemui.plugins.clocks.ClockFaceEvents;
-import com.android.systemui.plugins.clocks.ClockTickRate;
-import com.android.systemui.plugins.statusbar.StatusBarStateController;
-import com.android.systemui.res.R;
-import com.android.systemui.shared.clocks.AnimatableClockView;
-import com.android.systemui.shared.clocks.ClockRegistry;
-import com.android.systemui.statusbar.StatusBarState;
-import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController;
-import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerAlwaysOnDisplayViewBinder;
-import com.android.systemui.statusbar.phone.NotificationIconContainer;
-import com.android.systemui.util.concurrency.FakeExecutor;
-import com.android.systemui.util.settings.SecureSettings;
-import com.android.systemui.util.time.FakeSystemClock;
-
-import org.junit.Before;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-public class KeyguardClockSwitchControllerBaseTest extends SysuiTestCase {
-
- @Mock
- protected KeyguardClockSwitch mView;
- @Mock
- protected StatusBarStateController mStatusBarStateController;
- @Mock
- protected ClockRegistry mClockRegistry;
- @Mock
- KeyguardSliceViewController mKeyguardSliceViewController;
- @Mock
- LockscreenSmartspaceController mSmartspaceController;
-
- @Mock
- Resources mResources;
- @Mock
- KeyguardUnlockAnimationController mKeyguardUnlockAnimationController;
- @Mock
- protected ClockController mClockController;
- @Mock
- protected ClockFaceController mLargeClockController;
- @Mock
- protected ClockFaceController mSmallClockController;
- @Mock
- protected ClockAnimations mClockAnimations;
- @Mock
- protected ClockEvents mClockEvents;
- @Mock
- protected ClockFaceEvents mClockFaceEvents;
- @Mock
- DumpManager mDumpManager;
- @Mock
- ClockEventController mClockEventController;
-
- @Mock
- protected NotificationIconContainer mNotificationIcons;
- @Mock
- protected AnimatableClockView mSmallClockView;
- @Mock
- protected AnimatableClockView mLargeClockView;
- @Mock
- protected FrameLayout mSmallClockFrame;
- @Mock
- protected FrameLayout mLargeClockFrame;
- @Mock
- protected SecureSettings mSecureSettings;
- @Mock
- protected LogBuffer mLogBuffer;
-
- @Mock
- protected KeyguardClockInteractor mKeyguardClockInteractor;
-
- protected final View mFakeDateView = (View) (new ViewGroup(mContext) {
- @Override
- protected void onLayout(boolean changed, int l, int t, int r, int b) {}
- });
- protected final View mFakeWeatherView = new View(mContext);
- protected final View mFakeSmartspaceView = new View(mContext);
-
- protected KeyguardClockSwitchController mController;
- protected View mSliceView;
- protected LinearLayout mStatusArea;
- protected FakeExecutor mExecutor;
- protected FakeFeatureFlags mFakeFeatureFlags;
- @Captor protected ArgumentCaptor<View.OnAttachStateChangeListener> mAttachCaptor =
- ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class);
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
-
- mFakeDateView.setTag(R.id.tag_smartspace_view, new Object());
- mFakeWeatherView.setTag(R.id.tag_smartspace_view, new Object());
- mFakeSmartspaceView.setTag(R.id.tag_smartspace_view, new Object());
-
- when(mView.findViewById(R.id.left_aligned_notification_icon_container))
- .thenReturn(mNotificationIcons);
- when(mNotificationIcons.getLayoutParams()).thenReturn(
- mock(RelativeLayout.LayoutParams.class));
- when(mView.getContext()).thenReturn(getContext());
- when(mView.getResources()).thenReturn(mResources);
- when(mResources.getDimensionPixelSize(R.dimen.keyguard_clock_top_margin))
- .thenReturn(100);
- when(mResources.getDimensionPixelSize(com.android.systemui.customization.R.dimen.keyguard_large_clock_top_margin))
- .thenReturn(-200);
- when(mResources.getInteger(com.android.internal.R.integer.config_doublelineClockDefault))
- .thenReturn(1);
- when(mResources.getInteger(R.integer.keyguard_date_weather_view_invisibility))
- .thenReturn(INVISIBLE);
-
- when(mView
- .findViewById(com.android.systemui.customization.R.id.lockscreen_clock_view_large))
- .thenReturn(mLargeClockFrame);
- when(mView
- .findViewById(com.android.systemui.customization.R.id.lockscreen_clock_view))
- .thenReturn(mSmallClockFrame);
- when(mSmallClockView.getContext()).thenReturn(getContext());
- when(mLargeClockView.getContext()).thenReturn(getContext());
-
- when(mView.isAttachedToWindow()).thenReturn(true);
- when(mSmartspaceController.buildAndConnectDateView(any())).thenReturn(mFakeDateView);
- when(mSmartspaceController.buildAndConnectWeatherView(any())).thenReturn(mFakeWeatherView);
- when(mSmartspaceController.buildAndConnectView(any())).thenReturn(mFakeSmartspaceView);
- mExecutor = new FakeExecutor(new FakeSystemClock());
- mFakeFeatureFlags = new FakeFeatureFlags();
- mController = new KeyguardClockSwitchController(
- mView,
- mStatusBarStateController,
- mClockRegistry,
- mKeyguardSliceViewController,
- mSmartspaceController,
- mock(NotificationIconContainerAlwaysOnDisplayViewBinder.class),
- mKeyguardUnlockAnimationController,
- mSecureSettings,
- mExecutor,
- mExecutor,
- mDumpManager,
- mClockEventController,
- mLogBuffer,
- KeyguardInteractorFactory.create(mFakeFeatureFlags).getKeyguardInteractor(),
- mKeyguardClockInteractor,
- mock(InWindowLauncherUnlockAnimationManager.class)
- );
-
- when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
- when(mLargeClockController.getView()).thenReturn(mLargeClockView);
- when(mSmallClockController.getView()).thenReturn(mSmallClockView);
- when(mClockController.getLargeClock()).thenReturn(mLargeClockController);
- when(mClockController.getSmallClock()).thenReturn(mSmallClockController);
- when(mClockController.getEvents()).thenReturn(mClockEvents);
- when(mSmallClockController.getEvents()).thenReturn(mClockFaceEvents);
- when(mLargeClockController.getEvents()).thenReturn(mClockFaceEvents);
- when(mLargeClockController.getAnimations()).thenReturn(mClockAnimations);
- when(mSmallClockController.getAnimations()).thenReturn(mClockAnimations);
- when(mClockRegistry.createCurrentClock()).thenReturn(mClockController);
- when(mClockEventController.getClock()).thenReturn(mClockController);
- when(mSmallClockController.getConfig())
- .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false, false, false));
- when(mLargeClockController.getConfig())
- .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, false, false, false));
-
- mSliceView = new View(getContext());
- when(mView.findViewById(R.id.keyguard_slice_view)).thenReturn(mSliceView);
- mStatusArea = new LinearLayout(getContext());
- when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea);
- }
-
- private void removeView(View v) {
- ViewGroup group = ((ViewGroup) v.getParent());
- if (group != null) {
- group.removeView(v);
- }
- }
-
- protected void init() {
- mController.init();
-
- verify(mView, atLeast(1)).addOnAttachStateChangeListener(mAttachCaptor.capture());
- mAttachCaptor.getValue().onViewAttachedToWindow(mView);
- }
-}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
deleted file mode 100644
index 892375d002c1..000000000000
--- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java
+++ /dev/null
@@ -1,278 +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.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.reset;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.database.ContentObserver;
-import android.os.UserHandle;
-import android.platform.test.annotations.DisableFlags;
-import android.provider.Settings;
-import android.view.View;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import com.android.systemui.Flags;
-import com.android.systemui.plugins.clocks.ClockFaceConfig;
-import com.android.systemui.plugins.clocks.ClockTickRate;
-import com.android.systemui.shared.clocks.ClockRegistry;
-import com.android.systemui.statusbar.StatusBarState;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.verification.VerificationMode;
-
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-@DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
-public class KeyguardClockSwitchControllerTest extends KeyguardClockSwitchControllerBaseTest {
- @Test
- public void testInit_viewAlreadyAttached() {
- mController.init();
-
- verifyAttachment(times(1));
- }
-
- @Test
- public void testInit_viewNotYetAttached() {
- ArgumentCaptor<View.OnAttachStateChangeListener> listenerArgumentCaptor =
- ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class);
-
- when(mView.isAttachedToWindow()).thenReturn(false);
- mController.init();
- verify(mView).addOnAttachStateChangeListener(listenerArgumentCaptor.capture());
-
- verifyAttachment(never());
-
- listenerArgumentCaptor.getValue().onViewAttachedToWindow(mView);
-
- verifyAttachment(times(1));
- }
-
- @Test
- public void testInitSubControllers() {
- mController.init();
- verify(mKeyguardSliceViewController).init();
- }
-
- @Test
- public void testInit_viewDetached() {
- ArgumentCaptor<View.OnAttachStateChangeListener> listenerArgumentCaptor =
- ArgumentCaptor.forClass(View.OnAttachStateChangeListener.class);
- mController.init();
- verify(mView).addOnAttachStateChangeListener(listenerArgumentCaptor.capture());
-
- verifyAttachment(times(1));
-
- listenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView);
- verify(mClockEventController).unregisterListeners();
- }
-
- @Test
- public void testPluginPassesStatusBarState() {
- ArgumentCaptor<ClockRegistry.ClockChangeListener> listenerArgumentCaptor =
- ArgumentCaptor.forClass(ClockRegistry.ClockChangeListener.class);
-
- mController.init();
- verify(mClockRegistry).registerClockChangeListener(listenerArgumentCaptor.capture());
-
- listenerArgumentCaptor.getValue().onCurrentClockChanged();
- verify(mView, times(2)).setClock(mClockController, StatusBarState.SHADE);
- verify(mClockEventController, times(2)).setClock(mClockController);
- }
-
- @Test
- public void testSmartspaceEnabledRemovesKeyguardStatusArea() {
- when(mSmartspaceController.isEnabled()).thenReturn(true);
- mController.init();
-
- assertEquals(View.GONE, mSliceView.getVisibility());
- }
-
- @Test
- public void onLocaleListChangedRebuildsSmartspaceView() {
- when(mSmartspaceController.isEnabled()).thenReturn(true);
- mController.init();
-
- mController.onLocaleListChanged();
- // Should be called once on initial setup, then once again for locale change
- verify(mSmartspaceController, times(2)).buildAndConnectView(mView);
- }
-
- @Test
- public void onLocaleListChanged_rebuildsSmartspaceViews_whenDecouplingEnabled() {
- when(mSmartspaceController.isEnabled()).thenReturn(true);
- when(mSmartspaceController.isDateWeatherDecoupled()).thenReturn(true);
- mController.init();
-
- mController.onLocaleListChanged();
- // Should be called once on initial setup, then once again for locale change
- verify(mSmartspaceController, times(2)).buildAndConnectDateView(mView);
- verify(mSmartspaceController, times(2)).buildAndConnectWeatherView(mView);
- verify(mSmartspaceController, times(2)).buildAndConnectView(mView);
- }
-
- @Test
- public void testSmartspaceDisabledShowsKeyguardStatusArea() {
- when(mSmartspaceController.isEnabled()).thenReturn(false);
- mController.init();
-
- assertEquals(View.VISIBLE, mSliceView.getVisibility());
- }
-
- @Test
- public void testRefresh() {
- mController.refresh();
-
- verify(mSmartspaceController).requestSmartspaceUpdate();
- }
-
- @Test
- public void testChangeToDoubleLineClockSetsSmallClock() {
- when(mSecureSettings.getIntForUser(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK, 1,
- UserHandle.USER_CURRENT))
- .thenReturn(0);
- ArgumentCaptor<ContentObserver> observerCaptor =
- ArgumentCaptor.forClass(ContentObserver.class);
- mController.init();
- mExecutor.runAllReady();
- verify(mSecureSettings).registerContentObserverForUserSync(
- eq(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK),
- anyBoolean(), observerCaptor.capture(), eq(UserHandle.USER_ALL));
- ContentObserver observer = observerCaptor.getValue();
- mExecutor.runAllReady();
-
- // When a settings change has occurred to the small clock, make sure the view is adjusted
- reset(mView);
- when(mView.getResources()).thenReturn(mResources);
- observer.onChange(true);
- mExecutor.runAllReady();
- verify(mView).switchToClock(KeyguardClockSwitch.SMALL, /* animate */ true);
- }
-
- @Test
- public void testGetClock_ForwardsToClock() {
- assertEquals(mClockController, mController.getClock());
- }
-
- @Test
- public void testGetLargeClockBottom_returnsExpectedValue() {
- when(mLargeClockFrame.getVisibility()).thenReturn(View.VISIBLE);
- when(mLargeClockFrame.getHeight()).thenReturn(100);
- when(mSmallClockFrame.getHeight()).thenReturn(50);
- when(mLargeClockView.getHeight()).thenReturn(40);
- when(mSmallClockView.getHeight()).thenReturn(20);
- mController.init();
-
- assertEquals(170, mController.getClockBottom(1000));
- }
-
- @Test
- public void testGetSmallLargeClockBottom_returnsExpectedValue() {
- when(mLargeClockFrame.getVisibility()).thenReturn(View.GONE);
- when(mLargeClockFrame.getHeight()).thenReturn(100);
- when(mSmallClockFrame.getHeight()).thenReturn(50);
- when(mLargeClockView.getHeight()).thenReturn(40);
- when(mSmallClockView.getHeight()).thenReturn(20);
- mController.init();
-
- assertEquals(1120, mController.getClockBottom(1000));
- }
-
- @Test
- public void testGetClockBottom_nullClock_returnsZero() {
- when(mClockEventController.getClock()).thenReturn(null);
- assertEquals(0, mController.getClockBottom(10));
- }
-
- @Test
- public void testChangeLockscreenWeatherEnabledSetsWeatherViewVisible() {
- when(mSmartspaceController.isWeatherEnabled()).thenReturn(true);
- ArgumentCaptor<ContentObserver> observerCaptor =
- ArgumentCaptor.forClass(ContentObserver.class);
- mController.init();
- mExecutor.runAllReady();
- verify(mSecureSettings).registerContentObserverForUserSync(
- eq(Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED), anyBoolean(),
- observerCaptor.capture(), eq(UserHandle.USER_ALL));
- ContentObserver observer = observerCaptor.getValue();
- mExecutor.runAllReady();
- // When a settings change has occurred, check that view is visible.
- observer.onChange(true);
- mExecutor.runAllReady();
- assertEquals(View.VISIBLE, mFakeWeatherView.getVisibility());
- }
-
- @Test
- public void testChangeClockDateWeatherEnabled_SetsDateWeatherViewVisibility() {
- ArgumentCaptor<ClockRegistry.ClockChangeListener> listenerArgumentCaptor =
- ArgumentCaptor.forClass(ClockRegistry.ClockChangeListener.class);
- when(mSmartspaceController.isEnabled()).thenReturn(true);
- when(mSmartspaceController.isDateWeatherDecoupled()).thenReturn(true);
- when(mSmartspaceController.isWeatherEnabled()).thenReturn(true);
- mController.init();
- mExecutor.runAllReady();
- assertEquals(View.VISIBLE, mFakeDateView.getVisibility());
-
- when(mSmallClockController.getConfig())
- .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true, false, true));
- when(mLargeClockController.getConfig())
- .thenReturn(new ClockFaceConfig(ClockTickRate.PER_MINUTE, true, false, true));
- verify(mClockRegistry).registerClockChangeListener(listenerArgumentCaptor.capture());
- listenerArgumentCaptor.getValue().onCurrentClockChanged();
-
- mExecutor.runAllReady();
- assertEquals(View.INVISIBLE, mFakeDateView.getVisibility());
- }
-
- @Test
- public void testGetClock_nullClock_returnsNull() {
- when(mClockEventController.getClock()).thenReturn(null);
- assertNull(mController.getClock());
- }
-
- private void verifyAttachment(VerificationMode times) {
- verify(mClockRegistry, times).registerClockChangeListener(
- any(ClockRegistry.ClockChangeListener.class));
- verify(mClockEventController, times).registerListeners(mView);
- }
-
- @Test
- public void testSplitShadeEnabledSetToSmartspaceController() {
- mController.setSplitShadeEnabled(true);
- verify(mSmartspaceController, times(1)).setSplitShadeEnabled(true);
- verify(mSmartspaceController, times(0)).setSplitShadeEnabled(false);
- }
-
- @Test
- public void testSplitShadeDisabledSetToSmartspaceController() {
- mController.setSplitShadeEnabled(false);
- verify(mSmartspaceController, times(1)).setSplitShadeEnabled(false);
- verify(mSmartspaceController, times(0)).setSplitShadeEnabled(true);
- }
-}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchTest.java b/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchTest.java
deleted file mode 100644
index 4ed5fd0a6e71..000000000000
--- a/packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardClockSwitchTest.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright (C) 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
- */
-
-package com.android.keyguard;
-
-import static android.view.View.INVISIBLE;
-import static android.view.View.VISIBLE;
-
-import static com.android.keyguard.KeyguardClockSwitch.LARGE;
-import static com.android.keyguard.KeyguardClockSwitch.SMALL;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static junit.framework.TestCase.assertEquals;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.platform.test.annotations.DisableFlags;
-import android.testing.TestableLooper.RunWithLooper;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-
-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.plugins.clocks.ClockController;
-import com.android.systemui.plugins.clocks.ClockFaceController;
-import com.android.systemui.res.R;
-import com.android.systemui.statusbar.StatusBarState;
-
-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)
-// Need to run on the main thread because KeyguardSliceView$Row init checks for
-// the main thread before acquiring a wake lock. This class is constructed when
-// the keyguard_clock_switch layout is inflated.
-@RunWithLooper(setAsMainLooper = true)
-@DisableFlags(Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
-public class KeyguardClockSwitchTest extends SysuiTestCase {
- @Mock
- ViewGroup mMockKeyguardSliceView;
-
- @Mock
- ClockController mClock;
-
- @Mock
- ClockFaceController mSmallClock;
-
- @Mock
- ClockFaceController mLargeClock;
-
- private FrameLayout mSmallClockFrame;
- private FrameLayout mLargeClockFrame;
- private KeyguardStatusAreaView mStatusArea;
-
- KeyguardClockSwitch mKeyguardClockSwitch;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- when(mMockKeyguardSliceView.getContext()).thenReturn(mContext);
- when(mMockKeyguardSliceView.findViewById(R.id.keyguard_status_area))
- .thenReturn(mMockKeyguardSliceView);
-
- when(mClock.getSmallClock()).thenReturn(mSmallClock);
- when(mClock.getLargeClock()).thenReturn(mLargeClock);
-
- when(mSmallClock.getView()).thenReturn(new TextView(getContext()));
- when(mLargeClock.getView()).thenReturn(new TextView(getContext()));
-
- LayoutInflater layoutInflater = LayoutInflater.from(getContext());
- layoutInflater.setPrivateFactory(new LayoutInflater.Factory2() {
-
- @Override
- public View onCreateView(View parent, String name, Context context,
- AttributeSet attrs) {
- return onCreateView(name, context, attrs);
- }
-
- @Override
- public View onCreateView(String name, Context context, AttributeSet attrs) {
- if ("com.android.keyguard.KeyguardSliceView".equals(name)) {
- return mMockKeyguardSliceView;
- }
- return null;
- }
- });
- mKeyguardClockSwitch =
- (KeyguardClockSwitch) layoutInflater.inflate(R.layout.keyguard_clock_switch, null);
- mSmallClockFrame = mKeyguardClockSwitch
- .findViewById(com.android.systemui.customization.R.id.lockscreen_clock_view);
- mLargeClockFrame = mKeyguardClockSwitch
- .findViewById(com.android.systemui.customization.R.id.lockscreen_clock_view_large);
- mStatusArea = mKeyguardClockSwitch.findViewById(R.id.keyguard_status_area);
- mKeyguardClockSwitch.mChildrenAreLaidOut = true;
- }
-
- @Test
- public void noPluginConnected_showNothing() {
- mKeyguardClockSwitch.setClock(null, StatusBarState.KEYGUARD);
- assertEquals(mLargeClockFrame.getChildCount(), 0);
- assertEquals(mSmallClockFrame.getChildCount(), 0);
- }
-
- @Test
- public void pluginConnectedThenDisconnected_showNothing() {
- mKeyguardClockSwitch.setClock(mClock, StatusBarState.KEYGUARD);
- assertEquals(mLargeClockFrame.getChildCount(), 1);
- assertEquals(mSmallClockFrame.getChildCount(), 1);
-
- mKeyguardClockSwitch.setClock(null, StatusBarState.KEYGUARD);
- assertEquals(mLargeClockFrame.getChildCount(), 0);
- assertEquals(mSmallClockFrame.getChildCount(), 0);
- }
-
- @Test
- public void onPluginConnected_showClock() {
- mKeyguardClockSwitch.setClock(mClock, StatusBarState.KEYGUARD);
-
- assertEquals(mClock.getSmallClock().getView().getParent(), mSmallClockFrame);
- assertEquals(mClock.getLargeClock().getView().getParent(), mLargeClockFrame);
- }
-
- @Test
- public void onPluginConnected_showSecondPluginClock() {
- // GIVEN a plugin has already connected
- ClockController otherClock = mock(ClockController.class);
- ClockFaceController smallClock = mock(ClockFaceController.class);
- ClockFaceController largeClock = mock(ClockFaceController.class);
- when(otherClock.getSmallClock()).thenReturn(smallClock);
- when(otherClock.getLargeClock()).thenReturn(largeClock);
- when(smallClock.getView()).thenReturn(new TextView(getContext()));
- when(largeClock.getView()).thenReturn(new TextView(getContext()));
- mKeyguardClockSwitch.setClock(mClock, StatusBarState.KEYGUARD);
- mKeyguardClockSwitch.setClock(otherClock, StatusBarState.KEYGUARD);
-
- // THEN only the view from the second plugin should be a child of KeyguardClockSwitch.
- assertThat(otherClock.getSmallClock().getView().getParent()).isEqualTo(mSmallClockFrame);
- assertThat(otherClock.getLargeClock().getView().getParent()).isEqualTo(mLargeClockFrame);
- assertThat(mClock.getSmallClock().getView().getParent()).isNull();
- assertThat(mClock.getLargeClock().getView().getParent()).isNull();
- }
-
- @Test
- public void onPluginDisconnected_secondOfTwoDisconnected() {
- // GIVEN two plugins are connected
- ClockController otherClock = mock(ClockController.class);
- ClockFaceController smallClock = mock(ClockFaceController.class);
- ClockFaceController largeClock = mock(ClockFaceController.class);
- when(otherClock.getSmallClock()).thenReturn(smallClock);
- when(otherClock.getLargeClock()).thenReturn(largeClock);
- when(smallClock.getView()).thenReturn(new TextView(getContext()));
- when(largeClock.getView()).thenReturn(new TextView(getContext()));
- mKeyguardClockSwitch.setClock(otherClock, StatusBarState.KEYGUARD);
- mKeyguardClockSwitch.setClock(mClock, StatusBarState.KEYGUARD);
- // WHEN the second plugin is disconnected
- mKeyguardClockSwitch.setClock(null, StatusBarState.KEYGUARD);
- // THEN nothing should be shown
- assertThat(otherClock.getSmallClock().getView().getParent()).isNull();
- assertThat(otherClock.getLargeClock().getView().getParent()).isNull();
- assertThat(mClock.getSmallClock().getView().getParent()).isNull();
- assertThat(mClock.getLargeClock().getView().getParent()).isNull();
- }
-
- @Test
- public void switchingToBigClockWithAnimation_makesSmallClockDisappear() {
- mKeyguardClockSwitch.switchToClock(LARGE, /* animate */ true);
-
- mKeyguardClockSwitch.mClockInAnim.end();
- mKeyguardClockSwitch.mClockOutAnim.end();
- mKeyguardClockSwitch.mStatusAreaAnim.end();
-
- assertThat(mLargeClockFrame.getAlpha()).isEqualTo(1);
- assertThat(mLargeClockFrame.getVisibility()).isEqualTo(VISIBLE);
- assertThat(mSmallClockFrame.getAlpha()).isEqualTo(0);
- assertThat(mSmallClockFrame.getVisibility()).isEqualTo(INVISIBLE);
- }
-
- @Test
- public void switchingToBigClockNoAnimation_makesSmallClockDisappear() {
- mKeyguardClockSwitch.switchToClock(LARGE, /* animate */ false);
-
- assertThat(mLargeClockFrame.getAlpha()).isEqualTo(1);
- assertThat(mLargeClockFrame.getVisibility()).isEqualTo(VISIBLE);
- assertThat(mSmallClockFrame.getAlpha()).isEqualTo(0);
- assertThat(mSmallClockFrame.getVisibility()).isEqualTo(INVISIBLE);
- }
-
- @Test
- public void switchingToSmallClockWithAnimation_makesBigClockDisappear() {
- mKeyguardClockSwitch.switchToClock(SMALL, /* animate */ true);
-
- mKeyguardClockSwitch.mClockInAnim.end();
- mKeyguardClockSwitch.mClockOutAnim.end();
- mKeyguardClockSwitch.mStatusAreaAnim.end();
-
- assertThat(mSmallClockFrame.getAlpha()).isEqualTo(1);
- assertThat(mSmallClockFrame.getVisibility()).isEqualTo(VISIBLE);
- // only big clock is removed at switch
- assertThat(mLargeClockFrame.getParent()).isNull();
- assertThat(mLargeClockFrame.getAlpha()).isEqualTo(0);
- assertThat(mLargeClockFrame.getVisibility()).isEqualTo(INVISIBLE);
- }
-
- @Test
- public void switchingToSmallClockNoAnimation_makesBigClockDisappear() {
- mKeyguardClockSwitch.switchToClock(SMALL, false);
-
- assertThat(mSmallClockFrame.getAlpha()).isEqualTo(1);
- assertThat(mSmallClockFrame.getVisibility()).isEqualTo(VISIBLE);
- // only big clock is removed at switch
- assertThat(mLargeClockFrame.getParent()).isNull();
- assertThat(mLargeClockFrame.getAlpha()).isEqualTo(0);
- assertThat(mLargeClockFrame.getVisibility()).isEqualTo(INVISIBLE);
- }
-
- @Test
- public void switchingToSmallClockAnimation_resetsStatusArea() {
- mKeyguardClockSwitch.switchToClock(SMALL, true);
-
- mKeyguardClockSwitch.mClockInAnim.end();
- mKeyguardClockSwitch.mClockOutAnim.end();
- mKeyguardClockSwitch.mStatusAreaAnim.end();
-
- assertThat(mStatusArea.getTranslationX()).isEqualTo(0);
- assertThat(mStatusArea.getTranslationY()).isEqualTo(0);
- assertThat(mStatusArea.getScaleX()).isEqualTo(1);
- assertThat(mStatusArea.getScaleY()).isEqualTo(1);
- }
-
- @Test
- public void switchingToSmallClockNoAnimation_resetsStatusArea() {
- mKeyguardClockSwitch.switchToClock(SMALL, false);
-
- assertThat(mStatusArea.getTranslationX()).isEqualTo(0);
- assertThat(mStatusArea.getTranslationY()).isEqualTo(0);
- assertThat(mStatusArea.getScaleX()).isEqualTo(1);
- assertThat(mStatusArea.getScaleY()).isEqualTo(1);
- }
-
-
- @Test
- public void switchingToBigClock_returnsTrueOnlyWhenItWasNotVisibleBefore() {
- assertThat(mKeyguardClockSwitch.switchToClock(LARGE, /* animate */ true)).isTrue();
- assertThat(mKeyguardClockSwitch.switchToClock(LARGE, /* animate */ true)).isFalse();
- }
-}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index ec0f582dcb47..0e1eccc8231c 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -55,7 +55,6 @@ 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.icon.ui.viewbinder.NotificationIconContainerAlwaysOnDisplayViewBinder;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.util.ViewController;
@@ -85,7 +84,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private final DumpManager mDumpManager;
private final ClockEventController mClockEventController;
private final LogBuffer mLogBuffer;
- private final NotificationIconContainerAlwaysOnDisplayViewBinder mNicViewBinder;
private FrameLayout mSmallClockFrame; // top aligned clock
private FrameLayout mLargeClockFrame; // centered clock
@@ -147,7 +145,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
ClockRegistry clockRegistry,
KeyguardSliceViewController keyguardSliceViewController,
LockscreenSmartspaceController smartspaceController,
- NotificationIconContainerAlwaysOnDisplayViewBinder nicViewBinder,
KeyguardUnlockAnimationController keyguardUnlockAnimationController,
SecureSettings secureSettings,
@Main DelayableExecutor uiExecutor,
@@ -163,7 +160,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mClockRegistry = clockRegistry;
mKeyguardSliceViewController = keyguardSliceViewController;
mSmartspaceController = smartspaceController;
- mNicViewBinder = nicViewBinder;
mSecureSettings = secureSettings;
mUiExecutor = uiExecutor;
mBgExecutor = bgExecutor;
@@ -277,7 +273,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
hideSliceViewAndNotificationIconContainer();
return;
}
- updateAodIcons();
mStatusArea = mView.findViewById(R.id.keyguard_status_area);
mBgExecutor.execute(() -> {
@@ -569,21 +564,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
return mLargeClockFrame.getVisibility() != View.VISIBLE;
}
- private void updateAodIcons() {
- if (!MigrateClocksToBlueprint.isEnabled()) {
- NotificationIconContainer nic = (NotificationIconContainer)
- mView.findViewById(
- com.android.systemui.res.R.id.left_aligned_notification_icon_container);
- if (mAodIconsBindHandle != null) {
- mAodIconsBindHandle.dispose();
- }
- if (nic != null) {
- mAodIconsBindHandle = mNicViewBinder.bindWhileAttached(nic);
- mAodIconContainer = nic;
- }
- }
- }
-
private void setClock(ClockController clock) {
if (MigrateClocksToBlueprint.isEnabled()) {
return;
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt
index 273d763a8c57..0a958e9d06a4 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt
@@ -27,7 +27,6 @@ import androidx.constraintlayout.widget.ConstraintSet
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.app.tracing.coroutines.launchTraced as launch
-import com.android.systemui.keyguard.MigrateClocksToBlueprint
import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.ClockSize
@@ -73,7 +72,6 @@ object KeyguardClockViewBinder {
// When changing to new clock, we need to remove old views from burnInLayer
var lastClock: ClockController? = null
launch {
- if (!MigrateClocksToBlueprint.isEnabled) return@launch
viewModel.currentClock.collect { currentClock ->
if (lastClock != currentClock) {
cleanupClockViews(
@@ -99,7 +97,6 @@ object KeyguardClockViewBinder {
}
launch {
- if (!MigrateClocksToBlueprint.isEnabled) return@launch
viewModel.clockSize.collect { clockSize ->
updateBurnInLayer(keyguardRootView, viewModel, clockSize)
blueprintInteractor.refreshBlueprint(Type.ClockSize)
@@ -107,7 +104,6 @@ object KeyguardClockViewBinder {
}
launch {
- if (!MigrateClocksToBlueprint.isEnabled) return@launch
viewModel.clockShouldBeCentered.collect {
viewModel.currentClock.value?.let {
// TODO(b/301502635): remove "!it.config.useCustomClockScene" when
@@ -125,7 +121,6 @@ object KeyguardClockViewBinder {
}
launch {
- if (!MigrateClocksToBlueprint.isEnabled) return@launch
combine(
viewModel.hasAodIcons,
rootViewModel.isNotifIconContainerVisible.map { it.value },
@@ -143,7 +138,6 @@ object KeyguardClockViewBinder {
}
launch {
- if (!MigrateClocksToBlueprint.isEnabled) return@launch
aodBurnInViewModel.movement.collect { burnInModel ->
viewModel.currentClock.value
?.largeClock
@@ -159,7 +153,6 @@ object KeyguardClockViewBinder {
}
launch {
- if (!MigrateClocksToBlueprint.isEnabled) return@launch
viewModel.largeClockTextSize.collect { fontSizePx ->
viewModel.currentClock.value
?.largeClock
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
index f121aabe795a..cd4d9dcf366c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
@@ -31,14 +31,12 @@ import android.view.View.OnLayoutChangeListener
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.view.ViewGroup.OnHierarchyChangeListener
-import android.view.ViewPropertyAnimator
import android.view.WindowInsets
import androidx.activity.OnBackPressedDispatcher
import androidx.activity.OnBackPressedDispatcherOwner
import androidx.activity.setViewTreeOnBackPressedDispatcherOwner
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
-import com.android.app.animation.Interpolators
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.jank.InteractionJankMonitor.CUJ_SCREEN_OFF_SHOW_AOD
@@ -56,7 +54,6 @@ import com.android.systemui.customization.R as customR
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryHapticsInteractor
import com.android.systemui.keyguard.KeyguardBottomAreaRefactor
import com.android.systemui.keyguard.KeyguardViewMediator
-import com.android.systemui.keyguard.MigrateClocksToBlueprint
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
@@ -90,12 +87,9 @@ import kotlin.math.min
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.coroutineScope
-import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
-import com.android.app.tracing.coroutines.launchTraced as launch
/** Bind occludingAppDeviceEntryMessageViewModel to run whenever the keyguard view is attached. */
@OptIn(ExperimentalCoroutinesApi::class)
@@ -161,21 +155,19 @@ object KeyguardRootViewBinder {
disposables +=
view.repeatWhenAttached(mainImmediateDispatcher) {
repeatOnLifecycle(Lifecycle.State.CREATED) {
- if (MigrateClocksToBlueprint.isEnabled) {
- launch("$TAG#topClippingBounds") {
- val clipBounds = Rect()
- viewModel.topClippingBounds.collect { clipTop ->
- if (clipTop == null) {
- view.setClipBounds(null)
- } else {
- clipBounds.apply {
- top = clipTop
- left = view.getLeft()
- right = view.getRight()
- bottom = view.getBottom()
- }
- view.setClipBounds(clipBounds)
+ launch("$TAG#topClippingBounds") {
+ val clipBounds = Rect()
+ viewModel.topClippingBounds.collect { clipTop ->
+ if (clipTop == null) {
+ view.setClipBounds(null)
+ } else {
+ clipBounds.apply {
+ top = clipTop
+ left = view.getLeft()
+ right = view.getRight()
+ bottom = view.getBottom()
}
+ view.setClipBounds(clipBounds)
}
}
}
@@ -190,40 +182,36 @@ object KeyguardRootViewBinder {
}
}
- if (MigrateClocksToBlueprint.isEnabled) {
- launch("$TAG#translationY") {
- // When translation happens in burnInLayer, it won't be weather clock
- // large clock isn't added to burnInLayer due to its scale transition
- // so we also need to add translation to it here
- // same as translationX
- viewModel.translationY.collect { y ->
- childViews[burnInLayerId]?.translationY = y
- childViews[largeClockId]?.translationY = y
- childViews[aodNotificationIconContainerId]?.translationY = y
- }
+ launch("$TAG#translationY") {
+ // When translation happens in burnInLayer, it won't be weather clock large
+ // clock isn't added to burnInLayer due to its scale transition so we also
+ // need to add translation to it here same as translationX
+ viewModel.translationY.collect { y ->
+ childViews[burnInLayerId]?.translationY = y
+ childViews[largeClockId]?.translationY = y
+ childViews[aodNotificationIconContainerId]?.translationY = y
}
+ }
- launch("$TAG#translationX") {
- viewModel.translationX.collect { state ->
- val px = state.value ?: return@collect
- when {
- state.isToOrFrom(KeyguardState.AOD) -> {
- // Large Clock is not translated in the x direction
- childViews[burnInLayerId]?.translationX = px
- childViews[aodNotificationIconContainerId]?.translationX =
- px
- }
- state.isToOrFrom(KeyguardState.GLANCEABLE_HUB) -> {
- for ((key, childView) in childViews.entries) {
- when (key) {
- indicationArea,
- startButton,
- endButton,
- deviceEntryIcon -> {
- // Do not move these views
- }
- else -> childView.translationX = px
+ launch("$TAG#translationX") {
+ viewModel.translationX.collect { state ->
+ val px = state.value ?: return@collect
+ when {
+ state.isToOrFrom(KeyguardState.AOD) -> {
+ // Large Clock is not translated in the x direction
+ childViews[burnInLayerId]?.translationX = px
+ childViews[aodNotificationIconContainerId]?.translationX = px
+ }
+ state.isToOrFrom(KeyguardState.GLANCEABLE_HUB) -> {
+ for ((key, childView) in childViews.entries) {
+ when (key) {
+ indicationArea,
+ startButton,
+ endButton,
+ deviceEntryIcon -> {
+ // Do not move these views
}
+ else -> childView.translationX = px
}
}
}
@@ -263,95 +251,92 @@ object KeyguardRootViewBinder {
}
}
- if (MigrateClocksToBlueprint.isEnabled) {
- launch {
- viewModel.burnInLayerVisibility.collect { visibility ->
- childViews[burnInLayerId]?.visibility = visibility
- }
+ launch {
+ viewModel.burnInLayerVisibility.collect { visibility ->
+ childViews[burnInLayerId]?.visibility = visibility
}
+ }
- launch {
- viewModel.burnInLayerAlpha.collect { alpha ->
- childViews[statusViewId]?.alpha = alpha
- }
+ launch {
+ viewModel.burnInLayerAlpha.collect { alpha ->
+ childViews[statusViewId]?.alpha = alpha
}
+ }
- launch {
- viewModel.lockscreenStateAlpha(viewState).collect { alpha ->
- childViews[statusViewId]?.alpha = alpha
- }
+ launch {
+ viewModel.lockscreenStateAlpha(viewState).collect { alpha ->
+ childViews[statusViewId]?.alpha = alpha
}
+ }
- launch {
- viewModel.scale.collect { scaleViewModel ->
- if (scaleViewModel.scaleClockOnly) {
- // For clocks except weather clock, we have scale transition
- // besides translate
- childViews[largeClockId]?.let {
- it.scaleX = scaleViewModel.scale
- it.scaleY = scaleViewModel.scale
- }
+ launch {
+ viewModel.scale.collect { scaleViewModel ->
+ if (scaleViewModel.scaleClockOnly) {
+ // For clocks except weather clock, we have scale transition besides
+ // translate
+ childViews[largeClockId]?.let {
+ it.scaleX = scaleViewModel.scale
+ it.scaleY = scaleViewModel.scale
}
}
}
+ }
- launch {
- blueprintViewModel.currentTransition.collect { currentTransition ->
- // When blueprint/clock transitions end (null), make sure NSSL is in
- // the right place
- if (currentTransition == null) {
- childViews[nsslPlaceholderId]?.let { notificationListPlaceholder
- ->
- viewModel.onNotificationContainerBoundsChanged(
- notificationListPlaceholder.top.toFloat(),
- notificationListPlaceholder.bottom.toFloat(),
- animate = true,
- )
- }
+ launch {
+ blueprintViewModel.currentTransition.collect { currentTransition ->
+ // When blueprint/clock transitions end (null), make sure NSSL is in the
+ // right place
+ if (currentTransition == null) {
+ childViews[nsslPlaceholderId]?.let { notificationListPlaceholder ->
+ viewModel.onNotificationContainerBoundsChanged(
+ notificationListPlaceholder.top.toFloat(),
+ notificationListPlaceholder.bottom.toFloat(),
+ animate = true,
+ )
}
}
}
+ }
- launch {
- val iconsAppearTranslationPx =
- configuration
- .getDimensionPixelSize(R.dimen.shelf_appear_translation)
- .stateIn(this)
- viewModel.isNotifIconContainerVisible.collect { isVisible ->
- if (isVisible.value) {
- blueprintViewModel.refreshBlueprint()
- }
- childViews[aodNotificationIconContainerId]
- ?.setAodNotifIconContainerIsVisible(
- isVisible,
- iconsAppearTranslationPx.value,
- screenOffAnimationController,
- )
+ launch {
+ val iconsAppearTranslationPx =
+ configuration
+ .getDimensionPixelSize(R.dimen.shelf_appear_translation)
+ .stateIn(this)
+ viewModel.isNotifIconContainerVisible.collect { isVisible ->
+ if (isVisible.value) {
+ blueprintViewModel.refreshBlueprint()
}
+ childViews[aodNotificationIconContainerId]
+ ?.setAodNotifIconContainerIsVisible(
+ isVisible,
+ iconsAppearTranslationPx.value,
+ screenOffAnimationController,
+ )
}
+ }
- interactionJankMonitor?.let { jankMonitor ->
- launch {
- viewModel.goneToAodTransition.collect {
- when (it.transitionState) {
- TransitionState.STARTED -> {
- val clockId = clockInteractor.renderedClockId
- val builder =
- InteractionJankMonitor.Configuration.Builder
- .withView(CUJ_SCREEN_OFF_SHOW_AOD, view)
- .setTag(clockId)
- jankMonitor.begin(builder)
- }
- TransitionState.CANCELED ->
- jankMonitor.cancel(CUJ_SCREEN_OFF_SHOW_AOD)
- TransitionState.FINISHED -> {
- if (MigrateClocksToBlueprint.isEnabled) {
- keyguardViewMediator?.maybeHandlePendingLock()
- }
- jankMonitor.end(CUJ_SCREEN_OFF_SHOW_AOD)
- }
- TransitionState.RUNNING -> Unit
+ interactionJankMonitor?.let { jankMonitor ->
+ launch {
+ viewModel.goneToAodTransition.collect {
+ when (it.transitionState) {
+ TransitionState.STARTED -> {
+ val clockId = clockInteractor.renderedClockId
+ val builder =
+ InteractionJankMonitor.Configuration.Builder.withView(
+ CUJ_SCREEN_OFF_SHOW_AOD,
+ view,
+ )
+ .setTag(clockId)
+ jankMonitor.begin(builder)
+ }
+ TransitionState.CANCELED ->
+ jankMonitor.cancel(CUJ_SCREEN_OFF_SHOW_AOD)
+ TransitionState.FINISHED -> {
+ keyguardViewMediator?.maybeHandlePendingLock()
+ jankMonitor.end(CUJ_SCREEN_OFF_SHOW_AOD)
}
+ TransitionState.RUNNING -> Unit
}
}
}
@@ -406,13 +391,11 @@ object KeyguardRootViewBinder {
}
}
- if (MigrateClocksToBlueprint.isEnabled) {
- burnInParams.update { current ->
- current.copy(
- translationX = { childViews[burnInLayerId]?.translationX },
- translationY = { childViews[burnInLayerId]?.translationY },
- )
- }
+ burnInParams.update { current ->
+ current.copy(
+ translationX = { childViews[burnInLayerId]?.translationX },
+ translationY = { childViews[burnInLayerId]?.translationY },
+ )
}
disposables +=
@@ -515,20 +498,16 @@ object KeyguardRootViewBinder {
burnInParams.update { current ->
current.copy(
minViewY =
- if (MigrateClocksToBlueprint.isEnabled) {
- // To ensure burn-in doesn't enroach the top inset, get the min top Y
- childViews.entries.fold(Int.MAX_VALUE) { currentMin, (viewId, view) ->
- min(
- currentMin,
- if (!isUserVisible(view)) {
- Int.MAX_VALUE
- } else {
- view.getTop()
- },
- )
- }
- } else {
- childViews[statusViewId]?.top ?: 0
+ // To ensure burn-in doesn't enroach the top inset, get the min top Y
+ childViews.entries.fold(Int.MAX_VALUE) { currentMin, (viewId, view) ->
+ min(
+ currentMin,
+ if (!isUserVisible(view)) {
+ Int.MAX_VALUE
+ } else {
+ view.getTop()
+ },
+ )
}
)
}
@@ -542,28 +521,6 @@ object KeyguardRootViewBinder {
}
}
- suspend fun bindAodNotifIconVisibility(
- view: View,
- isVisible: Flow<AnimatedValue<Boolean>>,
- configuration: ConfigurationState,
- screenOffAnimationController: ScreenOffAnimationController,
- ) {
- if (MigrateClocksToBlueprint.isEnabled) {
- throw IllegalStateException("should only be called in legacy code paths")
- }
- coroutineScope {
- val iconAppearTranslationPx =
- configuration.getDimensionPixelSize(R.dimen.shelf_appear_translation).stateIn(this)
- isVisible.collect { isVisible ->
- view.setAodNotifIconContainerIsVisible(
- isVisible = isVisible,
- iconsAppearTranslationPx = iconAppearTranslationPx.value,
- screenOffAnimationController = screenOffAnimationController,
- )
- }
- }
- }
-
private fun View.setAodNotifIconContainerIsVisible(
isVisible: AnimatedValue<Boolean>,
iconsAppearTranslationPx: Int,
@@ -578,9 +535,6 @@ object KeyguardRootViewBinder {
}
when {
!isVisible.isAnimating -> {
- if (!MigrateClocksToBlueprint.isEnabled) {
- translationY = 0f
- }
visibility =
if (isVisible.value) {
alpha = 1f
@@ -591,7 +545,6 @@ object KeyguardRootViewBinder {
}
}
else -> {
- animateInIconTranslation()
if (isVisible.value) {
CrossFadeHelper.fadeIn(this, animatorListener)
} else {
@@ -601,19 +554,10 @@ object KeyguardRootViewBinder {
}
}
- private fun View.animateInIconTranslation() {
- if (!MigrateClocksToBlueprint.isEnabled) {
- animate().animateInIconTranslation().setDuration(AOD_ICONS_APPEAR_DURATION).start()
- }
- }
-
private fun MotionEvent.isTouchscreenSource(): Boolean {
return device?.supportsSource(InputDevice.SOURCE_TOUCHSCREEN) == true
}
- private fun ViewPropertyAnimator.animateInIconTranslation(): ViewPropertyAnimator =
- setInterpolator(Interpolators.DECELERATE_QUINT).translationY(0f)
-
private val statusViewId = R.id.keyguard_status_view
private val burnInLayerId = R.id.burn_in_layer
private val aodNotificationIconContainerId = R.id.aod_notification_icon_container
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
index de4a1b03203c..213083db71c9 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt
@@ -22,7 +22,6 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.app.tracing.coroutines.launchTraced as launch
-import com.android.systemui.keyguard.MigrateClocksToBlueprint
import com.android.systemui.keyguard.domain.interactor.KeyguardBlueprintInteractor
import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransition.Config
import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransition.Type
@@ -44,13 +43,12 @@ object KeyguardSmartspaceViewBinder {
return keyguardRootView.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.CREATED) {
launch("$TAG#clockViewModel.hasCustomWeatherDataDisplay") {
- if (!MigrateClocksToBlueprint.isEnabled) return@launch
clockViewModel.hasCustomWeatherDataDisplay.collect { hasCustomWeatherDataDisplay
->
updateDateWeatherToBurnInLayer(
keyguardRootView,
clockViewModel,
- smartspaceViewModel
+ smartspaceViewModel,
)
blueprintInteractor.refreshBlueprint(
Config(
@@ -63,7 +61,6 @@ object KeyguardSmartspaceViewBinder {
}
launch("$TAG#smartspaceViewModel.bcSmartspaceVisibility") {
- if (!MigrateClocksToBlueprint.isEnabled) return@launch
smartspaceViewModel.bcSmartspaceVisibility.collect {
updateBCSmartspaceInBurnInLayer(keyguardRootView, clockViewModel)
blueprintInteractor.refreshBlueprint(
@@ -100,7 +97,7 @@ object KeyguardSmartspaceViewBinder {
private fun updateDateWeatherToBurnInLayer(
keyguardRootView: ConstraintLayout,
clockViewModel: KeyguardClockViewModel,
- smartspaceViewModel: KeyguardSmartspaceViewModel
+ smartspaceViewModel: KeyguardSmartspaceViewModel,
) {
if (clockViewModel.hasCustomWeatherDataDisplay.value) {
removeDateWeatherFromBurnInLayer(keyguardRootView, smartspaceViewModel)
@@ -112,7 +109,7 @@ object KeyguardSmartspaceViewBinder {
private fun addDateWeatherToBurnInLayer(
constraintLayout: ConstraintLayout,
- smartspaceViewModel: KeyguardSmartspaceViewModel
+ smartspaceViewModel: KeyguardSmartspaceViewModel,
) {
val burnInLayer = constraintLayout.requireViewById<Layer>(R.id.burn_in_layer)
burnInLayer.apply {
@@ -129,7 +126,7 @@ object KeyguardSmartspaceViewBinder {
private fun removeDateWeatherFromBurnInLayer(
constraintLayout: ConstraintLayout,
- smartspaceViewModel: KeyguardSmartspaceViewModel
+ smartspaceViewModel: KeyguardSmartspaceViewModel,
) {
val burnInLayer = constraintLayout.requireViewById<Layer>(R.id.burn_in_layer)
burnInLayer.apply {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt
index 4c23adfe92e8..6f7872c9cb96 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/AodNotificationIconsSection.kt
@@ -30,7 +30,6 @@ import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
import com.android.systemui.common.ui.ConfigurationState
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.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.res.R
@@ -62,9 +61,6 @@ constructor(
private lateinit var nic: NotificationIconContainer
override fun addViews(constraintLayout: ConstraintLayout) {
- if (!MigrateClocksToBlueprint.isEnabled) {
- return
- }
nic =
NotificationIconContainer(context, null).apply {
id = nicId
@@ -81,10 +77,6 @@ constructor(
}
override fun bindData(constraintLayout: ConstraintLayout) {
- if (!MigrateClocksToBlueprint.isEnabled) {
- return
- }
-
nicBindingDisposable?.dispose()
nicBindingDisposable =
NotificationIconContainerViewBinder.bindWhileAttached(
@@ -98,10 +90,6 @@ constructor(
}
override fun applyConstraints(constraintSet: ConstraintSet) {
- if (!MigrateClocksToBlueprint.isEnabled) {
- return
- }
-
val bottomMargin =
context.resources.getDimensionPixelSize(R.dimen.keyguard_status_view_bottom_margin)
val isVisible = rootViewModel.isNotifIconContainerVisible.value
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerAlwaysOnDisplayViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerAlwaysOnDisplayViewBinder.kt
index fc432ba973ab..839028e4c3b1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerAlwaysOnDisplayViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/ui/viewbinder/NotificationIconContainerAlwaysOnDisplayViewBinder.kt
@@ -16,62 +16,9 @@
package com.android.systemui.statusbar.notification.icon.ui.viewbinder
-import androidx.lifecycle.lifecycleScope
-import com.android.app.tracing.coroutines.launchTraced as launch
-import com.android.app.tracing.traceSection
-import com.android.systemui.common.ui.ConfigurationState
-import com.android.systemui.keyguard.ui.binder.KeyguardRootViewBinder
-import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
-import com.android.systemui.lifecycle.repeatWhenAttached
-import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.statusbar.notification.collection.NotifCollection
import com.android.systemui.statusbar.notification.icon.ui.viewbinder.NotificationIconContainerViewBinder.IconViewStore
-import com.android.systemui.statusbar.notification.icon.ui.viewmodel.NotificationIconContainerAlwaysOnDisplayViewModel
-import com.android.systemui.statusbar.phone.NotificationIconContainer
-import com.android.systemui.statusbar.phone.ScreenOffAnimationController
-import com.android.systemui.statusbar.ui.SystemBarUtilsState
import javax.inject.Inject
-import kotlinx.coroutines.DisposableHandle
-
-/** Binds a [NotificationIconContainer] to a [NotificationIconContainerAlwaysOnDisplayViewModel]. */
-class NotificationIconContainerAlwaysOnDisplayViewBinder
-@Inject
-constructor(
- private val viewModel: NotificationIconContainerAlwaysOnDisplayViewModel,
- private val keyguardRootViewModel: KeyguardRootViewModel,
- @ShadeDisplayAware private val configuration: ConfigurationState,
- private val failureTracker: StatusBarIconViewBindingFailureTracker,
- private val screenOffAnimationController: ScreenOffAnimationController,
- private val systemBarUtilsState: SystemBarUtilsState,
- private val viewStore: AlwaysOnDisplayNotificationIconViewStore,
-) {
- fun bindWhileAttached(view: NotificationIconContainer): DisposableHandle {
- return traceSection("NICAlwaysOnDisplay#bindWhileAttached") {
- view.repeatWhenAttached {
- lifecycleScope.launch {
- launch {
- NotificationIconContainerViewBinder.bind(
- view = view,
- viewModel = viewModel,
- configuration = configuration,
- systemBarUtilsState = systemBarUtilsState,
- failureTracker = failureTracker,
- viewStore = viewStore,
- )
- }
- launch {
- KeyguardRootViewBinder.bindAodNotifIconVisibility(
- view = view,
- isVisible = keyguardRootViewModel.isNotifIconContainerVisible,
- configuration = configuration,
- screenOffAnimationController = screenOffAnimationController,
- )
- }
- }
- }
- }
- }
-}
/** [IconViewStore] for the always-on display. */
class AlwaysOnDisplayNotificationIconViewStore