Merge "Fixed the launch animation with flag auto cancel"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 1056ecc..b3f68d3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -1472,7 +1472,6 @@
return mPrivateLayout.getActiveRemoteInputText();
}
-
public void animateTranslateNotification(final float leftTarget) {
if (mTranslateAnim != null) {
mTranslateAnim.cancel();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java
index 8336d29..907af69 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java
@@ -19,6 +19,7 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
+import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.graphics.Matrix;
import android.graphics.Rect;
@@ -35,10 +36,11 @@
import com.android.systemui.Interpolators;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.NotificationListContainer;
+import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment;
import com.android.systemui.statusbar.phone.NotificationPanelView;
+import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.phone.StatusBarWindowView;
-import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import java.util.function.Consumer;
@@ -57,16 +59,17 @@
private final NotificationPanelView mNotificationPanel;
private final NotificationListContainer mNotificationContainer;
private final StatusBarWindowView mStatusBarWindow;
- private final Consumer<Boolean> mPanelCollapser;
+ private final StatusBar mStatusBar;
+ private boolean mAnimationPending;
public ActivityLaunchAnimator(StatusBarWindowView statusBarWindow,
- Consumer<Boolean> panelCollapser,
+ StatusBar statusBar,
NotificationPanelView notificationPanel,
NotificationListContainer container) {
mNotificationPanel = notificationPanel;
mNotificationContainer = container;
mStatusBarWindow = statusBarWindow;
- mPanelCollapser = panelCollapser;
+ mStatusBar = statusBar;
}
public ActivityOptions getLaunchAnimation(
@@ -76,6 +79,21 @@
new RemoteAnimationAdapter(animationRunner, 1000 /* Duration */, 0 /* delay */));
}
+ public boolean isAnimationPending() {
+ return mAnimationPending;
+ }
+
+ public void setLaunchResult(int launchResult) {
+ setAnimationPending((launchResult == ActivityManager.START_TASK_TO_FRONT
+ || launchResult == ActivityManager.START_SUCCESS)
+ && mStatusBar.getBarState() == StatusBarState.SHADE);
+ }
+
+ private void setAnimationPending(boolean pending) {
+ mAnimationPending = pending;
+ mStatusBarWindow.setExpandAnimationPending(pending);
+ }
+
class AnimationRunner extends IRemoteAnimationRunner.Stub {
private final ExpandableNotificationRow mSourceNotification;
@@ -94,7 +112,6 @@
IRemoteAnimationFinishedCallback iRemoteAnimationFinishedCallback)
throws RemoteException {
mSourceNotification.post(() -> {
- boolean first = true;
for (RemoteAnimationTarget app : remoteAnimationTargets) {
if (app.mode == RemoteAnimationTarget.MODE_OPENING) {
setExpandAnimationRunning(true);
@@ -139,7 +156,7 @@
public void onAnimationEnd(Animator animation) {
setExpandAnimationRunning(false);
if (mInstantCollapsePanel) {
- mPanelCollapser.accept(false /* animate */);
+ mStatusBar.collapsePanel(false /* animate */);
}
try {
iRemoteAnimationFinishedCallback.onAnimationFinished();
@@ -152,6 +169,7 @@
break;
}
}
+ setAnimationPending(false);
});
}
@@ -198,6 +216,10 @@
@Override
public void onAnimationCancelled() throws RemoteException {
+ mSourceNotification.post(() -> {
+ setAnimationPending(false);
+ mStatusBar.onLaunchAnimationCancelled();
+ });
}
};
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
index a62a424..2b7e474 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelView.java
@@ -950,7 +950,7 @@
}
public boolean isCollapsing() {
- return mClosing;
+ return mClosing || mLaunchingNotification;
}
public boolean isTracking() {
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 7d84550..b519824 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -100,7 +100,6 @@
import android.service.notification.StatusBarNotification;
import android.service.vr.IVrManager;
import android.service.vr.IVrStateCallbacks;
-import android.text.SpannedString;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.EventLog;
@@ -589,7 +588,7 @@
private NavigationBarFragment mNavigationBar;
private View mNavigationBarView;
- private ActivityLaunchAnimator mActivityLaunchAnimator;
+ protected ActivityLaunchAnimator mActivityLaunchAnimator;
@Override
public void start() {
@@ -760,7 +759,7 @@
mNotificationPanel = mStatusBarWindow.findViewById(R.id.notification_panel);
mStackScroller = mStatusBarWindow.findViewById(R.id.notification_stack_scroller);
mActivityLaunchAnimator = new ActivityLaunchAnimator(mStatusBarWindow,
- this::collapsePanel,
+ this,
mNotificationPanel,
mStackScroller);
mGutsManager.setUpWithPresenter(this, mEntryManager, mStackScroller, mCheckSaveListener,
@@ -2054,6 +2053,12 @@
}
}
+ public void onLaunchAnimationCancelled() {
+ if (!isCollapsing()) {
+ onClosingFinished();
+ }
+ }
+
/**
* All changes to the status bar and notifications funnel through here and are batched.
*/
@@ -3418,7 +3423,7 @@
}
public boolean isCollapsing() {
- return mNotificationPanel.isCollapsing();
+ return mNotificationPanel.isCollapsing() || mActivityLaunchAnimator.isAnimationPending();
}
public void addPostCollapseAction(Runnable r) {
@@ -4959,6 +4964,7 @@
try {
launchResult = intent.sendAndReturnResult(mContext, 0, fillInIntent, null,
null, null, getActivityOptions(row));
+ mActivityLaunchAnimator.setLaunchResult(launchResult);
} catch (PendingIntent.CanceledException e) {
// the stack trace isn't very helpful here.
// Just log the exception message.
@@ -4970,7 +4976,7 @@
mAssistManager.hideAssist();
}
}
- if (shouldCollapse(launchResult)) {
+ if (shouldCollapse()) {
if (Looper.getMainLooper().isCurrentThread()) {
collapsePanel();
} else {
@@ -5003,17 +5009,8 @@
}, afterKeyguardGone);
}
- private boolean shouldCollapse(int launchResult) {
- return mState != StatusBarState.SHADE
- || (launchResult != ActivityManager.START_TASK_TO_FRONT
- && launchResult != ActivityManager.START_SUCCESS);
- }
-
- public void onExpandAnimationFinished() {
- if (!isPresenterFullyCollapsed()) {
- instantCollapseNotificationPanel();
- visibilityChanged(false);
- }
+ private boolean shouldCollapse() {
+ return mState != StatusBarState.SHADE || !mActivityLaunchAnimator.isAnimationPending();
}
public void collapsePanel(boolean animate) {
@@ -5128,7 +5125,8 @@
.addNextIntentWithParentStack(intent)
.startActivities(getActivityOptions(row),
new UserHandle(UserHandle.getUserId(appUid)));
- if (shouldCollapse(launchResult)) {
+ mActivityLaunchAnimator.setLaunchResult(launchResult);
+ if (shouldCollapse()) {
// Putting it back on the main thread, since we're touching views
mStatusBarWindow.post(() -> animateCollapsePanels(
CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index f7d0967..e32914f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -89,6 +89,7 @@
private boolean mTouchCancelled;
private boolean mTouchActive;
private boolean mExpandAnimationRunning;
+ private boolean mExpandAnimationPending;
public StatusBarWindowView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -268,7 +269,7 @@
|| ev.getActionMasked() == MotionEvent.ACTION_CANCEL) {
setTouchActive(false);
}
- if (mTouchCancelled || mExpandAnimationRunning) {
+ if (mTouchCancelled || mExpandAnimationRunning || mExpandAnimationPending) {
return false;
}
mFalsingManager.onTouchEvent(ev, getWidth(), getHeight());
@@ -393,6 +394,10 @@
mExpandAnimationRunning = expandAnimationRunning;
}
+ public void setExpandAnimationPending(boolean pending) {
+ mExpandAnimationPending = pending;
+ }
+
public class LayoutParams extends FrameLayout.LayoutParams {
public boolean ignoreRightInset;
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
index 99202f4..bdf9b1f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
@@ -84,6 +84,7 @@
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
import com.android.systemui.statusbar.StatusBarState;
+import com.android.systemui.statusbar.notification.ActivityLaunchAnimator;
import com.android.systemui.statusbar.notification.VisualStabilityManager;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.HeadsUpManager;
@@ -188,7 +189,8 @@
mKeyguardIndicationController, mStackScroller, mHeadsUpManager,
mPowerManager, mNotificationPanelView, mBarService, mNotificationListener,
mNotificationLogger, mVisualStabilityManager, mViewHierarchyManager,
- mEntryManager, mScrimController, mFingerprintUnlockController);
+ mEntryManager, mScrimController, mFingerprintUnlockController,
+ mock(ActivityLaunchAnimator.class));
mStatusBar.mContext = mContext;
mStatusBar.mComponents = mContext.getComponents();
mEntryManager.setUpForTest(mStatusBar, mStackScroller, mStatusBar, mHeadsUpManager,
@@ -593,7 +595,8 @@
VisualStabilityManager visualStabilityManager,
NotificationViewHierarchyManager viewHierarchyManager,
TestableNotificationEntryManager entryManager, ScrimController scrimController,
- FingerprintUnlockController fingerprintUnlockController) {
+ FingerprintUnlockController fingerprintUnlockController,
+ ActivityLaunchAnimator launchAnimator) {
mStatusBarKeyguardViewManager = man;
mUnlockMethodCache = unlock;
mKeyguardIndicationController = key;
@@ -610,6 +613,7 @@
mEntryManager = entryManager;
mScrimController = scrimController;
mFingerprintUnlockController = fingerprintUnlockController;
+ mActivityLaunchAnimator = launchAnimator;
}
private WakefulnessLifecycle createAwakeWakefulnessLifecycle() {