summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2013-10-10 18:12:59 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2013-10-11 11:36:18 -0700
commitfca1e603236b8d1681f784e77e3719d1d59c1428 (patch)
treed40948aea2db2c25a567a5f637c389b808370b35 /policy
parent5bd70c5eb3ccb5d1eed3f1f7e924a4fb96b0a053 (diff)
downloadframeworks_base-fca1e603236b8d1681f784e77e3719d1d59c1428.zip
frameworks_base-fca1e603236b8d1681f784e77e3719d1d59c1428.tar.gz
frameworks_base-fca1e603236b8d1681f784e77e3719d1d59c1428.tar.bz2
Remote volume changes
When the user plays media remotely, and presses on the volume keys with the screen off, verify whether not only local playback is active, but also if remote playback is active to see if the volume should be adjusted. When adjusting the volume with screen off, adjust the remote volume if applicable. When controlling volume, give priority to local media playback. Bug 11169862 Change-Id: I88a8c003969177d50d4c1569ec6cd2a7c153a341
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindowManager.java34
1 files changed, 23 insertions, 11 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index e9e3b27..d776e38 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -42,6 +42,7 @@ import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.media.AudioManager;
+import android.media.AudioSystem;
import android.media.IAudioService;
import android.media.Ringtone;
import android.media.RingtoneManager;
@@ -3645,7 +3646,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
/**
- * @return Whether music is being played right now.
+ * @return Whether music is being played right now "locally" (e.g. on the device's speakers
+ * or wired headphones) or "remotely" (e.g. on a device using the Cast protocol and
+ * controlled by this device, or through remote submix).
*/
boolean isMusicActive() {
final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE);
@@ -3653,7 +3656,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
Log.w(TAG, "isMusicActive: couldn't get AudioManager reference");
return false;
}
- return am.isMusicActive();
+ return am.isLocalOrRemoteMusicActive();
}
/**
@@ -3666,19 +3669,28 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return;
}
try {
- // since audio is playing, we shouldn't have to hold a wake lock
+ // when audio is playing locally, we shouldn't have to hold a wake lock
// during the call, but we do it as a precaution for the rare possibility
- // that the music stops right before we call this
+ // that the music stops right before we call this.
+ // Otherwise we might also be in a remote playback case.
// TODO: Actually handle MUTE.
mBroadcastWakeLock.acquire();
- audioService.adjustStreamVolume(stream,
- keycode == KeyEvent.KEYCODE_VOLUME_UP
- ? AudioManager.ADJUST_RAISE
- : AudioManager.ADJUST_LOWER,
- 0,
- mContext.getOpPackageName());
+ if (stream == AudioSystem.STREAM_MUSIC) {
+ audioService.adjustLocalOrRemoteStreamVolume(stream,
+ keycode == KeyEvent.KEYCODE_VOLUME_UP
+ ? AudioManager.ADJUST_RAISE
+ : AudioManager.ADJUST_LOWER,
+ mContext.getOpPackageName());
+ } else {
+ audioService.adjustStreamVolume(stream,
+ keycode == KeyEvent.KEYCODE_VOLUME_UP
+ ? AudioManager.ADJUST_RAISE
+ : AudioManager.ADJUST_LOWER,
+ 0,
+ mContext.getOpPackageName());
+ }
} catch (RemoteException e) {
- Log.w(TAG, "IAudioService.adjustStreamVolume() threw RemoteException " + e);
+ Log.w(TAG, "IAudioService.adjust*StreamVolume() threw RemoteException " + e);
} finally {
mBroadcastWakeLock.release();
}