Bug 822686 - Check for null BitmapDrawable for missing jar resources. r=mfinkle

This commit is contained in:
Chris Peterson 2013-03-05 12:08:43 +00:00
parent 77b7b0355d
commit f7a27ec142
3 changed files with 10 additions and 9 deletions

View File

@ -241,8 +241,7 @@ public class Favicons {
// Runs in background thread
private Bitmap downloadFavicon(URL faviconUrl) {
if (mFaviconUrl.startsWith("jar:jar:")) {
BitmapDrawable d = GeckoJarReader.getBitmapDrawable(mContext.getResources(), mFaviconUrl);
return d.getBitmap();
return GeckoJarReader.getBitmap(mContext.getResources(), mFaviconUrl);
}
URI uri;

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.util;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;
@ -24,10 +25,15 @@ import java.util.zip.ZipInputStream;
* jar:jar:file:///data/app/org.mozilla.fennec.apk!/omni.ja!/chrome/chrome/content/branding/favicon32.png
*/
public final class GeckoJarReader {
private static String LOGTAG = "GeckoJarReader";
private static final String LOGTAG = "GeckoJarReader";
private GeckoJarReader() {}
public static Bitmap getBitmap(Resources resources, String url) {
BitmapDrawable drawable = getBitmapDrawable(resources, url);
return (drawable != null) ? drawable.getBitmap() : null;
}
public static BitmapDrawable getBitmapDrawable(Resources resources, String url) {
Stack<String> jarUrls = parseUrl(url);
InputStream inputStream = null;

View File

@ -1131,12 +1131,8 @@ public class BrowserProvider extends ContentProvider {
String apkPath = mContext.getPackageResourcePath();
File apkFile = new File(apkPath);
BitmapDrawable bitmapDrawable = GeckoJarReader.getBitmapDrawable(mContext.getResources(),
"jar:jar:" + apkFile.toURI() + "!/omni.ja!/" + path);
if (bitmapDrawable == null) {
return null;
}
return bitmapDrawable.getBitmap();
String bitmapPath = "jar:jar:" + apkFile.toURI() + "!/omni.ja!/" + path;
return GeckoJarReader.getBitmap(mContext.getResources(), bitmapPath);
} catch (java.lang.IllegalAccessException ex) {
Log.e(LOGTAG, "[Path] Can't create favicon " + name, ex);
} catch (java.lang.NoSuchFieldException ex) {