diff options
-rw-r--r-- | src/com/android/launcher3/AppsCustomizePagedView.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/Stats.java | 35 |
3 files changed, 28 insertions, 12 deletions
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java index dd870e402..4e9d68b50 100644 --- a/src/com/android/launcher3/AppsCustomizePagedView.java +++ b/src/com/android/launcher3/AppsCustomizePagedView.java @@ -500,6 +500,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen mPressedIcon.lockDrawableState(); } mLauncher.startActivitySafely(v, appInfo.intent, appInfo); + mLauncher.getStats().recordLaunch(appInfo.intent); } else if (v instanceof PagedViewWidget) { // Let the user know that they have to long press to add a widget if (mWidgetInstructionToast != null) { diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 102f4c272..8f0fddea9 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -634,6 +634,10 @@ public class Launcher extends Activity } } + public Stats getStats() { + return mStats; + } + public LayoutInflater getInflater() { return mInflater; } diff --git a/src/com/android/launcher3/Stats.java b/src/com/android/launcher3/Stats.java index ca088f71a..882fb04a3 100644 --- a/src/com/android/launcher3/Stats.java +++ b/src/com/android/launcher3/Stats.java @@ -103,20 +103,24 @@ public class Stats { } } + public void recordLaunch(Intent intent) { + recordLaunch(intent, null); + } + public void recordLaunch(Intent intent, ShortcutInfo shortcut) { intent = new Intent(intent); intent.setSourceBounds(null); final String flat = intent.toUri(0); - mLauncher.sendBroadcast( - new Intent(ACTION_LAUNCH) - .putExtra(EXTRA_INTENT, flat) - .putExtra(EXTRA_CONTAINER, shortcut.container) - .putExtra(EXTRA_SCREEN, shortcut.screenId) - .putExtra(EXTRA_CELLX, shortcut.cellX) - .putExtra(EXTRA_CELLY, shortcut.cellY), - PERM_LAUNCH); + Intent broadcastIntent = new Intent(ACTION_LAUNCH).putExtra(EXTRA_INTENT, flat); + if (shortcut != null) { + broadcastIntent.putExtra(EXTRA_CONTAINER, shortcut.container) + .putExtra(EXTRA_SCREEN, shortcut.screenId) + .putExtra(EXTRA_CELLX, shortcut.cellX) + .putExtra(EXTRA_CELLY, shortcut.cellY); + } + mLauncher.sendBroadcast(broadcastIntent, PERM_LAUNCH); incrementLaunch(flat); @@ -128,10 +132,17 @@ public class Stats { try { mLog.writeInt(LOG_TAG_LAUNCH); mLog.writeLong(System.currentTimeMillis()); - mLog.writeShort((short) shortcut.container); - mLog.writeShort((short) shortcut.screenId); - mLog.writeShort((short) shortcut.cellX); - mLog.writeShort((short) shortcut.cellY); + if (shortcut == null) { + mLog.writeShort(0); + mLog.writeShort(0); + mLog.writeShort(0); + mLog.writeShort(0); + } else { + mLog.writeShort((short) shortcut.container); + mLog.writeShort((short) shortcut.screenId); + mLog.writeShort((short) shortcut.cellX); + mLog.writeShort((short) shortcut.cellY); + } mLog.writeUTF(flat); if (FLUSH_IMMEDIATELY) { mLog.flush(); // TODO: delayed writes |