Bootstrap

Android 在卓智达对讲应用外使用PTT对讲按键无声

/frameworks/av/services/audiopolicy/service/AudioPolicyService.cpp

抓log查看可见

MTK_ALOGD:

 

        MTK_ALOGD("APSMuteRec1 allowCapture[%d] hasOp[%d] canCaptureIfInCallOrCommunication[%d] State[%d] source[%d] [%zu]/[%zu] uid[%u] portId[%d] isA11yOnTop[%d] isAssistantOnTop[%d] isSensitiveActive[%d] isInCall[%d] isInCommunication[%d] rttCallActive[%d] onlyHotwordActive[%d] isTopOrLatestActive[%d] isTopOrLatestSensitive[%d] UIDTYPE[%d]/[%d]/[%d]"
            , allowCapture, current->hasOp(), canCaptureIfInCallOrCommunication(current), apmStatFromAmState(mUidPolicy->getUidState(currentUid)), source, i, mAudioRecordClients.size(), currentUid, current->portId, isA11yOnTop, isAssistantOnTop, isSensitiveActive
            , isInCall, isInCommunication, rttCallActive, onlyHotwordActive, isTopOrLatestActive, isTopOrLatestSensitive
            , mUidPolicy->isAssistantUid(currentUid), mUidPolicy->isA11yUid(currentUid), mUidPolicy->isCurrentImeUid(currentUid));

        /*/rm idle status stay on foreground or background
        setAppState_l(current,allowCapture ? apmStatFromAmState(mUidPolicy->getUidState(currentUid)) :APP_STATE_IDLE);
        //*/
         setAppState_l(current,apmStatFromAmState(mUidPolicy->getUidState(currentUid)));
        //*/

    }
}

void AudioPolicyService::silenceAllRecordings_l() {
    for (size_t i = 0; i < mAudioRecordClients.size(); i++) {
        sp<AudioRecordClient> current = mAudioRecordClients[i];
        if (!isVirtualSource(current->attributes.source)) {
            /*/add set idle status
            setAppState_l(current, APP_STATE_IDLE);
            //*/
            setAppState_l(current, APP_STATE_FOREGROUND);
            //*/

        }
    }
}

/* static */
app_state_t AudioPolicyService::apmStatFromAmState(int amState) {

    if (amState == ActivityManager::PROCESS_STATE_UNKNOWN) {
        /*/add。rm idle status
        return APP_STATE_IDLE;
        //*/
        return APP_STATE_FOREGROUND;
        //*/
    } else if (amState <= ActivityManager::PROCESS_STATE_TOP) {
      // include persistent services
      return APP_STATE_TOP;
    }
    return APP_STATE_FOREGROUND;
}

 

去掉当前闲置状态,设置为前台或后台运行/顶部即可

;