diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 48eb64c5f549352a9a925e7167f9aa3c54843396..7ef52a00ee8a6fdeacfc9643e5ca88a2822c9c9e 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; } }