From 91ea34a7fb020eda6d824ff3f870bb700633a378 Mon Sep 17 00:00:00 2001 From: edwardcaoyue Date: Mon, 18 Mar 2024 14:58:06 +0800 Subject: [PATCH] save focus pid Signed-off-by: edwardcaoyue --- services/include/concurrent_task_controller.h | 1 + services/src/concurrent_task_controller.cpp | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 9b5f5e8..e9c5803 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -95,6 +95,7 @@ private: bool rsAuthed_ = false; std::atomic curGamePid_ = -1; int executorNum_ = 0; + int focusPid_ = -1; const std::string RENDER_SERVICE_PROCESS_NAME = "render_service"; const std::string RESOURCE_SCHEDULE_PROCESS_NAME = "resource_schedule_service"; diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 8eb4245..dde0dfd 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -386,8 +386,7 @@ void TaskController::NewForeground(int uid, int pid) CONCUR_LOGI("un-authed pid %{public}d", pid); return; } - int ret = AuthGet(pid); - if (ret != static_cast(AuthStatus::AUTH_STATUS_FOCUS)) { + if (focusPid_ != pid) { unsigned int pidParam = static_cast(pid); unsigned int uaFlag = AF_RTG_ALL; unsigned int status = static_cast(AuthStatus::AUTH_STATUS_FOREGROUND); @@ -536,9 +535,11 @@ void TaskController::FocusStatusProcess(int uid, int pid, int status) unsigned int qosFlag = AF_QOS_DELEGATED; if (status == static_cast(MSG_GET_FOCUS)) { ret = AuthSwitch(pid, rtgFlag, qosFlag, static_cast(AuthStatus::AUTH_STATUS_FOCUS)); + focusPid_ = pid; CONCUR_LOGI("pid %{public}d get focus. ret %{public}d", pid, ret); } else if (status == static_cast(MSG_LOSE_FOCUS)) { ret = AuthSwitch(pid, rtgFlag, qosFlag, static_cast(AuthStatus::AUTH_STATUS_FOREGROUND)); + focusPid_ = -1; CONCUR_LOGI("pid %{public}d lose focus. ret %{public}d", pid, ret); } else { CONCUR_LOGE("Invalid focus status %{public}d", status); -- Gitee