summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-03-18 16:57:19 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-06-30 18:29:32 -0700
commit922eed5762f3253183726a5acb0edcd9a3f38fc4 (patch)
tree2b552c66efcbab4f21594d302823bef15de85594
parent5aa2fe13b5c5f7d34f653e70943b45e0231c5d09 (diff)
downloadandroid_packages_apps_Trebuchet-922eed5762f3253183726a5acb0edcd9a3f38fc4.tar.gz
android_packages_apps_Trebuchet-922eed5762f3253183726a5acb0edcd9a3f38fc4.tar.bz2
android_packages_apps_Trebuchet-922eed5762f3253183726a5acb0edcd9a3f38fc4.zip
Removing unused logging
> We store some local logs which are never propagated to the server and cause unnecessary file-io during app launch Change-Id: I2b41c3af182de2a87f38ad88f3bae9d250574c26 Bug: 19940630
-rw-r--r--src/com/android/launcher3/LauncherFiles.java9
-rw-r--r--src/com/android/launcher3/Stats.java142
2 files changed, 6 insertions, 145 deletions
diff --git a/src/com/android/launcher3/LauncherFiles.java b/src/com/android/launcher3/LauncherFiles.java
index fa053650f..8c0bf0f97 100644
--- a/src/com/android/launcher3/LauncherFiles.java
+++ b/src/com/android/launcher3/LauncherFiles.java
@@ -18,9 +18,7 @@ public class LauncherFiles {
public static final String DEFAULT_WALLPAPER_THUMBNAIL_OLD = "default_thumb.jpg";
public static final String LAUNCHER_DB = "launcher.db";
public static final String LAUNCHER_PREFERENCES = "launcher.preferences";
- public static final String LAUNCHES_LOG = "launches.log";
public static final String SHARED_PREFERENCES_KEY = "com.android.launcher3.prefs";
- public static final String STATS_LOG = "stats.log";
public static final String WALLPAPER_CROP_PREFERENCES_KEY =
WallpaperCropActivity.class.getName();
public static final String WALLPAPER_IMAGES_DB = "saved_wallpaper_images.db";
@@ -31,10 +29,13 @@ public class LauncherFiles {
DEFAULT_WALLPAPER_THUMBNAIL_OLD,
LAUNCHER_DB,
LAUNCHER_PREFERENCES,
- LAUNCHES_LOG,
SHARED_PREFERENCES_KEY + XML,
- STATS_LOG,
WALLPAPER_CROP_PREFERENCES_KEY + XML,
WALLPAPER_IMAGES_DB,
WIDGET_PREVIEWS_DB));
+
+ // TODO: Delete these files on upgrade
+ public static final List<String> OBSOLETE_FILES = Collections.unmodifiableList(Arrays.asList(
+ "launches.log",
+ "stats.log"));
}
diff --git a/src/com/android/launcher3/Stats.java b/src/com/android/launcher3/Stats.java
index 0a9807277..9d4842851 100644
--- a/src/com/android/launcher3/Stats.java
+++ b/src/com/android/launcher3/Stats.java
@@ -22,14 +22,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
-import java.io.*;
-import java.util.ArrayList;
-
public class Stats {
private static final boolean DEBUG_BROADCASTS = false;
- private static final String TAG = "Launcher3/Stats";
-
- private static final boolean LOCAL_LAUNCH_LOG = true;
public static final String ACTION_LAUNCH = "com.android.launcher3.action.LAUNCH";
public static final String EXTRA_INTENT = "intent";
@@ -54,54 +48,20 @@ public class Stats {
public static final String SUB_CONTAINER_ALL_APPS_PREDICTION = "prediction";
public static final String SUB_CONTAINER_ALL_APPS_SEARCH = "search";
- private static final int LOG_VERSION = 1;
- private static final int LOG_TAG_VERSION = 0x1;
- private static final int LOG_TAG_LAUNCH = 0x1000;
-
- private static final int STATS_VERSION = 1;
- private static final int INITIAL_STATS_SIZE = 100;
-
- // TODO: delayed/batched writes
- private static final boolean FLUSH_IMMEDIATELY = true;
-
private final Launcher mLauncher;
-
private final String mLaunchBroadcastPermission;
- DataOutputStream mLog;
-
- ArrayList<String> mIntents;
- ArrayList<Integer> mHistogram;
-
public Stats(Launcher launcher) {
mLauncher = launcher;
-
mLaunchBroadcastPermission =
launcher.getResources().getString(R.string.receive_launch_broadcasts_permission);
- loadStats();
-
- if (LOCAL_LAUNCH_LOG) {
- try {
- mLog = new DataOutputStream(mLauncher.openFileOutput(
- LauncherFiles.LAUNCHES_LOG, Context.MODE_APPEND));
- mLog.writeInt(LOG_TAG_VERSION);
- mLog.writeInt(LOG_VERSION);
- } catch (FileNotFoundException e) {
- Log.e(TAG, "unable to create stats log: " + e);
- mLog = null;
- } catch (IOException e) {
- Log.e(TAG, "unable to write to stats log: " + e);
- mLog = null;
- }
- }
-
if (DEBUG_BROADCASTS) {
launcher.registerReceiver(
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- android.util.Log.v("Stats", "got broadcast: " + intent + " for launched intent: "
+ Log.v("Stats", "got broadcast: " + intent + " for launched intent: "
+ intent.getStringExtra(EXTRA_INTENT));
}
},
@@ -112,16 +72,6 @@ public class Stats {
}
}
- public void incrementLaunch(String intentStr) {
- int pos = mIntents.indexOf(intentStr);
- if (pos < 0) {
- mIntents.add(intentStr);
- mHistogram.add(1);
- } else {
- mHistogram.set(pos, mHistogram.get(pos) + 1);
- }
- }
-
public void recordLaunch(Intent intent) {
recordLaunch(intent, null);
}
@@ -131,7 +81,6 @@ public class Stats {
intent.setSourceBounds(null);
final String flat = intent.toUri(0);
-
Intent broadcastIntent = new Intent(ACTION_LAUNCH).putExtra(EXTRA_INTENT, flat);
if (shortcut != null) {
broadcastIntent.putExtra(EXTRA_CONTAINER, shortcut.container)
@@ -140,94 +89,5 @@ public class Stats {
.putExtra(EXTRA_CELLY, shortcut.cellY);
}
mLauncher.sendBroadcast(broadcastIntent, mLaunchBroadcastPermission);
-
- incrementLaunch(flat);
-
- if (FLUSH_IMMEDIATELY) {
- saveStats();
- }
-
- if (LOCAL_LAUNCH_LOG && mLog != null) {
- try {
- mLog.writeInt(LOG_TAG_LAUNCH);
- mLog.writeLong(System.currentTimeMillis());
- 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
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- private void saveStats() {
- DataOutputStream stats = null;
- try {
- stats = new DataOutputStream(mLauncher.openFileOutput(
- LauncherFiles.STATS_LOG + ".tmp", Context.MODE_PRIVATE));
- stats.writeInt(STATS_VERSION);
- final int N = mHistogram.size();
- stats.writeInt(N);
- for (int i=0; i<N; i++) {
- stats.writeUTF(mIntents.get(i));
- stats.writeInt(mHistogram.get(i));
- }
- stats.close();
- stats = null;
- mLauncher.getFileStreamPath(LauncherFiles.STATS_LOG + ".tmp")
- .renameTo(mLauncher.getFileStreamPath(LauncherFiles.STATS_LOG));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "unable to create stats data: " + e);
- } catch (IOException e) {
- Log.e(TAG, "unable to write to stats data: " + e);
- } finally {
- if (stats != null) {
- try {
- stats.close();
- } catch (IOException e) { }
- }
- }
- }
-
- private void loadStats() {
- mIntents = new ArrayList<String>(INITIAL_STATS_SIZE);
- mHistogram = new ArrayList<Integer>(INITIAL_STATS_SIZE);
- DataInputStream stats = null;
- try {
- stats = new DataInputStream(mLauncher.openFileInput(LauncherFiles.STATS_LOG));
- final int version = stats.readInt();
- if (version == STATS_VERSION) {
- final int N = stats.readInt();
- for (int i=0; i<N; i++) {
- final String pkg = stats.readUTF();
- final int count = stats.readInt();
- mIntents.add(pkg);
- mHistogram.add(count);
- }
- }
- } catch (FileNotFoundException e) {
- // not a problem
- } catch (IOException e) {
- // more of a problem
-
- } finally {
- if (stats != null) {
- try {
- stats.close();
- } catch (IOException e) { }
- }
- }
}
}