Unblock 'am start -W' if activity is brought to front without launching

If -W is used to start an activity successfully, but this activity just
brings another activity to front without actual launching, the waiting
will be stuck because neither activity will report launch complete.

In this case, we have to treat it as if the -W started an activity and
received return code START_TASK_TO_FRONT. It needs to wait for the new
activity to become visible (or report launch complete if it's already
visible).

This reverts earlier commits afb776d5447e19565c9a826a554911decb9ed92a,
since it's causing problems with launch time reporting.

bug: 28333487
bug: 29451567
Change-Id: I9fd79ab5b3ed8f9de5df34ed9c7b0be3a94620b2
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index 6510cb4..50b6c0c 100755
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -1157,13 +1157,6 @@
 
     public void reportFullyDrawnLocked() {
         final long curTime = SystemClock.uptimeMillis();
-        // Normally launch time counts from the point when the activity is resumed, to when the
-        // first window is drawn. However the activity could become visible before it is resumed,
-        // due to some other activity in the same task being launched. In this case we still need
-        // to report launch time to unblock ActivityStarter.startActivityMayWait().
-        if (displayStartTime == 0 && task != null && task.isLaunching) {
-            displayStartTime = curTime;
-        }
         if (displayStartTime != 0) {
             reportLaunchTimeLocked(curTime);
         }
@@ -1229,22 +1222,13 @@
             //service.mUsageStatsService.noteLaunchTime(realActivity, (int)totalTime);
         }
         displayStartTime = 0;
-        task.isLaunching = false;
         stack.mLaunchStartTime = 0;
     }
 
     void windowsDrawnLocked() {
         mStackSupervisor.mActivityMetricsLogger.notifyWindowsDrawn();
-        final long curTime = SystemClock.uptimeMillis();
-        // Normally launch time counts from the point when the activity is resumed, to when the
-        // first window is drawn. However the activity could become visible before it is resumed,
-        // due to some other activity in the same task being launched. In this case we still need
-        // to report launch time to unblock ActivityStarter.startActivityMayWait().
-        if (displayStartTime == 0 && task != null && task.isLaunching) {
-            displayStartTime = curTime;
-        }
         if (displayStartTime != 0) {
-            reportLaunchTimeLocked(curTime);
+            reportLaunchTimeLocked(SystemClock.uptimeMillis());
         }
         mStackSupervisor.sendWaitingVisibleReportLocked(this);
         startTime = 0;