summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruabdullah <uabdullah@google.com>2018-01-25 15:08:15 -0800
committerCopybara-Service <copybara-piper@google.com>2018-01-25 16:15:18 -0800
commit0b98bace4d2b5bd828d11f758f39dffc14955fef (patch)
treeeec2857da0034bdc4c8c252c937fee551d0993eb
parentb9596e65467d9ad33efdfebb5ebc098207fda991 (diff)
By pass media player strict mode violation
The media player throws a strict mode violation when setting the data source and calling prepare async. This currently makes the voicemail fragment unusable since you can't play voicemails. I've added a todo to remove this in the future. Test: N/A PiperOrigin-RevId: 183298572 Change-Id: I821a700cc7e60d0bdde7ec4d7b543dfa7acaf274
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java
index 48062a87d..519a0dfbd 100644
--- a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayer.java
@@ -26,6 +26,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
+import com.android.dialer.strictmode.StrictModeUtils;
import java.io.IOException;
/** A wrapper around {@link MediaPlayer} */
@@ -45,6 +46,7 @@ public class NewVoicemailMediaPlayer {
mediaPlayer = Assert.isNotNull(player);
}
+ // TODO(uabdullah): Consider removing the StrictModeUtils.bypass (a bug)
public void prepareMediaPlayerAndPlayVoicemailWhenReady(Context context, Uri uri)
throws IOException {
Assert.checkArgument(uri != null, "Media player cannot play a null uri");
@@ -57,9 +59,23 @@ public class NewVoicemailMediaPlayer {
voicemailUriLastPreparedOrPreparingToPlay = uri;
verifyListenersNotNull();
LogUtil.i("NewVoicemailMediaPlayer", "setData source");
- mediaPlayer.setDataSource(context, uri);
+ StrictModeUtils.bypass(
+ () -> {
+ try {
+ mediaPlayer.setDataSource(context, uri);
+ } catch (IOException e) {
+ LogUtil.i(
+ "NewVoicemailMediaPlayer",
+ "threw an Exception when setting datasource "
+ + e
+ + " for uri: "
+ + uri
+ + "for context : "
+ + context);
+ }
+ });
LogUtil.i("NewVoicemailMediaPlayer", "prepare async");
- mediaPlayer.prepareAsync();
+ StrictModeUtils.bypass(() -> mediaPlayer.prepareAsync());
} catch (IllegalStateException e) {
LogUtil.i(
"NewVoicemailMediaPlayer", "caught an IllegalStateException state exception : \n" + e);