private Widget packWidget(int dpi,WidgetPreviewLoader previewLoader,IconCache iconCache,ComponentName provider){
  final AppWidgetProviderInfo info=findAppWidgetProviderInfo(provider);
  Widget widget=new Widget();
  widget.provider=provider.flattenToShortString();
  widget.label=info.label;
  widget.configure=info.configure != null;
  if (info.icon != 0) {
    widget.icon=new Resource();
    Drawable fullResIcon=iconCache.getFullResIcon(provider.getPackageName(),info.icon);
    Bitmap icon=Utilities.createIconBitmap(fullResIcon,mContext);
    ByteArrayOutputStream os=new ByteArrayOutputStream();
    if (icon.compress(IMAGE_FORMAT,IMAGE_COMPRESSION_QUALITY,os)) {
      widget.icon.data=os.toByteArray();
      widget.icon.dpi=dpi;
    }
  }
  if (info.previewImage != 0) {
    widget.preview=new Resource();
    Bitmap preview=previewLoader.generateWidgetPreview(info,null);
    ByteArrayOutputStream os=new ByteArrayOutputStream();
    if (preview.compress(IMAGE_FORMAT,IMAGE_COMPRESSION_QUALITY,os)) {
      widget.preview.data=os.toByteArray();
      widget.preview.dpi=dpi;
    }
  }
  return widget;
}

private Widget packWidget ( int dpi , WidgetPreviewLoader previewLoader , IconCache iconCache , ComponentName provider ) { final AppWidgetProviderInfo info = findAppWidgetProviderInfo ( provider ) ; Widget widget = new Widget ( ) ; widget . provider = provider . flattenToShortString ( ) ; widget . label = info . label ; widget . configure = info . configure != null ; if ( info . icon != 0 ) { widget . icon = new Resource ( ) ; Drawable fullResIcon = iconCache . getFullResIcon ( provider . getPackageName ( ) , info . icon ) ; Bitmap icon = Utilities . createIconBitmap ( fullResIcon , mContext ) ; ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; if ( icon . compress ( IMAGE_FORMAT , IMAGE_COMPRESSION_QUALITY , os ) ) { widget . icon . data = os . toByteArray ( ) ; widget . icon . dpi = dpi ; } } if ( info . previewImage != 0 ) { widget . preview = new Resource ( ) ; Bitmap preview = previewLoader . generateWidgetPreview ( info , null ) ; ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; if ( preview . compress ( IMAGE_FORMAT , IMAGE_COMPRESSION_QUALITY , os ) ) { widget . preview . data = os . toByteArray ( ) ; widget . preview . dpi = dpi ; } } return widget ; }
serialize a widget for persistence , including a checksum wrapper .
