diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 9b5f5e87d7eed8239b7e11f91470036a29fa03e4..9bef6996e15418fdadd8d63e83b219d1a2bd110f 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 8eb42450edc2a5d05d61ea9f1a2475e8fe991fa8..ccb9c7d9b993ab7c0f766fb11dfebe576f360cb6 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; }