summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2015-02-02 17:47:51 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-02-02 17:47:52 +0000
commit00b1b712d2a04b04845f77992187c1cdfe6b39f0 (patch)
treec018a3de9faa9ebb4c48a31d065add5af9bd5537 /media
parenta2bfc837ccb89ad9d4ef9dd7ead95b8759846690 (diff)
parent001c59c6374a171a0bd3bd969744be6a4318efce (diff)
downloadframeworks_base-00b1b712d2a04b04845f77992187c1cdfe6b39f0.zip
frameworks_base-00b1b712d2a04b04845f77992187c1cdfe6b39f0.tar.gz
frameworks_base-00b1b712d2a04b04845f77992187c1cdfe6b39f0.tar.bz2
Merge "Route volume keys directly to the audio system on TVs"
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioService.java36
-rw-r--r--media/java/android/media/session/MediaSessionLegacyHelper.java2
2 files changed, 25 insertions, 13 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index d96fee6..98a43a8 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -153,11 +153,11 @@ public class AudioService extends IAudioService.Stub {
private final AppOpsManager mAppOps;
// the platform has no specific capabilities
- private static final int PLATFORM_DEFAULT = 0;
+ public static final int PLATFORM_DEFAULT = 0;
// the platform is voice call capable (a phone)
- private static final int PLATFORM_VOICE = 1;
+ public static final int PLATFORM_VOICE = 1;
// the platform is a television or a set-top box
- private static final int PLATFORM_TELEVISION = 2;
+ public static final int PLATFORM_TELEVISION = 2;
// the platform type affects volume and silent mode behavior
private final int mPlatformType;
@@ -546,15 +546,7 @@ public class AudioService extends IAudioService.Stub {
mContentResolver = context.getContentResolver();
mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
- if (mContext.getResources().getBoolean(
- com.android.internal.R.bool.config_voice_capable)) {
- mPlatformType = PLATFORM_VOICE;
- } else if (context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_LEANBACK)) {
- mPlatformType = PLATFORM_TELEVISION;
- } else {
- mPlatformType = PLATFORM_DEFAULT;
- }
+ mPlatformType = getPlatformType(context);
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
mAudioEventWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "handleAudioEvent");
@@ -667,6 +659,26 @@ public class AudioService extends IAudioService.Stub {
LocalServices.addService(AudioManagerInternal.class, new AudioServiceInternal());
}
+ /**
+ * Return the platform type that this is running on. One of:
+ * <ul>
+ * <li>{@link #PLATFORM_VOICE}</li>
+ * <li>{@link #PLATFORM_TELEVISION}</li>
+ * <li>{@link #PLATFORM_DEFAULT}</li>
+ * </ul>
+ */
+ public static int getPlatformType(Context context) {
+ if (context.getResources().getBoolean(
+ com.android.internal.R.bool.config_voice_capable)) {
+ return PLATFORM_VOICE;
+ } else if (context.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_LEANBACK)) {
+ return PLATFORM_TELEVISION;
+ } else {
+ return PLATFORM_DEFAULT;
+ }
+ }
+
public void systemReady() {
sendMsg(mAudioHandler, MSG_SYSTEM_READY, SENDMSG_QUEUE,
0, 0, null, 0);
diff --git a/media/java/android/media/session/MediaSessionLegacyHelper.java b/media/java/android/media/session/MediaSessionLegacyHelper.java
index 9954de5..4ea22f9 100644
--- a/media/java/android/media/session/MediaSessionLegacyHelper.java
+++ b/media/java/android/media/session/MediaSessionLegacyHelper.java
@@ -221,7 +221,7 @@ public class MediaSessionLegacyHelper {
mSessionManager.dispatchAdjustVolume(AudioManager.USE_DEFAULT_STREAM_TYPE,
direction, flags);
} else if (isMute) {
- if (down) {
+ if (down && keyEvent.getRepeatCount() == 0) {
mSessionManager.dispatchAdjustVolume(AudioManager.USE_DEFAULT_STREAM_TYPE,
AudioManager.ADJUST_TOGGLE_MUTE, flags);
}