prevent crash if installing app without icon (closes #1006)
Right now, org.fdroid.fdroid.privileged.ota and FFupdater do not
provide any icons and it seems that that triggers this crash:
ACRA caught a NullPointerException for org.fdroid.fdroid
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.lastIndexOf(int)' on a null object reference
at org.fdroid.fdroid.FDroidApp$5.generate(FDroidApp.java:282)
at com.nostra13.universalimageloader.cache.disc.impl.BaseDiskCache.getFile(BaseDiskCache.java:167)
at com.nostra13.universalimageloader.cache.disc.impl.BaseDiskCache.get(BaseDiskCache.java:98)
at com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache.get(LimitedAgeDiskCache.java:74)
at com.nostra13.universalimageloader.utils.DiskCacheUtils.findInCache(DiskCacheUtils.java:36)
at org.fdroid.fdroid.NotificationHelper.getLargeIconForEntry(NotificationHelper.java:506)
at org.fdroid.fdroid.NotificationHelper.createUpdateNotification(NotificationHelper.java:300)
at org.fdroid.fdroid.NotificationHelper.createNotification(NotificationHelper.java:191)
at org.fdroid.fdroid.NotificationHelper.access$400(NotificationHelper.java:37)
at org.fdroid.fdroid.NotificationHelper$1.onReceive(NotificationHelper.java:106)
at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
This commit is contained in:
parent
5e031a5ac1
commit
4e375ca7f8
@ -279,7 +279,11 @@ public class FDroidApp extends Application {
|
||||
new FileNameGenerator() {
|
||||
@Override
|
||||
public String generate(String imageUri) {
|
||||
return imageUri.substring(imageUri.lastIndexOf('/') + 1);
|
||||
if (TextUtils.isEmpty(imageUri)) {
|
||||
return "null";
|
||||
} else {
|
||||
return imageUri.substring(imageUri.lastIndexOf('/') + 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 30 days in secs: 30*24*60*60 = 2592000
|
||||
|
||||
@ -18,6 +18,7 @@ import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.StyleSpan;
|
||||
import android.view.View;
|
||||
|
||||
@ -494,7 +495,9 @@ class NotificationHelper {
|
||||
private Bitmap getLargeIconForEntry(AppUpdateStatusManager.AppUpdateStatus entry) {
|
||||
final Point largeIconSize = getLargeIconSize();
|
||||
Bitmap iconLarge = null;
|
||||
if (entry.status == AppUpdateStatusManager.Status.Downloading || entry.status == AppUpdateStatusManager.Status.Installing) {
|
||||
if (TextUtils.isEmpty(entry.app.iconUrl)) {
|
||||
return null;
|
||||
} else if (entry.status == AppUpdateStatusManager.Status.Downloading || entry.status == AppUpdateStatusManager.Status.Installing) {
|
||||
Bitmap bitmap = Bitmap.createBitmap(largeIconSize.x, largeIconSize.y, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
Drawable downloadIcon = ContextCompat.getDrawable(context, R.drawable.ic_notification_download);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user