Making adjustSuggestestedStreamVolumes consistent
Shifting MediaMetrics and external volume controller check so both implementations of adjustSuggestedStreamVolume perform both actions Fixes: 157665889 Test: Ran target with external volume controller and verified it was triggered when adjusting volume Change-Id: I9d1bcb9a84f495bdb8c7575fcd80abab4bbd0763
This commit is contained in:
@@ -1908,31 +1908,11 @@ public class AudioService extends IAudioService.Stub
|
||||
/** @see AudioManager#adjustVolume(int, int) */
|
||||
public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags,
|
||||
String callingPackage, String caller) {
|
||||
final IAudioPolicyCallback extVolCtlr;
|
||||
synchronized (mExtVolumeControllerLock) {
|
||||
extVolCtlr = mExtVolumeController;
|
||||
}
|
||||
new MediaMetrics.Item(mMetricsId + "adjustSuggestedStreamVolume")
|
||||
.setUid(Binder.getCallingUid())
|
||||
.set(MediaMetrics.Property.CALLING_PACKAGE, callingPackage)
|
||||
.set(MediaMetrics.Property.CLIENT_NAME, caller)
|
||||
.set(MediaMetrics.Property.DIRECTION, direction > 0
|
||||
? MediaMetrics.Value.UP : MediaMetrics.Value.DOWN)
|
||||
.set(MediaMetrics.Property.EXTERNAL, extVolCtlr != null
|
||||
? MediaMetrics.Value.YES : MediaMetrics.Value.NO)
|
||||
.set(MediaMetrics.Property.FLAGS, flags)
|
||||
.record();
|
||||
if (extVolCtlr != null) {
|
||||
sendMsg(mAudioHandler, MSG_NOTIFY_VOL_EVENT, SENDMSG_QUEUE,
|
||||
direction, 0 /*ignored*/,
|
||||
extVolCtlr, 0 /*delay*/);
|
||||
} else {
|
||||
final boolean hasModifyAudioSettings =
|
||||
mContext.checkCallingPermission(Manifest.permission.MODIFY_AUDIO_SETTINGS)
|
||||
== PackageManager.PERMISSION_GRANTED;
|
||||
adjustSuggestedStreamVolume(direction, suggestedStreamType, flags, callingPackage,
|
||||
caller, Binder.getCallingUid(), hasModifyAudioSettings, VOL_ADJUST_NORMAL);
|
||||
}
|
||||
boolean hasModifyAudioSettings =
|
||||
mContext.checkCallingPermission(Manifest.permission.MODIFY_AUDIO_SETTINGS)
|
||||
== PackageManager.PERMISSION_GRANTED;
|
||||
adjustSuggestedStreamVolume(direction, suggestedStreamType, flags, callingPackage,
|
||||
caller, Binder.getCallingUid(), hasModifyAudioSettings, VOL_ADJUST_NORMAL);
|
||||
}
|
||||
|
||||
private void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags,
|
||||
@@ -1947,6 +1927,24 @@ public class AudioService extends IAudioService.Stub
|
||||
direction/*val1*/, flags/*val2*/, new StringBuilder(callingPackage)
|
||||
.append("/").append(caller).append(" uid:").append(uid).toString()));
|
||||
}
|
||||
|
||||
boolean hasExternalVolumeController = notifyExternalVolumeController(direction);
|
||||
|
||||
new MediaMetrics.Item(mMetricsId + "adjustSuggestedStreamVolume")
|
||||
.setUid(Binder.getCallingUid())
|
||||
.set(MediaMetrics.Property.CALLING_PACKAGE, callingPackage)
|
||||
.set(MediaMetrics.Property.CLIENT_NAME, caller)
|
||||
.set(MediaMetrics.Property.DIRECTION, direction > 0
|
||||
? MediaMetrics.Value.UP : MediaMetrics.Value.DOWN)
|
||||
.set(MediaMetrics.Property.EXTERNAL, hasExternalVolumeController
|
||||
? MediaMetrics.Value.YES : MediaMetrics.Value.NO)
|
||||
.set(MediaMetrics.Property.FLAGS, flags)
|
||||
.record();
|
||||
|
||||
if (hasExternalVolumeController) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int streamType;
|
||||
synchronized (mForceControlStreamLock) {
|
||||
// Request lock in case mVolumeControlStream is changed by other thread.
|
||||
@@ -1995,6 +1993,21 @@ public class AudioService extends IAudioService.Stub
|
||||
hasModifyAudioSettings, keyEventMode);
|
||||
}
|
||||
|
||||
private boolean notifyExternalVolumeController(int direction) {
|
||||
final IAudioPolicyCallback externalVolumeController;
|
||||
synchronized (mExtVolumeControllerLock) {
|
||||
externalVolumeController = mExtVolumeController;
|
||||
}
|
||||
if (externalVolumeController == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendMsg(mAudioHandler, MSG_NOTIFY_VOL_EVENT, SENDMSG_QUEUE,
|
||||
direction, 0 /*ignored*/,
|
||||
externalVolumeController, 0 /*delay*/);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @see AudioManager#adjustStreamVolume(int, int, int)
|
||||
* Part of service interface, check permissions here */
|
||||
public void adjustStreamVolume(int streamType, int direction, int flags,
|
||||
@@ -7378,6 +7391,7 @@ public class AudioService extends IAudioService.Stub
|
||||
pw.print(" mIsSingleVolume="); pw.println(mIsSingleVolume);
|
||||
pw.print(" mUseFixedVolume="); pw.println(mUseFixedVolume);
|
||||
pw.print(" mFixedVolumeDevices="); pw.println(dumpDeviceTypes(mFixedVolumeDevices));
|
||||
pw.print(" mExtVolumeController="); pw.println(mExtVolumeController);
|
||||
pw.print(" mHdmiCecSink="); pw.println(mHdmiCecSink);
|
||||
pw.print(" mHdmiAudioSystemClient="); pw.println(mHdmiAudioSystemClient);
|
||||
pw.print(" mHdmiPlaybackClient="); pw.println(mHdmiPlaybackClient);
|
||||
|
||||
Reference in New Issue
Block a user