Add toast when an app intercepts the launch of another app.

The activity manager looks for cases where one app launches immediately
after another.  If this happens, a brief toast is shown telling the user
when app is actually running and what was originally starting.

Change-Id: If94cf5bd393dd0bc0f09789dae044fde1386c481
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 3142ee4..483941d 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -752,6 +752,7 @@
     boolean mWaitingUpdate = false;
     boolean mDidUpdate = false;
     boolean mOnBattery = false;
+    boolean mLaunchWarningShown = false;
 
     Context mContext;
 
@@ -2902,6 +2903,30 @@
         }
     }
 
+    final void showLaunchWarningLocked(final ActivityRecord cur, final ActivityRecord next) {
+        if (!mLaunchWarningShown) {
+            mLaunchWarningShown = true;
+            mHandler.post(new Runnable() {
+                @Override
+                public void run() {
+                    synchronized (ActivityManagerService.this) {
+                        final Dialog d = new LaunchWarningWindow(mContext, cur, next);
+                        d.show();
+                        mHandler.postDelayed(new Runnable() {
+                            @Override
+                            public void run() {
+                                synchronized (ActivityManagerService.this) {
+                                    d.dismiss();
+                                    mLaunchWarningShown = false;
+                                }
+                            }
+                        }, 4000);
+                    }
+                }
+            });
+        }
+    }
+    
     final void decPersistentCountLocked(ProcessRecord app) {
         app.persistentActivities--;
         if (app.persistentActivities > 0) {