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 ace5b721c5c282e8cff1230bcca0fa89d71db72f..b1822ee6fabf8fc49c74cf65a25d46698de88cce 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 @@ -22,6 +22,7 @@ namespace ConcurrentTask { enum class ConcurrentTaskInterfaceCode { REPORT_DATA = 1, QUERY_INTERVAL = 2, + QUERY_DEADLINE = 3, }; } // namespace ConcurrentTask } // namespace OHOS diff --git a/frameworks/concurrent_task_client/include/concurrent_task_service_proxy.h b/frameworks/concurrent_task_client/include/concurrent_task_service_proxy.h index 82bf98598b2bda64be741b5b042efc95c1813b05..1d943c30a3d98d9edef6470efe2cfa3cc24c7018 100644 --- a/frameworks/concurrent_task_client/include/concurrent_task_service_proxy.h +++ b/frameworks/concurrent_task_client/include/concurrent_task_service_proxy.h @@ -30,6 +30,7 @@ public: void ReportData(uint32_t resType, int64_t value, const Json::Value& payload) override; void QueryInterval(int queryItem, IntervalReply& queryRs) override; + void QueryDeadline(int queryItem, DeadlineReply& ddlReply, const Json::Value& payload) override; private: DISALLOW_COPY_AND_MOVE(ConcurrentTaskServiceProxy); diff --git a/frameworks/concurrent_task_client/include/concurrent_task_type.h b/frameworks/concurrent_task_client/include/concurrent_task_type.h index b95fbc8c8dfc5fb64294485307a7d4bd0ec400ef..019e6d51d68a038cd3478ca3a7c326faec8abaef 100644 --- a/frameworks/concurrent_task_client/include/concurrent_task_type.h +++ b/frameworks/concurrent_task_client/include/concurrent_task_type.h @@ -47,12 +47,20 @@ enum QueryIntervalItem { QURRY_TYPE_MAX }; +enum DeadlineType { + DDL_RATE = 0 +}; + struct IntervalReply { int rtgId; int tid; int paramA; int paramB; }; + +struct DeadlineReply { + bool setStatus; +}; } } -#endif // CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_TYPE_H \ No newline at end of file +#endif // CONCURRENT_TASK_SERVICES_CONCURRENTSEVICE_INCLUDE_CONCURRENT_TASK_TYPE_H diff --git a/frameworks/concurrent_task_client/include/iconcurrent_task_service.h b/frameworks/concurrent_task_client/include/iconcurrent_task_service.h index 79ecefa8a73404c95baea1e46e5c50ca535755b1..bbe82413935c601ba75bc338261266ab9350d514 100644 --- a/frameworks/concurrent_task_client/include/iconcurrent_task_service.h +++ b/frameworks/concurrent_task_client/include/iconcurrent_task_service.h @@ -29,6 +29,7 @@ public: virtual void ReportData(uint32_t resType, int64_t value, const Json::Value& payload) = 0; virtual void QueryInterval(int queryItem, IntervalReply& queryRs) = 0; + virtual void QueryDeadline(int queryItem, DeadlineReply& ddlReply, const Json::Value& payload) = 0; }; } // namespace ConcurrentTask } // namespace OHOS diff --git a/frameworks/concurrent_task_client/src/concurrent_task_client.cpp b/frameworks/concurrent_task_client/src/concurrent_task_client.cpp index 03c3296ffc9994fcf32f4c25982c34fd44eae092..7418493de5d0c39828720875fbd8ce59fa1f1dfe 100644 --- a/frameworks/concurrent_task_client/src/concurrent_task_client.cpp +++ b/frameworks/concurrent_task_client/src/concurrent_task_client.cpp @@ -53,6 +53,20 @@ void ConcurrentTaskClient::QueryInterval(int queryItem, IntervalReply& queryRs) return; } +void ConcurrentTaskClient::QueryDeadline(int queryItem, DeadlineReply& ddlReply, + const std::unordered_map& mapPayload) +{ + if (TryConnect() != ERR_OK) { + return; + } + Json::Value payload; + for (auto it = mapPayload.begin(); it != mapPayload.end(); ++it) { + payload[std::to_string(it->first)] = std::to_string(it->second); + } + clientService_->QueryDeadline(queryItem, ddlReply, payload); + return; +} + ErrCode ConcurrentTaskClient::TryConnect() { std::lock_guard lock(mutex_); @@ -107,4 +121,4 @@ void ConcurrentTaskClient::ConcurrentTaskDeathRecipient::OnRemoteDied(const wptr concurrentTaskClient_.StopRemoteObject(); } } // namespace ConcurrentTask -} // namespace OHOS \ No newline at end of file +} // namespace OHOS 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 7b7782e228668be96ecee80623280c448869881a..27afecb32ebc9ac6e39609e9b9af604231d94cc4 100644 --- a/frameworks/concurrent_task_client/src/concurrent_task_service_proxy.cpp +++ b/frameworks/concurrent_task_client/src/concurrent_task_service_proxy.cpp @@ -76,5 +76,29 @@ void ConcurrentTaskServiceProxy::QueryInterval(int queryItem, IntervalReply& que } return; } + +void ConcurrentTaskServiceProxy::QueryDeadline(int queryItem, DeadlineReply& ddlReply, const Json::Value& payload) +{ + int32_t error; + MessageParcel data; + MessageParcel reply; + MessageOption option = { MessageOption::TF_SYNC }; + + if (!data.WriteInterfaceToken(ConcurrentTaskServiceProxy::GetDescriptor())) { + CONCUR_LOGE("Write interface token failed in QueryDeadline Proxy"); + return; + } + if (!data.WriteInt32(queryItem) || !data.WriteString(payload.toStyledString())) { + CONCUR_LOGE("Write info failed in QueryDeadline Proxy"); + return; + } + uint32_t code = static_cast(ConcurrentTaskInterfaceCode::QUERY_DEADLINE); + error = Remote()->SendRequest(code, data, reply, option); + if (error != NO_ERROR) { + CONCUR_LOGE("QueryDeadline error: %{public}d", error); + return; + } + CONCUR_LOGD("ConcurrentTaskServiceProxy::QueryDeadline success."); +} } // namespace ConcurrentTask } // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/concurrent_task_client.h b/interfaces/inner_api/concurrent_task_client.h index 9a76377b77d97113228d3a95a98b8b56d0d3b64c..f867391f24dfd62b2e9d2339b3033cd64964895b 100644 --- a/interfaces/inner_api/concurrent_task_client.h +++ b/interfaces/inner_api/concurrent_task_client.h @@ -55,6 +55,9 @@ public: */ void QueryInterval(int queryItem, IntervalReply& queryRs); + void QueryDeadline(int queryItem, DeadlineReply& ddlReply, + const std::unordered_map& mapPayload); + /** * @brief Stop remote object and reset ConcurrentTaskClient. */ diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index d81478869241e6e6641f4d8ea1891e49ab5c597f..837a0d3a7fd8670e6729de24a854a4731f0ad9ed 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -36,6 +36,7 @@ public: virtual ~TaskController() = default; void ReportData(uint32_t resType, int64_t value, const Json::Value& payload); void QueryInterval(int queryItem, IntervalReply& queryRs); + void QueryDeadline(int queryItem, DeadlineReply& ddlReply, const Json::Value& payload); void Init(); void Release(); @@ -56,6 +57,12 @@ private: void NewBackground(int uid, int pid); void NewAppStart(int uid, int pid); void AppKilled(int uid, int pid); + bool ModifySystemRate(const Json::Value& payload); + void SetAppRate(const Json::Value& payload); + int FindRateFromInfo(int uiTid, const Json::Value& payload); + void SetRenderServiceRate(const Json::Value& payload); + bool CheckJsonValid(const Json::Value& payload); + void SetFrameRate(int rtgId, int rate); std::list::iterator GetRecordOfUid(int uid); void PrintInfo(); bool ParsePayload(const Json::Value& payload, int& uid, int& pid); @@ -67,6 +74,7 @@ private: std::map> authApps_; int renderServiceGrpId_ = -1; int rsTid_ = -1; + int systemRate_ = 0; bool rtgEnabled_ = false; }; @@ -78,14 +86,19 @@ public: void AddKeyThread(int tid, int prio = PRIO_NORMAL); bool BeginScene(); bool EndScene(); - int GetUid(); - int GetGrpId(); + int GetUid() const; + int GetGrpId() const; + int GetRate() const; + void SetRate(int appRate); + int GetUiTid() const; + void SetUiTid(int uiTid); bool IsValid(); void PrintKeyThreads(); private: int uid_ = 0; int grpId_ = 0; + int rate_ = 0; int uiTid_ = 0; std::unordered_set keyThreads_; }; diff --git a/services/include/concurrent_task_service.h b/services/include/concurrent_task_service.h index 3c8f5aca82014b2fb2a7a426a21b187a229ef4a7..6eac2e19909fead7a1c19bd076ee7057be34c9d1 100644 --- a/services/include/concurrent_task_service.h +++ b/services/include/concurrent_task_service.h @@ -28,6 +28,7 @@ public: void ReportData(uint32_t resType, int64_t value, const Json::Value& payload) override; void QueryInterval(int queryItem, IntervalReply& queryRs) override; + void QueryDeadline(int queryItem, DeadlineReply& ddlReply, const Json::Value& payload) override; private: DISALLOW_COPY_AND_MOVE(ConcurrentTaskService); }; diff --git a/services/include/concurrent_task_service_stub.h b/services/include/concurrent_task_service_stub.h index 022d5d8d39e5f3f9c3153797b70cffb104aa3d17..cbdc0980a3ca730ff7c748be8a4b39379665d4b5 100644 --- a/services/include/concurrent_task_service_stub.h +++ b/services/include/concurrent_task_service_stub.h @@ -32,6 +32,7 @@ public: private: int32_t ReportDataInner(MessageParcel& data, MessageParcel& reply); int32_t QueryIntervalInner(MessageParcel& data, MessageParcel& reply); + int32_t QueryDeadlineInner(MessageParcel& data, MessageParcel& reply); Json::Value StringToJson(const std::string& str); void Init(); diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 48eb64c5f549352a9a925e7167f9aa3c54843396..5d56ab4b2bc0cdee4a3b8ba17fc9597e47648d44 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -46,13 +46,7 @@ void TaskController::ReportData(uint32_t resType, int64_t value, const Json::Val CONCUR_LOGE("only system call can be allowed"); return; } - Json::ValueType type = payload.type(); - if (type != Json::objectValue) { - CONCUR_LOGE("error payload"); - return; - } - if (payload.empty()) { - CONCUR_LOGE("payload is empty"); + if (!CheckJsonValid(payload)) { return; } std::string strRequstType = ""; @@ -460,6 +454,101 @@ void TaskController::AppKilled(int uid, int pid) } } +void TaskController::QueryDeadline(int queryItem, DeadlineReply& ddlReply, const Json::Value& payload) +{ + pid_t uid = IPCSkeleton::GetInstance().GetCallingUid(); + if ((uid != RS_UID) && (uid != ROOT_UID)) { + CONCUR_LOGE("only render service call can be allowed, but uid is %{public}d", uid); + return; + } + switch (queryItem) { + case DDL_RATE: { + bool ret = ModifySystemRate(payload); + ddlReply.setStatus = ret; + break; + } + default: { + break; + } + } +} + +bool TaskController::ModifySystemRate(const Json::Value& payload) +{ + if (!CheckJsonValid(payload)) { + CONCUR_LOGI("service receive json invalid"); + return false; + } + SetAppRate(payload); + SetRenderServiceRate(payload); + return true; +} + +void TaskController::SetAppRate(const Json::Value& payload) +{ + int rtgId = 0; + int uiTid = 0; + int appRate = 0; + for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { + uiTid = iter->GetUiTid(); + rtgId = iter->GetGrpId(); + if (uiTid > 0 && rtgId > 0) { + appRate = FindRateFromInfo(uiTid, payload); + if (appRate > 0 && appRate != iter->GetRate()) { + CONCUR_LOGI("set app rate %{public}d rtgId is %{public}d", appRate, rtgId); + SetFrameRate(rtgId, appRate); + iter->SetRate(appRate); + } + } + } +} + +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); + return appRate; + } + try { + appRate = stoi(payload[std::to_string(uiTid)].asString()); + } catch (...) { + CONCUR_LOGI("application %{public}d is not in rtg_group", uiTid); + } + return appRate; +} + +void TaskController::SetRenderServiceRate(const Json::Value& payload) +{ + int rsRate = FindRateFromInfo(rsTid_, payload); + if (renderServiceGrpId_ > 0 && rsRate > 0 && rsRate != systemRate_) { + CONCUR_LOGI("set rs rate %{public}d rtgId is %{public}d", rsRate, renderServiceGrpId_); + SetFrameRate(renderServiceGrpId_, rsRate); + systemRate_ = rsRate; + } +} + +bool TaskController::CheckJsonValid(const Json::Value& payload) +{ + Json::ValueType type = payload.type(); + if (type != Json::objectValue) { + CONCUR_LOGE("error payload"); + return false; + } + if (payload.empty()) { + CONCUR_LOGI("payload empty"); + return false; + } + return true; +} + +void TaskController::SetFrameRate(int rtgId, int rate) +{ + if (rtgId > 0) { + SetFrameRateAndPrioType(rtgId, rate, PARAM_TYPE); + } +} + void TaskController::PrintInfo() { for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { @@ -534,16 +623,36 @@ bool ForegroundAppRecord::EndScene() return true; } -int ForegroundAppRecord::GetUid() +int ForegroundAppRecord::GetUid() const { return uid_; } -int ForegroundAppRecord::GetGrpId() +int ForegroundAppRecord::GetGrpId() const { return grpId_; } +void ForegroundAppRecord::SetRate(int appRate) +{ + rate_ = appRate; +} + +int ForegroundAppRecord::GetRate() const +{ + return rate_; +} + +void ForegroundAppRecord::SetUiTid(int uiTid) +{ + uiTid_ = uiTid; +} + +int ForegroundAppRecord::GetUiTid() const +{ + return uiTid_; +} + bool ForegroundAppRecord::IsValid() { if (uid_ > 0) { diff --git a/services/src/concurrent_task_service.cpp b/services/src/concurrent_task_service.cpp index 1173d1ef77c8d8c48a75854ed2a1ca729555e809..23b6480ce93474399c81e0c1c9ec7decb3cd7c7d 100644 --- a/services/src/concurrent_task_service.cpp +++ b/services/src/concurrent_task_service.cpp @@ -27,5 +27,10 @@ void ConcurrentTaskService::QueryInterval(int queryItem, IntervalReply& queryRs) { TaskController::GetInstance().QueryInterval(queryItem, queryRs); } + +void ConcurrentTaskService::QueryDeadline(int queryItem, DeadlineReply& queryRs, const Json::Value& payload) +{ + TaskController::GetInstance().QueryDeadline(queryItem, queryRs, payload); +} } // namespace ConcurrentTask } // namespace OHOS diff --git a/services/src/concurrent_task_service_stub.cpp b/services/src/concurrent_task_service_stub.cpp index 2e8daccde144b9e6f3b79422d3187dcafa5a21d1..151c354201951f0557ee0f0c27c7fb0e0755eb83 100644 --- a/services/src/concurrent_task_service_stub.cpp +++ b/services/src/concurrent_task_service_stub.cpp @@ -84,6 +84,25 @@ int32_t ConcurrentTaskServiceStub::QueryIntervalInner(MessageParcel& data, [[may return ERR_OK; } +int32_t ConcurrentTaskServiceStub::QueryDeadlineInner(MessageParcel& data, [[maybe_unused]] MessageParcel& reply) +{ + if (!IsValidToken(data)) { + return ERR_CONCURRENT_TASK_PARCEL_ERROR; + } + int queryItem; + DeadlineReply ddlReply; + std::string payload; + if (!data.ReadInt32(queryItem) || !data.ReadString(payload)) { + CONCUR_LOGE("Read info failed in QueryDeadline Stub"); + return IPC_STUB_ERR; + } + if (payload.empty()) { + return ERR_OK; + } + QueryDeadline(queryItem, ddlReply, StringToJson(payload)); + return ERR_OK; +} + int32_t ConcurrentTaskServiceStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) { @@ -132,6 +151,8 @@ void ConcurrentTaskServiceStub::Init() [this](auto& data, auto& reply) {return ReportDataInner(data, reply); } }, { static_cast(ConcurrentTaskInterfaceCode::QUERY_INTERVAL), [this](auto& data, auto& reply) {return QueryIntervalInner(data, reply); } }, + { static_cast(ConcurrentTaskInterfaceCode::QUERY_DEADLINE), + [this](auto& data, auto& reply) {return QueryDeadlineInner(data, reply); } }, }; } } // namespace ResourceSchedule diff --git a/test/fuzztest/concurrent_fuzzer/concurrent_fuzzer.cpp b/test/fuzztest/concurrent_fuzzer/concurrent_fuzzer.cpp index c5d113e0da7a2445b3d57c50cc36c5683b990174..112650ecbf65bb5be613d846649c4cf8cb3e8b1a 100644 --- a/test/fuzztest/concurrent_fuzzer/concurrent_fuzzer.cpp +++ b/test/fuzztest/concurrent_fuzzer/concurrent_fuzzer.cpp @@ -102,6 +102,30 @@ bool FuzzConcurrentTaskServiceQueryInterval(const uint8_t* data, size_t size) } return true; } + +bool FuzzConcurrentTaskServiceQueryDeadline(const uint8_t* data, size_t size) +{ + g_baseFuzzData = data; + g_baseFuzzSize = size; + g_baseFuzzPos = 0; + if (size > sizeof(int) + sizeof(int)) { + MessageParcel data1; + Parcel parcel; + sptr iremoteobject = IRemoteObject::Unmarshalling(parcel); + int intdata = GetData(); + void *voiddata = &intdata; + size_t size1 = sizeof(int); + data1.WriteRemoteObject(iremoteobject); + data1.WriteRawData(voiddata, size1); + data1.ReadRawData(size1); + MessageParcel reply; + MessageOption option; + uint32_t code = static_cast(ConcurrentTaskInterfaceCode::QUERY_DEADLINE); + ConcurrentTaskService s = ConcurrentTaskService(); + s.OnRemoteRequest(code, data1, reply, option); + } + return true; +} } // namespace OHOS /* Fuzzer entry point */ diff --git a/test/unittest/phone/concurrent_task_client_test.cpp b/test/unittest/phone/concurrent_task_client_test.cpp index 0339ef73f12316cc82ac37436bb7008188c1b6c3..050ab80ca4e793059db7701a306ff88563aac785 100644 --- a/test/unittest/phone/concurrent_task_client_test.cpp +++ b/test/unittest/phone/concurrent_task_client_test.cpp @@ -83,5 +83,20 @@ HWTEST_F(ConcurrentTaskClientTest, StopRemoteObjectTest, TestSize.Level1) { ConcurrentTaskClient::GetInstance().StopRemoteObject(); } + +/** + * @tc.name: PushTaskTest + * @tc.desc: Test whether the PushTask interface are normal. + * @tc.type: FUNC +*/ +HWTEST_F(ConcurrentTaskClientTest, QueryDeadlineTest, TestSize.Level1) +{ + int queryItem = 0; + DeadlineReply ddlReply = { false }; + std::unordered_map payload; + payload[1111] = 60; + payload[2222] = 90; + ConcurrentTaskClient::GetInstance().QueryDeadline(queryItem, ddlReply, payload); +} } } \ No newline at end of file diff --git a/test/unittest/phone/concurrent_task_controller_test.cpp b/test/unittest/phone/concurrent_task_controller_test.cpp index c9621ac9d4fd71609c38a7313c87918a6c0133ed..e8afd668ff95a000da1362ffe99537386f684f4e 100644 --- a/test/unittest/phone/concurrent_task_controller_test.cpp +++ b/test/unittest/phone/concurrent_task_controller_test.cpp @@ -336,5 +336,140 @@ HWTEST_F(ConcurrentTaskControllerTest, PrintKeyThreadsTest, TestSize.Level1) EXPECT_NE(iter, foregroundapprecord.keyThreads_.end()); foregroundapprecord.PrintKeyThreads(); } + + +/** + * @tc.name: QueryDeadlineTest + * @tc.desc: Test whether the QueryDeadlineTest interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, QueryDeadlineTest, TestSize.Level1) +{ + int queryItem = DDL_RATE; + DeadlineReply ddlReply = { false }; + const Json::Value payload; + TaskController::GetInstance().QueryDeadline(queryItem, ddlReply, payload); +} + +/** + * @tc.name: ModifySystemRateTest + * @tc.desc: Test whether the ModifySystemRate interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, ModifySystemRateTest, TestSize.Level1) +{ + Json::Value payload; + TaskController::GetInstance().ModifySystemRate(payload); + payload["1111"] = "60"; + TaskController::GetInstance().ModifySystemRate(payload); +} + +/** + * @tc.name: SetAppRate + * @tc.desc: Test whether the SetAppRate interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, SetAppRateTest, TestSize.Level1) +{ + Json::Value payload; + ForegroundAppRecord foreApp1 = ForegroundAppRecord(758, 758); + foreApp1.SetRate(60); + TaskController::GetInstance().foregroundApp_.push_back(foreApp1); + TaskController::GetInstance().foregroundApp_.begin()->grpId_ = 1; + payload["758"] = "120"; + TaskController::GetInstance().SetAppRate(payload); + int curAppRate = TaskController::GetInstance().foregroundApp_.begin()->GetRate(); + EXPECT_EQ(curAppRate, 120); +} + +/** + * @tc.name: FindRateFromInfo + * @tc.desc: Test whether the FindRateFromInfo interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, FindRateFromInfoTest, TestSize.Level1) +{ + Json::Value payload; + payload["758"] = "120"; + payload["759"] = "120XXY"; + int ret = TaskController::GetInstance().FindRateFromInfo(754, payload); + EXPECT_EQ(ret, 0); + ret = TaskController::GetInstance().FindRateFromInfo(758, payload); + EXPECT_EQ(ret, 120); + TaskController::GetInstance().FindRateFromInfo(759, payload); +} + +/** + * @tc.name: SetRenderServiceRate + * @tc.desc: Test whether the SetRenderServiceRate interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, SetRenderServiceRateTest, TestSize.Level1) +{ + Json::Value payload; + payload["758"] = "120"; + TaskController::GetInstance().rsTid_ = 758; + TaskController::GetInstance().systemRate_ = 0; + TaskController::GetInstance().SetRenderServiceRate(payload); + EXPECT_EQ(TaskController::GetInstance().systemRate_, 120); +} + +/** + * @tc.name: SetFrameRate + * @tc.desc: Test whether the SetFrameRate interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, SetFrameRateTest, TestSize.Level1) +{ + TaskController::GetInstance().SetFrameRate(758, 120); + TaskController::GetInstance().SetFrameRate(0, 120); +} + +/** + * @tc.name: GetUid + * @tc.desc: Test whether the GetUid interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, GetUidTest, TestSize.Level1) +{ + ForegroundAppRecord foreApp = ForegroundAppRecord(758, 0); + EXPECT_EQ(foreApp.GetUid(), 758); +} + +/** + * @tc.name: GetUiTid + * @tc.desc: Test whether the GetUiTid interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, GetUiTidTest, TestSize.Level1) +{ + ForegroundAppRecord foreApp = ForegroundAppRecord(758, 758); + EXPECT_EQ(foreApp.GetUiTid(), 758); +} + +/** + * @tc.name: SetRate + * @tc.desc: Test whether the SetRate interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, SetRateTest, TestSize.Level1) +{ + ForegroundAppRecord foreApp = ForegroundAppRecord(758, 758); + foreApp.SetRate(120); + EXPECT_EQ(foreApp.GetRate(), 120); +} + +/** + * @tc.name: SetUiTid + * @tc.desc: Test whether the SetUiTid interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskControllerTest, SetUiTidTest, TestSize.Level1) +{ + ForegroundAppRecord foreApp = ForegroundAppRecord(758, 758); + EXPECT_EQ(foreApp.GetUiTid(), 758); + foreApp.SetUiTid(755); + EXPECT_EQ(foreApp.GetUiTid(), 755); +} } } \ No newline at end of file diff --git a/test/unittest/phone/concurrent_task_service_test.cpp b/test/unittest/phone/concurrent_task_service_test.cpp index 31a8dee7fd6124792cdb20d9473c846955d56694..9f16cf4d413ea319b64b5dfdd7aa01c54b34560e 100644 --- a/test/unittest/phone/concurrent_task_service_test.cpp +++ b/test/unittest/phone/concurrent_task_service_test.cpp @@ -60,5 +60,21 @@ HWTEST_F(ConcurrentTaskServiceTest, QueryIntervalTest, TestSize.Level1) ConcurrentTaskService queInt; queInt.QueryInterval(queryItem, queryRs); } + +/** + * @tc.name: QueryDeadlineTest + * @tc.desc: Test whether the QueryDeadline interface are normal. + * @tc.type: FUNC + */ +HWTEST_F(ConcurrentTaskServiceTest, QueryDeadlineTest, TestSize.Level1) +{ + int queryItem = 0; + DeadlineReply ddlReply = { false }; + Json::Value payload; + payload["1111"] = "60"; + payload["2222"] = "90"; + ConcurrentTaskService queInt; + queInt.QueryDeadline(queryItem, ddlReply, payload); +} } } \ No newline at end of file