Reduce log output for failing bitmap loads

Do not log the exception stack traces raised by the BitmapLoader when a
bitmap fails to load, e.g. when the artwork's URI scheme is not
supported by the SimpleBitmapLoader. The logs are kept in place but only
a single line is printed.

#minor-release

PiperOrigin-RevId: 492191461
This commit is contained in:
christosts 2022-12-01 15:33:00 +00:00 committed by Ian Baker
parent e4fb663b23
commit f768ff970c
2 changed files with 12 additions and 4 deletions

View File

@ -332,7 +332,7 @@ public class DefaultMediaNotificationProvider implements MediaNotification.Provi
try {
builder.setLargeIcon(Futures.getDone(bitmapFuture));
} catch (ExecutionException e) {
Log.w(TAG, "Failed to load bitmap", e);
Log.w(TAG, getBitmapLoadErrorMessage(e));
}
} else {
pendingOnBitmapLoadedFutureCallback =
@ -634,7 +634,7 @@ public class DefaultMediaNotificationProvider implements MediaNotification.Provi
@Override
public void onFailure(Throwable t) {
if (!discarded) {
Log.d(TAG, "Failed to load bitmap", t);
Log.w(TAG, getBitmapLoadErrorMessage(t));
}
}
}
@ -655,4 +655,8 @@ public class DefaultMediaNotificationProvider implements MediaNotification.Provi
notificationManager.createNotificationChannel(channel);
}
}
private static String getBitmapLoadErrorMessage(Throwable throwable) {
return "Failed to load bitmap: " + throwable.getMessage();
}
}

View File

@ -1177,7 +1177,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
try {
artworkBitmap = Futures.getDone(bitmapFuture);
} catch (ExecutionException e) {
Log.w(TAG, "Failed to load bitmap", e);
Log.w(TAG, getBitmapLoadErrorMessage(e));
}
} else {
pendingBitmapLoadCallback =
@ -1199,7 +1199,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
if (this != pendingBitmapLoadCallback) {
return;
}
Log.d(TAG, "Failed to load bitmap", t);
Log.w(TAG, getBitmapLoadErrorMessage(t));
}
};
Futures.addCallback(
@ -1270,4 +1270,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
return hasMessages(MSG_DOUBLE_TAP_TIMED_OUT);
}
}
private static String getBitmapLoadErrorMessage(Throwable throwable) {
return "Failed to load bitmap: " + throwable.getMessage();
}
}