Buggy code:
public class MozAppsPlugin extends Plugin { private static final String TAG = "MozAppsPlugin" ; @ Override public PluginResult execute ( String action , JSONArray data , String callback ) { } public boolean isSynch ( String action ) { } public synchronized PluginResult install ( final String callbackId , final String manifestUri , final JSONObject install_data , final String origin , final int installed ) throws Exception { ctx . runOnUiThread ( new Runnable ( ) { public void run ( ) { ctx . showDialog ( DIALOG_LOADING_ID ) ; final Uri installOriginUri = Uri . parse ( webView . getUrl ( ) ) ; new Thread ( new Runnable ( ) { public void run ( ) { Looper . prepare ( ) ; JSONObject manifest = HttpFactory . getManifest ( ctx , manifestUri ) ; Log . d ( MozAppsPlugin . TAG , ( "Parsed<seq2seq4repair_space>manifest:<seq2seq4repair_space>" + manifest ) ) ; if ( manifest == null ) { ctx . dismissDialog ( DIALOG_LOADING_ID ) ; JSONObject errorEvent = null ; try { errorEvent = new JSONObject ( ) . put ( "message" , "NETWORK_ERROR" ) ; } catch ( JSONException e ) { } Toast . makeText ( ctx , ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>reach<seq2seq4repair_space>" + ( Uri . parse ( manifestUri ) . getHost ( ) ) ) , LENGTH_SHORT ) . show ( ) ; error ( new PluginResult ( Status . ERROR , errorEvent ) , callbackId ) ; Looper . loop ( ) ; return ; } final ContentValues values = new ContentValues ( ) ; final String name = manifest . optString ( "name" , "No<seq2seq4repair_space>Name" ) ; final String description = manifest . optString ( "description" , "" ) ; values . put ( NAME , name ) ; values . put ( DESCRIPTION , description ) ; <START_BUG> final Bitmap bitmap = Apps . fetchIconByApp ( origin , manifest ) ; <END_BUG> if ( bitmap != null ) { values . put ( ICON , ImageFactory . bitmapToBytes ( bitmap ) ) ; } else { Log . w ( MozAppsPlugin . TAG , "Could<seq2seq4repair_space>not<seq2seq4repair_space>load<seq2seq4repair_space>icon" ) ; } values . put ( ORIGIN , origin ) ; values . put ( MANIFEST_URL , manifestUri ) ; values . put ( MANIFEST , manifest . toString ( ) ) ; String installOrigin = ( ( installOriginUri . getScheme ( ) ) + ":////" ) + ( installOriginUri . getAuthority ( ) ) ; values . put ( INSTALL_ORIGIN , installOrigin ) ; if ( install_data != null ) { values . put ( INSTALL_DATA , install_data . toString ( ) ) ; if ( install_data . has ( "receipt" ) ) { values . put ( INSTALL_RECEIPT , install_data . optString ( "receipt" ) ) ; } } final String launchUri = origin + ( manifest . optString ( "launch_path" , "//" ) ) ; SharedPreferences prefs = PreferenceManager . getDefaultSharedPreferences ( ctx ) ; final boolean [ ] appSettings = new boolean [ ] { prefs . getBoolean ( "install_shortcut" , true ) , prefs . getBoolean ( "install_launch" , true ) } ; ctx . dismissDialog ( DIALOG_LOADING_ID ) ; AlertDialog . Builder installDlg = new AlertDialog . Builder ( ctx ) ; String title = ( "Install<seq2seq4repair_space>" + name ) + "?" ; if ( installed != 0 ) { title = ( "Update<seq2seq4repair_space>" + name ) + "?" ; } installDlg . setTitle ( title ) . setMultiChoiceItems ( install_dialog_array , appSettings , new DialogInterface . OnMultiChoiceClickListener ( ) { public void onClick ( DialogInterface dialog , int whichButton , boolean isChecked ) { appSettings [ whichButton ] = isChecked ; } } ) . setCancelable ( true ) ; if ( bitmap != null ) { installDlg . setIcon ( new android . graphics . drawable . BitmapDrawable ( bitmap ) ) ; } installDlg . setNegativeButton ( cancel , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { JSONObject errorEvent = null ; try { errorEvent = new JSONObject ( ) . put ( "message" , "DENIED" ) . put ( "message" , "denied" ) ; } catch ( JSONException e ) { } error ( new PluginResult ( Status . ERROR , errorEvent ) , callbackId ) ; } } ) . setPositiveButton ( ok , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { Uri uri = null ; if ( installed != 0 ) { values . put ( STATUS , OK . ordinal ( ) ) ; } try { if ( installed != 0 ) { uri = ContentUris . withAppendedId ( CONTENT_URI , installed ) ; ctx . getContentResolver ( ) . update ( uri , values , null , null ) ; } else { uri = ctx . getContentResolver ( ) . insert ( CONTENT_URI , values ) ; } } catch ( Exception e ) { Log . e ( MozAppsPlugin . TAG , ( "Installation<seq2seq4repair_space>failed<seq2seq4repair_space>for<seq2seq4repair_space>" + values ) , e ) ; Toast . makeText ( ctx , "Installation<seq2seq4repair_space>flopped.<seq2seq4repair_space>Please<seq2seq4repair_space>try<seq2seq4repair_space>again!" , LENGTH_SHORT ) ; } if ( uri == null ) { JSONObject errorEvent = null ; try { errorEvent = new JSONObject ( ) . put ( "message" , "DENIED" ) ; } catch ( JSONException e ) { } error ( new PluginResult ( Status . ERROR , errorEvent ) , callbackId ) ; return ; } success ( new PluginResult ( Status . OK , 0 ) , callbackId ) ; Intent shortcutIntent = new Intent ( ctx , AppActivity . class ) ; shortcutIntent . setAction ( ACTION_WEBAPP ) ; shortcutIntent . addFlags ( FLAG_ACTIVITY_NEW_TASK ) ; shortcutIntent . putExtra ( "uri" , launchUri ) ; ( ( org . mozilla . labs . Soup . app . SoupApplication ) ( ctx . getApplication ( ) ) ) . triggerSync ( ) ;

Fix:
final Bitmap bitmap = Apps . fetchIconByApp ( ctx , origin , manifest ) ;