diff options
| author | 2022-11-09 23:10:58 +0000 | |
|---|---|---|
| committer | 2022-11-09 23:10:58 +0000 | |
| commit | 8726760ff9a861cae1fcdf928f2adc37f86b827a (patch) | |
| tree | f83f6aff9481c897bfa61c4985e2b617ea9b98a6 | |
| parent | 5b1020a99daba81370d7cbf8185edd5a86bbd8b2 (diff) | |
| parent | 3c3f89e0247fe0ae0727b1a330df5261a6c138b6 (diff) | |
Merge "Revert "Extract camera launch code from NPVC into CentralSurfaces"" into tm-qpr-dev
7 files changed, 53 insertions, 117 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/shade/CameraLauncher.java b/packages/SystemUI/src/com/android/systemui/shade/CameraLauncher.java deleted file mode 100644 index fc61e90ab8f7..000000000000 --- a/packages/SystemUI/src/com/android/systemui/shade/CameraLauncher.java +++ /dev/null @@ -1,73 +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.camera.CameraGestureHelper; -import com.android.systemui.dagger.SysUISingleton; -import com.android.systemui.statusbar.phone.KeyguardBypassController; - -import javax.inject.Inject; - -/** Handles launching camera from Shade. */ -@SysUISingleton -public class CameraLauncher { - private final CameraGestureHelper mCameraGestureHelper; - private final KeyguardBypassController mKeyguardBypassController; - - private boolean mLaunchingAffordance; - - @Inject - public CameraLauncher( - CameraGestureHelper cameraGestureHelper, - KeyguardBypassController keyguardBypassController - ) { - mCameraGestureHelper = cameraGestureHelper; - mKeyguardBypassController = keyguardBypassController; - } - - /** Launches the camera. */ - public void launchCamera(int source, boolean isShadeFullyCollapsed) { - if (!isShadeFullyCollapsed) { - setLaunchingAffordance(true); - } - - mCameraGestureHelper.launchCamera(source); - } - - /** - * Set whether we are currently launching an affordance. This is currently only set when - * launched via a camera gesture. - */ - public void setLaunchingAffordance(boolean launchingAffordance) { - mLaunchingAffordance = launchingAffordance; - mKeyguardBypassController.setLaunchingAffordance(launchingAffordance); - } - - /** - * Return true when a bottom affordance is launching an occluded activity with a splash screen. - */ - public boolean isLaunchingAffordance() { - return mLaunchingAffordance; - } - - /** - * Whether the camera application can be launched for the camera launch gesture. - */ - public boolean canCameraGestureBeLaunched(int barState) { - return mCameraGestureHelper.canCameraGestureBeLaunched(barState); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index ce30aaa754a7..58833d1e877e 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -124,6 +124,7 @@ import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.animation.Interpolators; import com.android.systemui.animation.LaunchAnimator; 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.qualifiers.DisplayId; @@ -463,6 +464,7 @@ public final class NotificationPanelViewController implements Dumpable { private boolean mCollapsedOnDown; private boolean mClosingWithAlphaFadeOut; private boolean mHeadsUpAnimatingAway; + private boolean mLaunchingAffordance; private final FalsingManager mFalsingManager; private final FalsingCollector mFalsingCollector; @@ -613,6 +615,7 @@ public final class NotificationPanelViewController implements Dumpable { private final NotificationListContainer mNotificationListContainer; private final NotificationStackSizeCalculator mNotificationStackSizeCalculator; private final NPVCDownEventState.Buffer mLastDownEvents; + private final CameraGestureHelper mCameraGestureHelper; private final KeyguardBottomAreaViewModel mKeyguardBottomAreaViewModel; private final KeyguardBottomAreaInteractor mKeyguardBottomAreaInteractor; private float mMinExpandHeight; @@ -740,6 +743,7 @@ public final class NotificationPanelViewController implements Dumpable { UnlockedScreenOffAnimationController unlockedScreenOffAnimationController, ShadeTransitionController shadeTransitionController, SystemClock systemClock, + CameraGestureHelper cameraGestureHelper, KeyguardBottomAreaViewModel keyguardBottomAreaViewModel, KeyguardBottomAreaInteractor keyguardBottomAreaInteractor, DumpManager dumpManager) { @@ -920,6 +924,7 @@ public final class NotificationPanelViewController implements Dumpable { unlockAnimationStarted(playingCannedAnimation, isWakeAndUnlock, startDelay); } }); + mCameraGestureHelper = cameraGestureHelper; mKeyguardBottomAreaInteractor = keyguardBottomAreaInteractor; dumpManager.registerDumpable(this); } @@ -3947,10 +3952,6 @@ public final class NotificationPanelViewController implements Dumpable { } } - public int getBarState() { - return mBarState; - } - private boolean isOnKeyguard() { return mBarState == KEYGUARD; } @@ -3996,6 +3997,35 @@ public final class NotificationPanelViewController implements Dumpable { && mBarState == StatusBarState.SHADE; } + /** Launches the camera. */ + public void launchCamera(int source) { + if (!isFullyCollapsed()) { + setLaunchingAffordance(true); + } + + mCameraGestureHelper.launchCamera(source); + } + + public void onAffordanceLaunchEnded() { + setLaunchingAffordance(false); + } + + /** Set whether we are currently launching an affordance (i.e. camera gesture). */ + private void setLaunchingAffordance(boolean launchingAffordance) { + mLaunchingAffordance = launchingAffordance; + mKeyguardBypassController.setLaunchingAffordance(launchingAffordance); + } + + /** Returns whether a bottom affordance is launching an occluded activity with splash screen. */ + public boolean isLaunchingAffordanceWithPreview() { + return mLaunchingAffordance; + } + + /** Whether the camera application can be launched by the camera launch gesture. */ + public boolean canCameraGestureBeLaunched() { + return mCameraGestureHelper.canCameraGestureBeLaunched(mBarState); + } + public boolean hideStatusBarIconsWhenExpanded() { if (mIsLaunchAnimationRunning) { return mHideIconsDuringLaunchAnimation; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java index 9e5a66f1e306..1e95dad6b115 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacks.java @@ -55,7 +55,6 @@ import com.android.systemui.dagger.qualifiers.DisplayId; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.qs.QSPanelController; -import com.android.systemui.shade.CameraLauncher; import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.shade.ShadeController; import com.android.systemui.statusbar.CommandQueue; @@ -72,8 +71,6 @@ import java.util.Optional; import javax.inject.Inject; -import dagger.Lazy; - /** */ @CentralSurfacesComponent.CentralSurfacesScope public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callbacks { @@ -102,7 +99,6 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba private final boolean mVibrateOnOpening; private final VibrationEffect mCameraLaunchGestureVibrationEffect; private final SystemBarAttributesListener mSystemBarAttributesListener; - private final Lazy<CameraLauncher> mCameraLauncherLazy; private static final VibrationAttributes HARDWARE_FEEDBACK_VIBRATION_ATTRIBUTES = VibrationAttributes.createForUsage(VibrationAttributes.USAGE_HARDWARE_FEEDBACK); @@ -132,8 +128,8 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba Optional<Vibrator> vibratorOptional, DisableFlagsLogger disableFlagsLogger, @DisplayId int displayId, - SystemBarAttributesListener systemBarAttributesListener, - Lazy<CameraLauncher> cameraLauncherLazy) { + SystemBarAttributesListener systemBarAttributesListener) { + mCentralSurfaces = centralSurfaces; mContext = context; mShadeController = shadeController; @@ -156,7 +152,6 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba mVibratorOptional = vibratorOptional; mDisableFlagsLogger = disableFlagsLogger; mDisplayId = displayId; - mCameraLauncherLazy = cameraLauncherLazy; mVibrateOnOpening = resources.getBoolean(R.bool.config_vibrateOnIconAnimation); mCameraLaunchGestureVibrationEffect = getCameraGestureVibrationEffect( @@ -351,8 +346,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba mCentralSurfaces.setLaunchCameraOnFinishedGoingToSleep(true); return; } - if (!mCameraLauncherLazy.get().canCameraGestureBeLaunched( - mNotificationPanelViewController.getBarState())) { + if (!mNotificationPanelViewController.canCameraGestureBeLaunched()) { if (CentralSurfaces.DEBUG_CAMERA_LIFT) { Slog.d(CentralSurfaces.TAG, "Can't launch camera right now"); } @@ -389,8 +383,7 @@ public class CentralSurfacesCommandQueueCallbacks implements CommandQueue.Callba if (mStatusBarKeyguardViewManager.isBouncerShowing()) { mStatusBarKeyguardViewManager.reset(true /* hide */); } - mCameraLauncherLazy.get().launchCamera(source, - mNotificationPanelViewController.isFullyCollapsed()); + mNotificationPanelViewController.launchCamera(source); mCentralSurfaces.updateScrimController(); } else { // We need to defer the camera launch until the screen comes on, since otherwise diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 121d312127df..1f9480cd1898 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -177,7 +177,6 @@ import com.android.systemui.recents.ScreenPinningRequest; import com.android.systemui.ripple.RippleShader.RippleShape; import com.android.systemui.scrim.ScrimView; import com.android.systemui.settings.brightness.BrightnessSliderController; -import com.android.systemui.shade.CameraLauncher; import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.shade.NotificationShadeWindowView; import com.android.systemui.shade.NotificationShadeWindowViewController; @@ -486,7 +485,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private final PluginManager mPluginManager; private final ShadeController mShadeController; private final InitController mInitController; - private final Lazy<CameraLauncher> mCameraLauncherLazy; private final PluginDependencyProvider mPluginDependencyProvider; private final KeyguardDismissUtil mKeyguardDismissUtil; @@ -619,7 +617,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private Runnable mLaunchTransitionEndRunnable; private Runnable mLaunchTransitionCancelRunnable; - private boolean mLaunchingAffordance; private boolean mLaunchCameraWhenFinishedWaking; private boolean mLaunchCameraOnFinishedGoingToSleep; private boolean mLaunchEmergencyActionWhenFinishedWaking; @@ -764,8 +761,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { InteractionJankMonitor jankMonitor, DeviceStateManager deviceStateManager, WiredChargingRippleController wiredChargingRippleController, - IDreamManager dreamManager, - Lazy<CameraLauncher> cameraLauncherLazy) { + IDreamManager dreamManager) { mContext = context; mNotificationsController = notificationsController; mFragmentService = fragmentService; @@ -842,7 +838,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mMessageRouter = messageRouter; mWallpaperManager = wallpaperManager; mJankMonitor = jankMonitor; - mCameraLauncherLazy = cameraLauncherLazy; mLockscreenShadeTransitionController = lockscreenShadeTransitionController; mStartingSurfaceOptional = startingSurfaceOptional; @@ -2976,7 +2971,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private void onLaunchTransitionFadingEnded() { mNotificationPanelViewController.resetAlpha(); - mCameraLauncherLazy.get().setLaunchingAffordance(false); + mNotificationPanelViewController.onAffordanceLaunchEnded(); releaseGestureWakeLock(); runLaunchTransitionEndRunnable(); mKeyguardStateController.setLaunchTransitionFadingAway(false); @@ -3046,7 +3041,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { private void onLaunchTransitionTimeout() { Log.w(TAG, "Launch transition: Timeout!"); - mCameraLauncherLazy.get().setLaunchingAffordance(false); + mNotificationPanelViewController.onAffordanceLaunchEnded(); releaseGestureWakeLock(); mNotificationPanelViewController.resetViews(false /* animate */); } @@ -3099,7 +3094,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { } mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); releaseGestureWakeLock(); - mCameraLauncherLazy.get().setLaunchingAffordance(false); + mNotificationPanelViewController.onAffordanceLaunchEnded(); mNotificationPanelViewController.resetAlpha(); mNotificationPanelViewController.resetTranslation(); mNotificationPanelViewController.resetViewGroupFade(); @@ -3257,7 +3252,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { @Override public void endAffordanceLaunch() { releaseGestureWakeLock(); - mCameraLauncherLazy.get().setLaunchingAffordance(false); + mNotificationPanelViewController.onAffordanceLaunchEnded(); } /** @@ -3529,7 +3524,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { final WakefulnessLifecycle.Observer mWakefulnessObserver = new WakefulnessLifecycle.Observer() { @Override public void onFinishedGoingToSleep() { - mCameraLauncherLazy.get().setLaunchingAffordance(false); + mNotificationPanelViewController.onAffordanceLaunchEnded(); releaseGestureWakeLock(); mLaunchCameraWhenFinishedWaking = false; mDeviceInteractive = false; @@ -3630,8 +3625,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { .updateSensitivenessForOccludedWakeup(); } if (mLaunchCameraWhenFinishedWaking) { - mCameraLauncherLazy.get().launchCamera(mLastCameraLaunchSource, - mNotificationPanelViewController.isFullyCollapsed()); + mNotificationPanelViewController.launchCamera(mLastCameraLaunchSource); mLaunchCameraWhenFinishedWaking = false; } if (mLaunchEmergencyActionWhenFinishedWaking) { @@ -3822,7 +3816,8 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mScrimController.setExpansionAffectsAlpha(!unlocking); - boolean launchingAffordanceWithPreview = mLaunchingAffordance; + boolean launchingAffordanceWithPreview = + mNotificationPanelViewController.isLaunchingAffordanceWithPreview(); mScrimController.setLaunchingAffordanceWithPreview(launchingAffordanceWithPreview); if (mStatusBarKeyguardViewManager.isShowingAlternateBouncer()) { 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 369e5d8fddb3..9c306ef25536 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -94,6 +94,7 @@ import com.android.systemui.DejankUtils; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.biometrics.AuthController; +import com.android.systemui.camera.CameraGestureHelper; import com.android.systemui.classifier.FalsingCollectorFake; import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.doze.DozeLog; @@ -491,6 +492,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase { mUnlockedScreenOffAnimationController, mShadeTransitionController, systemClock, + mock(CameraGestureHelper.class), mKeyguardBottomAreaViewModel, mKeyguardBottomAreaInteractor, mDumpManager); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java index bf31eb287579..57fb976c03ec 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesCommandQueueCallbacksTest.java @@ -41,7 +41,6 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.SysuiTestCase; import com.android.systemui.assist.AssistManager; import com.android.systemui.keyguard.WakefulnessLifecycle; -import com.android.systemui.shade.CameraLauncher; import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.shade.ShadeController; import com.android.systemui.statusbar.CommandQueue; @@ -61,8 +60,6 @@ import org.mockito.stubbing.Answer; import java.util.Optional; -import dagger.Lazy; - @SmallTest @RunWith(AndroidTestingRunner.class) public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase { @@ -87,7 +84,6 @@ public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase { @Mock private Vibrator mVibrator; @Mock private StatusBarHideIconsForBouncerManager mStatusBarHideIconsForBouncerManager; @Mock private SystemBarAttributesListener mSystemBarAttributesListener; - @Mock private Lazy<CameraLauncher> mCameraLauncherLazy; CentralSurfacesCommandQueueCallbacks mSbcqCallbacks; @@ -119,8 +115,7 @@ public class CentralSurfacesCommandQueueCallbacksTest extends SysuiTestCase { Optional.of(mVibrator), new DisableFlagsLogger(), DEFAULT_DISPLAY, - mSystemBarAttributesListener, - mCameraLauncherLazy); + mSystemBarAttributesListener); when(mDeviceProvisionedController.isCurrentUserSetup()).thenReturn(true); when(mRemoteInputQuickSettingsDisabler.adjustDisableFlags(anyInt())) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index 5818e578f97d..7ce3a67ce835 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -112,7 +112,6 @@ import com.android.systemui.plugins.PluginDependencyProvider; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.recents.ScreenPinningRequest; import com.android.systemui.settings.brightness.BrightnessSliderController; -import com.android.systemui.shade.CameraLauncher; import com.android.systemui.shade.NotificationPanelView; import com.android.systemui.shade.NotificationPanelViewController; import com.android.systemui.shade.NotificationShadeWindowView; @@ -288,8 +287,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase { @Mock private InteractionJankMonitor mJankMonitor; @Mock private DeviceStateManager mDeviceStateManager; @Mock private WiredChargingRippleController mWiredChargingRippleController; - @Mock private Lazy<CameraLauncher> mCameraLauncherLazy; - @Mock private CameraLauncher mCameraLauncher; /** * The process of registering/unregistering a predictive back callback requires a * ViewRootImpl, which is present IRL, but may be missing during a Mockito unit test. @@ -381,7 +378,6 @@ public class CentralSurfacesImplTest extends SysuiTestCase { when(mLockscreenWallpaperLazy.get()).thenReturn(mLockscreenWallpaper); when(mBiometricUnlockControllerLazy.get()).thenReturn(mBiometricUnlockController); - when(mCameraLauncherLazy.get()).thenReturn(mCameraLauncher); when(mStatusBarComponentFactory.create()).thenReturn(mCentralSurfacesComponent); when(mCentralSurfacesComponent.getNotificationShadeWindowViewController()).thenReturn( @@ -483,9 +479,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { mActivityLaunchAnimator, mJankMonitor, mDeviceStateManager, - mWiredChargingRippleController, - mDreamManager, - mCameraLauncherLazy) { + mWiredChargingRippleController, mDreamManager) { @Override protected ViewRootImpl getViewRootImpl() { return mViewRootImpl; @@ -897,7 +891,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { mCentralSurfaces.showKeyguardImpl(); // Starting a pulse should change the scrim controller to the pulsing state - when(mCameraLauncher.isLaunchingAffordance()).thenReturn(true); + when(mNotificationPanelViewController.isLaunchingAffordanceWithPreview()).thenReturn(true); mCentralSurfaces.updateScrimController(); verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); } @@ -933,7 +927,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { mCentralSurfaces.showKeyguardImpl(); // Starting a pulse should change the scrim controller to the pulsing state - when(mCameraLauncher.isLaunchingAffordance()).thenReturn(false); + when(mNotificationPanelViewController.isLaunchingAffordanceWithPreview()).thenReturn(false); mCentralSurfaces.updateScrimController(); verify(mScrimController).transitionTo(eq(ScrimState.KEYGUARD)); } |