summaryrefslogtreecommitdiffstats
path: root/services/core
diff options
context:
space:
mode:
authorDongwon Kang <dwkang@google.com>2015-06-17 23:51:11 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-17 23:51:23 +0000
commitc7c12e5639c170cb7ba3d3b492f9455b8b6bb9b4 (patch)
treefb283839324fda41c12e265a922037d926b4a803 /services/core
parent9ce9ffec9e307e29c3d575854d4e357ecf06d2d8 (diff)
parenta38e1f4ed997bea3cbfbf8094a52c23570d59d2a (diff)
downloadframeworks_base-c7c12e5639c170cb7ba3d3b492f9455b8b6bb9b4.zip
frameworks_base-c7c12e5639c170cb7ba3d3b492f9455b8b6bb9b4.tar.gz
frameworks_base-c7c12e5639c170cb7ba3d3b492f9455b8b6bb9b4.tar.bz2
Merge "Make MediaSessionService not blocked by AudioService." into mnc-dev
Diffstat (limited to 'services/core')
-rw-r--r--services/core/java/com/android/server/media/MediaSessionRecord.java34
1 files changed, 27 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java
index dca762c..569a0fc 100644
--- a/services/core/java/com/android/server/media/MediaSessionRecord.java
+++ b/services/core/java/com/android/server/media/MediaSessionRecord.java
@@ -242,19 +242,17 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
}
if (mVolumeType == PlaybackInfo.PLAYBACK_TYPE_LOCAL) {
int stream = AudioAttributes.toLegacyStreamType(mAudioAttrs);
+ // Adjust the volume with a handler not to be blocked by other system service.
if (useSuggested) {
if (AudioSystem.isStreamActive(stream, 0)) {
- mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(stream, direction,
- flags, packageName, uid);
+ postAdjustSuggestedStreamVolume(stream, direction, flags, packageName, uid);
} else {
flags |= previousFlagPlaySound;
- mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(
- AudioManager.USE_DEFAULT_STREAM_TYPE, direction, flags, packageName,
- uid);
+ postAdjustSuggestedStreamVolume(AudioManager.USE_DEFAULT_STREAM_TYPE, direction,
+ flags, packageName, uid);
}
} else {
- mAudioManagerInternal.adjustStreamVolumeForUid(stream, direction, flags,
- packageName, uid);
+ postAdjustStreamVolume(stream, direction, flags, packageName, uid);
}
} else {
if (mVolumeControlType == VolumeProvider.VOLUME_CONTROL_FIXED) {
@@ -461,6 +459,28 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
return mPackageName + "/" + mTag;
}
+ private void postAdjustSuggestedStreamVolume(final int streamType, final int direction,
+ final int flags, final String callingPackage, final int uid) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mAudioManagerInternal.adjustSuggestedStreamVolumeForUid(streamType, direction,
+ flags, callingPackage, uid);
+ }
+ });
+ }
+
+ private void postAdjustStreamVolume(final int streamType, final int direction, final int flags,
+ final String callingPackage, final int uid) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ mAudioManagerInternal.adjustStreamVolumeForUid(streamType, direction, flags,
+ callingPackage, uid);
+ }
+ });
+ }
+
private String getShortMetadataString() {
int fields = mMetadata == null ? 0 : mMetadata.size();
MediaDescription description = mMetadata == null ? null : mMetadata