From 1c7e67f05afde914ffa59e3f959882d8d91b04c3 Mon Sep 17 00:00:00 2001 From: joseph_ju Date: Tue, 31 Oct 2023 02:31:38 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E6=97=B6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=B3=A8=E5=86=8C=E5=A4=9A=E6=A8=A1=E7=9A=84=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: joseph_ju --- cgroup_sched/framework/BUILD.gn | 7 ++-- .../sched_controller/include/supervisor.h | 1 + .../observer/include/observer_manager.h | 2 ++ .../observer/src/observer_manager.cpp | 34 +++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/cgroup_sched/framework/BUILD.gn b/cgroup_sched/framework/BUILD.gn index d547b310..c1158811 100644 --- a/cgroup_sched/framework/BUILD.gn +++ b/cgroup_sched/framework/BUILD.gn @@ -15,14 +15,17 @@ import("//build/ohos.gni") import("../cgroup_sched.gni") config("cgroup_sched_public_config") { - include_dirs = [ "../interfaces/innerkits/include" ] + include_dirs = [ + "../interfaces/innerkits/include", + "sched_controller/include", + "process_group/include", + ] } config("cgroup_sched_private_config") { include_dirs = [ "../../ressched/interfaces/innerkits/ressched_client/include", "../common/include", - "./sched_controller/include", "./utils/include", ] } diff --git a/cgroup_sched/framework/sched_controller/include/supervisor.h b/cgroup_sched/framework/sched_controller/include/supervisor.h index feb12a7e..1343b384 100644 --- a/cgroup_sched/framework/sched_controller/include/supervisor.h +++ b/cgroup_sched/framework/sched_controller/include/supervisor.h @@ -101,6 +101,7 @@ public: bool isActive_ {false}; bool inSelfRenderCgroup_ = false; bool isExtensionProcess_ = false; + bool isSubscribedMmiEvent_ = false; uint32_t continuousTaskFlag_ = 0; int32_t renderTid_ = 0; diff --git a/ressched/sched_controller/observer/include/observer_manager.h b/ressched/sched_controller/observer/include/observer_manager.h index f1cb5603..c02ef3ca 100644 --- a/ressched/sched_controller/observer/include/observer_manager.h +++ b/ressched/sched_controller/observer/include/observer_manager.h @@ -61,6 +61,7 @@ public: void DisableMMiEventObserver(); void InitSysAbilityListener(); void AddItemToSysAbilityListener(int32_t systemAbilityId, sptr& systemAbilityManager); + void GetAllMmiStatusData(); pid_t pid_ = -1; std::map> handleObserverMap_; @@ -76,6 +77,7 @@ public: #endif sptr sysAbilityListener_ = nullptr; std::shared_ptr mmiEventObserver_ = nullptr; + std::vector> mmiStatusData_; }; } // namespace ResourceSchedule } // namespace OHOS diff --git a/ressched/sched_controller/observer/src/observer_manager.cpp b/ressched/sched_controller/observer/src/observer_manager.cpp index 87f81b09..7af15831 100644 --- a/ressched/sched_controller/observer/src/observer_manager.cpp +++ b/ressched/sched_controller/observer/src/observer_manager.cpp @@ -32,10 +32,15 @@ #include "movement_data_utils.h" #endif #include "input_manager.h" +#include "sched_controller.h" +#include "supervisor.h" namespace OHOS { namespace ResourceSchedule { const static int8_t OPERATION_SUCCESS = 0; +const static int32_t TUPLE_PID = 0; +const static int32_t TUPLE_UID = 1; +const static int32_t TUPLE_NAME = 2; const static bool DEVICE_MOVEMENT_OBSERVER_ENABLE = system::GetBoolParameter("persist.sys.ressched_device_movement_observer_switch", false); IMPLEMENT_SINGLE_INSTANCE(ObserverManager) @@ -337,6 +342,8 @@ void ObserverManager::InitMMiEventObserver() "ERR_TYPE", "register failure", "ERR_MSG", "Register a mmi observer failed!"); } + // Get all events registered in multimodal input. + GetAllMmiStatusData(); } void ObserverManager::DisableMMiEventObserver() @@ -356,6 +363,33 @@ void ObserverManager::DisableMMiEventObserver() mmiEventObserver_ = nullptr; } +void ObserverManager::GetAllMmiStatusData() +{ + RESSCHED_LOGI("get all mmi subscribed events."); + MMI::InputManager::GetInstance()->GetAllMmiSubscribedEvents(mmiStatusData_); + if (mmiStatusData_.empty()) { + RESSCHED_LOGI("get mmi subscribed events is null."); + return; + } + auto supervisor = SchedController::GetInstance().GetSupervisor(); + if (supervisor == nullptr) { + RESSCHED_LOGE("get supervisor is null."); + return; + } + + for (const auto& data : mmiStatusData_) { + int32_t pid = std::get(data); + int32_t uid = std::get(data); + std::string bundleName = std::get(data); + RESSCHED_LOGD("get mmi subscribed events, pid:%{public}d, uid:%{public}d, bundleName:%{public}s.", + pid, uid, bundleName.c_str()); + auto app = supervisor->GetAppRecordNonNull(uid); + auto procRecord = app->GetProcessRecordNonNull(pid); + app->SetName(bundleName); + procRecord->isSubscribedMmiEvent_ = true; + } +} + extern "C" void ObserverManagerInit() { ObserverManager::GetInstance().Init(); -- Gitee