am 1102e712: Merge "Throw IOException when missing default ringtone." into lmp-mr1-dev
automerge: 8650c35
* commit '8650c358fb44b943dd74751742333bf1cebf7b8e':
Throw IOException when missing default ringtone.
This commit is contained in:
@@ -61,6 +61,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@@ -979,6 +980,9 @@ public class MediaPlayer implements SubtitleController.Listener
|
|||||||
// Redirect ringtones to go directly to underlying provider
|
// Redirect ringtones to go directly to underlying provider
|
||||||
uri = RingtoneManager.getActualDefaultRingtoneUri(context,
|
uri = RingtoneManager.getActualDefaultRingtoneUri(context,
|
||||||
RingtoneManager.getDefaultType(uri));
|
RingtoneManager.getDefaultType(uri));
|
||||||
|
if (uri == null) {
|
||||||
|
throw new FileNotFoundException("Failed to resolve default ringtone");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetFileDescriptor fd = null;
|
AssetFileDescriptor fd = null;
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ public class Ringtone {
|
|||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final AudioManager mAudioManager;
|
private final AudioManager mAudioManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag indicating if we're allowed to fall back to remote playback using
|
||||||
|
* {@link #mRemotePlayer}. Typically this is false when we're the remote
|
||||||
|
* player and there is nobody else to delegate to.
|
||||||
|
*/
|
||||||
private final boolean mAllowRemote;
|
private final boolean mAllowRemote;
|
||||||
private final IRingtonePlayer mRemotePlayer;
|
private final IRingtonePlayer mRemotePlayer;
|
||||||
private final Binder mRemoteToken;
|
private final Binder mRemoteToken;
|
||||||
@@ -211,12 +217,7 @@ public class Ringtone {
|
|||||||
mLocalPlayer.setAudioAttributes(mAudioAttributes);
|
mLocalPlayer.setAudioAttributes(mAudioAttributes);
|
||||||
mLocalPlayer.prepare();
|
mLocalPlayer.prepare();
|
||||||
|
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException | IOException e) {
|
||||||
destroyLocalPlayer();
|
|
||||||
if (!mAllowRemote) {
|
|
||||||
Log.w(TAG, "Remote playback not allowed: " + e);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
destroyLocalPlayer();
|
destroyLocalPlayer();
|
||||||
if (!mAllowRemote) {
|
if (!mAllowRemote) {
|
||||||
Log.w(TAG, "Remote playback not allowed: " + e);
|
Log.w(TAG, "Remote playback not allowed: " + e);
|
||||||
|
|||||||
Reference in New Issue
Block a user