From ba0c161e2f995d0191478e083d75e28a773c7cbe Mon Sep 17 00:00:00 2001 From: Justin Weir Date: Thu, 20 Oct 2022 15:23:47 -0400 Subject: Merge PanelEventsEmitter into ShadeExpansionStateManager The purpose is to further consolidate and standardize how changes in the shade state are propogated throughout the system. The change renames NotifPanelEvents, merges the PanelEventsEmmitter impl into ShadeExpansionStateManager, and deletes the FakeNotifPanelEvents impl, which is unnecessary given the simplicity of ShadeExpansionStateManager. Bug: 254512692 Test: atest and manual verification Change-Id: I4d3e580eb2e8838b84b32fd1f1cdb05098db49ff --- .../media/controls/ui/MediaHierarchyManager.kt | 9 ++-- .../com/android/systemui/shade/NotifPanelEvents.kt | 53 ---------------------- .../systemui/shade/NotifPanelEventsModule.java | 30 ------------ .../shade/NotificationPanelViewController.java | 49 ++------------------ .../android/systemui/shade/ShadeEventsModule.java | 29 ++++++++++++ .../systemui/shade/ShadeExpansionStateManager.kt | 30 +++++++++++- .../com/android/systemui/shade/ShadeStateEvents.kt | 50 ++++++++++++++++++++ .../coordinator/VisualStabilityCoordinator.java | 12 ++--- .../notification/dagger/NotificationsModule.java | 4 +- .../media/controls/ui/MediaHierarchyManagerTest.kt | 6 +-- .../shade/NotificationPanelViewControllerTest.java | 3 -- .../systemui/shade/testing/FakeNotifPanelEvents.kt | 37 --------------- .../VisualStabilityCoordinatorTest.java | 14 +++--- 13 files changed, 135 insertions(+), 191 deletions(-) delete mode 100644 packages/SystemUI/src/com/android/systemui/shade/NotifPanelEvents.kt delete mode 100644 packages/SystemUI/src/com/android/systemui/shade/NotifPanelEventsModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/shade/ShadeEventsModule.java create mode 100644 packages/SystemUI/src/com/android/systemui/shade/ShadeStateEvents.kt delete mode 100644 packages/SystemUI/tests/src/com/android/systemui/shade/testing/FakeNotifPanelEvents.kt diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt index 6b46d8f30cad..cbb670ebf02d 100644 --- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt +++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/MediaHierarchyManager.kt @@ -43,7 +43,8 @@ import com.android.systemui.dreams.DreamOverlayStateController import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.media.dream.MediaDreamComplication import com.android.systemui.plugins.statusbar.StatusBarStateController -import com.android.systemui.shade.NotifPanelEvents +import com.android.systemui.shade.ShadeStateEvents +import com.android.systemui.shade.ShadeStateEvents.ShadeStateEventsListener import com.android.systemui.statusbar.CrossFadeHelper import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.SysuiStatusBarStateController @@ -96,7 +97,7 @@ constructor( private val dreamOverlayStateController: DreamOverlayStateController, configurationController: ConfigurationController, wakefulnessLifecycle: WakefulnessLifecycle, - panelEventsEvents: NotifPanelEvents, + panelEventsEvents: ShadeStateEvents, private val secureSettings: SecureSettings, @Main private val handler: Handler, ) { @@ -534,8 +535,8 @@ constructor( mediaHosts.forEach { it?.updateViewVisibility() } } - panelEventsEvents.registerListener( - object : NotifPanelEvents.Listener { + panelEventsEvents.addShadeStateEventsListener( + object : ShadeStateEventsListener { override fun onExpandImmediateChanged(isExpandImmediateEnabled: Boolean) { skipQqsOnExpansion = isExpandImmediateEnabled updateDesiredLocation() diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotifPanelEvents.kt b/packages/SystemUI/src/com/android/systemui/shade/NotifPanelEvents.kt deleted file mode 100644 index 4558061de1a2..000000000000 --- a/packages/SystemUI/src/com/android/systemui/shade/NotifPanelEvents.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2022 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.shade - -/** Provides certain notification panel events. */ -interface NotifPanelEvents { - - /** Registers callbacks to be invoked when notification panel events occur. */ - fun registerListener(listener: Listener) - - /** Unregisters callbacks previously registered via [registerListener] */ - fun unregisterListener(listener: Listener) - - /** Callbacks for certain notification panel events. */ - interface Listener { - - /** Invoked when the notification panel starts or stops collapsing. */ - @JvmDefault - fun onPanelCollapsingChanged(isCollapsing: Boolean) {} - - /** - * Invoked when the notification panel starts or stops launching an [android.app.Activity]. - */ - @JvmDefault - fun onLaunchingActivityChanged(isLaunchingActivity: Boolean) {} - - /** - * Invoked when the "expand immediate" attribute changes. - * - * An example of expanding immediately is when swiping down from the top with two fingers. - * Instead of going to QQS, we immediately expand to full QS. - * - * Another example is when full QS is showing, and we swipe up from the bottom. Instead of - * going to QQS, the panel fully collapses. - */ - @JvmDefault - fun onExpandImmediateChanged(isExpandImmediateEnabled: Boolean) {} - } -} diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotifPanelEventsModule.java b/packages/SystemUI/src/com/android/systemui/shade/NotifPanelEventsModule.java deleted file mode 100644 index 67723843086a..000000000000 --- a/packages/SystemUI/src/com/android/systemui/shade/NotifPanelEventsModule.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2022 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.shade; - -import com.android.systemui.dagger.SysUISingleton; - -import dagger.Binds; -import dagger.Module; - -/** Provides a {@link NotifPanelEvents} in {@link SysUISingleton} scope. */ -@Module -public abstract class NotifPanelEventsModule { - @Binds - abstract NotifPanelEvents bindPanelEvents( - NotificationPanelViewController.PanelEventsEmitter impl); -} diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index ddb57f74cacf..026ef0e80686 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -135,7 +135,6 @@ import com.android.systemui.biometrics.AuthController; import com.android.systemui.camera.CameraGestureHelper; import com.android.systemui.classifier.Classifier; import com.android.systemui.classifier.FalsingCollector; -import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.DisplayId; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.doze.DozeLog; @@ -231,7 +230,6 @@ import com.android.systemui.statusbar.window.StatusBarWindowStateController; import com.android.systemui.unfold.SysUIUnfoldComponent; import com.android.systemui.util.Compile; import com.android.systemui.util.LargeScreenUtils; -import com.android.systemui.util.ListenerSet; import com.android.systemui.util.Utils; import com.android.systemui.util.time.SystemClock; import com.android.wm.shell.animation.FlingAnimationUtils; @@ -372,7 +370,6 @@ public final class NotificationPanelViewController { private final TapAgainViewController mTapAgainViewController; private final LargeScreenShadeHeaderController mLargeScreenShadeHeaderController; private final RecordingController mRecordingController; - private final PanelEventsEmitter mPanelEventsEmitter; private final boolean mVibrateOnOpening; private final VelocityTracker mVelocityTracker = VelocityTracker.obtain(); private final FlingAnimationUtils mFlingAnimationUtilsClosing; @@ -880,7 +877,6 @@ public final class NotificationPanelViewController { Provider keyguardBottomAreaViewControllerProvider, KeyguardUnlockAnimationController keyguardUnlockAnimationController, NotificationListContainer notificationListContainer, - PanelEventsEmitter panelEventsEmitter, NotificationStackSizeCalculator notificationStackSizeCalculator, UnlockedScreenOffAnimationController unlockedScreenOffAnimationController, ShadeTransitionController shadeTransitionController, @@ -993,7 +989,6 @@ public final class NotificationPanelViewController { mMediaDataManager = mediaDataManager; mTapAgainViewController = tapAgainViewController; mSysUiState = sysUiState; - mPanelEventsEmitter = panelEventsEmitter; pulseExpansionHandler.setPulseExpandAbortListener(() -> { if (mQs != null) { mQs.animateHeaderSlidingOut(); @@ -1948,7 +1943,7 @@ public final class NotificationPanelViewController { private void setQsExpandImmediate(boolean expandImmediate) { if (expandImmediate != mQsExpandImmediate) { mQsExpandImmediate = expandImmediate; - mPanelEventsEmitter.notifyExpandImmediateChange(expandImmediate); + mShadeExpansionStateManager.notifyExpandImmediateChange(expandImmediate); } } @@ -3889,7 +3884,7 @@ public final class NotificationPanelViewController { boolean wasRunning = mIsLaunchAnimationRunning; mIsLaunchAnimationRunning = running; if (wasRunning != mIsLaunchAnimationRunning) { - mPanelEventsEmitter.notifyLaunchingActivityChanged(running); + mShadeExpansionStateManager.notifyLaunchingActivityChanged(running); } } @@ -3898,7 +3893,7 @@ public final class NotificationPanelViewController { boolean wasClosing = isClosing(); mClosing = isClosing; if (wasClosing != isClosing) { - mPanelEventsEmitter.notifyPanelCollapsingChanged(isClosing); + mShadeExpansionStateManager.notifyPanelCollapsingChanged(isClosing); } mAmbientState.setIsClosing(isClosing); } @@ -5921,44 +5916,6 @@ public final class NotificationPanelViewController { } } - @SysUISingleton - static class PanelEventsEmitter implements NotifPanelEvents { - - private final ListenerSet mListeners = new ListenerSet<>(); - - @Inject - PanelEventsEmitter() { - } - - @Override - public void registerListener(@androidx.annotation.NonNull @NonNull Listener listener) { - mListeners.addIfAbsent(listener); - } - - @Override - public void unregisterListener(@androidx.annotation.NonNull @NonNull Listener listener) { - mListeners.remove(listener); - } - - private void notifyLaunchingActivityChanged(boolean isLaunchingActivity) { - for (Listener cb : mListeners) { - cb.onLaunchingActivityChanged(isLaunchingActivity); - } - } - - private void notifyPanelCollapsingChanged(boolean isCollapsing) { - for (NotifPanelEvents.Listener cb : mListeners) { - cb.onPanelCollapsingChanged(isCollapsing); - } - } - - private void notifyExpandImmediateChange(boolean expandImmediateEnabled) { - for (NotifPanelEvents.Listener cb : mListeners) { - cb.onExpandImmediateChanged(expandImmediateEnabled); - } - } - } - /** Handles MotionEvents for the Shade. */ public final class TouchHandler implements View.OnTouchListener { private long mLastTouchDownTime = -1L; diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeEventsModule.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeEventsModule.java new file mode 100644 index 000000000000..959c339ab3e5 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeEventsModule.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2022 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.shade; + +import com.android.systemui.dagger.SysUISingleton; + +import dagger.Binds; +import dagger.Module; + +/** Provides a {@link ShadeStateEvents} in {@link SysUISingleton} scope. */ +@Module +public abstract class ShadeEventsModule { + @Binds + abstract ShadeStateEvents bindShadeEvents(ShadeExpansionStateManager impl); +} diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt index 7bba74a8b125..667392c9796e 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt @@ -20,6 +20,7 @@ import android.annotation.IntDef import android.util.Log import androidx.annotation.FloatRange import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.shade.ShadeStateEvents.ShadeStateEventsListener import com.android.systemui.util.Compile import java.util.concurrent.CopyOnWriteArrayList import javax.inject.Inject @@ -30,11 +31,12 @@ import javax.inject.Inject * TODO(b/200063118): Make this class the one source of truth for the state of panel expansion. */ @SysUISingleton -class ShadeExpansionStateManager @Inject constructor() { +class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents { private val expansionListeners = CopyOnWriteArrayList() private val qsExpansionListeners = CopyOnWriteArrayList() private val stateListeners = CopyOnWriteArrayList() + private val shadeStateEventsListeners = CopyOnWriteArrayList() @PanelState private var state: Int = STATE_CLOSED @FloatRange(from = 0.0, to = 1.0) private var fraction: Float = 0f @@ -79,6 +81,14 @@ class ShadeExpansionStateManager @Inject constructor() { stateListeners.remove(listener) } + override fun addShadeStateEventsListener(listener: ShadeStateEventsListener) { + shadeStateEventsListeners.addIfAbsent(listener) + } + + override fun removeShadeStateEventsListener(listener: ShadeStateEventsListener) { + shadeStateEventsListeners.remove(listener) + } + /** Returns true if the panel is currently closed and false otherwise. */ fun isClosed(): Boolean = state == STATE_CLOSED @@ -162,6 +172,24 @@ class ShadeExpansionStateManager @Inject constructor() { stateListeners.forEach { it.onPanelStateChanged(state) } } + fun notifyLaunchingActivityChanged(isLaunchingActivity: Boolean) { + for (cb in shadeStateEventsListeners) { + cb.onLaunchingActivityChanged(isLaunchingActivity) + } + } + + fun notifyPanelCollapsingChanged(isCollapsing: Boolean) { + for (cb in shadeStateEventsListeners) { + cb.onPanelCollapsingChanged(isCollapsing) + } + } + + fun notifyExpandImmediateChange(expandImmediateEnabled: Boolean) { + for (cb in shadeStateEventsListeners) { + cb.onExpandImmediateChanged(expandImmediateEnabled) + } + } + private fun debugLog(msg: String) { if (!DEBUG) return Log.v(TAG, msg) diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeStateEvents.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeStateEvents.kt new file mode 100644 index 000000000000..56bb1a6020cf --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeStateEvents.kt @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2022 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.shade + +/** Provides certain notification panel events. */ +interface ShadeStateEvents { + + /** Registers callbacks to be invoked when notification panel events occur. */ + fun addShadeStateEventsListener(listener: ShadeStateEventsListener) + + /** Unregisters callbacks previously registered via [addShadeStateEventsListener] */ + fun removeShadeStateEventsListener(listener: ShadeStateEventsListener) + + /** Callbacks for certain notification panel events. */ + interface ShadeStateEventsListener { + + /** Invoked when the notification panel starts or stops collapsing. */ + @JvmDefault fun onPanelCollapsingChanged(isCollapsing: Boolean) {} + + /** + * Invoked when the notification panel starts or stops launching an [android.app.Activity]. + */ + @JvmDefault fun onLaunchingActivityChanged(isLaunchingActivity: Boolean) {} + + /** + * Invoked when the "expand immediate" attribute changes. + * + * An example of expanding immediately is when swiping down from the top with two fingers. + * Instead of going to QQS, we immediately expand to full QS. + * + * Another example is when full QS is showing, and we swipe up from the bottom. Instead of + * going to QQS, the panel fully collapses. + */ + @JvmDefault fun onExpandImmediateChanged(isExpandImmediateEnabled: Boolean) {} + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java index d3bc257d8a54..3002a6820990 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinator.java @@ -28,7 +28,7 @@ import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.shade.NotifPanelEvents; +import com.android.systemui.shade.ShadeStateEvents; import com.android.systemui.statusbar.notification.collection.GroupEntry; import com.android.systemui.statusbar.notification.collection.ListEntry; import com.android.systemui.statusbar.notification.collection.NotifPipeline; @@ -55,12 +55,12 @@ import javax.inject.Inject; // TODO(b/204468557): Move to @CoordinatorScope @SysUISingleton public class VisualStabilityCoordinator implements Coordinator, Dumpable, - NotifPanelEvents.Listener { + ShadeStateEvents.ShadeStateEventsListener { public static final String TAG = "VisualStability"; public static final boolean DEBUG = Compile.IS_DEBUG && Log.isLoggable(TAG, Log.VERBOSE); private final DelayableExecutor mDelayableExecutor; private final HeadsUpManager mHeadsUpManager; - private final NotifPanelEvents mNotifPanelEvents; + private final ShadeStateEvents mShadeStateEvents; private final StatusBarStateController mStatusBarStateController; private final VisualStabilityProvider mVisualStabilityProvider; private final WakefulnessLifecycle mWakefulnessLifecycle; @@ -92,7 +92,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable, DelayableExecutor delayableExecutor, DumpManager dumpManager, HeadsUpManager headsUpManager, - NotifPanelEvents notifPanelEvents, + ShadeStateEvents shadeStateEvents, StatusBarStateController statusBarStateController, VisualStabilityProvider visualStabilityProvider, WakefulnessLifecycle wakefulnessLifecycle) { @@ -101,7 +101,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable, mWakefulnessLifecycle = wakefulnessLifecycle; mStatusBarStateController = statusBarStateController; mDelayableExecutor = delayableExecutor; - mNotifPanelEvents = notifPanelEvents; + mShadeStateEvents = shadeStateEvents; dumpManager.registerDumpable(this); } @@ -114,7 +114,7 @@ public class VisualStabilityCoordinator implements Coordinator, Dumpable, mStatusBarStateController.addCallback(mStatusBarStateControllerListener); mPulsing = mStatusBarStateController.isPulsing(); - mNotifPanelEvents.registerListener(this); + mShadeStateEvents.addShadeStateEventsListener(this); pipeline.setVisualStabilityManager(mNotifStabilityManager); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java index da4cceda531f..ff6389141575 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/dagger/NotificationsModule.java @@ -32,8 +32,8 @@ import com.android.systemui.dagger.qualifiers.UiBackground; import com.android.systemui.people.widget.PeopleSpaceWidgetManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.settings.UserContextProvider; -import com.android.systemui.shade.NotifPanelEventsModule; import com.android.systemui.shade.ShadeController; +import com.android.systemui.shade.ShadeEventsModule; import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.notification.AssistantFeedbackController; import com.android.systemui.statusbar.notification.collection.NotifInflaterImpl; @@ -93,7 +93,7 @@ import dagger.Provides; @Module(includes = { CoordinatorsModule.class, KeyguardNotificationVisibilityProviderModule.class, - NotifPanelEventsModule.class, + ShadeEventsModule.class, NotifPipelineChoreographerModule.class, NotificationSectionHeadersModule.class, }) diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt index 071604dc5790..920801f95f5b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/MediaHierarchyManagerTest.kt @@ -31,7 +31,7 @@ import com.android.systemui.dreams.DreamOverlayStateController import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.media.dream.MediaDreamComplication import com.android.systemui.plugins.statusbar.StatusBarStateController -import com.android.systemui.shade.testing.FakeNotifPanelEvents +import com.android.systemui.shade.ShadeExpansionStateManager import com.android.systemui.statusbar.StatusBarState import com.android.systemui.statusbar.SysuiStatusBarStateController import com.android.systemui.statusbar.phone.KeyguardBypassController @@ -89,7 +89,7 @@ class MediaHierarchyManagerTest : SysuiTestCase() { private lateinit var mediaHierarchyManager: MediaHierarchyManager private lateinit var mediaFrame: ViewGroup private val configurationController = FakeConfigurationController() - private val notifPanelEvents = FakeNotifPanelEvents() + private val notifPanelEvents = ShadeExpansionStateManager() private val settings = FakeSettings() private lateinit var testableLooper: TestableLooper private lateinit var fakeHandler: FakeHandler @@ -346,7 +346,7 @@ class MediaHierarchyManagerTest : SysuiTestCase() { @Test fun isCurrentlyInGuidedTransformation_hostsVisible_expandImmediateEnabled_returnsFalse() { - notifPanelEvents.changeExpandImmediate(expandImmediate = true) + notifPanelEvents.notifyExpandImmediateChange(true) goToLockscreen() enterGuidedTransformation() whenever(lockHost.visible).thenReturn(true) diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index 02f28a235b95..300843f3da95 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -438,8 +438,6 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { when(mSysUiState.setFlag(anyInt(), anyBoolean())).thenReturn(mSysUiState); mMainHandler = new Handler(Looper.getMainLooper()); - NotificationPanelViewController.PanelEventsEmitter panelEventsEmitter = - new NotificationPanelViewController.PanelEventsEmitter(); mNotificationPanelViewController = new NotificationPanelViewController( mView, @@ -495,7 +493,6 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { () -> mKeyguardBottomAreaViewController, mKeyguardUnlockAnimationController, mNotificationListContainer, - panelEventsEmitter, mNotificationStackSizeCalculator, mUnlockedScreenOffAnimationController, mShadeTransitionController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/testing/FakeNotifPanelEvents.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/testing/FakeNotifPanelEvents.kt deleted file mode 100644 index d05213877232..000000000000 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/testing/FakeNotifPanelEvents.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2022 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.shade.testing - -import com.android.systemui.shade.NotifPanelEvents - -/** Fake implementation of [NotifPanelEvents] for testing. */ -class FakeNotifPanelEvents : NotifPanelEvents { - - private val listeners = mutableListOf() - - override fun registerListener(listener: NotifPanelEvents.Listener) { - listeners.add(listener) - } - - override fun unregisterListener(listener: NotifPanelEvents.Listener) { - listeners.remove(listener) - } - - fun changeExpandImmediate(expandImmediate: Boolean) { - listeners.forEach { it.onExpandImmediateChanged(expandImmediate) } - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.java index c961cec39208..b4a5f5ce205f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/VisualStabilityCoordinatorTest.java @@ -36,7 +36,8 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.plugins.statusbar.StatusBarStateController; -import com.android.systemui.shade.NotifPanelEvents; +import com.android.systemui.shade.ShadeStateEvents; +import com.android.systemui.shade.ShadeStateEvents.ShadeStateEventsListener; import com.android.systemui.statusbar.notification.collection.GroupEntry; import com.android.systemui.statusbar.notification.collection.GroupEntryBuilder; import com.android.systemui.statusbar.notification.collection.NotifPipeline; @@ -71,12 +72,12 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase { @Mock private StatusBarStateController mStatusBarStateController; @Mock private Pluggable.PluggableListener mInvalidateListener; @Mock private HeadsUpManager mHeadsUpManager; - @Mock private NotifPanelEvents mNotifPanelEvents; + @Mock private ShadeStateEvents mShadeStateEvents; @Mock private VisualStabilityProvider mVisualStabilityProvider; @Captor private ArgumentCaptor mWakefulnessObserverCaptor; @Captor private ArgumentCaptor mSBStateListenerCaptor; - @Captor private ArgumentCaptor mNotifPanelEventsCallbackCaptor; + @Captor private ArgumentCaptor mNotifPanelEventsCallbackCaptor; @Captor private ArgumentCaptor mNotifStabilityManagerCaptor; private FakeSystemClock mFakeSystemClock = new FakeSystemClock(); @@ -84,7 +85,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase { private WakefulnessLifecycle.Observer mWakefulnessObserver; private StatusBarStateController.StateListener mStatusBarStateListener; - private NotifPanelEvents.Listener mNotifPanelEventsCallback; + private ShadeStateEvents.ShadeStateEventsListener mNotifPanelEventsCallback; private NotifStabilityManager mNotifStabilityManager; private NotificationEntry mEntry; private GroupEntry mGroupEntry; @@ -97,7 +98,7 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase { mFakeExecutor, mDumpManager, mHeadsUpManager, - mNotifPanelEvents, + mShadeStateEvents, mStatusBarStateController, mVisualStabilityProvider, mWakefulnessLifecycle); @@ -111,7 +112,8 @@ public class VisualStabilityCoordinatorTest extends SysuiTestCase { verify(mStatusBarStateController).addCallback(mSBStateListenerCaptor.capture()); mStatusBarStateListener = mSBStateListenerCaptor.getValue(); - verify(mNotifPanelEvents).registerListener(mNotifPanelEventsCallbackCaptor.capture()); + verify(mShadeStateEvents).addShadeStateEventsListener( + mNotifPanelEventsCallbackCaptor.capture()); mNotifPanelEventsCallback = mNotifPanelEventsCallbackCaptor.getValue(); verify(mNotifPipeline).setVisualStabilityManager(mNotifStabilityManagerCaptor.capture()); -- cgit v1.2.3-59-g8ed1b