Merge "Count app launch correctly." into pi-dev
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java
index 7db3ac6..f9aa8da 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListener.java
@@ -17,6 +17,7 @@
package com.android.systemui.shared.system;
import android.app.ActivityManager.TaskSnapshot;
+import android.content.ComponentName;
import android.os.UserHandle;
import android.util.Log;
@@ -43,6 +44,7 @@
public void onActivityDismissingDockedStack() { }
public void onActivityLaunchOnSecondaryDisplayFailed() { }
public void onTaskProfileLocked(int taskId, int userId) { }
+ public void onTaskCreated(int taskId, ComponentName componentName) { }
public void onTaskRemoved(int taskId) { }
public void onTaskMovedToFront(int taskId) { }
public void onActivityRequestedOrientationChanged(int taskId, int requestedOrientation) { }
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
index 857e0ea..5e293c6 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
@@ -19,6 +19,7 @@
import android.app.ActivityManager.TaskSnapshot;
import android.app.IActivityManager;
import android.app.TaskStackListener;
+import android.content.ComponentName;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -140,12 +141,16 @@
}
@Override
- public void onTaskSnapshotChanged(int taskId, TaskSnapshot snapshot)
- throws RemoteException {
+ public void onTaskSnapshotChanged(int taskId, TaskSnapshot snapshot) throws RemoteException {
mHandler.obtainMessage(H.ON_TASK_SNAPSHOT_CHANGED, taskId, 0, snapshot).sendToTarget();
}
@Override
+ public void onTaskCreated(int taskId, ComponentName componentName) throws RemoteException {
+ mHandler.obtainMessage(H.ON_TASK_CREATED, taskId, 0, componentName).sendToTarget();
+ }
+
+ @Override
public void onTaskRemoved(int taskId) throws RemoteException {
mHandler.obtainMessage(H.ON_TASK_REMOVED, taskId, 0).sendToTarget();
}
@@ -174,9 +179,10 @@
private static final int ON_PINNED_STACK_ANIMATION_STARTED = 9;
private static final int ON_ACTIVITY_UNPINNED = 10;
private static final int ON_ACTIVITY_LAUNCH_ON_SECONDARY_DISPLAY_FAILED = 11;
- private static final int ON_TASK_REMOVED = 12;
- private static final int ON_TASK_MOVED_TO_FRONT = 13;
- private static final int ON_ACTIVITY_REQUESTED_ORIENTATION_CHANGE = 14;
+ private static final int ON_TASK_CREATED = 12;
+ private static final int ON_TASK_REMOVED = 13;
+ private static final int ON_TASK_MOVED_TO_FRONT = 14;
+ private static final int ON_ACTIVITY_REQUESTED_ORIENTATION_CHANGE = 15;
public H(Looper looper) {
@@ -262,6 +268,13 @@
}
break;
}
+ case ON_TASK_CREATED: {
+ for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
+ mTaskStackListeners.get(i).onTaskCreated(msg.arg1,
+ (ComponentName) msg.obj);
+ }
+ break;
+ }
case ON_TASK_REMOVED: {
for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
mTaskStackListeners.get(i).onTaskRemoved(msg.arg1);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java
index 69b0f31..368fa67 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsOnboarding.java
@@ -33,6 +33,7 @@
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -63,7 +64,6 @@
import com.android.systemui.recents.misc.SysUiTaskStackChangeListener;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.system.ActivityManagerWrapper;
-import com.android.systemui.shared.system.LauncherEventUtil;
import java.util.Collections;
import java.util.HashSet;
@@ -110,8 +110,19 @@
private int mOverviewOpenedCountSinceQuickScrubTipDismiss;
private final SysUiTaskStackChangeListener mTaskListener = new SysUiTaskStackChangeListener() {
+ private String mLastPackageName;
+
@Override
- public void onTaskStackChanged() {
+ public void onTaskCreated(int taskId, ComponentName componentName) {
+ onAppLaunch();
+ }
+
+ @Override
+ public void onTaskMovedToFront(int taskId) {
+ onAppLaunch();
+ }
+
+ private void onAppLaunch() {
ActivityManager.RunningTaskInfo info = ActivityManagerWrapper.getInstance()
.getRunningTask(ACTIVITY_TYPE_UNDEFINED /* ignoreActivityType */);
if (info == null) {
@@ -121,6 +132,10 @@
hide(true);
return;
}
+ if (info.baseActivity.getPackageName().equals(mLastPackageName)) {
+ return;
+ }
+ mLastPackageName = info.baseActivity.getPackageName();
int activityType = info.configuration.windowConfiguration.getActivityType();
if (activityType == ACTIVITY_TYPE_STANDARD) {
boolean alreadySeenSwipeUpOnboarding = hasSeenSwipeUpOnboarding();