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 { try {
builder.setLargeIcon(Futures.getDone(bitmapFuture)); builder.setLargeIcon(Futures.getDone(bitmapFuture));
} catch (ExecutionException e) { } catch (ExecutionException e) {
Log.w(TAG, "Failed to load bitmap", e); Log.w(TAG, getBitmapLoadErrorMessage(e));
} }
} else { } else {
pendingOnBitmapLoadedFutureCallback = pendingOnBitmapLoadedFutureCallback =
@ -634,7 +634,7 @@ public class DefaultMediaNotificationProvider implements MediaNotification.Provi
@Override @Override
public void onFailure(Throwable t) { public void onFailure(Throwable t) {
if (!discarded) { 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); 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 { try {
artworkBitmap = Futures.getDone(bitmapFuture); artworkBitmap = Futures.getDone(bitmapFuture);
} catch (ExecutionException e) { } catch (ExecutionException e) {
Log.w(TAG, "Failed to load bitmap", e); Log.w(TAG, getBitmapLoadErrorMessage(e));
} }
} else { } else {
pendingBitmapLoadCallback = pendingBitmapLoadCallback =
@ -1199,7 +1199,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
if (this != pendingBitmapLoadCallback) { if (this != pendingBitmapLoadCallback) {
return; return;
} }
Log.d(TAG, "Failed to load bitmap", t); Log.w(TAG, getBitmapLoadErrorMessage(t));
} }
}; };
Futures.addCallback( Futures.addCallback(
@ -1270,4 +1270,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
return hasMessages(MSG_DOUBLE_TAP_TIMED_OUT); return hasMessages(MSG_DOUBLE_TAP_TIMED_OUT);
} }
} }
private static String getBitmapLoadErrorMessage(Throwable throwable) {
return "Failed to load bitmap: " + throwable.getMessage();
}
} }