mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 00:11:44 +00:00
Bug 822686 - Check for null BitmapDrawable for missing jar resources. r=mfinkle
This commit is contained in:
parent
77b7b0355d
commit
f7a27ec142
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user