diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 5dadc7a3232e4c6a406eab9ba3b6afcdd2b55fa0..25e211ac3f32342dbfa23e3c88597a08f626be60 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -82,7 +82,7 @@ private: void SetAppAndRenderServiceRate(int appRate, int rsRate); bool CheckJsonValid(const Json::Value& payload); void SetFrameRate(int rtgId, int rate); - std::list::iterator GetRecordOfPid(int pid); + ForegroundAppRecord* GetRecordOfPid(int pid); void PrintInfo(); bool ParsePayload(const Json::Value& payload, int& uid, int& pid, std::string& bundleName); std::string GetProcessNameByToken(); diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 1596465125503ab630f423c1cf049334943947fd..dc4ad7a18838f9d6392e7ae4f9d8f7abcc5f8420 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -149,12 +149,12 @@ std::string TaskController::GetProcessNameByToken() void TaskController::QueryUi(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - auto iter = GetRecordOfPid(pid); - if (iter == foregroundApp_.end()) { + ForegroundAppRecord* record = GetRecordOfPid(pid); + if (!record) { CONCUR_LOGD("Query ui with pid %{public}d failed", pid); return; } - int grpId = iter->GetGrpId(); + int grpId = record->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query ui with none grpid", pid); queryRs.rtgId = -1; @@ -167,12 +167,12 @@ void TaskController::QueryUi(int uid, IntervalReply& queryRs) void TaskController::QueryRender(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - auto iter = GetRecordOfPid(pid); - if (iter == foregroundApp_.end()) { + ForegroundAppRecord* record = GetRecordOfPid(pid); + if (!record) { CONCUR_LOGD("Query render with pid %{public}d failed", pid); return; } - int grpId = iter->GetGrpId(); + int grpId = record->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query render with none grpid", pid); queryRs.rtgId = -1; @@ -312,12 +312,12 @@ void TaskController::QueryExecutorStart(int uid, int pid, IntervalReply& queryRs void TaskController::QueryHwc(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - auto iter = GetRecordOfPid(pid); - if (iter == foregroundApp_.end()) { + ForegroundAppRecord* record = GetRecordOfPid(pid); + if (!record) { CONCUR_LOGD("Query ipc thread with pid %{public}d failed", pid); return; } - int grpId = iter->GetGrpId(); + int grpId = record->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query ipc thread with none grpid", pid); queryRs.rtgId = -1; @@ -498,15 +498,15 @@ void TaskController::DealSystemRequest(int requestType, const Json::Value& paylo } } -std::list::iterator TaskController::GetRecordOfPid(int pid) +ForegroundAppRecord* TaskController::GetRecordOfPid(int pid) { std::lock_guard lock(appInfoLock_); for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { if (iter->GetPid() == pid) { - return iter; + return &*iter; } } - return foregroundApp_.end(); + return nullptr; } void TaskController::NewForeground(int uid, int pid) @@ -519,6 +519,7 @@ void TaskController::NewForeground(int uid, int pid) } int ret = AuthGet(pid); if (ret != static_cast(AuthStatus::AUTH_STATUS_FOCUS)) { + CONCUR_LOGI("pid %{public}d change to foreground.", pid); unsigned int pidParam = static_cast(pid); unsigned int uaFlag = AF_RTG_ALL; unsigned int status = static_cast(AuthStatus::AUTH_STATUS_FOREGROUND); @@ -528,7 +529,6 @@ void TaskController::NewForeground(int uid, int pid) } else { CONCUR_LOGE("auth_enable %{public}d fail with ret %{public}d", pid, ret); } - CONCUR_LOGI("pid %{public}d change to foreground.", pid); } else { CONCUR_LOGI("pid %{public}d is already focus", pid); } @@ -542,6 +542,7 @@ void TaskController::NewForeground(int uid, int pid) iter->AddKeyThread(uiTid, PRIO_RT); } iter->BeginScene(); + break; } } if (!found) { @@ -624,7 +625,7 @@ void TaskController::AppKilled(int uid, int pid) std::lock_guard lock(appInfoLock_); for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { if (iter->GetPid() == pid) { - foregroundApp_.erase(iter++); + foregroundApp_.erase(iter); break; } } @@ -882,7 +883,7 @@ int TaskController::FindRateFromInfo(int uiTid, const Json::Value& payload) { int appRate = 0; if (payload[std::to_string(uiTid)].isNull()) { - CONCUR_LOGI("FindRateFromInfo tid %{public}d is null", uiTid); + CONCUR_LOGD("FindRateFromInfo tid %{public}d is null", uiTid); return appRate; } try { diff --git a/services/src/qos_interface.cpp b/services/src/qos_interface.cpp index 0003b1733418f06c55e316599bc04edfba326562..b970b4b144878fe3a0ae8e812e64589e3441bfce 100644 --- a/services/src/qos_interface.cpp +++ b/services/src/qos_interface.cpp @@ -203,6 +203,7 @@ int AuthGet(unsigned int pid) ret = ioctl(fd, BASIC_AUTH_CTRL_OPERATION, &data); if (ret < 0) { + close(fd); return ret; } close(fd);