am c08ed337: am e539a197: Merge "Dump widget state to bugreport" into honeycomb

* commit 'c08ed337262289ee6739a71999819d7b2d09ec34':
  Dump widget state to bugreport
This commit is contained in:
Makoto Onuki 2011-01-19 14:41:31 -08:00 committed by Android Git Automerger
commit 2e91266295

View File

@ -59,8 +59,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";
@ -106,7 +109,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;
@ -147,6 +151,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();
}
public String getSelection(Context context) {
// For "all inbox", we define a special selection
if (this == ViewType.ALL_INBOX) {
@ -776,5 +798,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);
}
}
}
}