Adding debug code for LauncherModel crash
Change-Id: I9b8c053707cd5714874006c249651a69378569d2
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java
index ddc4b9f..c5bed16 100644
--- a/src/com/android/launcher2/BubbleTextView.java
+++ b/src/com/android/launcher2/BubbleTextView.java
@@ -111,6 +111,14 @@
}
@Override
+ public void setTag(Object tag) {
+ if (tag != null) {
+ LauncherModel.checkItemInfo((ItemInfo) tag);
+ }
+ super.setTag(tag);
+ }
+
+ @Override
protected void drawableStateChanged() {
if (isPressed()) {
// In this case, we have already created the pressed outline on ACTION_DOWN,
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index bada5cb..520d3f4 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -208,6 +208,33 @@
}
}
+ static void checkItemInfo(final ItemInfo item) {
+ final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
+ final long itemId = item.id;
+ Runnable r = new Runnable() {
+ public void run() {
+ ItemInfo modelItem = sItemsIdMap.get(itemId);
+ if (item != modelItem) {
+ // 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 checkItemInfo doesn't match original";
+ RuntimeException e = new RuntimeException(msg);
+ e.setStackTrace(stackTrace);
+ throw e;
+ }
+ }
+ };
+
+ if (sWorkerThread.getThreadId() == Process.myTid()) {
+ r.run();
+ } else {
+ sWorker.post(r);
+ }
+
+ }
+
static void updateItemInDatabaseHelper(Context context, final ContentValues values,
final ItemInfo item, final String callingFunction) {
final long itemId = item.id;
@@ -304,7 +331,7 @@
values.put(LauncherSettings.Favorites.SPANY, item.spanY);
values.put(LauncherSettings.Favorites.SCREEN, item.screen);
- updateItemInDatabaseHelper(context, values, item, "moveItemInDatabase");
+ updateItemInDatabaseHelper(context, values, item, "modifyItemInDatabase");
}
/**