@ -211,6 +211,7 @@ status_t AudioPolicyService::getOutputForAttr(audio_attributes_t *attr,
audio_stream_type_t * stream ,
audio_stream_type_t * stream ,
pid_t pid ,
pid_t pid ,
uid_t uid ,
uid_t uid ,
const String16 & opPackageName ,
const audio_config_t * config ,
const audio_config_t * config ,
audio_output_flags_t flags ,
audio_output_flags_t flags ,
audio_port_handle_t * selectedDeviceId ,
audio_port_handle_t * selectedDeviceId ,
@ -257,7 +258,8 @@ status_t AudioPolicyService::getOutputForAttr(audio_attributes_t *attr,
case AudioPolicyInterface : : API_OUTPUT_LEGACY :
case AudioPolicyInterface : : API_OUTPUT_LEGACY :
break ;
break ;
case AudioPolicyInterface : : API_OUTPUT_TELEPHONY_TX :
case AudioPolicyInterface : : API_OUTPUT_TELEPHONY_TX :
if ( ! modifyPhoneStateAllowed ( pid , uid ) ) {
if ( ! modifyPhoneStateAllowed ( pid , uid ) & &
! accessCallAudioAllowed ( opPackageName , pid , uid ) ) {
ALOGE ( " %s() permission denied: modify phone state not allowed for uid %d " ,
ALOGE ( " %s() permission denied: modify phone state not allowed for uid %d " ,
__func__ , uid ) ;
__func__ , uid ) ;
result = PERMISSION_DENIED ;
result = PERMISSION_DENIED ;
@ -454,15 +456,22 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
}
}
bool canCaptureOutput = captureAudioOutputAllowed ( pid , uid ) ;
bool canCaptureOutput = captureAudioOutputAllowed ( pid , uid ) ;
if ( ( inputSource = = AUDIO_SOURCE_VOICE_UPLINK | |
bool canCaptureTelephonyOutput = canCaptureOutput
inputSource = = AUDIO_SOURCE_VOICE_DOWNLINK | |
| | accessCallAudioAllowed ( opPackageName , pid , uid ) ;
inputSource = = AUDIO_SOURCE_VOICE_CALL | |
inputS ource = = AUDIO_SOURCE_ECHO_REFERENCE | |
if ( ( attr - > s ource = = AUDIO_SOURCE_ECHO_REFERENCE | |
inputS ource = = AUDIO_SOURCE_FM_TUNER ) & &
attr - > s ource = = AUDIO_SOURCE_FM_TUNER ) & &
! canCaptureOutput ) {
! canCaptureOutput ) {
return PERMISSION_DENIED ;
return PERMISSION_DENIED ;
}
}
if ( ( attr - > source = = AUDIO_SOURCE_VOICE_UPLINK | |
attr - > source = = AUDIO_SOURCE_VOICE_DOWNLINK | |
attr - > source = = AUDIO_SOURCE_VOICE_CALL ) & &
! canCaptureTelephonyOutput ) {
return PERMISSION_DENIED ;
}
bool canCaptureHotword = captureHotwordAllowed ( opPackageName , pid , uid ) ;
bool canCaptureHotword = captureHotwordAllowed ( opPackageName , pid , uid ) ;
if ( ( inputSource = = AUDIO_SOURCE_HOTWORD ) & & ! canCaptureHotword ) {
if ( ( inputSource = = AUDIO_SOURCE_HOTWORD ) & & ! canCaptureHotword ) {
return BAD_VALUE ;
return BAD_VALUE ;
@ -494,6 +503,11 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
break ;
break ;
case AudioPolicyInterface : : API_INPUT_TELEPHONY_RX :
case AudioPolicyInterface : : API_INPUT_TELEPHONY_RX :
// FIXME: use the same permission as for remote submix for now.
// FIXME: use the same permission as for remote submix for now.
if ( ! canCaptureTelephonyOutput ) {
ALOGE ( " getInputForAttr() permission denied: call capture not allowed " ) ;
status = PERMISSION_DENIED ;
}
break ;
case AudioPolicyInterface : : API_INPUT_MIX_CAPTURE :
case AudioPolicyInterface : : API_INPUT_MIX_CAPTURE :
if ( ! canCaptureOutput ) {
if ( ! canCaptureOutput ) {
ALOGE ( " getInputForAttr() permission denied: capture not allowed " ) ;
ALOGE ( " getInputForAttr() permission denied: capture not allowed " ) ;
@ -521,9 +535,13 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr,
return status ;
return status ;
}
}
bool allowAudioCapture = canCaptureOutput | |
( inputType = = AudioPolicyInterface : : API_INPUT_TELEPHONY_RX & &
canCaptureTelephonyOutput ) ;
sp < AudioRecordClient > client = new AudioRecordClient ( * attr , * input , uid , pid , session , * portId ,
sp < AudioRecordClient > client = new AudioRecordClient ( * attr , * input , uid , pid , session , * portId ,
* selectedDeviceId , opPackageName ,
* selectedDeviceId , opPackageName ,
canCaptureOutput , canCaptureHotword ) ;
allowAudioCapture , canCaptureHotword ) ;
mAudioRecordClients . add ( * portId , client ) ;
mAudioRecordClients . add ( * portId , client ) ;
}
}