Merge "Don't try caching null ringtones." into nyc-dev

This commit is contained in:
Jeff Sharkey
2016-02-24 16:55:36 +00:00
committed by Android (Google) Code Review

View File

@@ -663,13 +663,15 @@ public class RingtoneManager {
// Stream selected ringtone into cache so it's available for playback
// when CE storage is still locked
final ContentResolver cr = context.getContentResolver();
final Uri cacheUri = getCacheForType(type);
try (InputStream in = cr.openInputStream(ringtoneUri);
OutputStream out = cr.openOutputStream(cacheUri)) {
Streams.copy(in, out);
} catch (IOException e) {
Log.w(TAG, "Failed to cache ringtone: " + e);
if (ringtoneUri != null) {
final ContentResolver cr = context.getContentResolver();
final Uri cacheUri = getCacheForType(type);
try (InputStream in = cr.openInputStream(ringtoneUri);
OutputStream out = cr.openOutputStream(cacheUri)) {
Streams.copy(in, out);
} catch (IOException e) {
Log.w(TAG, "Failed to cache ringtone: " + e);
}
}
}