From a174e882511cc033a5de13d7b2a91fe68b78c8f5 Mon Sep 17 00:00:00 2001 From: Wei Sheng Shih Date: Thu, 14 May 2020 02:10:28 +0000 Subject: [PATCH] Revert^2 Fix missing animation when launch activity from notification The remote animaton is controlled by notification shade, if we set the notification shade set to invisible, although the animator is still running, but surface won't update. Extending the visibility time until the animation finish can solve this problem. Also post the calling of setLaunchResult from main thread so mIsLaunchForActivity and mAnimationPending can be synchronized. Fixes: 154815513 Test: atest SystemUITests Test: Follow the issue description. Change-Id: I735340498575e2d7dc5a95ec1be3aa886739ecc4 --- .../phone/NotificationShadeWindowController.java | 9 ++++++++- .../NotificationShadeWindowViewController.java | 16 +++++++++++++--- .../systemui/statusbar/phone/StatusBar.java | 2 +- .../StatusBarNotificationActivityStarter.java | 7 +++++-- .../phone/NotificationShadeWindowViewTest.java | 3 ++- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java index 926c1bd7c271a..2e4a929ded5b8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowController.java @@ -321,7 +321,8 @@ public class NotificationShadeWindowController implements Callback, Dumpable, || state.mPanelVisible || state.mKeyguardFadingAway || state.mBouncerShowing || state.mHeadsUpShowing || state.mScrimsVisibility != ScrimController.TRANSPARENT) - || state.mBackgroundBlurRadius > 0; + || state.mBackgroundBlurRadius > 0 + || state.mLaunchingActivity; } private void applyFitsSystemWindows(State state) { @@ -485,6 +486,11 @@ public class NotificationShadeWindowController implements Callback, Dumpable, apply(mCurrentState); } + void setLaunchingActivity(boolean launching) { + mCurrentState.mLaunchingActivity = launching; + apply(mCurrentState); + } + public void setScrimsVisibility(int scrimsVisibility) { mCurrentState.mScrimsVisibility = scrimsVisibility; apply(mCurrentState); @@ -645,6 +651,7 @@ public class NotificationShadeWindowController implements Callback, Dumpable, boolean mForceCollapsed; boolean mForceDozeBrightness; boolean mForceUserActivity; + boolean mLaunchingActivity; boolean mBackdropShowing; boolean mWallpaperSupportsAmbientMode; boolean mNotTouchable; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java index 596a607bb8ad9..42222d724896a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewController.java @@ -93,6 +93,7 @@ public class NotificationShadeWindowViewController { private PhoneStatusBarView mStatusBarView; private PhoneStatusBarTransitions mBarTransitions; private StatusBar mService; + private NotificationShadeWindowController mNotificationShadeWindowController; private DragDownHelper mDragDownHelper; private boolean mDoubleTapEnabled; private boolean mSingleTapEnabled; @@ -429,11 +430,19 @@ public class NotificationShadeWindowViewController { } public void setExpandAnimationPending(boolean pending) { - mExpandAnimationPending = pending; + if (mExpandAnimationPending != pending) { + mExpandAnimationPending = pending; + mNotificationShadeWindowController + .setLaunchingActivity(mExpandAnimationPending | mExpandAnimationRunning); + } } public void setExpandAnimationRunning(boolean running) { - mExpandAnimationRunning = running; + if (mExpandAnimationRunning != running) { + mExpandAnimationRunning = running; + mNotificationShadeWindowController + .setLaunchingActivity(mExpandAnimationPending | mExpandAnimationRunning); + } } public void cancelExpandHelper() { @@ -456,8 +465,9 @@ public class NotificationShadeWindowViewController { } } - public void setService(StatusBar statusBar) { + public void setService(StatusBar statusBar, NotificationShadeWindowController controller) { mService = statusBar; + mNotificationShadeWindowController = controller; } @VisibleForTesting diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index bbf83bc2057a7..dd54a3d800fb3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1001,7 +1001,7 @@ public class StatusBar extends SystemUI implements DemoMode, updateTheme(); inflateStatusBarWindow(); - mNotificationShadeWindowViewController.setService(this); + mNotificationShadeWindowViewController.setService(this, mNotificationShadeWindowController); mNotificationShadeWindowView.setOnTouchListener(getStatusBarWindowTouchListener()); // TODO: Deal with the ugliness that comes from having some of the statusbar broken out 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 44ece3584ee21..7924348d34d4f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java @@ -429,7 +429,9 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit } int launchResult = intent.sendAndReturnResult(mContext, 0, fillInIntent, null, null, null, getActivityOptions(adapter)); - mActivityLaunchAnimator.setLaunchResult(launchResult, isActivityIntent); + mMainThreadHandler.post(() -> { + mActivityLaunchAnimator.setLaunchResult(launchResult, isActivityIntent); + }); } catch (RemoteException | PendingIntent.CanceledException e) { // the stack trace isn't very helpful here. // Just log the exception message. @@ -449,10 +451,11 @@ public class StatusBarNotificationActivityStarter implements NotificationActivit mActivityLaunchAnimator.getLaunchAnimation( row, mStatusBar.isOccluded())), new UserHandle(UserHandle.getUserId(appUid))); - mActivityLaunchAnimator.setLaunchResult(launchResult, true /* isActivityIntent */); // Putting it back on the main thread, since we're touching views mMainThreadHandler.post(() -> { + mActivityLaunchAnimator.setLaunchResult(launchResult, + true /* isActivityIntent */); removeHUN(row); }); if (shouldCollapse()) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java index cc2d1c25de38f..e04d25b17c710 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationShadeWindowViewTest.java @@ -83,6 +83,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase { @Mock private NotificationStackScrollLayout mNotificationStackScrollLayout; @Mock private NotificationShadeDepthController mNotificationShadeDepthController; @Mock private SuperStatusBarViewFactory mStatusBarViewFactory; + @Mock private NotificationShadeWindowController mNotificationShadeWindowController; @Before public void setUp() { @@ -121,7 +122,7 @@ public class NotificationShadeWindowViewTest extends SysuiTestCase { mNotificationPanelViewController, mStatusBarViewFactory); mController.setupExpandedStatusBar(); - mController.setService(mStatusBar); + mController.setService(mStatusBar, mNotificationShadeWindowController); mController.setDragDownHelper(mDragDownHelper); }