From 01a6f7cc8b13b8fc3dfcd85c40e1c736b5b1c765 Mon Sep 17 00:00:00 2001 From: ustc_cg Date: Tue, 2 Sep 2025 17:24:14 +0800 Subject: [PATCH] avsession state maintain when switch background Signed-off-by: ustc_cg Change-Id: Id9a24bf3089e47ca945c45780e3d268c99560040 --- .../infra/appclient/src/audio_background_manager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/audio_policy/server/infra/appclient/src/audio_background_manager.cpp b/services/audio_policy/server/infra/appclient/src/audio_background_manager.cpp index 02e61f7391..6dd2317d58 100644 --- a/services/audio_policy/server/infra/appclient/src/audio_background_manager.cpp +++ b/services/audio_policy/server/infra/appclient/src/audio_background_manager.cpp @@ -134,7 +134,6 @@ void AudioBackgroundManager::NotifyAppStateChange(const int32_t uid, const int32 AUDIO_INFO_LOG("OnBackground with uid: %{public}d", uid); backgroundMuteListener_->OnBackgroundMute(uid); } - WriteAppStateChangeSysEvent(pid, appStatesMap_[pid], true); } void AudioBackgroundManager::NotifyBackgroundTaskStateChange(const int32_t uid, const int32_t pid, bool hasBackgroundTask) @@ -145,6 +144,7 @@ void AudioBackgroundManager::NotifyBackgroundTaskStateChange(const int32_t uid, appState.hasBackTask = hasBackgroundTask; appState.isSystem = CheckoutSystemAppUtil::CheckoutSystemApp(uid); InsertIntoAppStatesMap(pid, uid, appState); + WriteAppStateChangeSysEvent(pid, appStatesMap_[pid], true); } else { AppState &appState = appStatesMap_[pid]; CHECK_AND_RETURN(appState.hasBackTask != hasBackgroundTask); @@ -155,8 +155,8 @@ void AudioBackgroundManager::NotifyBackgroundTaskStateChange(const int32_t uid, if (appState.hasBackTask && !appState.isFreeze) { streamCollector_.HandleBackTaskStateChange(uid, appState.hasSession); } + WriteAppStateChangeSysEvent(pid, appStatesMap_[pid], true); } - WriteAppStateChangeSysEvent(pid, appStatesMap_[pid], true); } int32_t AudioBackgroundManager::NotifySessionStateChange(const int32_t uid, const int32_t pid, const bool hasSession) @@ -167,6 +167,7 @@ int32_t AudioBackgroundManager::NotifySessionStateChange(const int32_t uid, cons appState.hasSession = hasSession; appState.isSystem = CheckoutSystemAppUtil::CheckoutSystemApp(uid); InsertIntoAppStatesMap(pid, uid, appState); + WriteAppStateChangeSysEvent(pid, appStatesMap_[pid], true); } else { AppState &appState = appStatesMap_[pid]; CHECK_AND_RETURN_RET(appState.hasSession != hasSession, SUCCESS); @@ -175,8 +176,8 @@ int32_t AudioBackgroundManager::NotifySessionStateChange(const int32_t uid, cons "hasBackgroundTask: %{public}d, isFreeze: %{public}d", pid, appState.hasSession, appState.isBack, appState.hasBackTask, appState.isFreeze); HandleSessionStateChange(uid, pid); + WriteAppStateChangeSysEvent(pid, appStatesMap_[pid], true); } - WriteAppStateChangeSysEvent(pid, appStatesMap_[pid], true); return SUCCESS; } @@ -216,7 +217,6 @@ int32_t AudioBackgroundManager::NotifyFreezeStateChange(const std::set appState.hasBackTask, appState.isFreeze); HandleFreezeStateChange(pid, isFreeze); } - WriteAppStateChangeSysEvent(pid, appStatesMap_[pid], true); } return SUCCESS; } -- Gitee