1 /* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef IME_LIFECYCLE_MANAEGR_H 17 #define IME_LIFECYCLE_MANAEGR_H 18 #include <functional> 19 #include <memory> 20 21 #include "ime_state_manager.h" 22 #include "global.h" 23 namespace OHOS { 24 namespace MiscServices { 25 class ImeLifecycleManager final : public ImeStateManager, public std::enable_shared_from_this<ImeLifecycleManager> { 26 public: 27 explicit ImeLifecycleManager(pid_t pid, std::function<void()> stopImeFunc, int32_t stopDelayTime = STOP_DELAY_TIME) ImeStateManager(pid)28 : ImeStateManager(pid), stopImeFunc_(stopImeFunc), stopDelayTime_(stopDelayTime) 29 { 30 IMSA_HILOGD("Constructor"); 31 }; 32 33 ImeLifecycleManager(const ImeLifecycleManager&) = delete; 34 ImeLifecycleManager& operator=(const ImeLifecycleManager&) = delete; ~ImeLifecycleManager()35 ~ImeLifecycleManager() final 36 { 37 IMSA_HILOGD("Destructor"); 38 } 39 40 private: 41 void ControlIme(bool shouldApply) override; 42 std::function<void()> stopImeFunc_; 43 int32_t stopDelayTime_ { STOP_DELAY_TIME }; 44 constexpr static int32_t STOP_DELAY_TIME = 20000; 45 }; 46 } // namespace MiscServices 47 } // namespace OHOS 48 #endif // IME_LIFECYCLE_MANAEGR_H