From 47ad78a5b84e23f9030c37e169f42d30a93d3d52 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 12:28:01 +0000 Subject: [PATCH 01/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- .../native/audioutils/include/audio_utils.h | 5 +- .../native/audioutils/src/audio_utils.cpp | 5 + .../native/audiocommon/include/audio_info.h | 15 + .../include/audio_interrupt_info.h | 2 + .../include/audio_interrupt_service.h | 5 + .../interrupt/src/audio_interrupt_service.cpp | 43 ++- .../ipc_proxy/include/audio_server_proxy.h | 1 + .../ipc_proxy/src/audio_server_proxy.cpp | 11 + .../server/include/audio_service.h | 27 ++ .../server/src/audio_service.cpp | 303 ++++++++++++++++++ 10 files changed, 415 insertions(+), 2 deletions(-) diff --git a/frameworks/native/audioutils/include/audio_utils.h b/frameworks/native/audioutils/include/audio_utils.h index 1c884eda97..39f6ec7423 100644 --- a/frameworks/native/audioutils/include/audio_utils.h +++ b/frameworks/native/audioutils/include/audio_utils.h @@ -159,8 +159,11 @@ public: static int32_t StartUsingPermission(uint32_t targetTokenId, const char* permission); static int32_t StopUsingPermission(uint32_t targetTokenId, const char* permission); static bool CheckCallingUidPermission(const std::vector &allowedUids); + static bool VerifyMicrophoneBackgroundPermission(uint32_t tokenId); + static bool IsInNotNeedBackgroundCaptureSAList(int32_t callerUis); + static bool IsInNotNeedBackgroundCaptureSourceTypeList(SourceType sourceType); }; - +// will be move to audio_permission.h in the feture class SwitchStreamUtil { public: static bool UpdateSwitchStreamRecord(SwitchStreamInfo &info, SwitchState targetState); diff --git a/frameworks/native/audioutils/src/audio_utils.cpp b/frameworks/native/audioutils/src/audio_utils.cpp index c6f549b052..aa7d9bd82f 100644 --- a/frameworks/native/audioutils/src/audio_utils.cpp +++ b/frameworks/native/audioutils/src/audio_utils.cpp @@ -482,6 +482,11 @@ bool PermissionUtil::VerifySelfPermission() return false; } +bool PermissionUtils::VerifyMicrophoneBackgroundPermission(uint32_t tokenId) +{ + +} + bool PermissionUtil::VerifySystemPermission() { auto tokenId = IPCSkeleton::GetCallingTokenID(); diff --git a/interfaces/inner_api/native/audiocommon/include/audio_info.h b/interfaces/inner_api/native/audiocommon/include/audio_info.h index d984c5f385..57ce0e9c35 100644 --- a/interfaces/inner_api/native/audiocommon/include/audio_info.h +++ b/interfaces/inner_api/native/audiocommon/include/audio_info.h @@ -81,6 +81,7 @@ const float MIN_FLOAT_VOLUME = 0.0f; const float MAX_FLOAT_VOLUME = 1.0f; const char* MICROPHONE_PERMISSION = "ohos.permission.MICROPHONE"; +const char* MIC_BACK_PERMISSION = "ohos.permission.MICROPHONE_BACKGROUND"; const char* MODIFY_AUDIO_SETTINGS_PERMISSION = "ohos.permission.MODIFY_AUDIO_SETTINGS"; const char* ACCESS_NOTIFICATION_POLICY_PERMISSION = "ohos.permission.ACCESS_NOTIFICATION_POLICY"; const char* CAPTURER_VOICE_DOWNLINK_PERMISSION = "ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO"; @@ -1482,6 +1483,20 @@ struct SwitchStreamInfo { } }; +enum BackgroundCaptureState { + DENIED_INVALID, + DENIED_APP_IN_BACKGROUND, + ALLOWED_APP_IN_FOREGROUND, + ALLOWED_INTERRUPT_RESUME, + ALLOWED_SWITCH_STREAM_CREATE, + ALLOWED_SWITCH_STREAM_START, + ALLOWED_EXEMPTION_FOREGROUND_APP, + NOTNEED_SYSTEM_APP, + NOTNEED_EXEMPTION_SA, + NOTNEED_EXEMPTION_SOURCETYPE, + NOTNEED_MICROPHONE_BACKGROUND_PERMISSION +}; + struct StreamSetStateEventInternal : public Parcelable { StreamSetState streamSetState; StreamUsage streamUsage; diff --git a/interfaces/inner_api/native/audiocommon/include/audio_interrupt_info.h b/interfaces/inner_api/native/audiocommon/include/audio_interrupt_info.h index a303b6f778..048c4931f7 100644 --- a/interfaces/inner_api/native/audiocommon/include/audio_interrupt_info.h +++ b/interfaces/inner_api/native/audiocommon/include/audio_interrupt_info.h @@ -154,6 +154,7 @@ struct InterruptEventInternal : public Parcelable { InterruptHint hintType = INTERRUPT_HINT_NONE; float duckVolume = 1.0f; bool callbackToApp = true; + int64_t eventTimestamp = 0; InterruptEventInternal() = default; @@ -164,6 +165,7 @@ struct InterruptEventInternal : public Parcelable { forceType = forcetype; hintType = hinttype; duckVolume = duckvolume; + eventTimestamp = 0; } bool Marshalling(Parcel &parcel) const override diff --git a/services/audio_policy/server/domain/interrupt/include/audio_interrupt_service.h b/services/audio_policy/server/domain/interrupt/include/audio_interrupt_service.h index 1b4845448b..4601729ec5 100644 --- a/services/audio_policy/server/domain/interrupt/include/audio_interrupt_service.h +++ b/services/audio_policy/server/domain/interrupt/include/audio_interrupt_service.h @@ -122,6 +122,11 @@ public: std::vector GetAudioSessionUidList(int32_t zoneId); StreamUsage GetAudioSessionStreamUsage(int32_t callerPid); + bool ShouldAudioServerProcessInruptEvent(const InterruptEventInternal &interruptEvent, + const AudioInterrupt &audioInterrupt); + void SendInterruptEventToAudioServer(const InterruptEventInternal &interruptEvent, + const AudioInterrupt &audioInterrupt); + void ProcessRemoteInterrupt(std::set streamIds, InterruptEventInternal interruptEvent); int32_t SetQueryBundleNameListCallback(const sptr &object); void RegisterDefaultVolumeTypeListener(); diff --git a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp index a4a89fe517..60f75a9f05 100644 --- a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp +++ b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp @@ -30,6 +30,7 @@ #include "app_mgr_client.h" #include "dfx_msg_manager.h" #include "audio_bundle_manager.h" +#include "audio_server_proxy.h" #include "istandard_audio_service.h" #include "session_manager_lite.h" #include "audio_zone_service.h" @@ -2501,6 +2502,46 @@ void AudioInterruptService::SendInterruptEvent(AudioFocuState oldState, AudioFoc iterActive->second = newState; } +bool AudioInterruptService::ShouldAudioServerProcessInruptEvent(const InterruptEventInternal &interruptEvent, + const AudioInterrupt &audioInterrupt) +{ + //only process capture interruptEvent + CHECK_AND_RETURN_RET_LOG(!audioInterrupt.audioFocusType.isPlay, false, + "audioServer need not process playback interruptEvent"); + +#ifdef FEATURE_APPGALLERY + //CLIENT_TYPE_GAME will be muted or unmuted, need not process in FEATURE_APPGALLERY + uint32_t uid = interruptClients_[audioInterrupt.sessionId]->GetCallingUid(); + ClientType clientType = ClientTypeManager::GetInstance()->GetClientTypeByUid(uid); + CHECK_AND_RETURN_RET_LOG(clientType != CLIENT_TYPE_GAME, false, "clientType is Game"); +#endif + //only process INTERRUPT_HINT_PAUSE INTERRUPT_HINT_STOP INTERRUPT_HINT_RESUME + auto hintType = interruptEvent.hintType; + return hintType == INTERRUPT_HINT_PAUSE || + hintType == INTERRUPT_HINT_RESUME; +} + +void AudioInterruptService::SendInterruptEventToAudioServer( + const InterruptEventInternal &interruptEvent, const AudioInterrupt &audioInterrupt) +{ + CHECK_AND_RETURN_LOG(ShouldAudioServerProcessInruptEvent(interruptEvent, audioInterrupt), + "need not send audioInterrupt to audioServer"); + if (audioInterrupt.isAudioSessionInterrupt) { + AUDIO_INFO_LOG("is audioSession interrupt"); + // record stream may use audioSession in feature,only playback stream use audioSession now + CHECK_AND_RETURN_LOG(sessionService_ != nullptr, "sessionService_ is nullptr"); + const auto &audioInterrupts = sessionService_->GetStreams(audioInterrupt.pid); + for (auto &it : audioInterrupts) { + AudioServerProxy::GetInstance().SendInterruptEventToAudioServerProxy( + interruptEvent, it.sessionId); + } + } else { + //send interruptEvent to audioServer , allow start in background + AudioServerProxy::GetInstance().SendInterruptEventToAudioServerProxy( + interruptEvent, audioInterrupt.sessionId); + } +} + void AudioInterruptService::SendInterruptEventCallback(const InterruptEventInternal &interruptEvent, const uint32_t &streamId, const AudioInterrupt &audioInterrupt) { @@ -2522,7 +2563,7 @@ void AudioInterruptService::SendInterruptEventCallback(const InterruptEventInter AUDIO_ERR_LOG("AudioPolicyServerHandler is nullptr"); return; } - + SendInterruptEventToAudioServer(interruptEvent, audioInterrupt); if (audioInterrupt.isAudioSessionInterrupt) { SendAudioSessionInterruptEventCallback(interruptEvent, audioInterrupt); } else { diff --git a/services/audio_policy/server/infra/ipc_proxy/include/audio_server_proxy.h b/services/audio_policy/server/infra/ipc_proxy/include/audio_server_proxy.h index b66412a119..9e55b51714 100644 --- a/services/audio_policy/server/infra/ipc_proxy/include/audio_server_proxy.h +++ b/services/audio_policy/server/infra/ipc_proxy/include/audio_server_proxy.h @@ -120,6 +120,7 @@ public: void SetSessionMuteState(const uint32_t sessionId, const bool insert, const bool muteFlag); void SetBtHdiInvalidState(); int32_t ForceStopAudioStreamProxy(StopAudioType audioType); + void SendInterruptEventToAudioServerProxy(InterruptEventInternal interruptEvent, int32_t sessionId); private: AudioServerProxy() {} ~AudioServerProxy() {} diff --git a/services/audio_policy/server/infra/ipc_proxy/src/audio_server_proxy.cpp b/services/audio_policy/server/infra/ipc_proxy/src/audio_server_proxy.cpp index 4e0cb0edff..49b63e2bf2 100644 --- a/services/audio_policy/server/infra/ipc_proxy/src/audio_server_proxy.cpp +++ b/services/audio_policy/server/infra/ipc_proxy/src/audio_server_proxy.cpp @@ -699,5 +699,16 @@ int32_t AudioServerProxy::ForceStopAudioStreamProxy(StopAudioType audioType) IPCSkeleton::SetCallingIdentity(identity); return res; } + +void AudioServerProxy::SendInterruptEventToAudioServerProxy(InterruptEventInternal interruptEvent, + int32_t sessionId) +{ + AUDIO_INFO_LOG("hintType:%{public}d for stream:%{public}u", interruptEvent.hintType, sessionId); + const sptr gsp = GetAudioServerProxy(); + std::string identity = IPCSkeleton::ResetCallingIdentity(); + CHECK_AND_RETURN_LOG(gsp != nullptr, "error for audio server proxy null"); + gsp->SendInterruptEventToAudioServer(sessionId, interruptEvent); + IPCSkeleton::SetCallingIdentity(identity); +} } } diff --git a/services/audio_service/server/include/audio_service.h b/services/audio_service/server/include/audio_service.h index d7e6213c33..0b16b1555f 100644 --- a/services/audio_service/server/include/audio_service.h +++ b/services/audio_service/server/include/audio_service.h @@ -142,6 +142,27 @@ public: #endif void RenderersCheckForAudioWorkgroup(int32_t pid); + bool IsInSwitchStreamMap(uint32_t sessionId, SwitchState &switchState); + bool UpdateSwitchStreamMap(uint32_t sessionId, SwitchState switchState); + void RemoveSwitchStreamMap(uint32_t sessionId); + + bool IsInInterruptEventMap(const uint32_t sessionId, InterruptEventInternal &interruptEvent); + bool UpdateInterruptEventMap(const uint32_t sessionId, const InterruptEventInternal &interruptEvent); + bool RemoveInterruptEventMap(const uint32_t sessionIdt); + + bool IsInBackgroudCaptureMap(uint32_t sessionId, BackgroundCaptureState &backCapState); + void InsertBackgroundCaptureMap(const uint32_t sessionId, const BackgroundCaptureState backCapState); + void UpdateBackgroundCaptureMap(const uint32_t sessionId, const BackgroundCaptureState backCapState); + void RemoveBackgroundCaptureMap(const uint32_t sessionId); + bool NeedRemoveInterruptEventAndBackCap(uint32_t sessionId); + + bool NeedVerifyBackgroundCapture(uint32_t sessionId, AudioProcessConfig config); + BackgroundCaptureState VerifyBackgroundCapture(uint32_t sessionId, AudioProcessConfig config); + BackgroundCaptureState UpdateVerifyBackgroundCapture(uint32_t sessionId, AudioProcessConfig config); + bool IsAllowedUsingMicrophone(uint32_t sessionId, AudioProcessConfig config); + + void SendInterruptEventToAudioService(uint32_t sessionId, InterruptEventInternal interruptEvent); + private: AudioService(); void DelayCallReleaseEndpoint(std::string endpointName); @@ -187,6 +208,12 @@ private: std::mutex foregroundSetMutex_; std::set foregroundSet_; std::set foregroundUidSet_; + std::mutex audioSwitchStreamMutex_; + std::map audioSwitchStreamMap_; + std::mutex audioStreamInterruptEventMutex_; + std::map audioStreamInterruptEventMap_; + std::mutex audioStreamBackCapMutex_; + std::map audioStreamBackCapMap_; std::mutex processListMutex_; std::mutex releaseEndpointMutex_; std::condition_variable releaseEndpointCV_; diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index f9f4e3365a..677dea69fb 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -54,6 +54,7 @@ static const int32_t MEDIA_SERVICE_UID = 1013; static const int32_t RENDERER_STREAM_CNT_PER_UID_LIMIT = 40; static const int32_t INVALID_APP_UID = -1; static const int32_t INVALID_APP_CREATED_AUDIO_STREAM_NUM = 0; +static const uint32_t ALLOW_BACKGROUND_CAPTURE_INTERRUPT_RESUME_TIME_OUT = 2; //2s namespace { static inline const std::unordered_set specialSourceTypeSet_ = { SOURCE_TYPE_PLAYBACK_CAPTURE, @@ -61,6 +62,36 @@ static inline const std::unordered_set specialSourceTypeSet_ = { SOURCE_TYPE_VIRTUAL_CAPTURE, SOURCE_TYPE_REMOTE_CAST }; + +enum BackgroundCaptureState { + DENIED_INVALID, + DENIED_APP_IN_BACKGROUND, + ALLOWED_APP_IN_FOREGROUND, + ALLOWED_INTERRUPT_RESUME, + ALLOWED_SWITCH_STREAM_CREATE, + ALLOWED_SWITCH_STREAM_START, + ALLOWED_EXEMPTION_FOREGROUND_APP, + NOTNEED_SYSTEM_APP, + NOTNEED_EXEMPTION_SA, + NOTNEED_EXEMPTION_SOURCETYPE, + NOTNEED_MICROPHONE_BACKGROUND_PERMISSION +}; + +const std::set NEED_NOT_VERIFY_BACKGROUND_CAPTURE_LIST = { +NOTNEED_SYSTEM_APP, +NOTNEED_EXEMPTION_SA, +NOTNEED_EXEMPTION_SOURCETYPE, +NOTNEED_MICROPHONE_BACKGROUND_PERMISSION +}; + +const std::set ALLOWED_BACKGROUND_CAPTURE_LIST = { + ALLOWED_APP_IN_FOREGROUND, + ALLOWED_EXEMPTION_FOREGROUND_APP, + ALLOWED_SWITCH_STREAM_CREATE, + ALLOWED_SWITCH_STREAM_START, + ALLOWED_INTERRUPT_RESUME +}; + const size_t MAX_FG_LIST_SIZE = 10; } @@ -343,6 +374,278 @@ bool AudioService::InForegroundList(uint32_t uid) return false; } +bool AudioService::IsInSwitchStreamMap(uint32_t sessionId, SwitchState &switchState) +{ + std::lock_guardstd::mutex lock(audioSwitchStreamMutex_); + auto iter = audioSwitchStreamMap_.find(sessionId); + CHECK_AND_RETURN_RET_LOG(iter != audioSwitchStreamMap_.end(), false, + "can not find switchStream:%{public}u", sessionId); + switchState = iter->second; + AUDIO_INFO_LOG("SwitchStream:%{public}u, switchState:%{public}d", sessionId, switchState); + return true; +} + +bool AudioService::UpdateSwitchStreamMap(uint32_t sessionId, SwitchState switchState) +{ + std::lock_guardstd::mutex lock(audioSwitchStreamMutex_); + auto iter = audioSwitchStreamMap_.find(sessionId); + if (iter == audioSwitchStreamMap_.end()) { + audioSwitchStreamMap_.[sessionId] = switchState; + AUDIO_WARNING_LOG ("Inserted switchStream:%{public}u, switchState:%{public}d", sessionId, switchState); + return true; + } + iter->second = switchState; + AUDIO_INFO_LOG("Updated switchStream:%{public}u, switchState:%{public}d", sessionId, switchState); + return true; +} + +void AudioService::RemoveSwitchStreamMap(uint32_t sessionId) +{ + std::lock_guardstd::mutex lock(audioSwitchStreamMutex_); + auto iter = audioSwitchStreamMap_.find(sessionId); + if (iter != audioSwitchStreamMap_.end()) { + AUDIO_INFO_LOG("Removed switchStream:%{public}u, switchState:%{public}d", sessionId, iter->second); + audioSwitchStreamMap_.erase(iter); + } else { + AUDIO_WARNING_LOG("switchStream:%{public}u not found", sessionId); + } +} + +bool AudioService::IsInBackgroudCaptureMap(uint32_t sessionId, BackgroundCaptureState &backCapState) +{ + std::lock_guardstd::mutex lock(audioStreamBackCapMutex_); + auto iter = audioStreamBackCapMap_.find(sessionId); + CHECK_AND_RETURN_RET_LOG(iter != audioStreamBackCapMap_.end(), false, + "can not find sessionId:%{public}u", sessionId); + backCapState = iter->second; + AUDIO_INFO_LOG("sessionId:%{public}u, backCapState:%{public}d", sessionId, backCapState); + return true; +} + +void AudioService::UpdateBackgroundCaptureMap(const uint32_t sessionId, + const BackgroundCaptureState backCapState) +{ + std::unique_lockstd::mutex lock(audioStreamBackCapMutex_); + auto it = audioStreamBackCapMap_.find(sessionId); + if (it == audioStreamBackCapMap_.end()) { + audioStreamBackCapMap_[sessionId] = backCapState; + AUDIO_WARNING_LOG("Inserted backgroundCapture:%{public}u backCapState:%{public}d", sessionId, backCapState); + } else { + it->second = backCapState; + AUDIO_INFO_LOG("Updated backgroundCapture:%{public}u backCapState:%{public}d", sessionId, backCapState); + } +} + +void AudioService::RemoveBackgroundCaptureMap(const uint32_t sessionId) +{ + std::unique_lockstd::mutex lock(audioStreamBackCapMutex_); + auto it = audioStreamBackCapMap_.find(sessionId); + if (it != audioStreamBackCapMap_.end()) { + audioStreamBackCapMap_.erase(it); + AUDIO_INFO_LOG("Remove stream:%{public}u from map", sessionId); + } else { + AUDIO_ERR_LOG("Remove failed, stream:%{public}u not found", sessionId); + } +} + +bool AudioService::NeedVerifyBackgroundCapture(uint32_t sessionId, AudioProcessConfig config) +{ + auto sourceType = config.capturerInfo.sourceType; + int32_t callerUid = config.callerUid; + uint32_t tokenId = config.appInfo.appTokenId; + if (PermissionUtil::IsInNotNeedBackgroundCaptureSAList(config.callerUid)) { + AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:internal sa[%{public}d]", + sessionId, callerUid); + InsertBackgroundCaptureMap(sessionId, NOTNEED_WHITE_LIST_SA); + return false; + } + if (PermissionUtil::IsInNotNeedBackgroundCaptureSourceList(sourceType)) { + AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:special sourceType[%{public}d]", + sessionId, sourceType); + InsertBackgroundCaptureMap(sessionId, NOTNEED_SPECIAL_SOURCETYPE); + return false; + } + if (PermissionUtil::VerifyIsSystemApp()) { + AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:system app", sessionId); + InsertBackgroundCaptureMap(sessionId, NOTNEED_SYSTEM_APP); + return false; + } + if (PermissionUtil::VerifyMicrophoneBackgroundPermission(tokenId)) { + AUDIO_INFO_LOG("Stream:%{public}u Result:not need " + "Reason:has permission[MICROPHONE_BACKGROUND_PERMISSION]", sessionId); + InsertBackgroundCaptureMap(sessionId, NOTNEED_MICROPHONE_BACKGROUND_PERMISSION); + return false; +} + AUDIO_INFO_LOG("stream:%{public}u need check backgroud capture", sessionId); + return true; +} + +BackgroundCaptureState AudioService::VerifyBackgroundCapture(uint32_t sessionId, AudioProcessConfig config) +{ + uint32_t tokenId = config.appInfo.appTokenId; + uint64_t fullTokenId = config.appInfo.appFullTokenId; + BackgroundCaptureState backCapState = DENIED_INVALID; + bool res = PermissionUtil::VerifyBackgroundCapture(tokenId, fullTokenId); + if (res) { + AUDIO_INFO_LOG("Stream:%{public}u Result:allowed Reason:app in foreground", sessionId); + backCapState = ALLOWED_APP_IN_FOREGORND; + return backCapState; + } else { + backCapState = DENIED_APP_IN_BACKGROUND; + if (config.capturerInfo.sourceType == SOURCE_TYPE_VOICE_COMMUNICATION && + InForegroundList(config.appInfo.appUid)) { + UpdateForegroundState(tokenId, true); + res = PermissionUtil::VerifyBackgroundCapture(tokenId, fullTokenId); + UpdateForegroundState(tokenId, false); + backCapState = res ? ALLOWED_WHITE_LIST_FOREGROUND : DENIED_APP_IN_BACKGROUND; + } + } + AUDIO_INFO_LOG("Stream:%{public}u Result:%{public}s Reason:%{public}d", + sessionId, res ? "allowed" : "denied", backCapState); + return backCapState; +} + +BackgroundCaptureState AudioService::UpdateVerifyBackgroundCapture( + uint32_t sessionId, AudioProcessConfig config) +{ + BackgroundCaptureState backCapState = DENIED_INVALID; + //InterruptEvent Resume + InterruptEventInternal interruptEvent; + if(IsInInterruptEventMap(sessionId, interruptEvent)) { + int64_t stamp = interruptEvent.eventTimestamp; + stamp = (ClockTime::GetCurNano() - stamp) / AUDIO_US_PER_SECOND; + if (stamp <= ALLOW_BACKGROUND_CAPTURE_INTERRUPT_RESUME_TIME_OUT + && interruptEvent.hintType == INTERRUPT_HINT_RESUME) { + backCapState = ALLOWED_INTERRUPT_RESUME; + UpdateBackgroundCaptureMap(sessionId, backCapState); + RemoveInterruptEventMap(sessionId); + return backCapState; + } + } + return backCapState; +} + +bool AudioService::IsAllowedUsingMicrophone(uint32_t sessionId, AudioProcessConfig config) +{ + uint32_t tokenId = config.appInfo.appTokenId; + //check mic permission + if (!PermissionUtil::VerifyPermission(MICROPHONE_PERMISSION, tokenId)) { + RemoveBackgroundCaptureMap(sessionId); + AUDIO_ERR_LOG("Stream:%{public}u Result:deined Reason:no permission[MICROPHONE_PERMISSION]", sessionId, ); + return false; + } + //check background capture + BackgroundCaptureState backCapState = DENIED_INVALID; + if (IsInBackgroudCaptureMap(sessionId, backCapState)) { + if (NEED_NOT_VERIFY_BACKGROUND_CAPTURE_LIST.count(backCapState)) { + AUDIO_INFO_LOG("Stream:%{public}u, Result:not need, Reason:%{public}d", sessionId, backCapState); + return true; + } + BackgroundCaptureState lastBackCapState = backCapState; + backCapState = VerifyBackgroundCapture(sessionId, config); + if (ALLOWED_BACKGROUND_CAPTURE_LIST.count(backCapState)) { + AUDIO_INFO_LOG("Stream:%{public}u, Result:allowed, Reason:%{public}d", sessionId, backCapState); + UpdateBackgroundCaptureMap(sessionId, backCapState); + return true; + } + if (ALLOWED_BACKGROUND_CAPTURE_LIST.count(lastBackCapState)) { + backCapState = UpdateVerifyBackgroundCapture(sessionId, config); + CHECK_AND_RETURN_RET_LOG(!ALLOWED_BACKGROUND_CAPTURE_LIST.count(backCapState), + true, "check alloewd"); + } + } else { + if (NeedVerifyBackgroundCapture(sessionId, config)) { + backCapState = VerifyBackgroundCapture(sessionId, config); + InsertBackgroundCaptureMap(sessionId, backCapState); + CHECK_AND_RETURN_RET_LOG(!ALLOWED_BACKGROUND_CAPTURE_LIST.count(backCapState), + true, "check alloewd"); + } else { + InsertBackgroundCaptureMap(sessionId, backCapState); + AUDIO_INFO_LOG("stream:%{public}u result:not need Reason:%{public}d", sessionId, backCapState); + return true; + } + } + AUDIO_ERR_LOG("check background capture denied! stream:%{public}u", sessionId); + return false; +} + +bool AudioService::IsInInterruptEventMap(const uint32_t sessionId, + InterruptEventInternal &interruptEvent) +{ + std::lock_guardstd::mutex lock(audioStreamInterruptEventMutex_); + auto iter = audioStreamInterruptEventMap_.find(sessionId); + CHECK_AND_RETURN_RET_LOG(iter != audioStreamInterruptEventMap_.end(), false, + "can not find sessionId:%{public}u", sessionId); + interruptEvent = iter->second; + AUDIO_INFO_LOG("sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); + return true; +} + +bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, + const InterruptEventInternal &interruptEvent) +{ + std::lock_guardstd::mutex lock(audioStreamInterruptEventMutex_); + auto iter = audioStreamInterruptEventMap_.find(sessionId); + + if (iter == audioStreamInterruptEventMap_.end()) { + audioStreamInterruptEventMap_[sessionId] = interruptEvent; + AUDIO_INFO_LOG("Inserted sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); + return true; + } else { + iter->second = interruptEvent; + AUDIO_INFO_LOG("Updated sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); + return true; + } +} + +bool AudioService::RemoveInterruptEventMap(const uint32_t sessionId) +{ + std::lock_guardstd::mutex lock(audioStreamInterruptEventMutex_); + auto iter = audioStreamInterruptEventMap_.find(sessionId); + if (iter == audioStreamInterruptEventMap_.end()) { + return false; + } + audioStreamInterruptEventMap_.erase(iter); + AUDIO_INFO_LOG("Removed sessionId:%{public}u", sessionId); + return true; +} + +bool AudioService::NeedRemoveInterruptEventAndBackCap(uint32_t sessionId) +{ + SwitchState switchState; + if (IsInSwitchStreamMap(sessionId, switchState) ) { + if (switchState == SWITCH_STATE_WAITING) { + AUDIO_WARNING_LOG("SwitchStream should not reset"); + return false; + } + RemoveSwitchStreamMap(sessionId); + } + InterruptEventInternal interruptEvent; + BackgroundCaptureState backCapState = DENIED_INVALID; + if (IsInInterruptEventMap(sessionId, interruptEvent) && IsInBackgroudCaptureMap(sessionId, backCapState)) { + if (interruptEvent.hintType == INTERRUPT_HINT_PAUSE) { + AUDIO_WARNING_LOG ("Pause Intertrupt Event need not reset") + RemoveInterruptEventMap(sessionId); + return false; + } + if (interruptEvent.hintType == INTERRUPT_HINT_MUTE) { + AUDIO_WARNING_LOG("Mute Interrupt means Pause and Resume, need change to Resume "); + interruptEvent.hintType = INTERRUPT_HINT_RESUME; + UpdateInterruptEventMap(sessionId, interruptEvent); + return false; + } + } + return true; +} + +void AudioService::SendInterruptEventToAudioService(uint32_t sessionId, + InterruptEventInternal interruptEvent) +{ + interruptEvent.eventTimestamp = ClockTime::GetCurNano(); + AUDIO_INFO_LOG("Recive InterruptEvent:[%{public}] from InterruptService") + InsertInterruptEventMap(sessionId, interruptEvent); +} + void AudioService::SaveRenderWhitelist(std::vector list) { std::lock_guard lock(renderWhitelistMutex_); -- Gitee From 68542f25efb201314d75dab69e1b2453bbea170b Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 14:18:39 +0000 Subject: [PATCH 02/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- .../native/audioutils/src/audio_utils.cpp | 27 ++++++++++++-- .../interrupt/src/audio_interrupt_service.cpp | 13 ++++--- .../idl/IStandardAudioService.idl | 2 ++ .../libaudio_process_service.versionscript | 3 ++ .../server/include/audio_server.h | 2 ++ .../server/src/audio_process_in_server.cpp | 17 ++++++--- .../audio_service/server/src/audio_server.cpp | 11 ++++++ .../server/src/audio_service.cpp | 35 ++++++++++++++----- .../server/src/capturer_in_server.cpp | 25 ++++++++----- 9 files changed, 106 insertions(+), 29 deletions(-) diff --git a/frameworks/native/audioutils/src/audio_utils.cpp b/frameworks/native/audioutils/src/audio_utils.cpp index aa7d9bd82f..fb009a05e7 100644 --- a/frameworks/native/audioutils/src/audio_utils.cpp +++ b/frameworks/native/audioutils/src/audio_utils.cpp @@ -482,9 +482,32 @@ bool PermissionUtil::VerifySelfPermission() return false; } -bool PermissionUtils::VerifyMicrophoneBackgroundPermission(uint32_t tokenId) +bool PermissionUtil::VerifyMicrophoneBackgroundPermission(uint32_t tokenId) { - + Trace trace("PermissionUtil::VerifyMicrophoneBackground"); + int res = Security::AccessToken::AccessTokenKit::VerifyAccessToken( + tokenId, MICROPHONE_BACKGROUND_PERMISSION); + CHECK_AND_RETURN_RET_LOG(res == Security::AccessToken::PermissionState::PERMISSION_GRANTED, + false, "Permission denied[MICROPHONE_BACKGROUND_PERMISSION]"); + return true; +} + +bool PermissionUtil::IsNotNeedBackgroundCaptureSA(int32_t callerUid) +{ + if (RECORD_ALLOW_BACKGROUND_LIST.count(callerUid)) { + AUDIO_INFO_LOG("internal sa(%{public}d) user directly recording", callerUid); + return true; + } + return false; +} + +bool PermissionUtil::IsNotNeedBackgroundCaptureSourceType(SourceType sourceType) +{ + if (NO_BACKGROUND_CHECK_SOURCE_TYPE.count(sourceType)) { + AUDIO_INFO_LOG("sourceType %{public}d", sourceType); + return true; + } + return false; } bool PermissionUtil::VerifySystemPermission() diff --git a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp index 60f75a9f05..ac580d99b7 100644 --- a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp +++ b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp @@ -2511,9 +2511,12 @@ bool AudioInterruptService::ShouldAudioServerProcessInruptEvent(const InterruptE #ifdef FEATURE_APPGALLERY //CLIENT_TYPE_GAME will be muted or unmuted, need not process in FEATURE_APPGALLERY - uint32_t uid = interruptClients_[audioInterrupt.sessionId]->GetCallingUid(); - ClientType clientType = ClientTypeManager::GetInstance()->GetClientTypeByUid(uid); - CHECK_AND_RETURN_RET_LOG(clientType != CLIENT_TYPE_GAME, false, "clientType is Game"); + if (interruptClients_.find(streamId) != interruptClients_.end() && + interruptClients_[it.streamId] != nullptr) { + uint32_t uid = interruptClients_[audioInterrupt.sessionId]->GetCallingUid(); + ClientType clientType = ClientTypeManager::GetInstance()->GetClientTypeByUid(uid); + CHECK_AND_RETURN_RET_LOG(clientType != CLIENT_TYPE_GAME, false, "clientType is Game"); + } #endif //only process INTERRUPT_HINT_PAUSE INTERRUPT_HINT_STOP INTERRUPT_HINT_RESUME auto hintType = interruptEvent.hintType; @@ -2528,7 +2531,7 @@ void AudioInterruptService::SendInterruptEventToAudioServer( "need not send audioInterrupt to audioServer"); if (audioInterrupt.isAudioSessionInterrupt) { AUDIO_INFO_LOG("is audioSession interrupt"); - // record stream may use audioSession in feature,only playback stream use audioSession now + // record stream may use audioSession in the future,only playback stream use audioSession now CHECK_AND_RETURN_LOG(sessionService_ != nullptr, "sessionService_ is nullptr"); const auto &audioInterrupts = sessionService_->GetStreams(audioInterrupt.pid); for (auto &it : audioInterrupts) { @@ -2536,7 +2539,7 @@ void AudioInterruptService::SendInterruptEventToAudioServer( interruptEvent, it.sessionId); } } else { - //send interruptEvent to audioServer , allow start in background + //send interruptEvent to audioServer , deal with recording in background AudioServerProxy::GetInstance().SendInterruptEventToAudioServerProxy( interruptEvent, audioInterrupt.sessionId); } diff --git a/services/audio_service/idl/IStandardAudioService.idl b/services/audio_service/idl/IStandardAudioService.idl index 491bfeaa64..5989f0b4c8 100644 --- a/services/audio_service/idl/IStandardAudioService.idl +++ b/services/audio_service/idl/IStandardAudioService.idl @@ -32,6 +32,7 @@ sequenceable audio_effect..OHOS.AudioStandard.AudioEnhancePropertyArray; sequenceable hdi_adapter_type..OHOS.AudioStandard.IAudioSinkAttr; sequenceable hdi_adapter_type..OHOS.AudioStandard.IAudioSourceAttr; sequenceable audio_stutter..OHOS.AudioStandard.DataTransferMonitorParam; +sequenceable audio_interrupt_info..OHOS.AudioStandard.InterruptEventInternal; interface IStandardAudioService { [ipccode 0] void GetAudioParameter([in] String key, [out] String value); @@ -143,4 +144,5 @@ interface IStandardAudioService { // undefined in AudioServerInterfaceCode [ipccode 1000] void SetForegroundList([in] List list); void GetVolumeDataCount([in] String sinkName, [out] long ret); + void SendInterruptEventToAudioServer([in] unsigned int sessionId, [in] InterruptEventInternal interruptEvent); } diff --git a/services/audio_service/libaudio_process_service.versionscript b/services/audio_service/libaudio_process_service.versionscript index 5ab9e8992a..f78d70d3a7 100644 --- a/services/audio_service/libaudio_process_service.versionscript +++ b/services/audio_service/libaudio_process_service.versionscript @@ -80,6 +80,9 @@ *SaveRenderWhitelist*; *InRenderWhitelist*; *HpaeCapturerStreamImpl*; + *UpdateSwitchStreamMap; + *SendInterruptEventToAudioServer; + *SendInterruptEventToAudioService; local: *; }; \ No newline at end of file diff --git a/services/audio_service/server/include/audio_server.h b/services/audio_service/server/include/audio_server.h index d282d6000d..4c2e85fd6f 100644 --- a/services/audio_service/server/include/audio_server.h +++ b/services/audio_service/server/include/audio_server.h @@ -267,6 +267,8 @@ public: void OnMuteStateChange(const int32_t &pid, const int32_t &callbackId, const int32_t &uid, const uint32_t &sessionId, const bool &isMuted) override; int32_t SetBtHdiInvalidState() override; + int32_t SendInterruptEventToAudioServer(uint32_t sessionId, + const InterruptEventInternal &interruptEvent) override; protected: void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; diff --git a/services/audio_service/server/src/audio_process_in_server.cpp b/services/audio_service/server/src/audio_process_in_server.cpp index 6249face77..dde62d6365 100644 --- a/services/audio_service/server/src/audio_process_in_server.cpp +++ b/services/audio_service/server/src/audio_process_in_server.cpp @@ -231,8 +231,12 @@ bool AudioProcessInServer::TurnOnMicIndicator(CapturerState capturerState) tokenId, capturerState, }; - if (!SwitchStreamUtil::IsSwitchStreamSwitching(info, SWITCH_STATE_STARTED)) { - CHECK_AND_RETURN_RET_LOG(CheckBGCapturer(), false, "Verify failed"); + if (SwitchStreamUtil::IsSwitchStreamSwitching(info, SWITCH_STATE_STARTED)) { + AudioService::GetInstance()->UpdateBackgroundCaptureMap(sessionId_, ALLOWED_SWITCH_STREAM_START); + AudioService::GetInstance()->UpdateSwitchStreamMap(sessionId_, SWITCH_STATE_STARTED); + } else { + CHECK_AND_RETURN_RET_LOG(AudioService::GetInstance()->IsAllowedUsingMicrophone( + sessionId_, processConfig_), false, "Verify failed"); } SwitchStreamUtil::UpdateSwitchStreamRecord(info, SWITCH_STATE_STARTED); @@ -262,6 +266,11 @@ bool AudioProcessInServer::TurnOffMicIndicator(CapturerState capturerState) }; SwitchStreamUtil::UpdateSwitchStreamRecord(info, SWITCH_STATE_FINISHED); + if (AudioService::GetInstance()->NeedRemoveInterruptEventAndBackCap(sessionId_)) { + AudioService::GetInstance()->RemoveBackgroundCaptureMap(sessionId_); + AudioService::GetInstance()->RemoveInterruptEventMap(sessionId_); + } + if (isMicIndicatorOn_) { PermissionUtil::NotifyPrivacyStop(tokenId, sessionId_); AUDIO_INFO_LOG("Turn off micIndicator of stream:%{public}d from on after NotifyPrivacyStop!", sessionId_); @@ -835,8 +844,8 @@ RestoreStatus AudioProcessInServer::RestoreSession(RestoreInfo restoreInfo) HandleStreamStatusToCapturerState(streamStatus_->load()) }; AUDIO_INFO_LOG("Insert fast record stream:%{public}u uid:%{public}d tokenId:%{public}u " - "into switchStreamRecord because restoreStatus:NEED_RESTORE", - sessionId_, info.callerUid, info.appTokenId); + "restoreStatus:NEED_RESTORE", sessionId_, info.callerUid, info.appTokenId); + AudioService::GetInstance()->UpdateSwitchStreamMap(sessionId_, SWITCH_STATE_WAITING); SwitchStreamUtil::UpdateSwitchStreamRecord(info, SWITCH_STATE_WAITING); } diff --git a/services/audio_service/server/src/audio_server.cpp b/services/audio_service/server/src/audio_server.cpp index 2319cf0186..320d5876b7 100644 --- a/services/audio_service/server/src/audio_server.cpp +++ b/services/audio_service/server/src/audio_server.cpp @@ -2272,6 +2272,15 @@ bool AudioServer::CheckRecorderPermission(const AudioProcessConfig &config) } // LCOV_EXCL_STOP +int32_t AudioServer::SendInterruptEventToAudioServer(uint32_t sessionId, const InterruptEventInternal &interruptEvent) +{ + int32_t callingUid = IPCSkeleton::GetCallingUid(); + CHECK_AND_RETURN_RET_LOG(PermissionUtil::VerifyIsAudio(), ERR_PERMISSION_DENIED, + "Refused for %{public}d", callingUid); + AudioService::GetInstance()->SendInterruptEventToAudioService(sessionId, interruptEvent); + return SUCCESS; +} + bool AudioServer::HandleCheckRecorderBackgroundCapture(const AudioProcessConfig &config) { if (!PermissionUtil::NeedVerifyBackgroundCapture(config.callerUid, config.capturerInfo.sourceType)) { @@ -2297,6 +2306,8 @@ bool AudioServer::HandleCheckRecorderBackgroundCapture(const AudioProcessConfig AUDIO_INFO_LOG("Recreating stream for callerUid:%{public}d need not VerifyBackgroundCapture", config.callerUid); SwitchStreamUtil::UpdateSwitchStreamRecord(info, SWITCH_STATE_CREATED); + AudioService::GetInstance()->UpdateBackgroundCaptureMap(sessionId_, ALLOWED_SWITCH_STREAM_CREATED); + AudioService::GetInstance()->UpdateSwitchStreamMap(config.originalSessionId, SWITCH_STATE_CREATED); return true; } diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index 677dea69fb..123c4f5f2f 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -514,12 +514,23 @@ BackgroundCaptureState AudioService::UpdateVerifyBackgroundCapture( if(IsInInterruptEventMap(sessionId, interruptEvent)) { int64_t stamp = interruptEvent.eventTimestamp; stamp = (ClockTime::GetCurNano() - stamp) / AUDIO_US_PER_SECOND; - if (stamp <= ALLOW_BACKGROUND_CAPTURE_INTERRUPT_RESUME_TIME_OUT - && interruptEvent.hintType == INTERRUPT_HINT_RESUME) { - backCapState = ALLOWED_INTERRUPT_RESUME; - UpdateBackgroundCaptureMap(sessionId, backCapState); + if (stamp <= ALLOW_BACKGROUND_CAPTURE_INTERRUPT_RESUME_TIME_OUT) { + if (interruptEvent.hintType == INTERRUPT_HINT_NONE) { + AUDIO_WARNING_LOG("NONE Interrupt means Pause and Resume, need change to Pause "); + interruptEvent.hintType = INTERRUPT_HINT_PAUSE; + UpdateInterruptEventMap(sessionId, interruptEvent); + backCapState = ALLOWED_INTERRUPT_RESUME; + UpdateBackgroundCaptureMap(sessionId, backCapState); + } else if (interruptEvent.hintType = INTERRUPT_HINT_RESUME){ + backCapState = ALLOWED_INTERRUPT_RESUME; + UpdateBackgroundCaptureMap(sessionId, backCapState); + RemoveInterruptEventMap(sessionId); + } else { + AUDIO_WARNING_LOG("PAUSE interrupt event"); + return backCapState; + } + } else { RemoveInterruptEventMap(sessionId); - return backCapState; } } return backCapState; @@ -591,10 +602,16 @@ bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, audioStreamInterruptEventMap_[sessionId] = interruptEvent; AUDIO_INFO_LOG("Inserted sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); return true; + } else if (iter->second.hintType = INTERRUPT_HINT_NONE|| + (iter->second.hintType = INTERRUPT_HINT_PAUSE && interruptEvent.hintType == INTERRUPT_HINT_RESUME) || + (iter->second.hintType = INTERRUPT_HINT_RESUME && interruptEvent.hintType == INTERRUPT_HINT_PAUSE) { + interruptEvent.hintType = INTERRUPT_HINT_NONE; + iter->second = interruptEvent; + AUDIO_WARNNING_LOG("Updated sessionId:%{public}u, hintType: PAUSE and RESUME", sessionId); + return true; } else { iter->second = interruptEvent; AUDIO_INFO_LOG("Updated sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); - return true; } } @@ -628,8 +645,8 @@ bool AudioService::NeedRemoveInterruptEventAndBackCap(uint32_t sessionId) RemoveInterruptEventMap(sessionId); return false; } - if (interruptEvent.hintType == INTERRUPT_HINT_MUTE) { - AUDIO_WARNING_LOG("Mute Interrupt means Pause and Resume, need change to Resume "); + if (interruptEvent.hintType == INTERRUPT_HINT_NONE) { + AUDIO_WARNING_LOG("NONE Interrupt means Pause and Resume, need change to Resume "); interruptEvent.hintType = INTERRUPT_HINT_RESUME; UpdateInterruptEventMap(sessionId, interruptEvent); return false; @@ -643,7 +660,7 @@ void AudioService::SendInterruptEventToAudioService(uint32_t sessionId, { interruptEvent.eventTimestamp = ClockTime::GetCurNano(); AUDIO_INFO_LOG("Recive InterruptEvent:[%{public}] from InterruptService") - InsertInterruptEventMap(sessionId, interruptEvent); + UpdateInterruptEventMap(sessionId, interruptEvent); } void AudioService::SaveRenderWhitelist(std::vector list) diff --git a/services/audio_service/server/src/capturer_in_server.cpp b/services/audio_service/server/src/capturer_in_server.cpp index 79bc27a988..2ad6d9391d 100644 --- a/services/audio_service/server/src/capturer_in_server.cpp +++ b/services/audio_service/server/src/capturer_in_server.cpp @@ -521,19 +521,22 @@ bool CapturerInServer::TurnOnMicIndicator(CapturerState capturerState) tokenId, capturerState, }; - if (!SwitchStreamUtil::IsSwitchStreamSwitching(info, SWITCH_STATE_STARTED)) { - CHECK_AND_RETURN_RET_LOG(CheckBGCapture(), false, "Verify failed"); + if (SwitchStreamUtil::IsSwitchStreamSwitching(info, SWITCH_STATE_STARTED)) { + AudioService::GetInstance()->UpdateBackgroundCaptureMap( + streamIndex_, ALLOWED_SWITCH_STREAM_START); + AudioService::GetInstance()->UpdateSwitchStreamMap(streamIndex_, SWITCH_STATE_STARTED); + } else { + CHECK_AND_RETURN_RET_LOG(AudioService::GetInstance()->IsAllowedUsingMicrophone( + streamIndex_, processConfig_), false, "Verify failed"); } SwitchStreamUtil::UpdateSwitchStreamRecord(info, SWITCH_STATE_STARTED); if (isMicIndicatorOn_) { - AUDIO_WARNING_LOG("MicIndicator of stream:%{public}d is already on." - "No need to call NotifyPrivacyStart!", streamIndex_); + AUDIO_WARNING_LOG("MicIndicator of stream:%{public}d is already on", streamIndex_); } else { CHECK_AND_RETURN_RET_LOG(PermissionUtil::NotifyPrivacyStart(tokenId, streamIndex_), false, "NotifyPrivacyStart failed!"); - AUDIO_INFO_LOG("Turn on micIndicator of stream:%{public}d from off " - "after NotifyPrivacyStart success!", streamIndex_); + AUDIO_INFO_LOG("Turn on micIndicator of stream:%{public}d", streamIndex_); isMicIndicatorOn_ = true; } return true; @@ -552,6 +555,11 @@ bool CapturerInServer::TurnOffMicIndicator(CapturerState capturerState) }; SwitchStreamUtil::UpdateSwitchStreamRecord(info, SWITCH_STATE_FINISHED); + if (AudioService::GetInstance()->NeedRemoveInterruptEventAndBackCap(streamIndex_)) { + AudioService::GetInstance()->RemoveBackgroundCaptureMap(streamIndex_); + AudioService::GetInstance()->RemoveInterruptEventMap(streamIndex_); + } + if (isMicIndicatorOn_) { PermissionUtil::NotifyPrivacyStop(tokenId, streamIndex_); AUDIO_INFO_LOG("Turn off micIndicator of stream:%{public}d from on after NotifyPrivacyStop!", streamIndex_); @@ -904,10 +912,9 @@ RestoreStatus CapturerInServer::RestoreSession(RestoreInfo restoreInfo) HandleStreamStatusToCapturerState(status_) }; AUDIO_INFO_LOG("Insert fast record stream:%{public}u uid:%{public}d tokenId:%{public}u " - "into switchStreamRecord because restoreStatus:NEED_RESTORE", - streamIndex_, info.callerUid, info.appTokenId); + "restoreStatus:NEED_RESTORE", streamIndex_, info.callerUid, info.appTokenId); + AudioService::GetInstance()->UpdateSwitchStreamMap(streamIndex_, SWITCH_STATE_WAITING); SwitchStreamUtil::UpdateSwitchStreamRecord(info, SWITCH_STATE_WAITING); - audioServerBuffer_->SetRestoreInfo(restoreInfo); } return restoreStatus; -- Gitee From 21b02890a86da645e8a7d8f9907cd9ab2cdd0676 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 14:39:20 +0000 Subject: [PATCH 03/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- .../server/src/audio_service.cpp | 49 +++++++------------ 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index 123c4f5f2f..1c17afd436 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -63,20 +63,6 @@ static inline const std::unordered_set specialSourceTypeSet_ = { SOURCE_TYPE_REMOTE_CAST }; -enum BackgroundCaptureState { - DENIED_INVALID, - DENIED_APP_IN_BACKGROUND, - ALLOWED_APP_IN_FOREGROUND, - ALLOWED_INTERRUPT_RESUME, - ALLOWED_SWITCH_STREAM_CREATE, - ALLOWED_SWITCH_STREAM_START, - ALLOWED_EXEMPTION_FOREGROUND_APP, - NOTNEED_SYSTEM_APP, - NOTNEED_EXEMPTION_SA, - NOTNEED_EXEMPTION_SOURCETYPE, - NOTNEED_MICROPHONE_BACKGROUND_PERMISSION -}; - const std::set NEED_NOT_VERIFY_BACKGROUND_CAPTURE_LIST = { NOTNEED_SYSTEM_APP, NOTNEED_EXEMPTION_SA, @@ -376,7 +362,7 @@ bool AudioService::InForegroundList(uint32_t uid) bool AudioService::IsInSwitchStreamMap(uint32_t sessionId, SwitchState &switchState) { - std::lock_guardstd::mutex lock(audioSwitchStreamMutex_); + std::lock_guard lock(audioSwitchStreamMutex_); auto iter = audioSwitchStreamMap_.find(sessionId); CHECK_AND_RETURN_RET_LOG(iter != audioSwitchStreamMap_.end(), false, "can not find switchStream:%{public}u", sessionId); @@ -387,10 +373,10 @@ bool AudioService::IsInSwitchStreamMap(uint32_t sessionId, SwitchState &switchSt bool AudioService::UpdateSwitchStreamMap(uint32_t sessionId, SwitchState switchState) { - std::lock_guardstd::mutex lock(audioSwitchStreamMutex_); + std::lock_guard lock(audioSwitchStreamMutex_); auto iter = audioSwitchStreamMap_.find(sessionId); if (iter == audioSwitchStreamMap_.end()) { - audioSwitchStreamMap_.[sessionId] = switchState; + audioSwitchStreamMap_[sessionId] = switchState; AUDIO_WARNING_LOG ("Inserted switchStream:%{public}u, switchState:%{public}d", sessionId, switchState); return true; } @@ -401,7 +387,7 @@ bool AudioService::UpdateSwitchStreamMap(uint32_t sessionId, SwitchState switchS void AudioService::RemoveSwitchStreamMap(uint32_t sessionId) { - std::lock_guardstd::mutex lock(audioSwitchStreamMutex_); + std::lock_guard lock(audioSwitchStreamMutex_); auto iter = audioSwitchStreamMap_.find(sessionId); if (iter != audioSwitchStreamMap_.end()) { AUDIO_INFO_LOG("Removed switchStream:%{public}u, switchState:%{public}d", sessionId, iter->second); @@ -413,7 +399,7 @@ void AudioService::RemoveSwitchStreamMap(uint32_t sessionId) bool AudioService::IsInBackgroudCaptureMap(uint32_t sessionId, BackgroundCaptureState &backCapState) { - std::lock_guardstd::mutex lock(audioStreamBackCapMutex_); + std::lock_guard lock(audioStreamBackCapMutex_); auto iter = audioStreamBackCapMap_.find(sessionId); CHECK_AND_RETURN_RET_LOG(iter != audioStreamBackCapMap_.end(), false, "can not find sessionId:%{public}u", sessionId); @@ -425,7 +411,7 @@ bool AudioService::IsInBackgroudCaptureMap(uint32_t sessionId, BackgroundCapture void AudioService::UpdateBackgroundCaptureMap(const uint32_t sessionId, const BackgroundCaptureState backCapState) { - std::unique_lockstd::mutex lock(audioStreamBackCapMutex_); + std::unique_lock lock(audioStreamBackCapMutex_); auto it = audioStreamBackCapMap_.find(sessionId); if (it == audioStreamBackCapMap_.end()) { audioStreamBackCapMap_[sessionId] = backCapState; @@ -438,7 +424,7 @@ void AudioService::UpdateBackgroundCaptureMap(const uint32_t sessionId, void AudioService::RemoveBackgroundCaptureMap(const uint32_t sessionId) { - std::unique_lockstd::mutex lock(audioStreamBackCapMutex_); + std::unique_lock lock(audioStreamBackCapMutex_); auto it = audioStreamBackCapMap_.find(sessionId); if (it != audioStreamBackCapMap_.end()) { audioStreamBackCapMap_.erase(it); @@ -453,16 +439,16 @@ bool AudioService::NeedVerifyBackgroundCapture(uint32_t sessionId, AudioProcessC auto sourceType = config.capturerInfo.sourceType; int32_t callerUid = config.callerUid; uint32_t tokenId = config.appInfo.appTokenId; - if (PermissionUtil::IsInNotNeedBackgroundCaptureSAList(config.callerUid)) { + if (PermissionUtil::IsNotNeedBackgroundCaptureSAList(config.callerUid)) { AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:internal sa[%{public}d]", sessionId, callerUid); - InsertBackgroundCaptureMap(sessionId, NOTNEED_WHITE_LIST_SA); + InsertBackgroundCaptureMap(sessionId, NOTNEED_EXEMPTION_SA); return false; } - if (PermissionUtil::IsInNotNeedBackgroundCaptureSourceList(sourceType)) { + if (PermissionUtil::IsNotNeedBackgroundCaptureSourceList(sourceType)) { AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:special sourceType[%{public}d]", sessionId, sourceType); - InsertBackgroundCaptureMap(sessionId, NOTNEED_SPECIAL_SOURCETYPE); + InsertBackgroundCaptureMap(sessionId, NOTNEED_EXEMPTION_SOURCETYPE); return false; } if (PermissionUtil::VerifyIsSystemApp()) { @@ -474,8 +460,9 @@ bool AudioService::NeedVerifyBackgroundCapture(uint32_t sessionId, AudioProcessC AUDIO_INFO_LOG("Stream:%{public}u Result:not need " "Reason:has permission[MICROPHONE_BACKGROUND_PERMISSION]", sessionId); InsertBackgroundCaptureMap(sessionId, NOTNEED_MICROPHONE_BACKGROUND_PERMISSION); - return false; -} + return false; + } + AUDIO_INFO_LOG("stream:%{public}u need check backgroud capture", sessionId); return true; } @@ -542,7 +529,7 @@ bool AudioService::IsAllowedUsingMicrophone(uint32_t sessionId, AudioProcessConf //check mic permission if (!PermissionUtil::VerifyPermission(MICROPHONE_PERMISSION, tokenId)) { RemoveBackgroundCaptureMap(sessionId); - AUDIO_ERR_LOG("Stream:%{public}u Result:deined Reason:no permission[MICROPHONE_PERMISSION]", sessionId, ); + AUDIO_ERR_LOG("Stream:%{public}u Result:deined Reason:no permission[MICROPHONE_PERMISSION]", sessionId); return false; } //check background capture @@ -583,7 +570,7 @@ bool AudioService::IsAllowedUsingMicrophone(uint32_t sessionId, AudioProcessConf bool AudioService::IsInInterruptEventMap(const uint32_t sessionId, InterruptEventInternal &interruptEvent) { - std::lock_guardstd::mutex lock(audioStreamInterruptEventMutex_); + std::lock_guard lock(audioStreamInterruptEventMutex_); auto iter = audioStreamInterruptEventMap_.find(sessionId); CHECK_AND_RETURN_RET_LOG(iter != audioStreamInterruptEventMap_.end(), false, "can not find sessionId:%{public}u", sessionId); @@ -595,7 +582,7 @@ bool AudioService::IsInInterruptEventMap(const uint32_t sessionId, bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, const InterruptEventInternal &interruptEvent) { - std::lock_guardstd::mutex lock(audioStreamInterruptEventMutex_); + std::lock_guard lock(audioStreamInterruptEventMutex_); auto iter = audioStreamInterruptEventMap_.find(sessionId); if (iter == audioStreamInterruptEventMap_.end()) { @@ -617,7 +604,7 @@ bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, bool AudioService::RemoveInterruptEventMap(const uint32_t sessionId) { - std::lock_guardstd::mutex lock(audioStreamInterruptEventMutex_); + std::lock_guard lock(audioStreamInterruptEventMutex_); auto iter = audioStreamInterruptEventMap_.find(sessionId); if (iter == audioStreamInterruptEventMap_.end()) { return false; -- Gitee From 2bd7cfd99a9ddbc0b3091efdd3728f3b2fdad167 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 14:47:26 +0000 Subject: [PATCH 04/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- .../libaudio_process_service.versionscript | 6 +++--- .../audio_service/server/src/audio_service.cpp | 18 +++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/services/audio_service/libaudio_process_service.versionscript b/services/audio_service/libaudio_process_service.versionscript index f78d70d3a7..e9d5f64691 100644 --- a/services/audio_service/libaudio_process_service.versionscript +++ b/services/audio_service/libaudio_process_service.versionscript @@ -80,9 +80,9 @@ *SaveRenderWhitelist*; *InRenderWhitelist*; *HpaeCapturerStreamImpl*; - *UpdateSwitchStreamMap; - *SendInterruptEventToAudioServer; - *SendInterruptEventToAudioService; + *UpdateSwitchStreamMap*; + *SendInterruptEventToAudioServer*; + *SendInterruptEventToAudioService*; local: *; }; \ No newline at end of file diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index 1c17afd436..1bf097c913 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -64,10 +64,10 @@ static inline const std::unordered_set specialSourceTypeSet_ = { }; const std::set NEED_NOT_VERIFY_BACKGROUND_CAPTURE_LIST = { -NOTNEED_SYSTEM_APP, -NOTNEED_EXEMPTION_SA, -NOTNEED_EXEMPTION_SOURCETYPE, -NOTNEED_MICROPHONE_BACKGROUND_PERMISSION + NOTNEED_SYSTEM_APP, + NOTNEED_EXEMPTION_SA, + NOTNEED_EXEMPTION_SOURCETYPE, + NOTNEED_MICROPHONE_BACKGROUND_PERMISSION }; const std::set ALLOWED_BACKGROUND_CAPTURE_LIST = { @@ -442,27 +442,23 @@ bool AudioService::NeedVerifyBackgroundCapture(uint32_t sessionId, AudioProcessC if (PermissionUtil::IsNotNeedBackgroundCaptureSAList(config.callerUid)) { AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:internal sa[%{public}d]", sessionId, callerUid); - InsertBackgroundCaptureMap(sessionId, NOTNEED_EXEMPTION_SA); return false; } if (PermissionUtil::IsNotNeedBackgroundCaptureSourceList(sourceType)) { AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:special sourceType[%{public}d]", sessionId, sourceType); - InsertBackgroundCaptureMap(sessionId, NOTNEED_EXEMPTION_SOURCETYPE); return false; } if (PermissionUtil::VerifyIsSystemApp()) { AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:system app", sessionId); - InsertBackgroundCaptureMap(sessionId, NOTNEED_SYSTEM_APP); return false; } if (PermissionUtil::VerifyMicrophoneBackgroundPermission(tokenId)) { AUDIO_INFO_LOG("Stream:%{public}u Result:not need " "Reason:has permission[MICROPHONE_BACKGROUND_PERMISSION]", sessionId); - InsertBackgroundCaptureMap(sessionId, NOTNEED_MICROPHONE_BACKGROUND_PERMISSION); return false; } - + AUDIO_INFO_LOG("stream:%{public}u need check backgroud capture", sessionId); return true; } @@ -554,11 +550,11 @@ bool AudioService::IsAllowedUsingMicrophone(uint32_t sessionId, AudioProcessConf } else { if (NeedVerifyBackgroundCapture(sessionId, config)) { backCapState = VerifyBackgroundCapture(sessionId, config); - InsertBackgroundCaptureMap(sessionId, backCapState); + UpdateBackgroundCaptureMap(sessionId, backCapState); CHECK_AND_RETURN_RET_LOG(!ALLOWED_BACKGROUND_CAPTURE_LIST.count(backCapState), true, "check alloewd"); } else { - InsertBackgroundCaptureMap(sessionId, backCapState); + UpdateBackgroundCaptureMap(sessionId, backCapState); AUDIO_INFO_LOG("stream:%{public}u result:not need Reason:%{public}d", sessionId, backCapState); return true; } -- Gitee From 86198da11b65bfa901622b2eef86b8e9086c6a89 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 15:15:09 +0000 Subject: [PATCH 05/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- .../native/audiocapturer/src/audio_capturer.cpp | 2 +- .../native/audioutils/include/audio_utils.h | 4 ++-- frameworks/native/audioutils/src/audio_utils.cpp | 6 +++--- .../native/audiocommon/include/audio_info.h | 2 +- .../interrupt/src/audio_interrupt_service.cpp | 2 +- .../audio_service/server/include/audio_service.h | 2 +- .../audio_service/server/src/audio_server.cpp | 2 +- .../audio_service/server/src/audio_service.cpp | 15 ++++++++------- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/frameworks/native/audiocapturer/src/audio_capturer.cpp b/frameworks/native/audiocapturer/src/audio_capturer.cpp index 53e285d8ac..980710196c 100644 --- a/frameworks/native/audiocapturer/src/audio_capturer.cpp +++ b/frameworks/native/audiocapturer/src/audio_capturer.cpp @@ -167,7 +167,7 @@ std::shared_ptr AudioCapturer::CreateCapturer(const AudioCapturer } AUDIO_INFO_LOG("StreamClientState for Capturer::CreateCapturer sourceType:%{public}d, capturerFlags:%{public}d, " - "AppInfo:[%{public}d] [%{public}s] [%{public}s], ", sourceType, capturerOptions.capturerInfo.capturerFlags, + "AppInfo:[%{public}d] [%{public}s] [%{public}s] ", sourceType, capturerOptions.capturerInfo.capturerFlags, appInfo.appUid, appInfo.appTokenId == 0 ? "T" : "F", appInfo.appFullTokenId == 0 ? "T" : "F"); AudioStreamType audioStreamType = FindStreamTypeBySourceType(sourceType); diff --git a/frameworks/native/audioutils/include/audio_utils.h b/frameworks/native/audioutils/include/audio_utils.h index 39f6ec7423..1c0afd0d3f 100644 --- a/frameworks/native/audioutils/include/audio_utils.h +++ b/frameworks/native/audioutils/include/audio_utils.h @@ -160,8 +160,8 @@ public: static int32_t StopUsingPermission(uint32_t targetTokenId, const char* permission); static bool CheckCallingUidPermission(const std::vector &allowedUids); static bool VerifyMicrophoneBackgroundPermission(uint32_t tokenId); - static bool IsInNotNeedBackgroundCaptureSAList(int32_t callerUis); - static bool IsInNotNeedBackgroundCaptureSourceTypeList(SourceType sourceType); + static bool IsNotNeedBackgroundCaptureSA(int32_t callerUid); + static bool IsNotNeedBackgroundCaptureSourceType(SourceType sourceType); }; // will be move to audio_permission.h in the feture class SwitchStreamUtil { diff --git a/frameworks/native/audioutils/src/audio_utils.cpp b/frameworks/native/audioutils/src/audio_utils.cpp index fb009a05e7..1e49016abc 100644 --- a/frameworks/native/audioutils/src/audio_utils.cpp +++ b/frameworks/native/audioutils/src/audio_utils.cpp @@ -492,7 +492,7 @@ bool PermissionUtil::VerifyMicrophoneBackgroundPermission(uint32_t tokenId) return true; } -bool PermissionUtil::IsNotNeedBackgroundCaptureSA(int32_t callerUid) +bool PermissionUtil::IsNotNeedBackgroundCaptureSA(int32_t callerUid) { if (RECORD_ALLOW_BACKGROUND_LIST.count(callerUid)) { AUDIO_INFO_LOG("internal sa(%{public}d) user directly recording", callerUid); @@ -500,8 +500,8 @@ bool PermissionUtil::IsNotNeedBackgroundCaptureSA(int32_t callerUid) } return false; } - -bool PermissionUtil::IsNotNeedBackgroundCaptureSourceType(SourceType sourceType) + +bool PermissionUtil::IsNotNeedBackgroundCaptureSourceType(SourceType sourceType) { if (NO_BACKGROUND_CHECK_SOURCE_TYPE.count(sourceType)) { AUDIO_INFO_LOG("sourceType %{public}d", sourceType); diff --git a/interfaces/inner_api/native/audiocommon/include/audio_info.h b/interfaces/inner_api/native/audiocommon/include/audio_info.h index 57ce0e9c35..5854768b10 100644 --- a/interfaces/inner_api/native/audiocommon/include/audio_info.h +++ b/interfaces/inner_api/native/audiocommon/include/audio_info.h @@ -81,7 +81,7 @@ const float MIN_FLOAT_VOLUME = 0.0f; const float MAX_FLOAT_VOLUME = 1.0f; const char* MICROPHONE_PERMISSION = "ohos.permission.MICROPHONE"; -const char* MIC_BACK_PERMISSION = "ohos.permission.MICROPHONE_BACKGROUND"; +const char* MICROPHONE_BACKGROUND_PERMISSION = "ohos.permission.MICROPHONE_BACKGROUND"; const char* MODIFY_AUDIO_SETTINGS_PERMISSION = "ohos.permission.MODIFY_AUDIO_SETTINGS"; const char* ACCESS_NOTIFICATION_POLICY_PERMISSION = "ohos.permission.ACCESS_NOTIFICATION_POLICY"; const char* CAPTURER_VOICE_DOWNLINK_PERMISSION = "ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO"; diff --git a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp index ac580d99b7..e7247772be 100644 --- a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp +++ b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp @@ -2516,7 +2516,7 @@ bool AudioInterruptService::ShouldAudioServerProcessInruptEvent(const InterruptE uint32_t uid = interruptClients_[audioInterrupt.sessionId]->GetCallingUid(); ClientType clientType = ClientTypeManager::GetInstance()->GetClientTypeByUid(uid); CHECK_AND_RETURN_RET_LOG(clientType != CLIENT_TYPE_GAME, false, "clientType is Game"); - } + } #endif //only process INTERRUPT_HINT_PAUSE INTERRUPT_HINT_STOP INTERRUPT_HINT_RESUME auto hintType = interruptEvent.hintType; diff --git a/services/audio_service/server/include/audio_service.h b/services/audio_service/server/include/audio_service.h index 0b16b1555f..437019e53c 100644 --- a/services/audio_service/server/include/audio_service.h +++ b/services/audio_service/server/include/audio_service.h @@ -151,7 +151,7 @@ public: bool RemoveInterruptEventMap(const uint32_t sessionIdt); bool IsInBackgroudCaptureMap(uint32_t sessionId, BackgroundCaptureState &backCapState); - void InsertBackgroundCaptureMap(const uint32_t sessionId, const BackgroundCaptureState backCapState); + void UpdateBackgroundCaptureMap(const uint32_t sessionId, const BackgroundCaptureState backCapState); void RemoveBackgroundCaptureMap(const uint32_t sessionId); bool NeedRemoveInterruptEventAndBackCap(uint32_t sessionId); diff --git a/services/audio_service/server/src/audio_server.cpp b/services/audio_service/server/src/audio_server.cpp index 320d5876b7..67d2ee41d3 100644 --- a/services/audio_service/server/src/audio_server.cpp +++ b/services/audio_service/server/src/audio_server.cpp @@ -2306,7 +2306,7 @@ bool AudioServer::HandleCheckRecorderBackgroundCapture(const AudioProcessConfig AUDIO_INFO_LOG("Recreating stream for callerUid:%{public}d need not VerifyBackgroundCapture", config.callerUid); SwitchStreamUtil::UpdateSwitchStreamRecord(info, SWITCH_STATE_CREATED); - AudioService::GetInstance()->UpdateBackgroundCaptureMap(sessionId_, ALLOWED_SWITCH_STREAM_CREATED); + AudioService::GetInstance()->UpdateBackgroundCaptureMap(sessionId_, ALLOWED_SWITCH_STREAM_CREATED); AudioService::GetInstance()->UpdateSwitchStreamMap(config.originalSessionId, SWITCH_STATE_CREATED); return true; } diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index 1bf097c913..67f29cc6ff 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -430,7 +430,7 @@ void AudioService::RemoveBackgroundCaptureMap(const uint32_t sessionId) audioStreamBackCapMap_.erase(it); AUDIO_INFO_LOG("Remove stream:%{public}u from map", sessionId); } else { - AUDIO_ERR_LOG("Remove failed, stream:%{public}u not found", sessionId); + AUDIO_ERR_LOG("Remove failed, stream:%{public}u not found", sessionId); } } @@ -484,7 +484,7 @@ BackgroundCaptureState AudioService::VerifyBackgroundCapture(uint32_t sessionId, } } AUDIO_INFO_LOG("Stream:%{public}u Result:%{public}s Reason:%{public}d", - sessionId, res ? "allowed" : "denied", backCapState); + sessionId, res ? "allowed" : "denied", backCapState); return backCapState; } @@ -494,7 +494,7 @@ BackgroundCaptureState AudioService::UpdateVerifyBackgroundCapture( BackgroundCaptureState backCapState = DENIED_INVALID; //InterruptEvent Resume InterruptEventInternal interruptEvent; - if(IsInInterruptEventMap(sessionId, interruptEvent)) { + if (IsInInterruptEventMap(sessionId, interruptEvent)) { int64_t stamp = interruptEvent.eventTimestamp; stamp = (ClockTime::GetCurNano() - stamp) / AUDIO_US_PER_SECOND; if (stamp <= ALLOW_BACKGROUND_CAPTURE_INTERRUPT_RESUME_TIME_OUT) { @@ -504,7 +504,7 @@ BackgroundCaptureState AudioService::UpdateVerifyBackgroundCapture( UpdateInterruptEventMap(sessionId, interruptEvent); backCapState = ALLOWED_INTERRUPT_RESUME; UpdateBackgroundCaptureMap(sessionId, backCapState); - } else if (interruptEvent.hintType = INTERRUPT_HINT_RESUME){ + } else if (interruptEvent.hintType = INTERRUPT_HINT_RESUME) { backCapState = ALLOWED_INTERRUPT_RESUME; UpdateBackgroundCaptureMap(sessionId, backCapState); RemoveInterruptEventMap(sessionId); @@ -513,6 +513,7 @@ BackgroundCaptureState AudioService::UpdateVerifyBackgroundCapture( return backCapState; } } else { + AUDIO_WARNING_LOG("Timeout! Remove all interruptEvent for stream:%{public}u", sessionId); RemoveInterruptEventMap(sessionId); } } @@ -585,9 +586,9 @@ bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, audioStreamInterruptEventMap_[sessionId] = interruptEvent; AUDIO_INFO_LOG("Inserted sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); return true; - } else if (iter->second.hintType = INTERRUPT_HINT_NONE|| + } else if (iter->second.hintType = INTERRUPT_HINT_NONE|| (iter->second.hintType = INTERRUPT_HINT_PAUSE && interruptEvent.hintType == INTERRUPT_HINT_RESUME) || - (iter->second.hintType = INTERRUPT_HINT_RESUME && interruptEvent.hintType == INTERRUPT_HINT_PAUSE) { + (iter->second.hintType = INTERRUPT_HINT_RESUME && interruptEvent.hintType == INTERRUPT_HINT_PAUSE)) { interruptEvent.hintType = INTERRUPT_HINT_NONE; iter->second = interruptEvent; AUDIO_WARNNING_LOG("Updated sessionId:%{public}u, hintType: PAUSE and RESUME", sessionId); @@ -613,7 +614,7 @@ bool AudioService::RemoveInterruptEventMap(const uint32_t sessionId) bool AudioService::NeedRemoveInterruptEventAndBackCap(uint32_t sessionId) { SwitchState switchState; - if (IsInSwitchStreamMap(sessionId, switchState) ) { + if (IsInSwitchStreamMap(sessionId, switchState)) { if (switchState == SWITCH_STATE_WAITING) { AUDIO_WARNING_LOG("SwitchStream should not reset"); return false; -- Gitee From ed414b98ba0c75dd6d4bb929d00503d797095163 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 15:25:32 +0000 Subject: [PATCH 06/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- services/audio_service/server/src/audio_service.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index 67f29cc6ff..4768d7ab92 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -586,9 +586,9 @@ bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, audioStreamInterruptEventMap_[sessionId] = interruptEvent; AUDIO_INFO_LOG("Inserted sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); return true; - } else if (iter->second.hintType = INTERRUPT_HINT_NONE|| - (iter->second.hintType = INTERRUPT_HINT_PAUSE && interruptEvent.hintType == INTERRUPT_HINT_RESUME) || - (iter->second.hintType = INTERRUPT_HINT_RESUME && interruptEvent.hintType == INTERRUPT_HINT_PAUSE)) { + } else if (iter->second.hintType == INTERRUPT_HINT_NONE|| + (iter->second.hintType == INTERRUPT_HINT_PAUSE && interruptEvent.hintType == INTERRUPT_HINT_RESUME) || + (iter->second.hintType == INTERRUPT_HINT_RESUME && interruptEvent.hintType == INTERRUPT_HINT_PAUSE)) { interruptEvent.hintType = INTERRUPT_HINT_NONE; iter->second = interruptEvent; AUDIO_WARNNING_LOG("Updated sessionId:%{public}u, hintType: PAUSE and RESUME", sessionId); -- Gitee From 39d2847b060b75a93a2eeeed1dae87c1afa15adf Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 15:35:17 +0000 Subject: [PATCH 07/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- .../server/domain/interrupt/src/audio_interrupt_service.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp index e7247772be..de8c906b99 100644 --- a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp +++ b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp @@ -2513,7 +2513,7 @@ bool AudioInterruptService::ShouldAudioServerProcessInruptEvent(const InterruptE //CLIENT_TYPE_GAME will be muted or unmuted, need not process in FEATURE_APPGALLERY if (interruptClients_.find(streamId) != interruptClients_.end() && interruptClients_[it.streamId] != nullptr) { - uint32_t uid = interruptClients_[audioInterrupt.sessionId]->GetCallingUid(); + uint32_t uid = interruptClients_[audioInterrupt.streamId]->GetCallingUid(); ClientType clientType = ClientTypeManager::GetInstance()->GetClientTypeByUid(uid); CHECK_AND_RETURN_RET_LOG(clientType != CLIENT_TYPE_GAME, false, "clientType is Game"); } @@ -2536,12 +2536,12 @@ void AudioInterruptService::SendInterruptEventToAudioServer( const auto &audioInterrupts = sessionService_->GetStreams(audioInterrupt.pid); for (auto &it : audioInterrupts) { AudioServerProxy::GetInstance().SendInterruptEventToAudioServerProxy( - interruptEvent, it.sessionId); + interruptEvent, it.streamId); } } else { //send interruptEvent to audioServer , deal with recording in background AudioServerProxy::GetInstance().SendInterruptEventToAudioServerProxy( - interruptEvent, audioInterrupt.sessionId); + interruptEvent, audioInterrupt.streamId); } } -- Gitee From 1eb36b695b9aba48ba10cee449b1f1177bdbcf56 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 15:53:36 +0000 Subject: [PATCH 08/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- services/audio_service/server/src/audio_service.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index 4768d7ab92..b95b8b8a81 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -585,18 +585,19 @@ bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, if (iter == audioStreamInterruptEventMap_.end()) { audioStreamInterruptEventMap_[sessionId] = interruptEvent; AUDIO_INFO_LOG("Inserted sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); - return true; } else if (iter->second.hintType == INTERRUPT_HINT_NONE|| (iter->second.hintType == INTERRUPT_HINT_PAUSE && interruptEvent.hintType == INTERRUPT_HINT_RESUME) || (iter->second.hintType == INTERRUPT_HINT_RESUME && interruptEvent.hintType == INTERRUPT_HINT_PAUSE)) { + AUDIO_WARNNING_LOG("Updated sessionId:%{public}u, HintType:%{public}d", + sessionId, interruptEvent.hintType); interruptEvent.hintType = INTERRUPT_HINT_NONE; iter->second = interruptEvent; AUDIO_WARNNING_LOG("Updated sessionId:%{public}u, hintType: PAUSE and RESUME", sessionId); - return true; } else { iter->second = interruptEvent; AUDIO_INFO_LOG("Updated sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); } + return true; } bool AudioService::RemoveInterruptEventMap(const uint32_t sessionId) -- Gitee From a2f7c957149184c585ad20870f6121899b8b4773 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 15:57:02 +0000 Subject: [PATCH 09/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- services/audio_service/server/src/audio_service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index b95b8b8a81..9b3993ccd0 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -439,12 +439,12 @@ bool AudioService::NeedVerifyBackgroundCapture(uint32_t sessionId, AudioProcessC auto sourceType = config.capturerInfo.sourceType; int32_t callerUid = config.callerUid; uint32_t tokenId = config.appInfo.appTokenId; - if (PermissionUtil::IsNotNeedBackgroundCaptureSAList(config.callerUid)) { + if (PermissionUtil::IsNotNeedBackgroundCaptureSA(config.callerUid)) { AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:internal sa[%{public}d]", sessionId, callerUid); return false; } - if (PermissionUtil::IsNotNeedBackgroundCaptureSourceList(sourceType)) { + if (PermissionUtil::IsNotNeedBackgroundCaptureSourceType(sourceType)) { AUDIO_INFO_LOG("Stream:%{public}u Result:not need Reason:special sourceType[%{public}d]", sessionId, sourceType); return false; -- Gitee From 7d5dfba83b2218668895c33e24a35477a5862168 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 16:08:57 +0000 Subject: [PATCH 10/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- services/audio_service/server/src/audio_service.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index 9b3993ccd0..5540e0f704 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -581,14 +581,13 @@ bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, { std::lock_guard lock(audioStreamInterruptEventMutex_); auto iter = audioStreamInterruptEventMap_.find(sessionId); - if (iter == audioStreamInterruptEventMap_.end()) { audioStreamInterruptEventMap_[sessionId] = interruptEvent; AUDIO_INFO_LOG("Inserted sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); - } else if (iter->second.hintType == INTERRUPT_HINT_NONE|| + } else if (iter->second.hintType == INTERRUPT_HINT_NONE || (iter->second.hintType == INTERRUPT_HINT_PAUSE && interruptEvent.hintType == INTERRUPT_HINT_RESUME) || (iter->second.hintType == INTERRUPT_HINT_RESUME && interruptEvent.hintType == INTERRUPT_HINT_PAUSE)) { - AUDIO_WARNNING_LOG("Updated sessionId:%{public}u, HintType:%{public}d", + AUDIO_WARNNING_LOG("Updated sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); interruptEvent.hintType = INTERRUPT_HINT_NONE; iter->second = interruptEvent; -- Gitee From c1b8f8d0d314f9c0707c9e9b825e8704e6ad8f35 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 16:13:23 +0000 Subject: [PATCH 11/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- services/audio_service/server/src/audio_service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index 5540e0f704..d740f65ff0 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -471,7 +471,7 @@ BackgroundCaptureState AudioService::VerifyBackgroundCapture(uint32_t sessionId, bool res = PermissionUtil::VerifyBackgroundCapture(tokenId, fullTokenId); if (res) { AUDIO_INFO_LOG("Stream:%{public}u Result:allowed Reason:app in foreground", sessionId); - backCapState = ALLOWED_APP_IN_FOREGORND; + backCapState = ALLOWED_APP_IN_FOREGROUND; return backCapState; } else { backCapState = DENIED_APP_IN_BACKGROUND; @@ -480,7 +480,7 @@ BackgroundCaptureState AudioService::VerifyBackgroundCapture(uint32_t sessionId, UpdateForegroundState(tokenId, true); res = PermissionUtil::VerifyBackgroundCapture(tokenId, fullTokenId); UpdateForegroundState(tokenId, false); - backCapState = res ? ALLOWED_WHITE_LIST_FOREGROUND : DENIED_APP_IN_BACKGROUND; + backCapState = res ? ALLOWED_EXEMPTION_FOREGROUND_APP : DENIED_APP_IN_BACKGROUND; } } AUDIO_INFO_LOG("Stream:%{public}u Result:%{public}s Reason:%{public}d", -- Gitee From 864791a7b4dec095499c97b5983cecb131cb9cad Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 16:50:00 +0000 Subject: [PATCH 12/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- services/audio_service/server/src/audio_service.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index d740f65ff0..d46329348e 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -504,7 +504,7 @@ BackgroundCaptureState AudioService::UpdateVerifyBackgroundCapture( UpdateInterruptEventMap(sessionId, interruptEvent); backCapState = ALLOWED_INTERRUPT_RESUME; UpdateBackgroundCaptureMap(sessionId, backCapState); - } else if (interruptEvent.hintType = INTERRUPT_HINT_RESUME) { + } else if (interruptEvent.hintType == INTERRUPT_HINT_RESUME) { backCapState = ALLOWED_INTERRUPT_RESUME; UpdateBackgroundCaptureMap(sessionId, backCapState); RemoveInterruptEventMap(sessionId); -- Gitee From 64c6fe98e27d627d9bbc33c75fe41ded8dc19280 Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 16:54:15 +0000 Subject: [PATCH 13/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- services/audio_service/server/src/audio_service.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index d46329348e..f0da574089 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -587,11 +587,11 @@ bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, } else if (iter->second.hintType == INTERRUPT_HINT_NONE || (iter->second.hintType == INTERRUPT_HINT_PAUSE && interruptEvent.hintType == INTERRUPT_HINT_RESUME) || (iter->second.hintType == INTERRUPT_HINT_RESUME && interruptEvent.hintType == INTERRUPT_HINT_PAUSE)) { - AUDIO_WARNNING_LOG("Updated sessionId:%{public}u, hintType:%{public}d", + AUDIO_WARNING_LOG("Updated sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); interruptEvent.hintType = INTERRUPT_HINT_NONE; iter->second = interruptEvent; - AUDIO_WARNNING_LOG("Updated sessionId:%{public}u, hintType: PAUSE and RESUME", sessionId); + AUDIO_WARNING_LOG("Updated sessionId:%{public}u, hintType: PAUSE and RESUME", sessionId); } else { iter->second = interruptEvent; AUDIO_INFO_LOG("Updated sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); -- Gitee From 5667f2f5544b1767c42ce608ee586b5b5733786a Mon Sep 17 00:00:00 2001 From: Jvgang Date: Mon, 18 Aug 2025 21:27:23 +0000 Subject: [PATCH 14/14] Interrupt Resume Scene Need to Allow BackgroundCapture Signed-off-by: Jvgang --- .../interrupt/src/audio_interrupt_service.cpp | 4 ++-- .../libaudio_process_service.versionscript | 1 + .../audio_service/server/include/audio_service.h | 2 +- services/audio_service/server/src/audio_server.cpp | 2 +- .../audio_service/server/src/audio_service.cpp | 14 ++++++-------- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp index de8c906b99..b4ff2b73eb 100644 --- a/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp +++ b/services/audio_policy/server/domain/interrupt/src/audio_interrupt_service.cpp @@ -2511,8 +2511,8 @@ bool AudioInterruptService::ShouldAudioServerProcessInruptEvent(const InterruptE #ifdef FEATURE_APPGALLERY //CLIENT_TYPE_GAME will be muted or unmuted, need not process in FEATURE_APPGALLERY - if (interruptClients_.find(streamId) != interruptClients_.end() && - interruptClients_[it.streamId] != nullptr) { + auto it = interruptClients_.find(audioInterrupt.streamId); + if (it != interruptClients_.end() && it->second != nullptr) { uint32_t uid = interruptClients_[audioInterrupt.streamId]->GetCallingUid(); ClientType clientType = ClientTypeManager::GetInstance()->GetClientTypeByUid(uid); CHECK_AND_RETURN_RET_LOG(clientType != CLIENT_TYPE_GAME, false, "clientType is Game"); diff --git a/services/audio_service/libaudio_process_service.versionscript b/services/audio_service/libaudio_process_service.versionscript index e9d5f64691..056d705215 100644 --- a/services/audio_service/libaudio_process_service.versionscript +++ b/services/audio_service/libaudio_process_service.versionscript @@ -81,6 +81,7 @@ *InRenderWhitelist*; *HpaeCapturerStreamImpl*; *UpdateSwitchStreamMap*; + *UpdateBackgroundCaptureMap*; *SendInterruptEventToAudioServer*; *SendInterruptEventToAudioService*; local: diff --git a/services/audio_service/server/include/audio_service.h b/services/audio_service/server/include/audio_service.h index 437019e53c..333db3af8c 100644 --- a/services/audio_service/server/include/audio_service.h +++ b/services/audio_service/server/include/audio_service.h @@ -147,7 +147,7 @@ public: void RemoveSwitchStreamMap(uint32_t sessionId); bool IsInInterruptEventMap(const uint32_t sessionId, InterruptEventInternal &interruptEvent); - bool UpdateInterruptEventMap(const uint32_t sessionId, const InterruptEventInternal &interruptEvent); + bool UpdateInterruptEventMap(const uint32_t sessionId, InterruptEventInternal interruptEvent); bool RemoveInterruptEventMap(const uint32_t sessionIdt); bool IsInBackgroudCaptureMap(uint32_t sessionId, BackgroundCaptureState &backCapState); diff --git a/services/audio_service/server/src/audio_server.cpp b/services/audio_service/server/src/audio_server.cpp index 67d2ee41d3..574f9244d5 100644 --- a/services/audio_service/server/src/audio_server.cpp +++ b/services/audio_service/server/src/audio_server.cpp @@ -2306,7 +2306,7 @@ bool AudioServer::HandleCheckRecorderBackgroundCapture(const AudioProcessConfig AUDIO_INFO_LOG("Recreating stream for callerUid:%{public}d need not VerifyBackgroundCapture", config.callerUid); SwitchStreamUtil::UpdateSwitchStreamRecord(info, SWITCH_STATE_CREATED); - AudioService::GetInstance()->UpdateBackgroundCaptureMap(sessionId_, ALLOWED_SWITCH_STREAM_CREATED); + AudioService::GetInstance()->UpdateBackgroundCaptureMap(config.originalSessionId, ALLOWED_SWITCH_STREAM_CREATE); AudioService::GetInstance()->UpdateSwitchStreamMap(config.originalSessionId, SWITCH_STATE_CREATED); return true; } diff --git a/services/audio_service/server/src/audio_service.cpp b/services/audio_service/server/src/audio_service.cpp index f0da574089..bcc8f11e0b 100644 --- a/services/audio_service/server/src/audio_service.cpp +++ b/services/audio_service/server/src/audio_service.cpp @@ -577,21 +577,19 @@ bool AudioService::IsInInterruptEventMap(const uint32_t sessionId, } bool AudioService::UpdateInterruptEventMap(const uint32_t sessionId, - const InterruptEventInternal &interruptEvent) + InterruptEventInternal interruptEvent) { std::lock_guard lock(audioStreamInterruptEventMutex_); auto iter = audioStreamInterruptEventMap_.find(sessionId); if (iter == audioStreamInterruptEventMap_.end()) { audioStreamInterruptEventMap_[sessionId] = interruptEvent; AUDIO_INFO_LOG("Inserted sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); - } else if (iter->second.hintType == INTERRUPT_HINT_NONE || - (iter->second.hintType == INTERRUPT_HINT_PAUSE && interruptEvent.hintType == INTERRUPT_HINT_RESUME) || + } else if ((iter->second.hintType == INTERRUPT_HINT_PAUSE && interruptEvent.hintType == INTERRUPT_HINT_RESUME) || (iter->second.hintType == INTERRUPT_HINT_RESUME && interruptEvent.hintType == INTERRUPT_HINT_PAUSE)) { - AUDIO_WARNING_LOG("Updated sessionId:%{public}u, hintType:%{public}d", - sessionId, interruptEvent.hintType); + AUDIO_WARNING_LOG("Updated sessionId:%{public}u, interruptEvent:NONE " + "hintType:%{public}d", sessionId, interruptEvent.hintType); interruptEvent.hintType = INTERRUPT_HINT_NONE; iter->second = interruptEvent; - AUDIO_WARNING_LOG("Updated sessionId:%{public}u, hintType: PAUSE and RESUME", sessionId); } else { iter->second = interruptEvent; AUDIO_INFO_LOG("Updated sessionId:%{public}u, hintType:%{public}d", sessionId, interruptEvent.hintType); @@ -625,7 +623,7 @@ bool AudioService::NeedRemoveInterruptEventAndBackCap(uint32_t sessionId) BackgroundCaptureState backCapState = DENIED_INVALID; if (IsInInterruptEventMap(sessionId, interruptEvent) && IsInBackgroudCaptureMap(sessionId, backCapState)) { if (interruptEvent.hintType == INTERRUPT_HINT_PAUSE) { - AUDIO_WARNING_LOG ("Pause Intertrupt Event need not reset") + AUDIO_WARNING_LOG ("Pause Intertrupt Event need not reset"); RemoveInterruptEventMap(sessionId); return false; } @@ -643,7 +641,7 @@ void AudioService::SendInterruptEventToAudioService(uint32_t sessionId, InterruptEventInternal interruptEvent) { interruptEvent.eventTimestamp = ClockTime::GetCurNano(); - AUDIO_INFO_LOG("Recive InterruptEvent:[%{public}] from InterruptService") + AUDIO_INFO_LOG("Recive InterruptEvent:[%{public}d] from InterruptService", interruptEvent.hintType); UpdateInterruptEventMap(sessionId, interruptEvent); } -- Gitee