From dbe43d5246fd80b270e9db3640566010d31a3dfe Mon Sep 17 00:00:00 2001 From: Justin Weir Date: Thu, 6 Jul 2023 15:32:45 -0400 Subject: [PATCH] Add empty implementation of ShadeController Variants without shades want this, so there should be only one, and it should be in the shade package to make updates not require topics. Also adds some default methods to ShadeController to reduce the size of ShadeControllerEmptyImpl and deemphasize ShadeController methods that are too tied to implementation details of ShadeControllerImpl. Test: presubmits are sufficient Bug: 288867586 Change-Id: Ia7015378f85a8a68db049069b2d678b57c4390b1 Merged-In: Ia7015378f85a8a68db049069b2d678b57c4390b1 --- .../systemui/shade/ShadeController.java | 27 ++++++---- .../shade/ShadeControllerEmptyImpl.kt | 52 +++++++++++++++++++ .../systemui/shade/ShadeControllerImpl.java | 20 ------- 3 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/shade/ShadeControllerEmptyImpl.kt diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java index 317d88585958c..ebb98883c679f 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeController.java @@ -18,6 +18,7 @@ package com.android.systemui.shade; import android.view.MotionEvent; +import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.phone.CentralSurfaces; @@ -39,16 +40,24 @@ public interface ShadeController { void instantCollapseShade(); /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ - void animateCollapseShade(); + default void animateCollapseShade() { + animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE); + } /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ - void animateCollapseShade(int flags); + default void animateCollapseShade(int flags) { + animateCollapseShade(flags, false, false, 1.0f); + } /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ - void animateCollapseShadeForced(); + default void animateCollapseShadeForced() { + animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE, true, false, 1.0f); + } /** See {@link #animateCollapseShade(int, boolean, boolean, float)}. */ - void animateCollapseShadeForcedDelayed(); + default void animateCollapseShadeForcedDelayed() { + animateCollapseShade(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, true, 1.0f); + } /** * Collapse the shade animated, showing the bouncer when on {@link StatusBarState#KEYGUARD} or @@ -155,17 +164,17 @@ public interface ShadeController { void onLaunchAnimationEnd(boolean launchIsFullScreen); /** Sets the listener for when the visibility of the shade changes. */ - void setVisibilityListener(ShadeVisibilityListener listener); + default void setVisibilityListener(ShadeVisibilityListener listener) {}; /** */ - void setNotificationPresenter(NotificationPresenter presenter); + default void setNotificationPresenter(NotificationPresenter presenter) {}; /** */ - void setNotificationShadeWindowViewController( - NotificationShadeWindowViewController notificationShadeWindowViewController); + default void setNotificationShadeWindowViewController( + NotificationShadeWindowViewController notificationShadeWindowViewController) {}; /** */ - void setShadeViewController(ShadeViewController shadeViewController); + default void setShadeViewController(ShadeViewController shadeViewController) {}; /** Listens for shade visibility changes. */ interface ShadeVisibilityListener { diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerEmptyImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerEmptyImpl.kt new file mode 100644 index 0000000000000..4d0500786ca3c --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerEmptyImpl.kt @@ -0,0 +1,52 @@ +package com.android.systemui.shade + +import android.view.MotionEvent +import com.android.systemui.dagger.SysUISingleton +import javax.inject.Inject + +/** Empty implementation of ShadeController for variants of Android without shades. */ +@SysUISingleton +open class ShadeControllerEmptyImpl @Inject constructor() : ShadeController { + override fun instantExpandShade() {} + override fun instantCollapseShade() {} + override fun animateCollapseShade( + flags: Int, + force: Boolean, + delayed: Boolean, + speedUpFactor: Float + ) {} + override fun animateExpandShade() {} + override fun animateExpandQs() {} + override fun postAnimateCollapseShade() {} + override fun postAnimateForceCollapseShade() {} + override fun postAnimateExpandQs() {} + override fun cancelExpansionAndCollapseShade() {} + override fun closeShadeIfOpen(): Boolean { + return false + } + override fun isKeyguard(): Boolean { + return false + } + override fun isShadeFullyOpen(): Boolean { + return false + } + override fun isExpandingOrCollapsing(): Boolean { + return false + } + override fun postOnShadeExpanded(action: Runnable?) {} + override fun addPostCollapseAction(action: Runnable?) {} + override fun runPostCollapseRunnables() {} + override fun collapseShade(): Boolean { + return false + } + override fun collapseShade(animate: Boolean) {} + override fun collapseOnMainThread() {} + override fun makeExpandedInvisible() {} + override fun makeExpandedVisible(force: Boolean) {} + override fun isExpandedVisible(): Boolean { + return false + } + override fun onStatusBarTouch(event: MotionEvent?) {} + override fun onLaunchAnimationCancelled(isLaunchForActivity: Boolean) {} + override fun onLaunchAnimationEnd(launchIsFullScreen: Boolean) {} +} diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java index b92afac047fab..af74a8d7dca17 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeControllerImpl.java @@ -111,26 +111,6 @@ public final class ShadeControllerImpl implements ShadeController { mCommandQueue.recomputeDisableFlags(mDisplayId, false /* animate */); } - @Override - public void animateCollapseShade() { - animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE); - } - - @Override - public void animateCollapseShade(int flags) { - animateCollapseShade(flags, false, false, 1.0f); - } - - @Override - public void animateCollapseShadeForced() { - animateCollapseShade(CommandQueue.FLAG_EXCLUDE_NONE, true, false, 1.0f); - } - - @Override - public void animateCollapseShadeForcedDelayed() { - animateCollapseShade(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true, true, 1.0f); - } - @Override public void animateCollapseShade(int flags, boolean force, boolean delayed, float speedUpFactor) {