diff --git a/bundle.json b/bundle.json index 62241f7e1a63fd14cf9d6df24c2d4491285f62c6..6f6da4793c4813539d0d3b499ab21c3b03c2a9be 100644 --- a/bundle.json +++ b/bundle.json @@ -15,8 +15,6 @@ "syscap": [], "features": [], "adapted_system_type": [ - "mini", - "small", "standard" ], "rom": "2048KB", @@ -30,6 +28,7 @@ "frame_aware_sched", "hilog", "hitrace", + "init", "ipc", "safwk", "samgr" diff --git a/etc/param/BUILD.gn b/etc/param/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d4856ffc655debfc100e76854f2e55e1b54b9f79 --- /dev/null +++ b/etc/param/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +group("ffrt_etc") { + deps = [ + ":ffrt.para", + ":ffrt.para.dac", + ] +} + +ohos_prebuilt_etc("ffrt.para") { + source = "ffrt.para" + relative_install_dir = "param" + part_name = "qos_manager" + subsystem_name = "resourceschedule" +} + +ohos_prebuilt_etc("ffrt.para.dac") { + source = "ffrt.para.dac" + relative_install_dir = "param" + part_name = "qos_manager" + subsystem_name = "resourceschedule" +} diff --git a/etc/param/ffrt.para b/etc/param/ffrt.para new file mode 100644 index 0000000000000000000000000000000000000000..dfc1ee834a276509cdcb3ec201ed3c3d8bc29462 --- /dev/null +++ b/etc/param/ffrt.para @@ -0,0 +1,18 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ffrt.interval.ui=false +ffrt.interval.renderthread=true +ffrt.interval.renderservice=false +ffrt.interval.slide=false +ffrt.interval.limit=false \ No newline at end of file diff --git a/etc/param/ffrt.para.dac b/etc/param/ffrt.para.dac new file mode 100644 index 0000000000000000000000000000000000000000..54d66a137e1cd67832383337a619aa7576ebba4c --- /dev/null +++ b/etc/param/ffrt.para.dac @@ -0,0 +1,18 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ffrt.interval.ui = system:system:0664 +ffrt.interval.renderthread = system:system:0664 +ffrt.interval.renderservice = system:system:0664 +ffrt.interval.slide = system:system:0664 +ffrt.interval.limit = system:system:0664 diff --git a/frameworks/concurrent_task_client/include/concurrent_task_service_ipc_interface_code.h b/frameworks/concurrent_task_client/include/concurrent_task_service_ipc_interface_code.h index 2ec5618c68adb2cdf66aaacf408a11d9099224c2..ace5b721c5c282e8cff1230bcca0fa89d71db72f 100644 --- a/frameworks/concurrent_task_client/include/concurrent_task_service_ipc_interface_code.h +++ b/frameworks/concurrent_task_client/include/concurrent_task_service_ipc_interface_code.h @@ -16,17 +16,13 @@ #ifndef CONCURRENT_TASK_SERVICES_IPC_INTERFACE_CODE_H #define CONCURRENT_TASK_SERVICES_IPC_INTERFACE_CODE_H -#include "iremote_broker.h" -#include "json/json.h" -#include "concurrent_task_type.h" - /* SAID:1912 */ namespace OHOS { namespace ConcurrentTask { - enum class ConcurrentTaskInterfaceCode { - REPORT_DATA = 1, - QUERY_INTERVAL = 2, - }; +enum class ConcurrentTaskInterfaceCode { + REPORT_DATA = 1, + QUERY_INTERVAL = 2, +}; } // namespace ConcurrentTask } // namespace OHOS diff --git a/frameworks/concurrent_task_client/include/concurrent_task_type.h b/frameworks/concurrent_task_client/include/concurrent_task_type.h index 70d5105d57af8fddf888867630de8b7540120f8e..b95fbc8c8dfc5fb64294485307a7d4bd0ec400ef 100644 --- a/frameworks/concurrent_task_client/include/concurrent_task_type.h +++ b/frameworks/concurrent_task_client/include/concurrent_task_type.h @@ -49,9 +49,9 @@ enum QueryIntervalItem { struct IntervalReply { int rtgId; + int tid; int paramA; int paramB; - int paramC; }; } } diff --git a/frameworks/concurrent_task_client/src/concurrent_task_service_proxy.cpp b/frameworks/concurrent_task_client/src/concurrent_task_service_proxy.cpp index 4ae78b93647d1f8ce9a92c7e9661557696666132..ae88636d59e4b32d7a0c0a7e63333c0301ec3bf9 100644 --- a/frameworks/concurrent_task_client/src/concurrent_task_service_proxy.cpp +++ b/frameworks/concurrent_task_client/src/concurrent_task_service_proxy.cpp @@ -26,15 +26,11 @@ void ConcurrentTaskServiceProxy::ReportData(uint32_t resType, int64_t value, con MessageParcel reply; MessageOption option = { MessageOption::TF_ASYNC }; if (!data.WriteInterfaceToken(ConcurrentTaskServiceProxy::GetDescriptor())) { + CONCUR_LOGE("Write interface token failed in ReportData Proxy"); return; } - if (!data.WriteUint32(resType)) { - return; - } - if (!data.WriteInt64(value)) { - return; - } - if (!data.WriteString(payload.toStyledString())) { + if (!data.WriteUint32(resType) || !data.WriteInt64(value) || !data.WriteString(payload.toStyledString())) { + CONCUR_LOGE("Write info failed in ReportData Proxy"); return; } uint32_t code = static_cast(ConcurrentTaskInterfaceCode::REPORT_DATA); @@ -52,14 +48,13 @@ void ConcurrentTaskServiceProxy::QueryInterval(int queryItem, IntervalReply& que MessageParcel data; MessageParcel reply; MessageOption option = { MessageOption::TF_SYNC }; - queryRs.rtgId = -1; - queryRs.paramA = -1; - queryRs.paramB = -1; - queryRs.paramC = -1; + if (!data.WriteInterfaceToken(ConcurrentTaskServiceProxy::GetDescriptor())) { + CONCUR_LOGE("Write interface token failed in QueryInterval Proxy"); return; } - if (!data.WriteInt64(queryItem)) { + if (!data.WriteInt32(queryItem) || !data.WriteInt32(queryRs.tid)) { + CONCUR_LOGE("Write info failed in QueryInterval Proxy"); return; } @@ -69,16 +64,14 @@ void ConcurrentTaskServiceProxy::QueryInterval(int queryItem, IntervalReply& que CONCUR_LOGE("QueryInterval error: %{public}d", error); return; } - if (!reply.ReadInt32(queryRs.rtgId)) { - return; - } - if (!reply.ReadInt32(queryRs.paramA)) { - return; - } - if (!reply.ReadInt32(queryRs.paramB)) { - return; - } - if (!reply.ReadInt32(queryRs.paramC)) { + queryRs.rtgId = -1; + queryRs.tid = -1; + queryRs.paramA = -1; + queryRs.paramB = -1; + + if (!data.ReadInt32(queryRs.rtgId) || !data.WriteInt32(queryRs.tid) + || !data.ReadInt32(queryRs.paramA) || !data.WriteInt32(queryRs.paramB)) { + CONCUR_LOGE("Read info failed in QueryInterval Proxy"); return; } return; diff --git a/services/BUILD.gn b/services/BUILD.gn index ac889527965e70f13a10b19db29501494915fdf2..6244b988347dc834e1a148c956c2e45c562ebbb6 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -16,6 +16,7 @@ import("//build/ohos.gni") config("concurrent_task_config") { visibility = [ ":*" ] cflags_cc = [ "-fexceptions" ] + cflags = [ "-fstack-protector-strong" ] include_dirs = [ "include", "../include", @@ -40,13 +41,21 @@ ohos_shared_library("concurrentsvc") { "src/qos_manager.cpp", ] - deps = [ "//third_party/jsoncpp:jsoncpp" ] + deps = [ + "../etc/param:ffrt_etc", + "//third_party/jsoncpp:jsoncpp", + ] + + if (defined(global_parts_info.resourceschedule_frame_aware_sched_override)) { + defines = [ "QOS_EXT_ENABLE" ] + } external_deps = [ "c_utils:utils", "eventhandler:libeventhandler", "frame_aware_sched:rtg_interface", "hilog:libhilog", + "init:libbegetutil", "ipc:ipc_single", "safwk:system_ability_fwk", "samgr:samgr_proxy", diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 4c7ed16ba609602835d3c97cd14984521c2df542..739cee9dde7e3c8a58e76254cc301cf8d8ce6cc3 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -43,7 +43,7 @@ private: bool CheckUid(pid_t uid); void TypeMapInit(); void QosApplyInit(); - void SetHwcAuth(bool status); + void SetSystemAuth(int uid, bool status); void TryCreateRsGroup(); void QueryUi(pid_t uid, IntervalReply& queryRs); void QueryRender(pid_t uid, IntervalReply& queryRs); @@ -52,7 +52,7 @@ private: int GetRequestType(std::string strRequstType); void DealSystemRequest(int requestType, const Json::Value& payload); void DealAppRequest(int requestType, const Json::Value& payload, pid_t uid); - void NewForeground(int uid); + void NewForeground(int uid, const Json::Value& payload); void NewBackground(int uid); void NewAppStart(int uid); void AppKilled(int uid); @@ -65,12 +65,13 @@ private: QosManager qosManager_; std::vector authApps_; int renderServiceGrpId_ = -1; + int rsTid_ = -1; bool rtgEnabled_ = false; }; class ForegroundAppRecord { public: - explicit ForegroundAppRecord(int uid); + explicit ForegroundAppRecord(int uid, int uiTid); ~ForegroundAppRecord(); void AddKeyThread(int tid, int prio = PRIO_NORMAL); @@ -84,6 +85,7 @@ public: private: int uid_ = 0; int grpId_ = 0; + int uiTid_ = 0; std::unordered_set keyThreads_; }; } // namespace ConcurrentTask diff --git a/services/include/qos_interface.h b/services/include/qos_interface.h index 37528b298bf96bed39fa7c18e677a85ed099a538..199e283d3db41fb58fb6de83b65ce664c291673e 100644 --- a/services/include/qos_interface.h +++ b/services/include/qos_interface.h @@ -23,8 +23,13 @@ extern "C" { /* * generic */ -#define SYSTEM_UID 1000 -#define ROOT_UID 0 +constexpr int SYSTEM_UID = 1000; +constexpr int ROOT_UID = 0; +constexpr int NR_QOS = 6; +constexpr unsigned int SET_RTG_ENABLE = 1; +constexpr unsigned int QOS_CTRL_IPC_MAGIC = 0xCC; +constexpr unsigned int AUTH_CTRL_IPC_MAGIC = 0xCD; +constexpr unsigned int RTG_SCHED_IPC_MAGIC = 0xAB; /* * auth_ctrl @@ -50,22 +55,19 @@ enum class AuthStatus { AUTH_STATUS_SYSTEM_SERVER = 2, AUTH_STATUS_FOREGROUND = 3, AUTH_STATUS_BACKGROUND = 4, +#ifdef QOS_EXT_ENABLE + AUTH_STATUS_FOCUS = 5, +#endif AUTH_STATUS_DEAD, }; -enum class QosClassLevel { - QOS_UNSPECIFIED = 0, - QOS_BACKGROUND = 1, - QOS_UTILITY = 2, - QOS_DEFAULT = 3, - QOS_USER_INITIATED = 4, - QOS_DEADLINE_REQUEST = 5, - QOS_USER_INTERACTIVE = 6, - QOS_MAX, +enum AuthCtrlCmdid { + BASIC_AUTH_CTRL = 1, + AUTH_CTRL_MAX_NR }; #define BASIC_AUTH_CTRL_OPERATION \ - _IOWR(0xCD, 1, struct AuthCtrlData) + _IOWR(AUTH_CTRL_IPC_MAGIC, BASIC_AUTH_CTRL, struct AuthCtrlData) /* * qos ctrl @@ -73,6 +75,9 @@ enum class QosClassLevel { enum class QosManipulateType { QOS_APPLY = 1, QOS_LEAVE, +#ifdef QOS_EXT_ENABLE + QOS_GET, +#endif QOS_MAX_NR, }; @@ -80,6 +85,12 @@ struct QosCtrlData { int pid; unsigned int type; unsigned int level; +#ifdef QOS_EXT_ENABLE + int qos; + int staticQos; + int dynamicQos; + bool tagSchedEnable = false; +#endif }; struct QosPolicyData { @@ -90,11 +101,14 @@ struct QosPolicyData { int rtSchedPriority; }; -enum class QosPolicyType { +enum QosPolicyType { QOS_POLICY_DEFAULT = 1, QOS_POLICY_SYSTEM_SERVER = 2, QOS_POLICY_FRONT = 3, QOS_POLICY_BACK = 4, +#ifdef QOS_EXT_ENABLE + QOS_POLICY_FOCUS = 5, +#endif QOS_POLICY_MAX_NR, }; @@ -111,13 +125,19 @@ enum class QosPolicyType { struct QosPolicyDatas { int policyType; unsigned int policyFlag; - struct QosPolicyData policys[static_cast(QosClassLevel::QOS_MAX)]; + struct QosPolicyData policys[NR_QOS + 1]; +}; + +enum QosCtrlCmdid { + QOS_CTRL = 1, + QOS_POLICY = 2, + QOS_CTRL_MAX_NR }; #define QOS_CTRL_BASIC_OPERATION \ - _IOWR(0xCC, 1, struct QosCtrlData) + _IOWR(QOS_CTRL_IPC_MAGIC, QOS_CTRL, struct QosCtrlData) #define QOS_CTRL_POLICY_OPERATION \ - _IOWR(0xCC, 2, struct QosPolicyDatas) + _IOWR(QOS_CTRL_IPC_MAGIC, QOS_POLICY, struct QosPolicyDatas) /* * RTG @@ -132,7 +152,7 @@ struct RtgEnableData { }; #define CMD_ID_SET_ENABLE \ - _IOWR(0xAB, 1, struct RtgEnableData) + _IOWR(RTG_SCHED_IPC_MAGIC, SET_RTG_ENABLE, struct RtgEnableData) /* * interface @@ -147,7 +167,7 @@ int QosApply(unsigned int level); int QosApplyForOther(unsigned int level, int tid); int QosLeave(void); int QosLeaveForOther(int tid); -int QosPolicy(struct QosPolicyDatas *policyDatas); +int QosPolicy(const struct QosPolicyDatas *policyDatas); #ifdef __cplusplus } diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 492919aae0c7184a1f20c4e26ae7bfe6670f5ba0..5269e2e0933e297ac8a2063d54dafd517b3e3366 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#include #include #include #include @@ -20,12 +21,18 @@ #include "rtg_interface.h" #include "ipc_skeleton.h" #include "concurrent_task_log.h" +#include "parameters.h" #include "concurrent_task_controller.h" -constexpr int TARGET_UID = 3039; + +constexpr int RS_UID = 1003; using namespace OHOS::RME; namespace OHOS { namespace ConcurrentTask { +const std::string INTERVAL_DDL = "ffrt.interval.renderthread"; +constexpr int CURRENT_RATE = 90; +constexpr int PARAM_TYPE = 1; + TaskController& TaskController::GetInstance() { static TaskController instance; @@ -131,14 +138,23 @@ void TaskController::QueryRender(int uid, IntervalReply& queryRs) void TaskController::QueryRenderService(int uid, IntervalReply& queryRs) { - if (renderServiceGrpId_ > 0) { - CONCUR_LOGD("uid %{public}d query rs group %{public}d.", uid, renderServiceGrpId_); - queryRs.rtgId = renderServiceGrpId_; - return; + if (renderServiceGrpId_ <= 0) { + TryCreateRsGroup(); + CONCUR_LOGI("uid %{public}d query rs group failed and create %{public}d.", uid, renderServiceGrpId_); + if (renderServiceGrpId_ <= 0) { + CONCUR_LOGE("uid %{public}d create rs group failed", uid); + return; + } } - TryCreateRsGroup(); queryRs.rtgId = renderServiceGrpId_; - CONCUR_LOGE("uid %{public}d query rs group failed and create %{public}d.", uid, renderServiceGrpId_); + if (rsTid_ <= 0) { + rsTid_ = queryRs.tid; + int ret = AddThreadToRtg(rsTid_, renderServiceGrpId_, PRIO_RT); + if (ret < 0) { + CONCUR_LOGE("uid %{public}d tid %{public}d join rs group failed.", uid, rsTid_); + } + } + SetFrameRateAndPrioType(renderServiceGrpId_, CURRENT_RATE, PARAM_TYPE); } void TaskController::QueryHwc(int uid, IntervalReply& queryRs) @@ -161,25 +177,25 @@ void TaskController::QueryHwc(int uid, IntervalReply& queryRs) } } -void TaskController::SetHwcAuth(bool status) +void TaskController::SetSystemAuth(int uid, bool status) { int ret; if (status) { - ret = AuthEnable(TARGET_UID, AF_RTG_ALL, static_cast(AuthStatus::AUTH_STATUS_FOREGROUND)); + ret = AuthEnable(uid, AF_RTG_ALL, static_cast(AuthStatus::AUTH_STATUS_FOREGROUND)); } else { - ret = AuthDelete(TARGET_UID); + ret = AuthDelete(uid); } if (ret == 0) { - CONCUR_LOGI("set auth status(%{public}d) for %{public}d success", status, TARGET_UID); + CONCUR_LOGI("set auth status(%{public}d) for %{public}d success", status, uid); } else { - CONCUR_LOGE("set auth status(%{public}d) for %{public}d fail with ret %{public}d ", status, TARGET_UID, ret); + CONCUR_LOGE("set auth status(%{public}d) for %{public}d fail with ret %{public}d ", status, uid, ret); } } void TaskController::Init() { - SetHwcAuth(true); + SetSystemAuth(RS_UID, true); TypeMapInit(); qosManager_.Init(); TryCreateRsGroup(); @@ -187,7 +203,7 @@ void TaskController::Init() void TaskController::Release() { - SetHwcAuth(false); + SetSystemAuth(RS_UID, false); msgType_.clear(); if (renderServiceGrpId_ <= 0) { return; @@ -222,7 +238,9 @@ void TaskController::TryCreateRsGroup() } if (renderServiceGrpId_ <= 0) { CONCUR_LOGI("CreateRsRtgGroup failed! rtGrp:%{public}d", renderServiceGrpId_); + return; } + SetSystemAuth(RS_UID, true); } int TaskController::GetRequestType(std::string strRequstType) @@ -256,7 +274,7 @@ void TaskController::DealSystemRequest(int requestType, const Json::Value& paylo } switch (requestType) { case MSG_FOREGROUND: - NewForeground(appUid); + NewForeground(appUid, payload); break; case MSG_BACKGROUND: NewBackground(appUid); @@ -309,8 +327,21 @@ std::list::iterator TaskController::GetRecordOfUid(int uid) return foregroundApp_.end(); } -void TaskController::NewForeground(int uid) +void TaskController::NewForeground(int uid, const Json::Value& payload) { + int uiTid = 0; +#ifdef QOS_EXT_ENABLE + try { + uiTid = std::stoi(payload["pid"].asString()); + } catch (...) { + CONCUR_LOGE("Unexpected pid format uiTid is %{public}d", uiTid); + return; + } + if (uiTid < 0) { + CONCUR_LOGE("uiTid error: %{public}d", uiTid); + return; + } +#endif auto it = find(authApps_.begin(), authApps_.end(), uid); if (it == authApps_.end()) { CONCUR_LOGI("un-authed uid %{public}d", uid); @@ -319,7 +350,6 @@ void TaskController::NewForeground(int uid) unsigned int uidParam = static_cast(uid); unsigned int uaFlag = AF_RTG_ALL; unsigned int status = static_cast(AuthStatus::AUTH_STATUS_FOREGROUND); - int ret = AuthEnable(uidParam, uaFlag, status); if (ret == 0) { CONCUR_LOGI("auth_enable %{public}d success", uid); @@ -327,18 +357,24 @@ void TaskController::NewForeground(int uid) 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; - CONCUR_LOGI("uid %{public}d is already in foreground.", uid); + 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); + 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; @@ -418,16 +454,14 @@ void TaskController::PrintInfo() } } -ForegroundAppRecord::ForegroundAppRecord(int uid) +ForegroundAppRecord::ForegroundAppRecord(int uid, int uiTid) { uid_ = uid; - grpId_ = CreateNewRtgGrp(PRIO_RT, MAX_KEY_THREADS); - if (grpId_ <= 0) { - CONCUR_LOGI("CreateNewRtgGroup with RT failed, try change to normal type."); - grpId_ = CreateNewRtgGrp(PRIO_NORMAL, MAX_KEY_THREADS); - } - if (grpId_ <= 0) { - CONCUR_LOGI("CreateNewRtgGroup failed! rtGrp:%{public}d, pid: %{public}d", grpId_, uid); + uiTid_ = uiTid; + if (OHOS::system::GetBoolParameter(INTERVAL_DDL, false)) { + grpId_ = CreateNewRtgGrp(PRIO_RT, MAX_KEY_THREADS); + } else { + grpId_ = -1; } } @@ -457,7 +491,7 @@ void ForegroundAppRecord::AddKeyThread(int tid, int prio) } else { int ret = AddThreadToRtg(tid, grpId_, rtgPrio); if (ret != 0) { - CONCUR_LOGI("Add key thread fail: Kernel err report."); + CONCUR_LOGI("Add key thread fail: Kernel err report. ret is %{public}d", ret); } else { CONCUR_LOGI("Add key thread %{public}d", tid); } @@ -478,8 +512,9 @@ bool ForegroundAppRecord::BeginScene() bool ForegroundAppRecord::EndScene() { + grpId_ = SearchRtgForTid(uiTid_); if (grpId_ <= 0) { - CONCUR_LOGI("Error end scene in uid %{public}d", uid_); + CONCUR_LOGI("Error end scene loss grpId_ in uid %{public}d", uid_); return false; } OHOS::RME::EndScene(grpId_); @@ -498,7 +533,7 @@ int ForegroundAppRecord::GetGrpId() bool ForegroundAppRecord::IsValid() { - if (uid_ > 0 && grpId_ > 0) { + if (uid_ > 0) { return true; } return false; diff --git a/services/src/concurrent_task_service_stub.cpp b/services/src/concurrent_task_service_stub.cpp index 1cc9427dcd016fdf49b669ae8e3031d42b0afc62..71e49c5812d66f56d74671148a5ac52cc23ff901 100644 --- a/services/src/concurrent_task_service_stub.cpp +++ b/services/src/concurrent_task_service_stub.cpp @@ -45,19 +45,13 @@ int32_t ConcurrentTaskServiceStub::ReportDataInner(MessageParcel& data, [[maybe_ if (!IsValidToken(data)) { return ERR_CONCURRENT_TASK_PARCEL_ERROR; } - uint32_t type = 0; - if (!data.ReadUint32(type)) { - return ERR_CONCURRENT_TASK_PARCEL_ERROR; - } + uint32_t type = 0; int64_t value = 0; - if (!data.ReadInt64(value)) { - return ERR_CONCURRENT_TASK_PARCEL_ERROR; - } - std::string payload; - if (!data.ReadString(payload)) { - return ERR_CONCURRENT_TASK_PARCEL_ERROR; + if (!data.ReadUint32(type) || !data.ReadInt64(value) || !data.ReadString(payload)) { + CONCUR_LOGE("Read info failed in ReportData Stub"); + return IPC_STUB_ERR; } if (payload.empty()) { return ERR_OK; @@ -72,26 +66,20 @@ int32_t ConcurrentTaskServiceStub::QueryIntervalInner(MessageParcel& data, [[may return ERR_CONCURRENT_TASK_PARCEL_ERROR; } int item; - if (!data.ReadInt32(item)) { - return ERR_CONCURRENT_TASK_PARCEL_ERROR; - } IntervalReply queryRs; queryRs.rtgId = -1; + queryRs.tid = -1; queryRs.paramA = -1; queryRs.paramB = -1; - queryRs.paramC = -1; - QueryInterval(item, queryRs); - if (!reply.WriteInt32(queryRs.rtgId)) { - return ERR_CONCURRENT_TASK_PARCEL_ERROR; - } - if (!reply.WriteInt32(queryRs.paramA)) { - return ERR_CONCURRENT_TASK_PARCEL_ERROR; + if (!data.ReadInt32(item) || !data.ReadInt32(queryRs.tid)) { + CONCUR_LOGE("Read info failed in QueryInterval Stub"); + return IPC_STUB_ERR; } - if (!reply.WriteInt32(queryRs.paramB)) { - return ERR_CONCURRENT_TASK_PARCEL_ERROR; - } - if (!reply.WriteInt32(queryRs.paramC)) { - return ERR_CONCURRENT_TASK_PARCEL_ERROR; + QueryInterval(item, queryRs); + if (!data.WriteInt32(queryRs.rtgId) || !data.WriteInt32(queryRs.tid) + || !data.WriteInt32(queryRs.paramA) || !data.WriteInt32(queryRs.paramB)) { + CONCUR_LOGE("Write info failed in QueryInterval Stub"); + return IPC_STUB_ERR; } return ERR_OK; } diff --git a/services/src/qos_interface.cpp b/services/src/qos_interface.cpp index e5d2fb6020ed1395e4c867fac763949a60f0379b..b16bbd918ff6157b65a2a1ecbbbb06fd0f909a94 100644 --- a/services/src/qos_interface.cpp +++ b/services/src/qos_interface.cpp @@ -66,7 +66,7 @@ static int TrivalOpenQosCtrlNode(void) int EnableRtg(bool flag) { struct RtgEnableData enableData; - char configStr[] = "load_freq_switch:1;sched_cycle:1;frame_max_util:750"; + char configStr[] = "load_freq_switch:1;sched_cycle:1;frame_max_util:1024"; int ret; enableData.enable = flag; @@ -303,7 +303,7 @@ int QosLeaveForOther(int tid) return ret; } -int QosPolicy(struct QosPolicyDatas *policyDatas) +int QosPolicy(const struct QosPolicyDatas *policyDatas) { int fd; int ret; diff --git a/services/src/qos_manager.cpp b/services/src/qos_manager.cpp index e9fe5ae60d5903bf236185e1a63ff622c600fe93..31db399af762dd2cae4fbbb458db442aaa701fdf 100644 --- a/services/src/qos_manager.cpp +++ b/services/src/qos_manager.cpp @@ -18,7 +18,7 @@ #include "concurrent_task_log.h" static struct QosPolicyDatas g_defaultQosPolicy = { - .policyType = static_cast(QosPolicyType::QOS_POLICY_DEFAULT), + .policyType = QOS_POLICY_DEFAULT, .policyFlag = QOS_FLAG_ALL, .policys = { {0, 0, 0, 1024, 0}, @@ -32,21 +32,27 @@ static struct QosPolicyDatas g_defaultQosPolicy = { }; static struct QosPolicyDatas g_foregroundQosPolicy = { - .policyType = static_cast(QosPolicyType::QOS_POLICY_FRONT), + .policyType = QOS_POLICY_FRONT, .policyFlag = QOS_FLAG_ALL, .policys = { {0, 0, 0, 1024, 0}, {10, 10, 0, 200, 0}, {5, 5, 0, 250, 0}, {0, 0, 0, 1024, 0}, - {-5, -5, 300, 1024, 0}, +#ifdef QOS_EXT_ENABLE + {-10, 0, 300, 1024, 0}, {-10, -10, 500, 1024, 0}, {-10, -10, 500, 1024, 2}, +#else + {0, 0, 0, 1024, 0}, + {0, 0, 0, 1024, 0}, + {0, 0, 0, 1024, 0}, +#endif } }; static struct QosPolicyDatas g_backgroundQosPolicy = { - .policyType = static_cast(QosPolicyType::QOS_POLICY_BACK), + .policyType = QOS_POLICY_BACK, .policyFlag = QOS_FLAG_ALL & ~QOS_FLAG_RT, .policys = { {0, 0, 0, 1024, 0}, @@ -54,22 +60,33 @@ static struct QosPolicyDatas g_backgroundQosPolicy = { {10, 10, 0, 200, 0}, {5, 5, 0, 250, 0}, {0, 0, 0, 300, 0}, +#ifdef QOS_EXT_ENABLE {-5, -5, 0, 350, 0}, {-5, -5, 0, 350, 3}, +#else + {0, 0, 0, 1024, 0}, + {0, 0, 0, 1024, 0}, +#endif } }; static struct QosPolicyDatas g_systemServerQosPolicy = { - .policyType = static_cast(QosPolicyType::QOS_POLICY_SYSTEM_SERVER), + .policyType = QOS_POLICY_SYSTEM_SERVER, .policyFlag = QOS_FLAG_ALL, .policys = { {0, 0, 0, 1024, 0}, {10, 10, 0, 200, 0}, {5, 5, 0, 250, 0}, {0, 0, 0, 1024, 0}, - {-5, -5, 300, 1024, 0}, +#ifdef QOS_EXT_ENABLE + {-10, 0, 300, 1024, 0}, {-10, -10, 500, 1024, 0}, {-10, -10, 500, 1024, 2}, +#else + {0, 0, 0, 1024, 0}, + {0, 0, 0, 1024, 0}, + {0, 0, 0, 1024, 0}, +#endif } }; diff --git a/test/unittest/phone/concurrent_task_controller_test.cpp b/test/unittest/phone/concurrent_task_controller_test.cpp index fda34038f1dda02ccbb88b9e37e25abf424c325c..46a85f642ab43dbf23829eaf740acb53a18698e4 100644 --- a/test/unittest/phone/concurrent_task_controller_test.cpp +++ b/test/unittest/phone/concurrent_task_controller_test.cpp @@ -107,11 +107,11 @@ HWTEST_F(ConcurrentTaskControllerTest, InitTest, TestSize.Level1) * @tc.desc: Test whether the PushTask interface are normal. * @tc.type: FUNC */ -HWTEST_F(ConcurrentTaskControllerTest, AuthHwcTest, TestSize.Level1) +HWTEST_F(ConcurrentTaskControllerTest, AuthSystemTest, TestSize.Level1) { - TaskController::GetInstance().SetHwcAuth(true); - TaskController::GetInstance().SetHwcAuth(false); - TaskController::GetInstance().SetHwcAuth(true); + TaskController::GetInstance().SetSystemAuth(3039, true); + TaskController::GetInstance().SetSystemAuth(3039, false); + TaskController::GetInstance().SetSystemAuth(3039, true); } /** @@ -201,22 +201,22 @@ HWTEST_F(ConcurrentTaskControllerTest, NewForegroundTest, TestSize.Level1) { TaskController fore; int uid = 0; - fore.NewForeground(uid); + fore.NewForeground(uid, 0); fore.NewBackground(uid); fore.NewAppStart(uid); - fore.NewForeground(uid); + fore.NewForeground(uid, 0); fore.NewBackground(uid); fore.AppKilled(uid); uid = 574; - fore.foregroundApp_.push_back(ForegroundAppRecord(574)); - fore.foregroundApp_.push_back(ForegroundAppRecord(1)); - fore.foregroundApp_.push_back(ForegroundAppRecord(3)); + fore.foregroundApp_.push_back(ForegroundAppRecord(574, 0)); + fore.foregroundApp_.push_back(ForegroundAppRecord(1, 0)); + fore.foregroundApp_.push_back(ForegroundAppRecord(3, 0)); auto iter = fore.foregroundApp_.begin(); EXPECT_EQ(iter->GetUid(), uid); - fore.NewForeground(uid); + fore.NewForeground(uid, 0); fore.NewBackground(uid); fore.NewAppStart(uid); - fore.NewForeground(uid); + fore.NewForeground(uid, 0); fore.NewBackground(uid); fore.AppKilled(uid); } @@ -229,9 +229,9 @@ HWTEST_F(ConcurrentTaskControllerTest, NewForegroundTest, TestSize.Level1) HWTEST_F(ConcurrentTaskControllerTest, PrintInfoTest, TestSize.Level1) { TaskController print; - print.foregroundApp_.push_back(ForegroundAppRecord(1)); - print.foregroundApp_.push_back(ForegroundAppRecord(3)); - print.foregroundApp_.push_back(ForegroundAppRecord(5)); + print.foregroundApp_.push_back(ForegroundAppRecord(1, 0)); + print.foregroundApp_.push_back(ForegroundAppRecord(3, 0)); + print.foregroundApp_.push_back(ForegroundAppRecord(5, 0)); auto iter = print.foregroundApp_.begin(); EXPECT_NE(iter, print.foregroundApp_.end()); print.PrintInfo(); @@ -251,7 +251,7 @@ HWTEST_F(ConcurrentTaskControllerTest, AddKeyThreadTest, TestSize.Level1) int tid4 = 48; int tid5 = 49; int prio = PRIO_NORMAL; - ForegroundAppRecord foregroundapprecord = ForegroundAppRecord(uid); + ForegroundAppRecord foregroundapprecord = ForegroundAppRecord(uid, 0); foregroundapprecord.AddKeyThread(tid, prio); foregroundapprecord.keyThreads_.insert(tid); foregroundapprecord.AddKeyThread(tid, prio); @@ -281,7 +281,7 @@ HWTEST_F(ConcurrentTaskControllerTest, AddKeyThreadTest, TestSize.Level1) HWTEST_F(ConcurrentTaskControllerTest, BeginSceneTest, TestSize.Level1) { int uid = 758; - ForegroundAppRecord foregroundapprecord = ForegroundAppRecord(uid); + ForegroundAppRecord foregroundapprecord = ForegroundAppRecord(uid, 0); foregroundapprecord.BeginScene(); foregroundapprecord.EndScene(); foregroundapprecord.grpId_ = -1; @@ -300,7 +300,7 @@ HWTEST_F(ConcurrentTaskControllerTest, BeginSceneTest, TestSize.Level1) HWTEST_F(ConcurrentTaskControllerTest, IsValidTest, TestSize.Level1) { int uid = 758; - ForegroundAppRecord foregroundapprecord = ForegroundAppRecord(uid); + ForegroundAppRecord foregroundapprecord = ForegroundAppRecord(uid, 0); EXPECT_EQ(foregroundapprecord.GetUid(), foregroundapprecord.uid_); EXPECT_EQ(foregroundapprecord.GetGrpId(), foregroundapprecord.grpId_); foregroundapprecord.uid_ = -1; @@ -311,7 +311,7 @@ HWTEST_F(ConcurrentTaskControllerTest, IsValidTest, TestSize.Level1) EXPECT_EQ(foregroundapprecord.IsValid(), false); foregroundapprecord.uid_ = 1; foregroundapprecord.grpId_ = -1; - EXPECT_EQ(foregroundapprecord.IsValid(), false); + EXPECT_EQ(foregroundapprecord.IsValid(), true); foregroundapprecord.uid_ = 1; foregroundapprecord.grpId_ = 1; EXPECT_EQ(foregroundapprecord.IsValid(), true); @@ -325,7 +325,7 @@ HWTEST_F(ConcurrentTaskControllerTest, IsValidTest, TestSize.Level1) HWTEST_F(ConcurrentTaskControllerTest, PrintKeyThreadsTest, TestSize.Level1) { int uid = 758; - ForegroundAppRecord foregroundapprecord = ForegroundAppRecord(uid); + ForegroundAppRecord foregroundapprecord = ForegroundAppRecord(uid, 0); foregroundapprecord.keyThreads_.insert(1); foregroundapprecord.keyThreads_.insert(3); foregroundapprecord.keyThreads_.insert(5); diff --git a/test/unittest/phone/qos_interface_test.cpp b/test/unittest/phone/qos_interface_test.cpp index 1a43acf534800b00586c293f14e18231993b7a58..e5beabdd33dd70b31ce42b12aa7fa9f8eaa7ad0d 100644 --- a/test/unittest/phone/qos_interface_test.cpp +++ b/test/unittest/phone/qos_interface_test.cpp @@ -212,7 +212,7 @@ HWTEST_F(QosInterfaceTest, QosLeaveForOtherTest, TestSize.Level1) */ static struct QosPolicyDatas g_defaultQosPolicy = { - .policyType = static_cast(QosPolicyType::QOS_POLICY_DEFAULT), + .policyType = QOS_POLICY_DEFAULT, .policyFlag = QOS_FLAG_ALL, .policys = { {0, 0, 0, 1024, 0},