Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d6bf910 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "getInputForAttr perm check cleanup pt1" into main

parents d55a65e4 89ff0436
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -1379,13 +1379,14 @@ status_t AudioSystem::getInputForAttr(const audio_attributes_t* attr,

    media::GetInputForAttrResponse response;

    status_t status = statusTFromBinderStatus(
            aps->getInputForAttr(attrAidl, inputAidl, riidAidl, sessionAidl, attributionSource,
                configAidl, flagsAidl, selectedDeviceIdAidl, &response));
    if (status != NO_ERROR) {
    const Status res = aps->getInputForAttr(attrAidl, inputAidl, riidAidl, sessionAidl,
                                            attributionSource, configAidl, flagsAidl,
                                            selectedDeviceIdAidl, &response);
    if (!res.isOk()) {
        ALOGE("getInputForAttr error: %s", res.toString8().c_str());
        *config = VALUE_OR_RETURN_STATUS(
                aidl2legacy_AudioConfigBase_audio_config_base_t(response.config, true /*isInput*/));
        return status;
        return statusTFromBinderStatus(res);
    }

    *input = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_io_handle_t(response.input));
+10 −0
Original line number Diff line number Diff line
@@ -77,15 +77,24 @@ static String16 resolveCallingPackage(PermissionController& permissionController
    return packages[0];
}

// NOTE/TODO(b/379754682):
// AUDIO_SOURCE_VOICE_DOWNLINK and AUDIO_SOURCE_VOICE_CALL are handled specially:
// DOWNLINK is an output source, but we still require RecordOp in addition to
// OP_RECORD_INCOMING_PHONE_AUDIO
// CALL includes both uplink and downlink, but we attribute RECORD_OP (only), since
// there is not support for noting multiple ops.
int32_t getOpForSource(audio_source_t source) {
  switch (source) {
    // BEGIN output sources
    case AUDIO_SOURCE_FM_TUNER:
        return AppOpsManager::OP_NONE;
    case AUDIO_SOURCE_ECHO_REFERENCE: // fallthrough
    case AUDIO_SOURCE_REMOTE_SUBMIX:
        // TODO -- valid in all cases?
      return AppOpsManager::OP_RECORD_AUDIO_OUTPUT;
    case AUDIO_SOURCE_VOICE_DOWNLINK:
      return AppOpsManager::OP_RECORD_INCOMING_PHONE_AUDIO;
    // END output sources
    case AUDIO_SOURCE_HOTWORD:
      return AppOpsManager::OP_RECORD_AUDIO_HOTWORD;
    case AUDIO_SOURCE_DEFAULT:
@@ -99,6 +108,7 @@ bool isRecordOpRequired(audio_source_t source) {
    case AUDIO_SOURCE_FM_TUNER:
    case AUDIO_SOURCE_ECHO_REFERENCE: // fallthrough
    case AUDIO_SOURCE_REMOTE_SUBMIX:
    // case AUDIO_SOURCE_VOICE_DOWNLINK:
        return false;
    default:
      return true;
+187 −143

File changed.

Preview size limit exceeded, changes collapsed.

+8 −0
Original line number Diff line number Diff line
@@ -504,6 +504,14 @@ private:
                            const audio_output_flags_t flags);
    status_t unregisterOutput(audio_io_handle_t output);

    error::BinderResult<bool> evaluatePermsForSource(const AttributionSourceState& attrSource,
                                                     AudioSource source, bool isHotword);

    error::BinderResult<bool> evaluatePermsForDevice(const AttributionSourceState& attrSource,
                                                     AudioSource source,
                                                     AudioPolicyInterface::input_type_t inputType,
                                                     uint32_t vdi, bool isCallRedir);

    // If recording we need to make sure the UID is allowed to do that. If the UID is idle
    // then it cannot record and gets buffers with zeros - silence. As soon as the UID
    // transitions to an active state we will start reporting buffers with data. This approach
+2 −4
Original line number Diff line number Diff line
@@ -90,14 +90,13 @@ public:
                      const DeviceIdVector deviceIds,
                      const AttributionSourceState& attributionSource,
                      const uint32_t virtualDeviceId,
                      bool canBypassConcurrentPolicy, bool canCaptureHotword,
                      bool canBypassConcurrentPolicy,
                      wp<AudioPolicyService::AudioCommandThread> commandThread) :
                AudioClient(attributes, io, attributionSource,
                    session, portId, deviceIds), attributionSource(attributionSource),
                    virtualDeviceId(virtualDeviceId),
                    startTimeNs(0), canBypassConcurrentPolicy(canBypassConcurrentPolicy),
                    canCaptureHotword(canCaptureHotword), silenced(false),
                    mOpRecordAudioMonitor(
                    silenced(false), mOpRecordAudioMonitor(
                            OpRecordAudioMonitor::createIfNeeded(attributionSource,
                                                                 virtualDeviceId,
                                                                 attributes, commandThread)) {
@@ -113,7 +112,6 @@ public:
    const uint32_t virtualDeviceId; // id of the virtual device associated with the audio device
    nsecs_t startTimeNs;
    const bool canBypassConcurrentPolicy;
    const bool canCaptureHotword;
    bool silenced;

private: