diff --git a/service/key_command/include/key_command_handler.h b/service/key_command/include/key_command_handler.h index 29754044473066dbad93b23731a9166f20b5c357..efb92e0b990842502c57f86c0f062c058c2f249f 100755 --- a/service/key_command/include/key_command_handler.h +++ b/service/key_command/include/key_command_handler.h @@ -151,6 +151,9 @@ public: #endif // OHOS_BUILD_ENABLE_TOUCH bool OnHandleEvent(const std::shared_ptr keyEvent); bool OnHandleEvent(const std::shared_ptr pointerEvent); + bool ParseConfig(); + void ParseStatusConfigObserver(); + void SetParseConfigFlg(bool parseConfigFlg); #ifdef UNIT_TEST public: @@ -159,10 +162,8 @@ private: #endif void Print(); void PrintSeq(); - bool ParseConfig(); bool ParseJson(const std::string &configFile); void ParseRepeatKeyMaxCount(); - void ParseStatusConfigObserver(); void LaunchAbility(const Ability &ability); void LaunchAbility(const Ability &ability, int64_t delay); void LaunchAbility(const ShortcutKey &key); @@ -269,7 +270,6 @@ private: bool isKeyCancel_ { false }; bool isHandleSequence_ { false }; bool isParseMaxCount_ { false }; - bool isParseStatusConfig_ { false }; }; } // namespace MMI } // namespace OHOS diff --git a/service/key_command/src/key_command_handler.cpp b/service/key_command/src/key_command_handler.cpp index 4da50cd5dab2c6170baeb4b43f067f234d1a6004..a0b775bf36d91823c8f322e8fc172333447edc4d 100644 --- a/service/key_command/src/key_command_handler.cpp +++ b/service/key_command/src/key_command_handler.cpp @@ -1389,11 +1389,6 @@ bool KeyCommandHandler::HandleEvent(const std::shared_ptr key) } } - if (!isParseStatusConfig_) { - ParseStatusConfigObserver(); - isParseStatusConfig_ = true; - } - bool isHandled = HandleShortKeys(key); isHandled = HandleSequences(key) || isHandled; if (isHandled) { @@ -2104,10 +2099,12 @@ KnuckleGesture KeyCommandHandler::GetSingleKnuckleGesture() { return singleKnuckleGesture_; } + KnuckleGesture KeyCommandHandler::GetDoubleKnuckleGesture() { return doubleKnuckleGesture_; } + void KeyCommandHandler::SetKnuckleDoubleTapIntervalTime(int64_t interval) { CALL_DEBUG_ENTER; @@ -2117,6 +2114,7 @@ void KeyCommandHandler::SetKnuckleDoubleTapIntervalTime(int64_t interval) } downToPrevUpTimeConfig_ = interval; } + void KeyCommandHandler::SetKnuckleDoubleTapDistance(float distance) { CALL_DEBUG_ENTER; @@ -2126,5 +2124,10 @@ void KeyCommandHandler::SetKnuckleDoubleTapDistance(float distance) } downToPrevDownDistanceConfig_ = distance; } + +void KeyCommandHandler::SetParseConfigFlg(bool parseConfigFlg) +{ + isParseConfig_ = parseConfigFlg; +} } // namespace MMI } // namespace OHOS \ No newline at end of file diff --git a/service/module_loader/include/mmi_service.h b/service/module_loader/include/mmi_service.h index 4d455e7eed3d4ba2aa00ac849919c912b2ef4225..4cf84ca0e3b9f3bdc419bd42f989213d5284f898 100644 --- a/service/module_loader/include/mmi_service.h +++ b/service/module_loader/include/mmi_service.h @@ -195,6 +195,7 @@ protected: void AddAppDebugListener(); void RemoveAppDebugListener(); int32_t UpdateCombineKeyState(bool enable); + void AddSystemObserver(); private: std::atomic state_ = ServiceRunningState::STATE_NOT_START; diff --git a/service/module_loader/src/mmi_service.cpp b/service/module_loader/src/mmi_service.cpp index 97ce064d077c0d090217ed005578f2cddfaf38f9..6948c36761678f0c601f59e37f574c51f6bc1585 100644 --- a/service/module_loader/src/mmi_service.cpp +++ b/service/module_loader/src/mmi_service.cpp @@ -66,6 +66,7 @@ constexpr int32_t REMOVE_OBSERVER = -2; constexpr int32_t UNSUBSCRIBED = -1; constexpr int32_t UNOBSERVED = -1; constexpr int32_t SUBSCRIBED = 1; +constexpr int32_t INTERVAL_MS = 5000; } // namespace const bool REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(DelayedSingleton::GetInstance().get()); @@ -278,6 +279,7 @@ int32_t MMIService::Init() SetRecvFun(std::bind(&ServerMsgHandler::OnMsgHandler, &sMsgHandler_, std::placeholders::_1, std::placeholders::_2)); KeyMapMgr->GetConfigKeyValue("default_keymap", KeyMapMgr->GetDefaultKeyId()); OHOS::system::SetParameter(INPUT_POINTER_DEVICES, "false"); + AddSystemObserver(); if (!InitService()) { MMI_HILOGE("Saservice init failed"); return SASERVICE_INIT_FAIL; @@ -286,6 +288,21 @@ int32_t MMIService::Init() return RET_OK; } +void MMIService::AddSystemObserver() +{ + std::shared_ptr eventKeyCommandHandler = InputHandler->GetKeyCommandHandler(); + CHKPV(eventKeyCommandHandler); + if (eventKeyCommandHandler->ParseConfig()) { + eventKeyCommandHandler->SetParseConfigFlg(true); + } + int32_t repeatCount = 1; + TimerMgr->AddTimer(INTERVAL_MS, repeatCount, [this]() { + std::shared_ptr eventKeyCommandHandler = InputHandler->GetKeyCommandHandler(); + CHKPV(eventKeyCommandHandler); + eventKeyCommandHandler->ParseStatusConfigObserver(); + }); +} + void MMIService::OnStart() { std::string name = "mmi-service";