Avoid misleading log while warm launch

When launch a new activity on an existing process, the original code
will let the activity with lastLaunchTime=0 go through setProc ->
addActivityIfNeeded -> setLastActivityLaunchTime. And because the
existing process has mLastActivityLaunchTime>0, the method will print
a confusing log.

So just move the assignment of lastLaunchTime before setProcess. And
remove the later setLastActivityLaunchTime because setProcess has
already called it.

Bug: 243164648
Test: Launch an activity and calls finish(), and then launch it again.
      There should not have a warning log:
      "Tried to set launchTime (0) < mLastActivityLaunchTime".
Change-Id: Id767a0589cbb7d9730a3deceb12789341391cdff
This commit is contained in:
Riddle Hsu
2022-08-22 17:18:09 +08:00
parent 0054cebd12
commit 2f37c0d5cf

View File

@@ -789,7 +789,7 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
// schedule launch ticks to collect information about slow apps.
r.startLaunchTickingLocked();
r.lastLaunchTime = SystemClock.uptimeMillis();
r.setProcess(proc);
// Ensure activity is allowed to be resumed after process has set.
@@ -835,8 +835,6 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
final IActivityClientController activityClientController =
proc.hasEverLaunchedActivity() ? null : mService.mActivityClientController;
r.launchCount++;
r.lastLaunchTime = SystemClock.uptimeMillis();
proc.setLastActivityLaunchTime(r.lastLaunchTime);
if (DEBUG_ALL) Slog.v(TAG, "Launching: " + r);