Index: chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java |
diff --git a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java |
index 4f36020b6d2285402a73df54045057f76554a5c0..6c576f55ee091d1a7d0a1aee00be44d679eb954e 100644 |
--- a/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java |
+++ b/chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java |
@@ -171,19 +171,7 @@ public class CastShellActivity extends Activity { |
// On pre-M devices, the device should be "unmuted" at the end of a Cast application |
// session, signaled by the activity exiting. See b/19964892. |
if (Build.VERSION.SDK_INT < 23) { |
- AudioManager audioManager = CastAudioManager.getAudioManager(this); |
- boolean isMuted = false; |
- try { |
- isMuted = (Boolean) audioManager.getClass().getMethod("isStreamMute", int.class) |
- .invoke(audioManager, AudioManager.STREAM_MUSIC); |
- } catch (Exception e) { |
- Log.e(TAG, "Cannot call AudioManager.isStreamMute().", e); |
- } |
- |
- if (isMuted) { |
- // Note: this is a no-op on fixed-volume devices. |
- audioManager.setStreamMute(AudioManager.STREAM_MUSIC, false); |
- } |
+ releaseStreamMuteIfNecessary(); |
} |
} |
@@ -236,6 +224,23 @@ public class CastShellActivity extends Activity { |
} |
} |
+ @SuppressWarnings("deprecation") |
+ private void releaseStreamMuteIfNecessary() { |
+ AudioManager audioManager = CastAudioManager.getAudioManager(this); |
+ boolean isMuted = false; |
+ try { |
+ isMuted = (Boolean) audioManager.getClass().getMethod("isStreamMute", int.class) |
+ .invoke(audioManager, AudioManager.STREAM_MUSIC); |
+ } catch (Exception e) { |
+ Log.e(TAG, "Cannot call AudioManager.isStreamMute().", e); |
+ } |
+ |
+ if (isMuted) { |
+ // Note: this is a no-op on fixed-volume devices. |
+ audioManager.setStreamMute(AudioManager.STREAM_MUSIC, false); |
+ } |
+ } |
+ |
private void registerBroadcastReceiver() { |
if (mBroadcastReceiver == null) { |
mBroadcastReceiver = new BroadcastReceiver() { |