Dump widget state to bugreport

This might be helpful someday...

Change-Id: I5a9e0a2948c7ea9fa5c9a7da61d143c10dda7d9a
This commit is contained in:
Makoto Onuki 2011-01-19 14:21:35 -08:00
parent 985155fddd
commit dc200a44a9

View File

@ -58,8 +58,11 @@ import android.view.View;
import android.widget.RemoteViews;
import android.widget.RemoteViewsService;
import java.util.HashMap;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class WidgetProvider extends AppWidgetProvider {
private static final String TAG = "WidgetProvider";
@ -105,7 +108,8 @@ public class WidgetProvider extends AppWidgetProvider {
// Map holding our instantiated widgets, accessed by widget id
private static HashMap<Integer, EmailWidget> sWidgetMap = new HashMap<Integer, EmailWidget>();
private final static Map<Integer, EmailWidget> sWidgetMap
= new ConcurrentHashMap<Integer, EmailWidget>();
private static AppWidgetManager sWidgetManager;
private static Context sContext;
private static ContentResolver sResolver;
@ -145,6 +149,24 @@ public class WidgetProvider extends AppWidgetProvider {
}
return title;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("ViewType:selection=");
sb.append("\"");
sb.append(selection);
sb.append("\"");
if (selectionArgs != null && selectionArgs.length > 0) {
sb.append(",args=(");
for (String arg : selectionArgs) {
sb.append(arg);
sb.append(", ");
}
sb.append(")");
}
return sb.toString();
}
}
static class EmailWidget implements RemoteViewsService.RemoteViewsFactory {
@ -741,5 +763,14 @@ public class WidgetProvider extends AppWidgetProvider {
startActivity(Welcome.createOpenMessageIntent(this, mailbox.mAccountKey, mailboxId,
messageId));
}
@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
int n = 0;
for (EmailWidget widget : sWidgetMap.values()) {
writer.println("Widget #" + (++n));
writer.println(" ViewType=" + widget.mViewType);
}
}
}
}