From 78c9e90da286d0e10f0c367106b820ba20f1605f Mon Sep 17 00:00:00 2001 From: edwardcaoyue Date: Thu, 9 Nov 2023 10:42:10 +0800 Subject: [PATCH] uid auth to pid auth Signed-off-by: edwardcaoyue --- .../include/intellisense_server.h | 6 ++-- .../src/intellisense_server.cpp | 32 +++++++++---------- qos_manager/include/qos_common.h | 8 ++--- qos_manager/src/qos_common.cpp | 18 +++++------ 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/frameworks/core/frame_aware_policy/include/intellisense_server.h b/frameworks/core/frame_aware_policy/include/intellisense_server.h index 7fbbe96..ed01efe 100644 --- a/frameworks/core/frame_aware_policy/include/intellisense_server.h +++ b/frameworks/core/frame_aware_policy/include/intellisense_server.h @@ -49,9 +49,9 @@ private: void NewBackground(int pid); void NewDiedProcess(int pid); void NewAppRecord(int pid, int uid); - void AuthAppKilled(int uid); - void AuthForeground(int uid); - void AuthBackground(int uid); + void AuthAppKilled(int pid); + void AuthForeground(int pid); + void AuthBackground(int pid); int TryCreateRtgForApp(AppInfo *app); int CreateNewRtgGrp(int prioType = 0, int rtNum = 0); inline CgroupPolicy CheckCgroupState(const CgroupPolicy cgroup); diff --git a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp index 699ceab..5abca73 100644 --- a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp +++ b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp @@ -284,11 +284,11 @@ void IntelliSenseServer::ReportCgroupChange(const int pid, const int uid, const if (newState == CgroupPolicy::SP_BACKGROUND) { RME_LOGI("CgroupChange NewBackground"); NewBackground(pid); - AuthBackground(uid); + AuthBackground(pid); } else if (newState == CgroupPolicy::SP_FOREGROUND) { RME_LOGI("web test CgroupChange NewForeground uid is %{public}d", uid); NewForeground(pid, uid); - AuthForeground(uid); + AuthForeground(pid); } } @@ -298,7 +298,7 @@ void IntelliSenseServer::ReportAppInfo(const int pid, const int uid, const std:: return; } if (state == ThreadState::CREATE) { - AuthForeground(uid); + AuthForeground(pid); } RME_LOGI("Get app info:%{public}d %{public}d %{public}s %{public}d", pid, uid, bundleName.c_str(), static_cast(state)); @@ -320,7 +320,7 @@ void IntelliSenseServer::ReportProcessInfo(const int pid, switch (state) { case ThreadState::DIED: RME_LOGI("ProcessInfo NewDiedProcess"); - AuthAppKilled(uid); + AuthAppKilled(pid); NewDiedProcess(pid); break; case ThreadState::CREATE: @@ -345,35 +345,35 @@ void IntelliSenseServer::SetPara(const int32_t currentFps, const int32_t current RME_LOGI("[SetPara]:subEventPara map size: %{public}zu", tempMap.size()); } -void IntelliSenseServer::AuthAppKilled(int uid) +void IntelliSenseServer::AuthAppKilled(int pid) { - int ret = AuthDelete(uid); + int ret = AuthDelete(pid); if (ret == 0) { - RME_LOGI("auth_delete %{public}d success", uid); + RME_LOGI("auth_delete %{public}d success", pid); } else { - RME_LOGE("auth_delete %{public}d failed", uid); + RME_LOGE("auth_delete %{public}d failed", pid); } } -void IntelliSenseServer::AuthForeground(int uid) +void IntelliSenseServer::AuthForeground(int pid) { unsigned int flag = AF_RTG_ALL; int status = AUTH_STATUS_FOREGROUND; - int ret = AuthEnable(uid, flag, status); + int ret = AuthEnable(pid, flag, status); if (ret == 0) { - RME_LOGI("auth_enable %{public}d success", uid); + RME_LOGI("auth_enable %{public}d success", pid); } else { - RME_LOGE("auth_enable %{public}d failed", uid); + RME_LOGE("auth_enable %{public}d failed", pid); } } -void IntelliSenseServer::AuthBackground(int uid) +void IntelliSenseServer::AuthBackground(int pid) { - int ret = AuthPause(uid); + int ret = AuthPause(pid); if (ret == 0) { - RME_LOGI("auth_pause %{public}d success", uid); + RME_LOGI("auth_pause %{public}d success", pid); } else { - RME_LOGE("auth_pause %{public}d failed", uid); + RME_LOGE("auth_pause %{public}d failed", pid); } } diff --git a/qos_manager/include/qos_common.h b/qos_manager/include/qos_common.h index 671bf5c..c99f96c 100644 --- a/qos_manager/include/qos_common.h +++ b/qos_manager/include/qos_common.h @@ -21,7 +21,7 @@ namespace QosCommon { constexpr int AF_RTG_ALL = 0x1fff; struct AuthCtrlData { - int uid; + int pid; unsigned int type; unsigned int rtgFlag; unsigned int qosFlag; @@ -47,9 +47,9 @@ enum AuthStatus { #define BASIC_AUTH_CTRL_OPERATION \ _IOWR(0xCD, 1, struct AuthCtrlData) -int AuthEnable(int uid, unsigned int flag, unsigned int status); -int AuthPause(int uid); -int AuthDelete(int uid); +int AuthEnable(int pid, unsigned int flag, unsigned int status); +int AuthPause(int pid); +int AuthDelete(int pid); } // namespace QosCommon } // namespace OHOS diff --git a/qos_manager/src/qos_common.cpp b/qos_manager/src/qos_common.cpp index 4d8f616..53a3956 100644 --- a/qos_manager/src/qos_common.cpp +++ b/qos_manager/src/qos_common.cpp @@ -34,7 +34,7 @@ static int TrivalOpenAuthCtrlNode(void) return fd; } -int AuthEnable(int uid, unsigned int flag, unsigned int status) +int AuthEnable(int pid, unsigned int flag, unsigned int status) { struct AuthCtrlData data; int fd; @@ -46,7 +46,7 @@ int AuthEnable(int uid, unsigned int flag, unsigned int status) return fd; } - data.uid = uid; + data.pid = pid; data.rtgFlag = flag; data.qosFlag = AF_QOS_DELEGATED; data.status = status; @@ -54,13 +54,13 @@ int AuthEnable(int uid, unsigned int flag, unsigned int status) ret = ioctl(fd, BASIC_AUTH_CTRL_OPERATION, &data); if (ret < 0) { - RME_LOGE("auth enable failed for uid %{public}d with status %{public}u\n", uid, status); + RME_LOGE("auth enable failed for pid %{public}d with status %{public}u\n", pid, status); } close(fd); return ret; } -int AuthPause(int uid) +int AuthPause(int pid) { struct AuthCtrlData data; int fd; @@ -72,7 +72,7 @@ int AuthPause(int uid) return fd; } - data.uid = uid; + data.pid = pid; data.rtgFlag = 0; data.qosFlag = AF_QOS_DELEGATED; data.status = AUTH_STATUS_BACKGROUND; @@ -80,13 +80,13 @@ int AuthPause(int uid) ret = ioctl(fd, BASIC_AUTH_CTRL_OPERATION, &data); if (ret < 0) { - RME_LOGE("auth pause failed for uid %{public}d\n", uid); + RME_LOGE("auth pause failed for pid %{public}d\n", pid); } close(fd); return ret; } -int AuthDelete(int uid) +int AuthDelete(int pid) { struct AuthCtrlData data; int fd; @@ -98,12 +98,12 @@ int AuthDelete(int uid) return fd; } - data.uid = uid; + data.pid = pid; data.type = AUTH_DELETE; ret = ioctl(fd, BASIC_AUTH_CTRL_OPERATION, &data); if (ret < 0) { - RME_LOGE("auth delete failed for uid %{public}d\n", uid); + RME_LOGE("auth delete failed for pid %{public}d\n", pid); } close(fd); return ret; -- Gitee