Merge "Inject NPVC into ShadeControllerImpl" into udc-qpr-dev

This commit is contained in:
Treehugger Robot
2023-07-12 18:08:32 +00:00
committed by Android (Google) Code Review
11 changed files with 87 additions and 38 deletions

View File

@@ -18,6 +18,7 @@ package com.android.systemui.dagger;
import com.android.systemui.globalactions.ShutdownUiModule; import com.android.systemui.globalactions.ShutdownUiModule;
import com.android.systemui.keyguard.CustomizationProvider; import com.android.systemui.keyguard.CustomizationProvider;
import com.android.systemui.shade.ShadeModule;
import com.android.systemui.statusbar.NotificationInsetsModule; import com.android.systemui.statusbar.NotificationInsetsModule;
import com.android.systemui.statusbar.QsFrameTranslateModule; import com.android.systemui.statusbar.QsFrameTranslateModule;
@@ -32,6 +33,7 @@ import dagger.Subcomponent;
DependencyProvider.class, DependencyProvider.class,
NotificationInsetsModule.class, NotificationInsetsModule.class,
QsFrameTranslateModule.class, QsFrameTranslateModule.class,
ShadeModule.class,
ShutdownUiModule.class, ShutdownUiModule.class,
SystemUIBinder.class, SystemUIBinder.class,
SystemUIModule.class, SystemUIModule.class,

View File

@@ -82,7 +82,6 @@ import com.android.systemui.screenshot.dagger.ScreenshotModule;
import com.android.systemui.security.data.repository.SecurityRepositoryModule; import com.android.systemui.security.data.repository.SecurityRepositoryModule;
import com.android.systemui.settings.DisplayTracker; import com.android.systemui.settings.DisplayTracker;
import com.android.systemui.shade.ShadeController; import com.android.systemui.shade.ShadeController;
import com.android.systemui.shade.ShadeModule;
import com.android.systemui.shade.transition.LargeScreenShadeInterpolator; import com.android.systemui.shade.transition.LargeScreenShadeInterpolator;
import com.android.systemui.shade.transition.LargeScreenShadeInterpolatorImpl; import com.android.systemui.shade.transition.LargeScreenShadeInterpolatorImpl;
import com.android.systemui.shared.condition.Monitor; import com.android.systemui.shared.condition.Monitor;
@@ -199,7 +198,6 @@ import javax.inject.Named;
SecurityRepositoryModule.class, SecurityRepositoryModule.class,
ScreenRecordModule.class, ScreenRecordModule.class,
SettingsUtilModule.class, SettingsUtilModule.class,
ShadeModule.class,
SmartRepliesInflationModule.class, SmartRepliesInflationModule.class,
SmartspaceModule.class, SmartspaceModule.class,
StatusBarPipelineModule.class, StatusBarPipelineModule.class,

View File

