From e2f2d9ab39a109ee688837be153418bb3c29f590 Mon Sep 17 00:00:00 2001 From: Caitlin Shkuratov Date: Fri, 7 Jul 2023 20:35:21 +0000 Subject: [PATCH 1/3] [CS] Move CS#wakeUpForFullScreenIntent to PowerInteractor. Bug: 277764509 Bug: 277762009 Test: manual: verified via logging that PowerInteractor#wakeUpForFullScreenIntent is called when an FSI notification comes in while dozing Test: atest PowerInteractorTest StatusBarNotificationActivityStarterTest Change-Id: I7641db4e63390a909431ccd4b200da33eedaf5c7 --- .../domain/interactor/PowerInteractor.kt | 19 +++++++ .../statusbar/phone/CentralSurfaces.java | 2 - .../statusbar/phone/CentralSurfacesImpl.java | 12 +--- .../StatusBarNotificationActivityStarter.java | 6 +- .../domain/interactor/PowerInteractorTest.kt | 57 +++++++++++++++++++ .../shade/PulsingGestureListenerTest.kt | 2 + ...LockscreenShadeTransitionControllerTest.kt | 4 +- .../NotificationShelfInteractorTest.kt | 1 + .../NotificationShelfViewModelTest.kt | 1 + ...tusBarNotificationActivityStarterTest.java | 24 +++++++- 10 files changed, 111 insertions(+), 17 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/power/domain/interactor/PowerInteractor.kt b/packages/SystemUI/src/com/android/systemui/power/domain/interactor/PowerInteractor.kt index c13476fbbe087..eb1ca66f6ca8b 100644 --- a/packages/SystemUI/src/com/android/systemui/power/domain/interactor/PowerInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/power/domain/interactor/PowerInteractor.kt @@ -20,6 +20,7 @@ package com.android.systemui.power.domain.interactor import android.os.PowerManager import com.android.systemui.classifier.FalsingCollector import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.keyguard.data.repository.KeyguardRepository import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.power.data.repository.PowerRepository import com.android.systemui.statusbar.phone.ScreenOffAnimationController @@ -32,6 +33,7 @@ class PowerInteractor @Inject constructor( private val repository: PowerRepository, + private val keyguardRepository: KeyguardRepository, private val falsingCollector: FalsingCollector, private val screenOffAnimationController: ScreenOffAnimationController, private val statusBarStateController: StatusBarStateController, @@ -54,4 +56,21 @@ constructor( falsingCollector.onScreenOnFromTouch() } } + + /** + * Wakes up the device if the device was dozing or going to sleep in order to display a + * full-screen intent. + */ + fun wakeUpForFullScreenIntent() { + if ( + keyguardRepository.wakefulness.value.isStartingToSleep() || + statusBarStateController.isDozing + ) { + repository.wakeUp(why = FSI_WAKE_WHY, wakeReason = PowerManager.WAKE_REASON_APPLICATION) + } + } + + companion object { + private const val FSI_WAKE_WHY = "full_screen_intent" + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index 478baf2f58d69..e0e597d4cdcd8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -362,8 +362,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner { @VisibleForTesting void setBarStateForTest(int state); - void wakeUpForFullScreenIntent(); - void showTransientUnchecked(); void clearTransient(); 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 8902a186c43ae..6959029c99640 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -1773,7 +1773,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { try { EventLog.writeEvent(EventLogTags.SYSUI_HEADS_UP_ESCALATION, sbn.getKey()); - wakeUpForFullScreenIntent(); + mPowerInteractor.wakeUpForFullScreenIntent(); ActivityOptions opts = ActivityOptions.makeBasic(); opts.setPendingIntentBackgroundActivityStartMode( ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED); @@ -1786,16 +1786,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { mHeadsUpManager.releaseAllImmediately(); } - @Override - public void wakeUpForFullScreenIntent() { - if (isGoingToSleep() || mDozing) { - mPowerManager.wakeUp( - SystemClock.uptimeMillis(), - PowerManager.WAKE_REASON_APPLICATION, - "com.android.systemui:full_screen_intent"); - } - } - /** * Called when another window is about to transfer it's input focus. */ diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java index b5d3f08e0f86c..f6a01ea4c94bb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java @@ -56,6 +56,7 @@ import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.assist.AssistManager; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.plugins.ActivityStarter; +import com.android.systemui.power.domain.interactor.PowerInteractor; import com.android.systemui.settings.UserTracker; import com.android.systemui.shade.ShadeController; import com.android.systemui.shade.ShadeViewController; @@ -126,6 +127,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte private final NotificationShadeWindowController mNotificationShadeWindowController; private final ActivityLaunchAnimator mActivityLaunchAnimator; private final NotificationLaunchAnimatorControllerProvider mNotificationAnimationProvider; + private final PowerInteractor mPowerInteractor; private final UserTracker mUserTracker; private final OnUserInteractionCallback mOnUserInteractionCallback; @@ -163,6 +165,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte ActivityLaunchAnimator activityLaunchAnimator, NotificationLaunchAnimatorControllerProvider notificationAnimationProvider, LaunchFullScreenIntentProvider launchFullScreenIntentProvider, + PowerInteractor powerInteractor, FeatureFlags featureFlags, UserTracker userTracker) { mContext = context; @@ -196,6 +199,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte mShadeViewController = shadeViewController; mActivityLaunchAnimator = activityLaunchAnimator; mNotificationAnimationProvider = notificationAnimationProvider; + mPowerInteractor = powerInteractor; mUserTracker = userTracker; launchFullScreenIntentProvider.registerListener(entry -> launchFullScreenIntent(entry)); @@ -592,7 +596,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte try { EventLog.writeEvent(EventLogTags.SYSUI_FULLSCREEN_NOTIFICATION, entry.getKey()); - mCentralSurfaces.wakeUpForFullScreenIntent(); + mPowerInteractor.wakeUpForFullScreenIntent(); ActivityOptions options = ActivityOptions.makeBasic(); options.setPendingIntentBackgroundActivityStartMode( diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt index 023ed061c642f..45bb9313264c5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/power/domain/interactor/PowerInteractorTest.kt @@ -21,6 +21,10 @@ import android.os.PowerManager import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.classifier.FalsingCollector +import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository +import com.android.systemui.keyguard.shared.model.WakeSleepReason +import com.android.systemui.keyguard.shared.model.WakefulnessModel +import com.android.systemui.keyguard.shared.model.WakefulnessState import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.power.data.repository.FakePowerRepository import com.android.systemui.statusbar.phone.ScreenOffAnimationController @@ -44,6 +48,7 @@ class PowerInteractorTest : SysuiTestCase() { private lateinit var underTest: PowerInteractor private lateinit var repository: FakePowerRepository + private val keyguardRepository = FakeKeyguardRepository() @Mock private lateinit var falsingCollector: FalsingCollector @Mock private lateinit var screenOffAnimationController: ScreenOffAnimationController @Mock private lateinit var statusBarStateController: StatusBarStateController @@ -59,6 +64,7 @@ class PowerInteractorTest : SysuiTestCase() { underTest = PowerInteractor( repository, + keyguardRepository, falsingCollector, screenOffAnimationController, statusBarStateController, @@ -125,6 +131,57 @@ class PowerInteractorTest : SysuiTestCase() { verify(falsingCollector).onScreenOnFromTouch() } + @Test + fun wakeUpForFullScreenIntent_notGoingToSleepAndNotDozing_notWoken() { + keyguardRepository.setWakefulnessModel( + WakefulnessModel( + state = WakefulnessState.AWAKE, + lastWakeReason = WakeSleepReason.OTHER, + lastSleepReason = WakeSleepReason.OTHER, + ) + ) + whenever(statusBarStateController.isDozing).thenReturn(false) + + underTest.wakeUpForFullScreenIntent() + + assertThat(repository.lastWakeWhy).isNull() + assertThat(repository.lastWakeReason).isNull() + } + + @Test + fun wakeUpForFullScreenIntent_startingToSleep_woken() { + keyguardRepository.setWakefulnessModel( + WakefulnessModel( + state = WakefulnessState.STARTING_TO_SLEEP, + lastWakeReason = WakeSleepReason.OTHER, + lastSleepReason = WakeSleepReason.OTHER, + ) + ) + whenever(statusBarStateController.isDozing).thenReturn(false) + + underTest.wakeUpForFullScreenIntent() + + assertThat(repository.lastWakeWhy).isNotNull() + assertThat(repository.lastWakeReason).isEqualTo(PowerManager.WAKE_REASON_APPLICATION) + } + + @Test + fun wakeUpForFullScreenIntent_dozing_woken() { + whenever(statusBarStateController.isDozing).thenReturn(true) + keyguardRepository.setWakefulnessModel( + WakefulnessModel( + state = WakefulnessState.AWAKE, + lastWakeReason = WakeSleepReason.OTHER, + lastSleepReason = WakeSleepReason.OTHER, + ) + ) + + underTest.wakeUpForFullScreenIntent() + + assertThat(repository.lastWakeWhy).isNotNull() + assertThat(repository.lastWakeReason).isEqualTo(PowerManager.WAKE_REASON_APPLICATION) + } + companion object { private val IMMEDIATE = Dispatchers.Main.immediate } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/PulsingGestureListenerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/PulsingGestureListenerTest.kt index a4fab1dbac575..77a22ac9b092d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/PulsingGestureListenerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/PulsingGestureListenerTest.kt @@ -28,6 +28,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.classifier.FalsingCollector import com.android.systemui.dock.DockManager import com.android.systemui.dump.DumpManager +import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository import com.android.systemui.plugins.FalsingManager import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.power.data.repository.FakePowerRepository @@ -89,6 +90,7 @@ class PulsingGestureListenerTest : SysuiTestCase() { dockManager, PowerInteractor( powerRepository, + FakeKeyguardRepository(), falsingCollector, screenOffAnimationController, statusBarStateController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt index ff2f1065049be..4a2518ae6f7d5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt @@ -101,16 +101,18 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { @Mock lateinit var activityStarter: ActivityStarter @Mock lateinit var transitionControllerCallback: LockscreenShadeTransitionController.Callback private val disableFlagsRepository = FakeDisableFlagsRepository() + private val keyguardRepository = FakeKeyguardRepository() private val shadeInteractor = ShadeInteractor( testScope.backgroundScope, disableFlagsRepository, - keyguardRepository = FakeKeyguardRepository(), + keyguardRepository, userSetupRepository = FakeUserSetupRepository(), deviceProvisionedController = mock(), userInteractor = mock(), ) private val powerInteractor = PowerInteractor( FakePowerRepository(), + keyguardRepository, FalsingCollectorFake(), screenOffAnimationController = mock(), statusBarStateController = mock(), diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractorTest.kt index a87dd2d3d6707..8881f42783fbc 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/shelf/domain/interactor/NotificationShelfInteractorTest.kt @@ -58,6 +58,7 @@ class NotificationShelfInteractorTest : SysuiTestCase() { private val powerInteractor = PowerInteractor( powerRepository, + keyguardRepository, FalsingCollectorFake(), screenOffAnimationController, statusBarStateController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/shelf/ui/viewmodel/NotificationShelfViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/shelf/ui/viewmodel/NotificationShelfViewModelTest.kt index 7ae150231b985..6221f3e89ad66 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/shelf/ui/viewmodel/NotificationShelfViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/shelf/ui/viewmodel/NotificationShelfViewModelTest.kt @@ -69,6 +69,7 @@ class NotificationShelfViewModelTest : SysuiTestCase() { private val powerInteractor by lazy { PowerInteractor( powerRepository, + keyguardRepository, FalsingCollectorFake(), screenOffAnimationController, statusBarStateController, diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java index 8f91950cb3297..59eff15b72ab1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java @@ -21,6 +21,8 @@ import static android.service.notification.NotificationListenerService.REASON_CL import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; +import static com.google.common.truth.Truth.assertThat; + import static org.mockito.AdditionalAnswers.answerVoid; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -61,10 +63,14 @@ import com.android.systemui.ActivityIntentHelper; import com.android.systemui.SysuiTestCase; import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.assist.AssistManager; +import com.android.systemui.classifier.FalsingCollectorFake; import com.android.systemui.flags.FeatureFlags; +import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.ActivityStarter.OnDismissAction; import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.power.data.repository.FakePowerRepository; +import com.android.systemui.power.domain.interactor.PowerInteractor; import com.android.systemui.settings.UserTracker; import com.android.systemui.shade.NotificationShadeWindowViewController; import com.android.systemui.shade.ShadeControllerImpl; @@ -118,6 +124,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { private NotificationClickNotifier mClickNotifier; @Mock private StatusBarStateController mStatusBarStateController; + @Mock private ScreenOffAnimationController mScreenOffAnimationController; @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @Mock @@ -150,6 +157,8 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { private ActivityLaunchAnimator mActivityLaunchAnimator; @Mock private InteractionJankMonitor mJankMonitor; + private FakePowerRepository mPowerRepository; + private PowerInteractor mPowerInteractor; @Mock private UserTracker mUserTracker; private final FakeExecutor mUiBgExecutor = new FakeExecutor(new FakeSystemClock()); @@ -199,6 +208,14 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { when(mUserTracker.getUserHandle()).thenReturn( UserHandle.of(ActivityManager.getCurrentUser())); + mPowerRepository = new FakePowerRepository(); + mPowerInteractor = new PowerInteractor( + mPowerRepository, + new FakeKeyguardRepository(), + new FalsingCollectorFake(), + mScreenOffAnimationController, + mStatusBarStateController); + HeadsUpManagerPhone headsUpManager = mock(HeadsUpManagerPhone.class); NotificationLaunchAnimatorControllerProvider notificationAnimationProvider = new NotificationLaunchAnimatorControllerProvider( @@ -238,6 +255,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { mActivityLaunchAnimator, notificationAnimationProvider, mock(LaunchFullScreenIntentProvider.class), + mPowerInteractor, mock(FeatureFlags.class), mUserTracker ); @@ -402,11 +420,13 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { when(entry.getImportance()).thenReturn(NotificationManager.IMPORTANCE_HIGH); when(entry.getSbn()).thenReturn(sbn); - // WHEN + // WHEN the intent is launched while dozing + when(mStatusBarStateController.isDozing()).thenReturn(true); mNotificationActivityStarter.launchFullScreenIntent(entry); // THEN display should try wake up for the full screen intent - verify(mCentralSurfaces).wakeUpForFullScreenIntent(); + assertThat(mPowerRepository.getLastWakeReason()).isNotNull(); + assertThat(mPowerRepository.getLastWakeWhy()).isNotNull(); } @Test From 74f9052fc55fcbebdee47ed0e07160583998cb7e Mon Sep 17 00:00:00 2001 From: Caitlin Shkuratov Date: Fri, 7 Jul 2023 20:51:46 +0000 Subject: [PATCH 2/3] [CS] Have SBNotifActivityStarter inject display ID directly. Bug: 277764509 Bug: 277762009 Test: restart sysui while device unfolded > verified via logging that CentralSurfacesImpl and SBNAS have the same display ID. Test: restart sysui while device folded > verified same Test: verified tapping on a notif launches the notif's intent Test: verified tapping on "History" button in shade opens notification history Test: atest StatusBarNotificationActivityStarterTest Change-Id: Ie71007b3ddadd7fd98b02fe1e5a76b800bc3b64c --- .../StatusBarNotificationActivityStarter.java | 16 ++++++++-------- ...StatusBarNotificationActivityStarterTest.java | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java index f6a01ea4c94bb..ec0c00e26c2fe 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java @@ -54,6 +54,7 @@ import com.android.systemui.ActivityIntentHelper; import com.android.systemui.EventLogTags; import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.assist.AssistManager; +import com.android.systemui.dagger.qualifiers.DisplayId; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.power.domain.interactor.PowerInteractor; @@ -95,6 +96,7 @@ import javax.inject.Inject; class StatusBarNotificationActivityStarter implements NotificationActivityStarter { private final Context mContext; + private final int mDisplayId; private final Handler mMainThreadHandler; private final Executor mUiBgExecutor; @@ -121,7 +123,6 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte private final MetricsLogger mMetricsLogger; private final StatusBarNotificationActivityStarterLogger mLogger; - private final CentralSurfaces mCentralSurfaces; private final NotificationPresenter mPresenter; private final ShadeViewController mShadeViewController; private final NotificationShadeWindowController mNotificationShadeWindowController; @@ -136,6 +137,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte @Inject StatusBarNotificationActivityStarter( Context context, + @DisplayId int displayId, Handler mainThreadHandler, Executor uiBgExecutor, NotificationVisibilityProvider visibilityProvider, @@ -158,7 +160,6 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte MetricsLogger metricsLogger, StatusBarNotificationActivityStarterLogger logger, OnUserInteractionCallback onUserInteractionCallback, - CentralSurfaces centralSurfaces, NotificationPresenter presenter, ShadeViewController shadeViewController, NotificationShadeWindowController notificationShadeWindowController, @@ -169,6 +170,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte FeatureFlags featureFlags, UserTracker userTracker) { mContext = context; + mDisplayId = displayId; mMainThreadHandler = mainThreadHandler; mUiBgExecutor = uiBgExecutor; mVisibilityProvider = visibilityProvider; @@ -193,8 +195,6 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte mMetricsLogger = metricsLogger; mLogger = logger; mOnUserInteractionCallback = onUserInteractionCallback; - // TODO: use KeyguardStateController#isOccluded to remove this dependency - mCentralSurfaces = centralSurfaces; mPresenter = presenter; mShadeViewController = shadeViewController; mActivityLaunchAnimator = activityLaunchAnimator; @@ -456,11 +456,11 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte long eventTime = row.getAndResetLastActionUpTime(); Bundle options = eventTime > 0 ? getActivityOptions( - mCentralSurfaces.getDisplayId(), + mDisplayId, adapter, mKeyguardStateController.isShowing(), eventTime) - : getActivityOptions(mCentralSurfaces.getDisplayId(), adapter); + : getActivityOptions(mDisplayId, adapter); int result = intent.sendAndReturnResult(mContext, 0, fillInIntent, null, null, null, options); mLogger.logSendPendingIntent(entry, intent, result); @@ -495,7 +495,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte (adapter) -> TaskStackBuilder.create(mContext) .addNextIntentWithParentStack(intent) .startActivities(getActivityOptions( - mCentralSurfaces.getDisplayId(), + mDisplayId, adapter), new UserHandle(UserHandle.getUserId(appUid)))); }); @@ -543,7 +543,7 @@ class StatusBarNotificationActivityStarter implements NotificationActivityStarte mActivityLaunchAnimator.startIntentWithAnimation(animationController, animate, intent.getPackage(), (adapter) -> tsb.startActivities( - getActivityOptions(mCentralSurfaces.getDisplayId(), adapter), + getActivityOptions(mDisplayId, adapter), mUserTracker.getUserHandle())); }); return true; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java index 59eff15b72ab1..9c7f6190de448 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarterTest.java @@ -116,6 +116,8 @@ import java.util.Optional; @TestableLooper.RunWithLooper(setAsMainLooper = true) public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { + private static final int DISPLAY_ID = 0; + @Mock private AssistManager mAssistManager; @Mock @@ -130,8 +132,6 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { @Mock private NotificationRemoteInputManager mRemoteInputManager; @Mock - private CentralSurfaces mCentralSurfaces; - @Mock private KeyguardStateController mKeyguardStateController; @Mock private NotificationInterruptStateProvider mNotificationInterruptStateProvider; @@ -226,6 +226,7 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { mNotificationActivityStarter = new StatusBarNotificationActivityStarter( getContext(), + DISPLAY_ID, mHandler, mUiBgExecutor, mVisibilityProvider, @@ -248,7 +249,6 @@ public class StatusBarNotificationActivityStarterTest extends SysuiTestCase { mock(MetricsLogger.class), mock(StatusBarNotificationActivityStarterLogger.class), mOnUserInteractionCallback, - mCentralSurfaces, mock(NotificationPresenter.class), mock(ShadeViewController.class), mock(NotificationShadeWindowController.class), From 34fa71ff416226a77d54689685a090ab093a2029 Mon Sep 17 00:00:00 2001 From: Caitlin Shkuratov Date: Mon, 10 Jul 2023 18:03:36 +0000 Subject: [PATCH 3/3] [CS] Have ActivityStarterImpl inject display ID directly. These were the last usages of CentralSurfacesImpl#getDisplayId, so that method is now removed. Bug: 277764509 Bug: 277762009 Test: restart sysui while device unfolded > verified via logging that CentralSurfacesImpl and ActivityStarterImpl have the same display ID. Test: restart sysui while device folded > verified same Test: long press on lockscreen > open "Customize lock screen" > verify customizer opens with animation Test: long press on QR code scanner lockscreen shortcut > verify QS code scanner opens with animation Test: atest ActivityStarterImplTest Change-Id: Idb054b6bd010c2f2d984db2fd64199534c6c8fbe --- .../systemui/statusbar/phone/ActivityStarterImpl.kt | 10 +++++----- .../systemui/statusbar/phone/CentralSurfaces.java | 2 -- .../systemui/statusbar/phone/CentralSurfacesImpl.java | 5 ----- .../statusbar/phone/ActivityStarterImplTest.kt | 5 +++++ 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt index 730ef57f19727..26b51a95acada 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ActivityStarterImpl.kt @@ -37,6 +37,7 @@ import com.android.systemui.animation.DelegateLaunchAnimatorController import com.android.systemui.assist.AssistManager import com.android.systemui.camera.CameraIntents.Companion.isInsecureCameraIntent import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.dagger.qualifiers.DisplayId import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.keyguard.KeyguardViewMediator import com.android.systemui.keyguard.WakefulnessLifecycle @@ -72,6 +73,7 @@ constructor( private val notifShadeWindowControllerLazy: Lazy, private val activityLaunchAnimator: ActivityLaunchAnimator, private val context: Context, + @DisplayId private val displayId: Int, private val lockScreenUserManager: NotificationLockscreenUserManager, private val statusBarWindowController: StatusBarWindowController, private val wakefulnessLifecycle: WakefulnessLifecycle, @@ -471,9 +473,7 @@ constructor( intent.getPackage() ) { adapter: RemoteAnimationAdapter? -> val options = - ActivityOptions( - CentralSurfaces.getActivityOptions(centralSurfaces!!.displayId, adapter) - ) + ActivityOptions(CentralSurfaces.getActivityOptions(displayId, adapter)) // We know that the intent of the caller is to dismiss the keyguard and // this runnable is called right after the keyguard is solved, so we tell @@ -596,7 +596,7 @@ constructor( val options = ActivityOptions( CentralSurfaces.getActivityOptions( - centralSurfaces!!.displayId, + displayId, animationAdapter ) ) @@ -762,7 +762,7 @@ constructor( TaskStackBuilder.create(context) .addNextIntent(intent) .startActivities( - CentralSurfaces.getActivityOptions(centralSurfaces!!.displayId, adapter), + CentralSurfaces.getActivityOptions(displayId, adapter), userHandle ) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index e0e597d4cdcd8..2b9c3d33e9b87 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -355,8 +355,6 @@ public interface CentralSurfaces extends Dumpable, LifecycleOwner { void updateNotificationPanelTouchState(); - int getDisplayId(); - int getRotation(); @VisibleForTesting 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 6959029c99640..09576735a94d5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -2097,11 +2097,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { return mDisplay.getRotation(); } - @Override - public int getDisplayId() { - return mDisplayId; - } - @Override public void readyForKeyguardDone() { mStatusBarKeyguardViewManager.readyForKeyguardDone(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ActivityStarterImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ActivityStarterImplTest.kt index 442ba0977cf62..5e0e140563cd4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ActivityStarterImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ActivityStarterImplTest.kt @@ -95,6 +95,7 @@ class ActivityStarterImplTest : SysuiTestCase() { Lazy { notifShadeWindowController }, activityLaunchAnimator, context, + DISPLAY_ID, lockScreenUserManager, statusBarWindowController, wakefulnessLifecycle, @@ -274,4 +275,8 @@ class ActivityStarterImplTest : SysuiTestCase() { mainExecutor.runAllReady() verify(statusBarStateController).setLeaveOpenOnKeyguardHide(true) } + + private companion object { + private const val DISPLAY_ID = 0 + } }