Skip to content

Commit eefff44

Browse files
ben Wanghungphan2001
authored andcommitted
[WMS][Bugfix]Fix screenshot sharing failure after the recent task is opened.
When open the recent task after taking the screenshot,the reorderMode will be changed to start a new activity of the screenshot. Change-Id: I6f3192d67e5db3aa8c861046483b1851c1766f6c
1 parent e05de86 commit eefff44

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

services/core/java/com/android/server/wm/ActivityStarter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,12 @@ private int startActivityUnchecked(final ActivityRecord r, ActivityRecord source
16761676
intentGrants);
16771677
} finally {
16781678
Trace.traceEnd(Trace.TRACE_TAG_WINDOW_MANAGER);
1679+
1680+
if (ActivityManager.isStartResultSuccessful(result) &&
1681+
mService.mWindowManager.getRecentsAnimationController() != null) {
1682+
mService.mWindowManager.getRecentsAnimationController().notifyActivityStarting();
1683+
}
1684+
16791685
startedActivityRootTask = handleStartResult(r, options, result, newTransition,
16801686
remoteTransition);
16811687
}

services/core/java/com/android/server/wm/RecentsAnimation.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ private void finishAnimation(@RecentsAnimationController.ReorderMode int reorder
290290
mWindowManager.getRecentsAnimationController();
291291
if (controller == null) return;
292292

293+
if (controller.isActivityStarting()) {
294+
//Fix screenshot sharing failure after the recent task is opened.
295+
Slog.i(TAG, "Change reorderMode because a activity is starting");
296+
reorderMode = REORDER_MOVE_TO_ORIGINAL_POSITION;
297+
}
298+
293299
// Just to be sure end the launch hint in case the target activity was never launched.
294300
// However, if we're keeping the activity and making it visible, we can leave it on.
295301
if (reorderMode != REORDER_KEEP_IN_PLACE) {
@@ -302,12 +308,14 @@ private void finishAnimation(@RecentsAnimationController.ReorderMode int reorder
302308
mService.stopAppSwitches();
303309
}
304310

311+
final int changedReorderMode = reorderMode;
312+
305313
mWindowManager.inSurfaceTransaction(() -> {
306314
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER,
307315
"RecentsAnimation#onAnimationFinished_inSurfaceTransaction");
308316
mService.deferWindowLayout();
309317
try {
310-
mWindowManager.cleanupRecentsAnimation(reorderMode);
318+
mWindowManager.cleanupRecentsAnimation(changedReorderMode);
311319

312320
final Task targetRootTask = mDefaultTaskDisplayArea.getRootTask(
313321
WINDOWING_MODE_UNDEFINED, mTargetActivityType);
@@ -327,7 +335,7 @@ private void finishAnimation(@RecentsAnimationController.ReorderMode int reorder
327335
// Restore the launched-behind state
328336
targetActivity.mLaunchTaskBehind = false;
329337

330-
if (reorderMode == REORDER_MOVE_TO_TOP) {
338+
if (changedReorderMode == REORDER_MOVE_TO_TOP) {
331339
// Bring the target root task to the front
332340
mTaskSupervisor.mNoAnimActivities.add(targetActivity);
333341

@@ -351,7 +359,7 @@ private void finishAnimation(@RecentsAnimationController.ReorderMode int reorder
351359
targetRootTask, topRootTask);
352360
}
353361
}
354-
} else if (reorderMode == REORDER_MOVE_TO_ORIGINAL_POSITION){
362+
} else if (changedReorderMode == REORDER_MOVE_TO_ORIGINAL_POSITION){
355363
// Restore the target root task to its previous position
356364
final TaskDisplayArea taskDisplayArea = targetActivity.getDisplayArea();
357365
taskDisplayArea.moveRootTaskBehindRootTask(targetRootTask,

services/core/java/com/android/server/wm/RecentsAnimationController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ public class RecentsAnimationController implements DeathRecipient {
155155

156156
private final ArrayList<RemoteAnimationTarget> mPendingTaskAppears = new ArrayList<>();
157157

158+
private boolean mIsActivityStarting = false;
159+
158160
/**
159161
* An app transition listener to cancel the recents animation only after the app transition
160162
* starts or is canceled.
@@ -368,6 +370,14 @@ public void animateNavigationBarToApp(long duration) {
368370
}
369371
};
370372

373+
void notifyActivityStarting() {
374+
mIsActivityStarting = true;
375+
}
376+
377+
boolean isActivityStarting() {
378+
return mIsActivityStarting;
379+
}
380+
371381
/**
372382
* @param remoteAnimationRunner The remote runner which should be notified when the animation is
373383
* ready to start or has been canceled

0 commit comments

Comments
 (0)