Tagging where ItemInfos are created for debug purposes

Change-Id: Iad3ed8ef4f81f4990c027ab46fd25b03b089babb
This commit is contained in:
Michael Jurka
2011-08-29 14:02:47 -07:00
parent fe1f9b0bd4
commit b60fd0eafb
12 changed files with 65 additions and 39 deletions
+2 -2
View File
@@ -91,7 +91,7 @@ class AllAppsList {
if (matches.size() > 0) {
for (ResolveInfo info : matches) {
add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null));
add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null, "15"));
}
}
}
@@ -142,7 +142,7 @@ class AllAppsList {
info.activityInfo.applicationInfo.packageName,
info.activityInfo.name);
if (applicationInfo == null) {
add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null));
add(new ApplicationInfo(context.getPackageManager(), info, mIconCache, null, "16"));
} else {
mIconCache.remove(applicationInfo.componentName);
mIconCache.getTitleAndIcon(applicationInfo, info, null);
@@ -60,7 +60,8 @@ class ApplicationInfo extends ItemInfo {
int flags = 0;
ApplicationInfo() {
ApplicationInfo(String whereCreated) {
super(whereCreated);
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
}
@@ -68,7 +69,8 @@ class ApplicationInfo extends ItemInfo {
* Must not hold the Context.
*/
public ApplicationInfo(PackageManager pm, ResolveInfo info, IconCache iconCache,
HashMap<Object, CharSequence> labelCache) {
HashMap<Object, CharSequence> labelCache, String whereCreated) {
super(whereCreated);
final String packageName = info.activityInfo.applicationInfo.packageName;
this.componentName = new ComponentName(packageName, info.activityInfo.name);
@@ -93,8 +95,8 @@ class ApplicationInfo extends ItemInfo {
iconCache.getTitleAndIcon(this, info, labelCache);
}
public ApplicationInfo(ApplicationInfo info) {
super(info);
public ApplicationInfo(ApplicationInfo info, String whereCreated) {
super(info, whereCreated);
componentName = info.componentName;
title = info.title.toString();
intent = new Intent(info.intent);
@@ -133,6 +135,6 @@ class ApplicationInfo extends ItemInfo {
}
public ShortcutInfo makeShortcut() {
return new ShortcutInfo(this);
return new ShortcutInfo(this, "18");
}
}
@@ -1016,7 +1016,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
if (rawInfo instanceof AppWidgetProviderInfo) {
// Fill in the widget information
AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo;
createItemInfo = new PendingAddWidgetInfo(info, null, null);
createItemInfo = new PendingAddWidgetInfo(info, null, null, "13");
int[] cellSpans = CellLayout.rectToCell(getResources(),
info.minWidth, info.minHeight, null);
FastBitmapDrawable preview = new FastBitmapDrawable(data.generatedImages.get(i));
@@ -1026,7 +1026,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
} else if (rawInfo instanceof ResolveInfo) {
// Fill in the shortcuts information
ResolveInfo info = (ResolveInfo) rawInfo;
createItemInfo = new PendingAddItemInfo();
createItemInfo = new PendingAddItemInfo("14");
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
createItemInfo.componentName = new ComponentName(info.activityInfo.packageName,
info.activityInfo.name);
+2 -1
View File
@@ -42,7 +42,8 @@ class FolderInfo extends ItemInfo {
ArrayList<FolderListener> listeners = new ArrayList<FolderListener>();
FolderInfo() {
FolderInfo(String whereCreated) {
super(whereCreated);
itemType = LauncherSettings.Favorites.ITEM_TYPE_FOLDER;
}
@@ -187,7 +187,7 @@ public class InstallWidgetReceiver {
final AppWidgetProviderInfo widgetInfo = mActivities.get(which).widgetInfo;
final PendingAddWidgetInfo createInfo = new PendingAddWidgetInfo(widgetInfo, mMimeType,
mClipData);
mClipData, "4");
mLauncher.addAppWidgetFromDrop(createInfo, LauncherSettings.Favorites.CONTAINER_DESKTOP,
mTargetLayoutScreen, null, mTargetLayoutPos);
}
+9 -2
View File
@@ -86,10 +86,16 @@ class ItemInfo {
*/
int[] dropPos = null;
ItemInfo() {
/*
* A tag to know where this item was created
*/
String whereCreated;
ItemInfo(String whereCreated) {
this.whereCreated = whereCreated;
}
ItemInfo(ItemInfo info) {
ItemInfo(ItemInfo info, String whereCreated) {
id = info.id;
cellX = info.cellX;
cellY = info.cellY;
@@ -98,6 +104,7 @@ class ItemInfo {
screen = info.screen;
itemType = info.itemType;
container = info.container;
this.whereCreated = whereCreated;
}
/**
+3 -3
View File
@@ -176,7 +176,7 @@ public final class Launcher extends Activity
private AppWidgetManager mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
private ItemInfo mPendingAddInfo = new ItemInfo();
private ItemInfo mPendingAddInfo = new ItemInfo("1");
private int[] mTmpAddItemCellCoordinates = new int[2];
private FolderInfo mFolderInfo;
@@ -930,7 +930,7 @@ public final class Launcher extends Activity
}
// Build Launcher-specific widget info and save to database
LauncherAppWidgetInfo launcherInfo = new LauncherAppWidgetInfo(appWidgetId);
LauncherAppWidgetInfo launcherInfo = new LauncherAppWidgetInfo(appWidgetId, "2");
launcherInfo.spanX = spanXY[0];
launcherInfo.spanY = spanXY[1];
@@ -1474,7 +1474,7 @@ public final class Launcher extends Activity
FolderIcon addFolder(CellLayout layout, long container, final int screen, int cellX,
int cellY) {
final FolderInfo folderInfo = new FolderInfo();
final FolderInfo folderInfo = new FolderInfo("3");
folderInfo.title = getText(R.string.folder_name);
// Update the model
@@ -51,7 +51,8 @@ class LauncherAppWidgetInfo extends ItemInfo {
/**
* Constructor for use with AppWidgets that haven't been instantiated yet.
*/
LauncherAppWidgetInfo(ComponentName providerName) {
LauncherAppWidgetInfo(ComponentName providerName, String whereCreated) {
super(whereCreated);
itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
this.providerName = providerName;
@@ -61,7 +62,8 @@ class LauncherAppWidgetInfo extends ItemInfo {
spanY = -1;
}
LauncherAppWidgetInfo(int appWidgetId) {
LauncherAppWidgetInfo(int appWidgetId, String whereCreated) {
super(whereCreated);
itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
this.appWidgetId = appWidgetId;
}
+19 -13
View File
@@ -210,8 +210,10 @@ public class LauncherModel extends BroadcastReceiver {
// the modelItem needs to match up perfectly with item if our model is to be
// consistent with the database-- for now, just require modelItem == item
String msg = "item: " + ((item != null) ? item.toString() : "null") +
"modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") +
"Error: ItemInfo passed to moveItemInDatabase doesn't match original";
" modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") +
" creation tag of item: " + ((item != null) ? item.whereCreated : "null") +
" creation tag of modelItem: " + ((modelItem != null) ? modelItem.whereCreated : "null") +
" Error: ItemInfo passed to moveItemInDatabase doesn't match original";
throw new RuntimeException(msg);
}
@@ -258,8 +260,10 @@ public class LauncherModel extends BroadcastReceiver {
// the modelItem needs to match up perfectly with item if our model is to be
// consistent with the database-- for now, just require modelItem == item
String msg = "item: " + ((item != null) ? item.toString() : "null") +
"modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") +
"Error: ItemInfo passed to resizeItemInDatabase doesn't match original";
" modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") +
" creation tag of item: " + ((item != null) ? item.whereCreated : "null") +
" creation tag of modelItem: " + ((modelItem != null) ? modelItem.whereCreated : "null") +
" Error: ItemInfo passed to resizeItemInDatabase doesn't match original";
throw new RuntimeException(msg);
}
}
@@ -306,7 +310,7 @@ public class LauncherModel extends BroadcastReceiver {
try {
while (c.moveToNext()) {
ItemInfo item = new ItemInfo();
ItemInfo item = new ItemInfo("17");
item.cellX = c.getInt(cellXIndex);
item.cellY = c.getInt(cellYIndex);
item.spanX = c.getInt(spanXIndex);
@@ -470,8 +474,10 @@ public class LauncherModel extends BroadcastReceiver {
// the modelItem needs to match up perfectly with item if our model is to be
// consistent with the database-- for now, just require modelItem == item
String msg = "item: " + ((item != null) ? item.toString() : "null") +
"modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") +
"Error: ItemInfo passed to updateItemInDatabase doesn't match original";
" modelItem: " + ((modelItem != null) ? modelItem.toString() : "null") +
" creation tag of item: " + ((item != null) ? item.whereCreated : "null") +
" creation tag of modelItem: " + ((modelItem != null) ? modelItem.whereCreated : "null") +
" Error: ItemInfo passed to updateItemInDatabase doesn't match original";
throw new RuntimeException(msg);
}
}
@@ -1059,7 +1065,7 @@ public class LauncherModel extends BroadcastReceiver {
+ id + " appWidgetId=" + appWidgetId);
itemsToRemove.add(id);
} else {
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId);
appWidgetInfo = new LauncherAppWidgetInfo(appWidgetId, "5");
appWidgetInfo.id = id;
appWidgetInfo.screen = c.getInt(screenIndex);
appWidgetInfo.cellX = c.getInt(cellXIndex);
@@ -1345,7 +1351,7 @@ public class LauncherModel extends BroadcastReceiver {
for (int j=0; i<N && j<batchSize; j++) {
// This builds the icon bitmaps.
mAllAppsList.add(new ApplicationInfo(packageManager, apps.get(i),
mIconCache, mLabelCache));
mIconCache, mLabelCache, "6"));
i++;
}
@@ -1541,7 +1547,7 @@ public class LauncherModel extends BroadcastReceiver {
public ShortcutInfo getShortcutInfo(PackageManager manager, Intent intent, Context context,
Cursor c, int iconIndex, int titleIndex, HashMap<Object, CharSequence> labelCache) {
Bitmap icon = null;
final ShortcutInfo info = new ShortcutInfo();
final ShortcutInfo info = new ShortcutInfo("7");
ComponentName componentName = intent.getComponent();
if (componentName == null) {
@@ -1606,7 +1612,7 @@ public class LauncherModel extends BroadcastReceiver {
int titleIndex) {
Bitmap icon = null;
final ShortcutInfo info = new ShortcutInfo();
final ShortcutInfo info = new ShortcutInfo("8");
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
// TODO: If there's an explicit component and we can't install that, delete it.
@@ -1765,7 +1771,7 @@ public class LauncherModel extends BroadcastReceiver {
}
}
final ShortcutInfo info = new ShortcutInfo();
final ShortcutInfo info = new ShortcutInfo("9");
if (icon == null) {
if (fallbackIcon != null) {
@@ -1833,7 +1839,7 @@ public class LauncherModel extends BroadcastReceiver {
FolderInfo folderInfo = folders.get(id);
if (folderInfo == null) {
// No placeholder -- create a new instance
folderInfo = new FolderInfo();
folderInfo = new FolderInfo("10");
folders.put(id, folderInfo);
}
return folderInfo;
@@ -28,6 +28,10 @@ class PendingAddItemInfo extends ItemInfo {
* The component that will be created.
*/
ComponentName componentName;
public PendingAddItemInfo(String whereCreated) {
super(whereCreated);
}
}
class PendingAddWidgetInfo extends PendingAddItemInfo {
@@ -39,7 +43,9 @@ class PendingAddWidgetInfo extends PendingAddItemInfo {
String mimeType;
Parcelable configurationData;
public PendingAddWidgetInfo(AppWidgetProviderInfo i, String dataMimeType, Parcelable data) {
public PendingAddWidgetInfo(
AppWidgetProviderInfo i, String dataMimeType, Parcelable data, String whereCreated) {
super(whereCreated);
itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
componentName = i.provider;
minWidth = i.minWidth;
+7 -5
View File
@@ -62,12 +62,14 @@ class ShortcutInfo extends ItemInfo {
*/
private Bitmap mIcon;
ShortcutInfo() {
ShortcutInfo(String whereCreated) {
super(whereCreated);
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
this.whereCreated = whereCreated;
}
public ShortcutInfo(ShortcutInfo info) {
super(info);
public ShortcutInfo(ShortcutInfo info, String whereCreated) {
super(info, whereCreated);
title = info.title.toString();
intent = new Intent(info.intent);
if (info.iconResource != null) {
@@ -80,8 +82,8 @@ class ShortcutInfo extends ItemInfo {
}
/** TODO: Remove this. It's only called by ApplicationInfo.makeShortcut. */
public ShortcutInfo(ApplicationInfo info) {
super(info);
public ShortcutInfo(ApplicationInfo info, String whereCreated) {
super(info, whereCreated);
title = info.title.toString();
intent = new Intent(info.intent);
customIcon = false;
+2 -2
View File
@@ -2575,7 +2575,7 @@ public class Workspace extends SmoothPagedView
// that widget
final AppWidgetProviderInfo widgetInfo = widgets.get(0).widgetInfo;
final PendingAddWidgetInfo createInfo =
new PendingAddWidgetInfo(widgetInfo, mimeType, data);
new PendingAddWidgetInfo(widgetInfo, mimeType, data, "11");
mLauncher.addAppWidgetFromDrop(createInfo,
LauncherSettings.Favorites.CONTAINER_DESKTOP, mCurrentPage, null, pos);
} else {
@@ -3091,7 +3091,7 @@ public class Workspace extends SmoothPagedView
case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
if (info.container == NO_ID && info instanceof ApplicationInfo) {
// Came from all apps -- make a copy
info = new ShortcutInfo((ApplicationInfo) info);
info = new ShortcutInfo((ApplicationInfo) info, "12");
}
view = mLauncher.createShortcut(R.layout.application, cellLayout,
(ShortcutInfo) info);