From 34de8defc59958ce9057da7a4a47c3b8e094a352 Mon Sep 17 00:00:00 2001 From: edwardcaoyue Date: Wed, 25 Oct 2023 15:40:30 +0800 Subject: [PATCH] process continuous task message Signed-off-by: edwardcaoyue Change-Id: I71acfa183289440cf372e97f75fc85e0574b9c4d --- common/include/rme_constants.h | 5 +++++ .../include/intellisense_server.h | 1 + .../src/intellisense_server.cpp | 19 +++++++++++++++++++ .../innerkits/frameintf/frame_msg_intf.cpp | 12 ++++++++++++ .../innerkits/frameintf/frame_msg_intf.h | 1 + test/unittest/phone/frame_msg_intf_test.cpp | 18 ++++++++++++++++++ 6 files changed, 56 insertions(+) diff --git a/common/include/rme_constants.h b/common/include/rme_constants.h index 119d4bc..d9fd4e0 100644 --- a/common/include/rme_constants.h +++ b/common/include/rme_constants.h @@ -33,6 +33,11 @@ enum class WindowState { FOCUS_NO, }; +enum class ContinuousTaskState { + TASK_START = 0, + TASK_END, +}; + enum class ErrorCode { FAIL, SUCC, diff --git a/frameworks/core/frame_aware_policy/include/intellisense_server.h b/frameworks/core/frame_aware_policy/include/intellisense_server.h index 7b34b8f..cb1b320 100644 --- a/frameworks/core/frame_aware_policy/include/intellisense_server.h +++ b/frameworks/core/frame_aware_policy/include/intellisense_server.h @@ -40,6 +40,7 @@ public: void ReportCgroupChange(const int pid, const int uid, const int oldGroup, const int newGroup); void ReportWindowFocus(const int pid, const int uid, int isFocus); void ReportRenderThread(const int pid, const int uid, int renderTid); + void ReportContinuousTask(const int pid, const int uid, const int status); bool ReadXml(); void SetPara(const int32_t currentFps, const int32_t currentRenderType); diff --git a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp index 6ca24c2..baaa4e4 100644 --- a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp +++ b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp @@ -214,6 +214,25 @@ void IntelliSenseServer::ReportRenderThread(const int pid, const int uid, int re } } +void IntelliSenseServer::ReportContinuousTask(const int pid, const int uid, const int status) +{ + if (!m_switch) { + return; + } + HITRACE_METER(HITRACE_TAG_ACE); + switch (status) { + case static_cast(ContinuousTaskState::TASK_START): + RME_LOGI("[ReportContinuousTask]:%{public}d continuous task start", pid); + break; + case static_cast(ContinuousTaskState::TASK_END): + RME_LOGI("[ReportContinuousTask]:%{public}d continuous task end", pid); + break; + default: + RME_LOGI("[ReportContinuousTask]:unknown continuous task status!"); + break; + } +} + void IntelliSenseServer::ReportWindowFocus(const int pid, const int uid, int isFocus) { if (!m_switch) { diff --git a/interfaces/innerkits/frameintf/frame_msg_intf.cpp b/interfaces/innerkits/frameintf/frame_msg_intf.cpp index d4e2b1a..f3bb487 100644 --- a/interfaces/innerkits/frameintf/frame_msg_intf.cpp +++ b/interfaces/innerkits/frameintf/frame_msg_intf.cpp @@ -123,6 +123,18 @@ void FrameMsgIntf::ReportCgroupChange(const int pid, const int uid, const int ol }); } +void FrameMsgIntf::ReportContinuousTask(const int pid, const int uid, const int status) +{ + std::lock_guard autoLock(frameMsgIntfMutex_); + if (threadHandler_ == nullptr) { + RME_LOGI("[ReportProcessInfo]:threandHandler none!"); + return; + } + threadHandler_->PostTask([pid, uid, status] { + IntelliSenseServer::GetInstance().ReportContinuousTask(pid, uid, status); + }); +} + void FrameMsgIntf::Stop() { std::lock_guard autoLock(frameMsgIntfMutex_); diff --git a/interfaces/innerkits/frameintf/frame_msg_intf.h b/interfaces/innerkits/frameintf/frame_msg_intf.h index 199f250..a36e8f1 100644 --- a/interfaces/innerkits/frameintf/frame_msg_intf.h +++ b/interfaces/innerkits/frameintf/frame_msg_intf.h @@ -32,6 +32,7 @@ public: void ReportCgroupChange(const int pid, const int uid, const int oldGroup, const int newGroup); void ReportWindowFocus(const int pid, const int uid, const int isFocus); void ReportRenderThread(const int pid, const int uid, const int renderTid); + void ReportContinuousTask(const int pid, const int uid, const int status); void Stop(); protected: FrameMsgIntf() = default; diff --git a/test/unittest/phone/frame_msg_intf_test.cpp b/test/unittest/phone/frame_msg_intf_test.cpp index c643f8c..34ce492 100644 --- a/test/unittest/phone/frame_msg_intf_test.cpp +++ b/test/unittest/phone/frame_msg_intf_test.cpp @@ -57,5 +57,23 @@ void FrameMsgIntfTest::TearDown() std::shared_ptr thread = FrameMsgIntf::GetInstance().threadHandler_; EXPECT_TRUE(thread == nullptr); } + +/** + * @tc.name: ReportContinuousTaskTest + * @tc.desc: Test whether ReportContinuousTask interface is normal + * @tc.type: FUNC + */ +HWTEST_F(FrameMsgIntfTest, ReportContinuousTaskTest, TestSize.Level1) +{ + FrameMsgIntf repCon; + const int pid = 12345; + const int uid = 100086; + const int status0 = 0; + const int status1 = 1; + repCon.GetThreadHandler(); + repCon.ReportContinuousTask(pid, uid, status0); + repCon.ReportContinuousTask(pid, uid, status1); +} + } // namespace RME } // namespace OHOS -- Gitee