@@ -18,6 +18,7 @@ package com.android.systemui.shade;
import android.view.MotionEvent; import android.view.MotionEvent;
import com.android.systemui.CoreStartable;
import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationPresenter; import com.android.systemui.statusbar.NotificationPresenter;
import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.StatusBarState;
@@ -31,7 +32,7 @@ import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
* these are coordinated with {@link StatusBarKeyguardViewManager} via * these are coordinated with {@link StatusBarKeyguardViewManager} via
* {@link com.android.systemui.keyguard.KeyguardViewMediator} and others. * {@link com.android.systemui.keyguard.KeyguardViewMediator} and others.
*/ */
public interface ShadeController { public interface ShadeController extends CoreStartable {
/** Make our window larger and the shade expanded */ /** Make our window larger and the shade expanded */
void instantExpandShade(); void instantExpandShade();
@@ -164,17 +165,14 @@ public interface ShadeController {
void onLaunchAnimationEnd(boolean launchIsFullScreen); void onLaunchAnimationEnd(boolean launchIsFullScreen);
/** Sets the listener for when the visibility of the shade changes. */ /** Sets the listener for when the visibility of the shade changes. */
default void setVisibilityListener(ShadeVisibilityListener listener) {}; default void setVisibilityListener(ShadeVisibilityListener listener) {}
/** */ /** */
default void setNotificationPresenter(NotificationPresenter presenter) {}; default void setNotificationPresenter(NotificationPresenter presenter) {}
/** */ /** */
default void setNotificationShadeWindowViewController( default void setNotificationShadeWindowViewController(
NotificationShadeWindowViewController notificationShadeWindowViewController) {}; NotificationShadeWindowViewController notificationShadeWindowViewController) {}
/** */
default void setShadeViewController(ShadeViewController shadeViewController) {};
/** Listens for shade visibility changes. */ /** Listens for shade visibility changes. */
interface ShadeVisibilityListener { interface ShadeVisibilityListener {

View File

@@ -1,3 +1,19 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.shade package com.android.systemui.shade
import android.view.MotionEvent import android.view.MotionEvent
@@ -7,6 +23,7 @@ import javax.inject.Inject
/** Empty implementation of ShadeController for variants of Android without shades. */ /** Empty implementation of ShadeController for variants of Android without shades. */
@SysUISingleton @SysUISingleton
open class ShadeControllerEmptyImpl @Inject constructor() : ShadeController { open class ShadeControllerEmptyImpl @Inject constructor() : ShadeController {
override fun start() {}
override fun instantExpandShade() {} override fun instantExpandShade() {}
override fun instantCollapseShade() {} override fun instantCollapseShade() {}
override fun animateCollapseShade( override fun animateCollapseShade(

View File

@@ -63,6 +63,7 @@ public final class ShadeControllerImpl implements ShadeController {
private final StatusBarWindowController mStatusBarWindowController; private final StatusBarWindowController mStatusBarWindowController;
private final DeviceProvisionedController mDeviceProvisionedController; private final DeviceProvisionedController mDeviceProvisionedController;
private final Lazy<ShadeViewController> mShadeViewControllerLazy;
private final Lazy<AssistManager> mAssistManagerLazy; private final Lazy<AssistManager> mAssistManagerLazy;
private final Lazy<NotificationGutsManager> mGutsManager; private final Lazy<NotificationGutsManager> mGutsManager;
@@ -70,8 +71,6 @@ public final class ShadeControllerImpl implements ShadeController {
private boolean mExpandedVisible; private boolean mExpandedVisible;
// TODO(b/237661616): Rename this variable to mShadeViewController.
private ShadeViewController mNotificationPanelViewController;
private NotificationPresenter mPresenter; private NotificationPresenter mPresenter;
private NotificationShadeWindowViewController mNotificationShadeWindowViewController; private NotificationShadeWindowViewController mNotificationShadeWindowViewController;
private ShadeVisibilityListener mShadeVisibilityListener; private ShadeVisibilityListener mShadeVisibilityListener;
@@ -87,11 +86,13 @@ public final class ShadeControllerImpl implements ShadeController {
DeviceProvisionedController deviceProvisionedController, DeviceProvisionedController deviceProvisionedController,
NotificationShadeWindowController notificationShadeWindowController, NotificationShadeWindowController notificationShadeWindowController,
WindowManager windowManager, WindowManager windowManager,
Lazy<ShadeViewController> shadeViewControllerLazy,
Lazy<AssistManager> assistManagerLazy, Lazy<AssistManager> assistManagerLazy,
Lazy<NotificationGutsManager> gutsManager Lazy<NotificationGutsManager> gutsManager
) { ) {
mCommandQueue = commandQueue; mCommandQueue = commandQueue;
mMainExecutor = mainExecutor; mMainExecutor = mainExecutor;
mShadeViewControllerLazy = shadeViewControllerLazy;
mStatusBarStateController = statusBarStateController; mStatusBarStateController = statusBarStateController;
mStatusBarWindowController = statusBarWindowController; mStatusBarWindowController = statusBarWindowController;
mDeviceProvisionedController = deviceProvisionedController; mDeviceProvisionedController = deviceProvisionedController;
@@ -107,7 +108,7 @@ public final class ShadeControllerImpl implements ShadeController {
public void instantExpandShade() { public void instantExpandShade() {
// Make our window larger and the panel expanded. // Make our window larger and the panel expanded.
makeExpandedVisible(true /* force */); makeExpandedVisible(true /* force */);
mNotificationPanelViewController.expand(false /* animate */); getShadeViewController().expand(false /* animate */);
mCommandQueue.recomputeDisableFlags(mDisplayId, false /* animate */); mCommandQueue.recomputeDisableFlags(mDisplayId, false /* animate */);
} }
@@ -123,13 +124,13 @@ public final class ShadeControllerImpl implements ShadeController {
"animateCollapse(): mExpandedVisible=" + mExpandedVisible + "flags=" + flags); "animateCollapse(): mExpandedVisible=" + mExpandedVisible + "flags=" + flags);
} }
if (getNotificationShadeWindowView() != null if (getNotificationShadeWindowView() != null
&& mNotificationPanelViewController.canBeCollapsed() && getShadeViewController().canBeCollapsed()
&& (flags & CommandQueue.FLAG_EXCLUDE_NOTIFICATION_PANEL) == 0) { && (flags & CommandQueue.FLAG_EXCLUDE_NOTIFICATION_PANEL) == 0) {
// release focus immediately to kick off focus change transition // release focus immediately to kick off focus change transition
mNotificationShadeWindowController.setNotificationShadeFocusable(false); mNotificationShadeWindowController.setNotificationShadeFocusable(false);
mNotificationShadeWindowViewController.cancelExpandHelper(); mNotificationShadeWindowViewController.cancelExpandHelper();
mNotificationPanelViewController.collapse(true, delayed, speedUpFactor); getShadeViewController().collapse(true, delayed, speedUpFactor);
} }
} }
@@ -138,7 +139,7 @@ public final class ShadeControllerImpl implements ShadeController {
if (!mCommandQueue.panelsEnabled()) { if (!mCommandQueue.panelsEnabled()) {
return; return;
} }
mNotificationPanelViewController.expandToNotifications(); getShadeViewController().expandToNotifications();
} }
@Override @Override
@@ -149,12 +150,12 @@ public final class ShadeControllerImpl implements ShadeController {
// Settings are not available in setup // Settings are not available in setup
if (!mDeviceProvisionedController.isCurrentUserSetup()) return; if (!mDeviceProvisionedController.isCurrentUserSetup()) return;
mNotificationPanelViewController.expandToQs(); getShadeViewController().expandToQs();
} }
@Override @Override
public boolean closeShadeIfOpen() { public boolean closeShadeIfOpen() {
if (!mNotificationPanelViewController.isFullyCollapsed()) { if (!getShadeViewController().isFullyCollapsed()) {
mCommandQueue.animateCollapsePanels( mCommandQueue.animateCollapsePanels(
CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */); CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */);
notifyVisibilityChanged(false); notifyVisibilityChanged(false);
@@ -170,12 +171,12 @@ public final class ShadeControllerImpl implements ShadeController {
@Override @Override
public boolean isShadeFullyOpen() { public boolean isShadeFullyOpen() {
return mNotificationPanelViewController.isShadeFullyExpanded(); return getShadeViewController().isShadeFullyExpanded();
} }
@Override @Override
public boolean isExpandingOrCollapsing() { public boolean isExpandingOrCollapsing() {
return mNotificationPanelViewController.isExpandingOrCollapsing(); return getShadeViewController().isExpandingOrCollapsing();
} }
@Override @Override
public void postAnimateCollapseShade() { public void postAnimateCollapseShade() {
@@ -194,13 +195,13 @@ public final class ShadeControllerImpl implements ShadeController {
@Override @Override
public void postOnShadeExpanded(Runnable executable) { public void postOnShadeExpanded(Runnable executable) {
mNotificationPanelViewController.addOnGlobalLayoutListener( getShadeViewController().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() { new ViewTreeObserver.OnGlobalLayoutListener() {
@Override @Override
public void onGlobalLayout() { public void onGlobalLayout() {
if (getNotificationShadeWindowView().isVisibleToUser()) { if (getNotificationShadeWindowView().isVisibleToUser()) {
mNotificationPanelViewController.removeOnGlobalLayoutListener(this); getShadeViewController().removeOnGlobalLayoutListener(this);
mNotificationPanelViewController.postToView(executable); getShadeViewController().postToView(executable);
} }
} }
}); });
@@ -224,7 +225,7 @@ public final class ShadeControllerImpl implements ShadeController {
@Override @Override
public boolean collapseShade() { public boolean collapseShade() {
if (!mNotificationPanelViewController.isFullyCollapsed()) { if (!getShadeViewController().isFullyCollapsed()) {
// close the shade if it was open // close the shade if it was open
animateCollapseShadeForcedDelayed(); animateCollapseShadeForcedDelayed();
notifyVisibilityChanged(false); notifyVisibilityChanged(false);
@@ -252,10 +253,10 @@ public final class ShadeControllerImpl implements ShadeController {
@Override @Override
public void cancelExpansionAndCollapseShade() { public void cancelExpansionAndCollapseShade() {
if (mNotificationPanelViewController.isTracking()) { if (getShadeViewController().isTracking()) {
mNotificationShadeWindowViewController.cancelCurrentTouch(); mNotificationShadeWindowViewController.cancelCurrentTouch();
} }
if (mNotificationPanelViewController.isPanelExpanded() if (getShadeViewController().isPanelExpanded()
&& mStatusBarStateController.getState() == StatusBarState.SHADE) { && mStatusBarStateController.getState() == StatusBarState.SHADE) {
animateCollapseShade(); animateCollapseShade();
} }
@@ -311,7 +312,7 @@ public final class ShadeControllerImpl implements ShadeController {
@Override @Override
public void instantCollapseShade() { public void instantCollapseShade() {
mNotificationPanelViewController.instantCollapse(); getShadeViewController().instantCollapse();
runPostCollapseRunnables(); runPostCollapseRunnables();
} }
@@ -342,7 +343,7 @@ public final class ShadeControllerImpl implements ShadeController {
} }
// Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868) // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868)
mNotificationPanelViewController.collapse(false, false, 1.0f); getShadeViewController().collapse(false, false, 1.0f);
mExpandedVisible = false; mExpandedVisible = false;
notifyVisibilityChanged(false); notifyVisibilityChanged(false);
@@ -364,7 +365,7 @@ public final class ShadeControllerImpl implements ShadeController {
notifyExpandedVisibleChanged(false); notifyExpandedVisibleChanged(false);
mCommandQueue.recomputeDisableFlags( mCommandQueue.recomputeDisableFlags(
mDisplayId, mDisplayId,
mNotificationPanelViewController.shouldHideStatusBarIconsWhenExpanded()); getShadeViewController().shouldHideStatusBarIconsWhenExpanded());
// Trimming will happen later if Keyguard is showing - doing it here might cause a jank in // Trimming will happen later if Keyguard is showing - doing it here might cause a jank in
// the bouncer appear animation. // the bouncer appear animation.
@@ -406,11 +407,14 @@ public final class ShadeControllerImpl implements ShadeController {
return mNotificationShadeWindowViewController.getView(); return mNotificationShadeWindowViewController.getView();
} }
private ShadeViewController getShadeViewController() {
return mShadeViewControllerLazy.get();
}
@Override @Override
public void setShadeViewController(ShadeViewController shadeViewController) { public void start() {
mNotificationPanelViewController = shadeViewController; getShadeViewController().setTrackingStartedListener(this::runPostCollapseRunnables);
mNotificationPanelViewController.setTrackingStartedListener(this::runPostCollapseRunnables); getShadeViewController().setOpenCloseListener(
mNotificationPanelViewController.setOpenCloseListener(
new OpenCloseListener() { new OpenCloseListener() {
@Override @Override
public void onClosingFinished() { public void onClosingFinished() {

View File

@@ -65,7 +65,7 @@ import javax.inject.Named
import javax.inject.Provider import javax.inject.Provider
/** Module for classes related to the notification shade. */ /** Module for classes related to the notification shade. */
@Module @Module(includes = [StartShadeModule::class])
abstract class ShadeModule { abstract class ShadeModule {
@Binds @Binds

View File

@@ -0,0 +1,31 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.shade
import com.android.systemui.CoreStartable
import dagger.Binds
import dagger.Module
import dagger.multibindings.ClassKey
import dagger.multibindings.IntoMap
@Module
internal abstract class StartShadeModule {
@Binds
@IntoMap
@ClassKey(ShadeController::class)
abstract fun bind(shadeController: ShadeController): CoreStartable
}

View File

@@ -1613,7 +1613,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
// (Right now, there's a circular dependency.) // (Right now, there's a circular dependency.)
mNotificationShadeWindowController.setWindowRootView(windowRootView); mNotificationShadeWindowController.setWindowRootView(windowRootView);
mNotificationShadeWindowViewController.setupExpandedStatusBar(); mNotificationShadeWindowViewController.setupExpandedStatusBar();
mShadeController.setShadeViewController(mShadeSurface);
mShadeController.setNotificationShadeWindowViewController( mShadeController.setNotificationShadeWindowViewController(
mNotificationShadeWindowViewController); mNotificationShadeWindowViewController);
mBackActionInteractor.setup(mQsController, mShadeSurface); mBackActionInteractor.setup(mQsController, mShadeSurface);

View File

@@ -45,7 +45,7 @@ import com.android.systemui.screenshot.ReferenceScreenshotModule;
import com.android.systemui.settings.dagger.MultiUserUtilsModule; import com.android.systemui.settings.dagger.MultiUserUtilsModule;
import com.android.systemui.shade.NotificationShadeWindowControllerImpl; import com.android.systemui.shade.NotificationShadeWindowControllerImpl;
import com.android.systemui.shade.ShadeController; import com.android.systemui.shade.ShadeController;
import com.android.systemui.shade.ShadeControllerImpl; import com.android.systemui.shade.ShadeControllerEmptyImpl;
import com.android.systemui.shade.ShadeExpansionStateManager; import com.android.systemui.shade.ShadeExpansionStateManager;
import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.NotificationListener; import com.android.systemui.statusbar.NotificationListener;
@@ -138,7 +138,7 @@ public abstract class TvSystemUIModule {
abstract DockManager bindDockManager(DockManagerImpl dockManager); abstract DockManager bindDockManager(DockManagerImpl dockManager);
@Binds @Binds
abstract ShadeController provideShadeController(ShadeControllerImpl shadeController); abstract ShadeController provideShadeController(ShadeControllerEmptyImpl shadeController);
@SysUISingleton @SysUISingleton
@Provides @Provides

View File

@@ -78,11 +78,11 @@ class ShadeControllerImplTest : SysuiTestCase() {
deviceProvisionedController, deviceProvisionedController,
notificationShadeWindowController, notificationShadeWindowController,
windowManager, windowManager,
Lazy { shadeViewController },
Lazy { assistManager }, Lazy { assistManager },
Lazy { gutsManager }, Lazy { gutsManager },
) )
shadeController.setNotificationShadeWindowViewController(nswvc) shadeController.setNotificationShadeWindowViewController(nswvc)
shadeController.setShadeViewController(shadeViewController)
} }
@Test @Test

View File

@@ -447,10 +447,10 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
mDeviceProvisionedController, mDeviceProvisionedController,
mNotificationShadeWindowController, mNotificationShadeWindowController,
mContext.getSystemService(WindowManager.class), mContext.getSystemService(WindowManager.class),
() -> mNotificationPanelViewController,
() -> mAssistManager, () -> mAssistManager,
() -> mNotificationGutsManager () -> mNotificationGutsManager
)); ));
mShadeController.setShadeViewController(mNotificationPanelViewController);
mShadeController.setNotificationShadeWindowViewController( mShadeController.setNotificationShadeWindowViewController(
mNotificationShadeWindowViewController); mNotificationShadeWindowViewController);
mShadeController.setNotificationPresenter(mNotificationPresenter); mShadeController.setNotificationPresenter(mNotificationPresenter);