Starting activity with ‘-W’ option from shell waited forever
because activity was brought to top, but being removed from
waiting visible activities (due to process was gone) without
reporting the wait result.
Also correcting the component to avoid waiting for a top
finishing activity.
Bug:
117579987
Test: atest ActivityManagerAmStartOptionsTests
Change-Id: I7c1e6781544f0d794225a13fdf417475ff0598a3
}
if (nowVisible) {
- // We won't get a call to reportActivityVisibleLocked() so dismiss lockscreen now.
- mStackSupervisor.reportActivityVisibleLocked(this);
+ mStackSupervisor.stopWaitingForActivityVisible(this);
}
// Schedule an idle timeout in case the app doesn't do it for us.
final @LaunchState int launchState = info != null ? info.getLaunchState() : -1;
mStackSupervisor.reportActivityLaunchedLocked(false /* timeout */, this,
windowsDrawnDelayMs, launchState);
- mStackSupervisor.sendWaitingVisibleReportLocked(this);
+ mStackSupervisor.stopWaitingForActivityVisible(this);
finishLaunchTickingLocked();
if (task != null) {
task.hasBeenVisible = true;
/** Called when the windows associated app window container are visible. */
public void onWindowsVisible() {
synchronized (mAtmService.mGlobalLock) {
- mStackSupervisor.reportActivityVisibleLocked(this);
+ mStackSupervisor.stopWaitingForActivityVisible(this);
if (DEBUG_SWITCH) Log.v(TAG_SWITCH, "windowsVisibleLocked(): " + this);
if (!nowVisible) {
nowVisible = true;
// down to the max limit while they are still waiting to finish.
mFinishingActivities.remove(r);
- for (int i = mWaitingForActivityVisible.size() - 1; i >= 0; --i) {
- if (mWaitingForActivityVisible.get(i).matches(r.mActivityComponent)) {
- mWaitingForActivityVisible.remove(i);
- }
- }
- }
-
- void reportActivityVisibleLocked(ActivityRecord r) {
- sendWaitingVisibleReportLocked(r);
+ stopWaitingForActivityVisible(r);
}
- void sendWaitingVisibleReportLocked(ActivityRecord r) {
+ void stopWaitingForActivityVisible(ActivityRecord r) {
boolean changed = false;
for (int i = mWaitingForActivityVisible.size() - 1; i >= 0; --i) {
final WaitInfo w = mWaitingForActivityVisible.get(i);
if (!mAddingToTask && mReuseTask == null) {
// We didn't do anything... but it was needed (a.k.a., client don't use that
// intent!) And for paranoia, make sure we have correctly resumed the top activity.
-
resumeTargetStackIfNeeded();
if (outActivity != null && outActivity.length > 0) {
- outActivity[0] = reusedActivity;
+ // The reusedActivity could be finishing, for example of starting an
+ // activity with FLAG_ACTIVITY_CLEAR_TOP flag. In that case, return the
+ // top running activity in the task instead.
+ outActivity[0] = reusedActivity.finishing
+ ? reusedActivity.getTaskRecord().getTopActivity() : reusedActivity;
}
return mMovedToFront ? START_TASK_TO_FRONT : START_DELIVERED_TO_TOP;