Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: chromecast/browser/android/apk/src/org/chromium/chromecast/shell/CastShellActivity.java

Issue 2334383002: Suppress deprecation warning in CastShellActivity. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698