diff options
Diffstat (limited to 'services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp')
| -rw-r--r-- | services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp index 3ba55f350a..5d4f6e78e4 100644 --- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp +++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp @@ -62,6 +62,11 @@ using media::audio::common::AudioUsage; using media::audio::common::AudioUuid; using media::audio::common::Int; +namespace { +constexpr auto PERMISSION_HARD_DENIED = permission::PermissionChecker::PERMISSION_HARD_DENIED; +constexpr auto PERMISSION_GRANTED = permission::PermissionChecker::PERMISSION_GRANTED; +} + const std::vector<audio_usage_t>& SYSTEM_USAGES = { AUDIO_USAGE_CALL_ASSISTANT, AUDIO_USAGE_EMERGENCY, @@ -782,13 +787,12 @@ Status AudioPolicyService::startInput(int32_t portIdAidl) std::stringstream msg; msg << "Audio recording on session " << client->session; + const auto permitted = isAudioServerOrMediaServerUid(client->attributionSource.uid) && + startRecording(client->attributionSource, String16(msg.str().c_str()), + client->attributes.source); + // check calling permissions - if (!isAudioServerOrMediaServerUid(client->attributionSource.uid) - && !(startRecording(client->attributionSource, String16(msg.str().c_str()), - client->attributes.source) - || client->attributes.source == AUDIO_SOURCE_FM_TUNER - || client->attributes.source == AUDIO_SOURCE_REMOTE_SUBMIX - || client->attributes.source == AUDIO_SOURCE_ECHO_REFERENCE)) { + if (permitted == PERMISSION_HARD_DENIED) { ALOGE("%s permission denied: recording not allowed for attribution source %s", __func__, client->attributionSource.toString().c_str()); return binderStatusFromStatusT(PERMISSION_DENIED); @@ -807,13 +811,17 @@ Status AudioPolicyService::startInput(int32_t portIdAidl) return binderStatusFromStatusT(INVALID_OPERATION); } - // Force the possibly silenced client to be unsilenced since we just called - // startRecording (i.e. we have assumed it is unsilenced). - // At this point in time, the client is inactive, so no calls to appops are sent in - // setAppState_l. - // This ensures existing clients have the same behavior as new clients (starting unsilenced). + // Force the possibly silenced client to match the state on the appops side + // following the call to startRecording (i.e. unsilenced iff call succeeded) + // At this point in time, the client is inactive, so no calls to appops are + // sent in setAppState_l. This ensures existing clients have the same + // behavior as new clients. // TODO(b/282076713) - setAppState_l(client, APP_STATE_TOP); + if (permitted == PERMISSION_GRANTED) { + setAppState_l(client, APP_STATE_TOP); + } else { + setAppState_l(client, APP_STATE_IDLE); + } client->active = true; client->startTimeNs = systemTime(); @@ -899,7 +907,9 @@ Status AudioPolicyService::startInput(int32_t portIdAidl) client->active = false; client->startTimeNs = 0; updateUidStates_l(); - finishRecording(client->attributionSource, client->attributes.source); + if (!client->silenced) { + finishRecording(client->attributionSource, client->attributes.source); + } } return binderStatusFromStatusT(status); @@ -928,7 +938,9 @@ Status AudioPolicyService::stopInput(int32_t portIdAidl) updateUidStates_l(); // finish the recording app op - finishRecording(client->attributionSource, client->attributes.source); + if (!client->silenced) { + finishRecording(client->attributionSource, client->attributes.source); + } AutoCallerClear acc; return binderStatusFromStatusT(mAudioPolicyManager->stopInput(portId)); } |
