return super.dumpProperties() + " componentName=" + componentName;
}
- /**
- * Helper method used for debugging.
- */
- public static void dumpApplicationInfoList(String tag, String label, ArrayList<AppInfo> list) {
- Log.d(tag, label + " size=" + list.size());
- for (AppInfo info: list) {
- Log.d(tag, " title=\"" + info.title + "\" iconBitmap=" + info.iconBitmap
- + " componentName=" + info.componentName.getPackageName());
- }
- }
-
public ShortcutInfo makeShortcut() {
return new ShortcutInfo(this);
}
import com.android.launcher3.util.ActivityResultInfo;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ItemInfoMatcher;
+import com.android.launcher3.util.LogConfig;
import com.android.launcher3.util.MultiHashMap;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.PackageUserKey;
*/
protected static final int REQUEST_LAST = 100;
- // To turn on these properties, type
- // adb shell setprop logTap.tag.PROPERTY_NAME [VERBOSE | SUPPRESS]
- static final String DUMP_STATE_PROPERTY = "launcher_dump_state";
-
// The Intent extra that defines whether to ignore the launch animation
static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION =
"com.android.launcher3.intent.extra.shortcut.INGORE_LAUNCH_ANIMATION";
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
- if (event.getAction() == KeyEvent.ACTION_DOWN) {
- switch (event.getKeyCode()) {
- case KeyEvent.KEYCODE_HOME:
- return true;
- case KeyEvent.KEYCODE_VOLUME_DOWN:
- if (Utilities.isPropertyEnabled(DUMP_STATE_PROPERTY)) {
- dumpState();
- return true;
- }
- break;
- }
- } else if (event.getAction() == KeyEvent.ACTION_UP) {
- switch (event.getKeyCode()) {
- case KeyEvent.KEYCODE_HOME:
- return true;
- }
- }
-
- return super.dispatchKeyEvent(event);
+ return (event.getKeyCode() == KeyEvent.KEYCODE_HOME) || super.dispatchKeyEvent(event);
}
@Override
}
/**
- * Prints out out state for debugging.
+ * $ adb shell dumpsys activity com.android.launcher3.Launcher [--all]
*/
- public void dumpState() {
- Log.d(TAG, "BEGIN launcher3 dump state for launcher " + this);
- Log.d(TAG, "mWorkspaceLoading=" + mWorkspaceLoading);
- Log.d(TAG, "mPendingRequestArgs=" + mPendingRequestArgs);
- Log.d(TAG, "mPendingActivityResult=" + mPendingActivityResult);
- mModel.dumpState();
- // TODO(hyunyoungs): add mWidgetsView.dumpState(); or mWidgetsModel.dumpState();
-
- Log.d(TAG, "END launcher3 dump state");
- }
-
@Override
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
super.dump(prefix, fd, writer, args);
- // Dump workspace
- writer.println(prefix + "Workspace Items");
- for (int i = mWorkspace.numCustomPages(); i < mWorkspace.getPageCount(); i++) {
- writer.println(prefix + " Homescreen " + i);
- ViewGroup layout = ((CellLayout) mWorkspace.getPageAt(i)).getShortcutsAndWidgets();
+ if (args.length > 0 && TextUtils.equals(args[0], "--all")) {
+ writer.println(prefix + "Workspace Items");
+ for (int i = mWorkspace.numCustomPages(); i < mWorkspace.getPageCount(); i++) {
+ writer.println(prefix + " Homescreen " + i);
+
+ ViewGroup layout = ((CellLayout) mWorkspace.getPageAt(i)).getShortcutsAndWidgets();
+ for (int j = 0; j < layout.getChildCount(); j++) {
+ Object tag = layout.getChildAt(j).getTag();
+ if (tag != null) {
+ writer.println(prefix + " " + tag.toString());
+ }
+ }
+ }
+
+ writer.println(prefix + " Hotseat");
+ ViewGroup layout = mHotseat.getLayout().getShortcutsAndWidgets();
for (int j = 0; j < layout.getChildCount(); j++) {
Object tag = layout.getChildAt(j).getTag();
if (tag != null) {
writer.println(prefix + " " + tag.toString());
}
}
- }
- writer.println(prefix + " Hotseat");
- ViewGroup layout = mHotseat.getLayout().getShortcutsAndWidgets();
- for (int j = 0; j < layout.getChildCount(); j++) {
- Object tag = layout.getChildAt(j).getTag();
- if (tag != null) {
- writer.println(prefix + " " + tag.toString());
+ try {
+ FileLog.flushAll(writer);
+ } catch (Exception e) {
+ // Ignore
}
}
- try {
- FileLog.flushAll(writer);
- } catch (Exception e) {
- // Ignore
- }
+ writer.println(prefix + "Misc:");
+ writer.print(prefix + "\tmWorkspaceLoading=" + mWorkspaceLoading);
+ writer.print(" mPendingRequestArgs=" + mPendingRequestArgs);
+ writer.println(" mPendingActivityResult=" + mPendingActivityResult);
+
+ mModel.dumpState(prefix, fd, writer, args);
if (mLauncherCallbacks != null) {
mLauncherCallbacks.dump(prefix, fd, writer, args);
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.ViewOnDrawExecutor;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.util.ArrayList;
}
bindDeepShortcuts();
}
-
- public void dumpState() {
- synchronized (sBgDataModel) {
- Log.d(TAG, "mLoaderTask.mContext=" + mContext);
- Log.d(TAG, "mLoaderTask.mStopped=" + mStopped);
- Log.d(TAG, "mLoaderTask.mLoadAndBindStepFinished=" + mLoadAndBindStepFinished);
- Log.d(TAG, "mItems size=" + sBgDataModel.workspaceItems.size());
- }
- }
}
public void bindDeepShortcuts() {
&& (provider.provider.getPackageName() != null);
}
- public void dumpState() {
- Log.d(TAG, "mCallbacks=" + mCallbacks);
- AppInfo.dumpApplicationInfoList(TAG, "mAllAppsList.data", mBgAllAppsList.data);
- AppInfo.dumpApplicationInfoList(TAG, "mAllAppsList.added", mBgAllAppsList.added);
- AppInfo.dumpApplicationInfoList(TAG, "mAllAppsList.removed", mBgAllAppsList.removed);
- AppInfo.dumpApplicationInfoList(TAG, "mAllAppsList.modified", mBgAllAppsList.modified);
- if (mLoaderTask != null) {
- mLoaderTask.dumpState();
- } else {
- Log.d(TAG, "mLoaderTask=null");
+ public void dumpState(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
+ if (args.length > 0 && TextUtils.equals(args[0], "--all")) {
+ writer.println(prefix + "All apps list: size=" + mBgAllAppsList.data.size());
+ for (AppInfo info : mBgAllAppsList.data) {
+ writer.println(prefix + " title=\"" + info.title + "\" iconBitmap=" + info.iconBitmap
+ + " componentName=" + info.componentName.getPackageName());
+ }
}
+ sBgDataModel.dump(prefix, fd, writer, args);
}
public Callbacks getCallback() {
import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.ComponentKey;
+import com.android.launcher3.util.LogConfig;
import java.util.List;
import java.util.Locale;
private static final String TAG = "UserEvent";
private static final boolean IS_VERBOSE =
- ProviderConfig.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(TAG);
+ ProviderConfig.IS_DOGFOOD_BUILD && Utilities.isPropertyEnabled(LogConfig.USEREVENT);
/**
* Implemented by containers to provide a container source for a given child.
import android.content.Context;
import android.os.UserHandle;
+import android.text.TextUtils;
import android.util.Log;
import android.util.MutableInt;
import com.android.launcher3.util.LongArrayMap;
import com.android.launcher3.util.MultiHashMap;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
deepShortcutMap.clear();
}
+ // TODO: current dump is very cryptic and hard to understand. Make it more legible.
+ public synchronized void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
+ writer.println(prefix + "Data Model:");
+ for (int i = 0; i < workspaceScreens.size(); i++) {
+ writer.println(prefix + "\tIndex of workspaceScreens:" + workspaceScreens.get(i).toString());
+ }
+ for (int i = 0; i < workspaceItems.size(); i++) {
+ writer.println(prefix + '\t' + workspaceItems.get(i).toString());
+ }
+ for (int i = 0; i < appWidgets.size(); i++) {
+ writer.println(prefix + '\t' + appWidgets.get(i).toString());
+ }
+ for (int i = 0; i< folders.size(); i++) {
+ writer.println(prefix + '\t' + folders.valueAt(i).toString());
+ }
+ for (int i = 0; i< itemsIdMap.size(); i++) {
+ writer.println(prefix + '\t' + itemsIdMap.valueAt(i).toString());
+ }
+
+ if (args.length > 0 && TextUtils.equals(args[0], "--all")) {
+ writer.println(prefix + "shortcuts");
+ for (ArrayList<String> map : deepShortcutMap.values()) {
+ writer.print(prefix + " ");
+ for (String str : map) {
+ writer.print(str.toString() + ", ");
+ }
+ writer.println();
+ }
+ }
+ }
+
public synchronized void removeItem(Context context, ItemInfo... items) {
removeItem(context, Arrays.asList(items));
}
import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.logging.FileLog;
+import com.android.launcher3.util.LogConfig;
import java.io.InvalidObjectException;
private static final String INFO_COLUMN_NAME = "name";
private static final String INFO_COLUMN_DEFAULT_VALUE = "dflt_value";
- /**
- * When enabled all icons are kept on the home screen, even if they don't have an active
- * session. To enable use:
- * adb shell setprop log.tag.launcher_keep_all_icons VERBOSE
- */
- private static final String KEEP_ALL_ICONS = "launcher_keep_all_icons";
-
public static boolean performRestore(DatabaseHelper helper) {
SQLiteDatabase db = helper.getWritableDatabase();
db.beginTransaction();
}
// Mark all items as restored.
- boolean keepAllIcons = Utilities.isPropertyEnabled(KEEP_ALL_ICONS);
+ boolean keepAllIcons = Utilities.isPropertyEnabled(LogConfig.KEEP_ALL_ICONS);
ContentValues values = new ContentValues();
values.put(Favorites.RESTORED, ShortcutInfo.FLAG_RESTORED_ICON
| (keepAllIcons ? ShortcutInfo.FLAG_RESTORE_STARTED : 0));
--- /dev/null
+package com.android.launcher3.util;
+
+/**
+ * This is a utility class that keeps track of all the tag that can be enabled to debug
+ * a behavior in runtime.
+ *
+ * To use any of the strings defined in this class, execute the following command.
+ *
+ * $ adb shell setprop log.tag.TAGNAME VERBOSE
+ */
+
+public class LogConfig {
+ // These are list of strings that can be used to replace TAGNAME.
+
+ /**
+ * After this tag is turned on, whenever there is n user event, debug information is
+ * printed out to logcat.
+ */
+ public static final String USEREVENT = "UserEvent";
+
+ /**
+ * When turned on, all icons are kept on the home screen, even if they don't have an active
+ * session.
+ */
+ public static final String KEEP_ALL_ICONS = "KeepAllIcons";
+
+ /**
+ * When turned on, icon cache is only fetched from memory and not disk.
+ */
+ public static final String MEMORY_ONLY_ICON_CACHE = "MemoryOnlyIconCache";
+}
private static final String TAG = "SQLiteCacheHelper";
private static final boolean NO_ICON_CACHE = ProviderConfig.IS_DOGFOOD_BUILD &&
- Utilities.isPropertyEnabled("MEMORY_ONLY_ICON_CACHE");
+ Utilities.isPropertyEnabled(LogConfig.MEMORY_ONLY_ICON_CACHE);
private final String mTableName;
private final MySQLiteOpenHelper mOpenHelper;