From 4888f37e76b72e44bbf4dfedddbd9193ff71bcb1 Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 21 Feb 2024 15:32:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E5=90=8E=E5=8F=B0=E5=88=A0=E9=99=A4RT?= =?UTF-8?q?G=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Brian --- services/include/concurrent_task_controller.h | 1 + services/src/concurrent_task_controller.cpp | 32 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 9b5f5e8..9bef699 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -78,6 +78,7 @@ private: int GetGamePid(const std::string &gameMsg) const; GameStatus GetGameScene(const std::string &gameMsg) const; void NewForegroundAppRecord(int pid, int uiTid, bool ddlEnabled); + void EraseBackgroundApp(int pid, bool appEnd); std::mutex appInfoLock_; std::mutex rateInfoLock_; diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 8eb4245..ccb9c7d 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -452,12 +452,26 @@ void TaskController::NewBackground(int uid, int pid) } else { CONCUR_LOGI("auth_pause %{public}d fail with %{public}d", pid, ret); } + EraseBackgroundApp(pid, false); +} + +void TaskController::EraseBackgroundApp(int pid, bool appEnd) +{ + std::lock_guard lock(appInfoLock_); for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { if (iter->GetPid() == pid) { - iter->EndScene(); + foregroundApp_.erase(iter++); return; } } + if (appEnd) { + for (auto iter = authApps_.begin(); iter != authApps_.end(); iter++) { + if (*iter == pid) { + authApps_.erase(iter++); + break; + } + } + } } void TaskController::NewAppStart(int uid, int pid) @@ -487,19 +501,7 @@ void TaskController::AppKilled(int uid, int pid) } else { CONCUR_LOGE("auth_delete %{public}d fail with %{public}d", pid, ret); } - std::lock_guard lock(appInfoLock_); - for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { - if (iter->GetPid() == pid) { - foregroundApp_.erase(iter++); - break; - } - } - for (auto iter = authApps_.begin(); iter != authApps_.end(); iter++) { - if (*iter == pid) { - authApps_.erase(iter); - break; - } - } + EraseBackgroundApp(pid, true); } int TaskController::AuthSystemProcess(int pid) @@ -825,8 +827,6 @@ bool ForegroundAppRecord::BeginScene() CONCUR_LOGI("Error begin scene in pid %{public}d", pid_); return false; } - OHOS::RME::BeginFrameFreq(0); - OHOS::RME::EndFrameFreq(0); return true; } -- Gitee