From 75700850578c18a2c916289a2221ebf811ba9f39 Mon Sep 17 00:00:00 2001 From: caozhijun Date: Sun, 8 Oct 2023 15:28:07 +0800 Subject: [PATCH] Signed-off-by: c459517356 delete rtg group while background --- services/src/concurrent_task_controller.cpp | 33 +++++++-------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 48eb64c..7ef52a0 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -354,29 +354,18 @@ void TaskController::NewForeground(int uid, int pid) } else { CONCUR_LOGE("auth_enable %{public}d fail with ret %{public}d", uid, ret); } - bool found = false; + bool ddlEnabled = OHOS::system::GetBoolParameter(INTERVAL_DDL, false); - for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { - if (iter->GetUid() == uid) { - found = true; - if (ddlEnabled) { - iter->AddKeyThread(uiTid, PRIO_RT); - } - iter->BeginScene(); - } - } - CONCUR_LOGI("uid %{public}d change to foreground.", uid); - if (!found) { - ForegroundAppRecord *tempRecord = new ForegroundAppRecord(uid, uiTid); - if (tempRecord->IsValid()) { - foregroundApp_.push_back(*tempRecord); - if (ddlEnabled) { - tempRecord->AddKeyThread(uiTid, PRIO_RT); - } - tempRecord->BeginScene(); - } else { - delete tempRecord; + + ForegroundAppRecord *tempRecord = new ForegroundAppRecord(uid, uiTid); + if (tempRecord->IsValid()) { + foregroundApp_.push_back(*tempRecord); + if (ddlEnabled) { + tempRecord->AddKeyThread(uiTid, PRIO_RT); } + tempRecord->BeginScene(); + } else { + delete tempRecord; } } @@ -398,7 +387,7 @@ void TaskController::NewBackground(int uid, int pid) } for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { if (iter->GetUid() == uid) { - iter->EndScene(); + foregroundApp_.erase(iter++); return; } } -- Gitee