• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_STATE_MANAGER_H
17 #define IME_STATE_MANAGER_H
18 #include "event_handler.h"
19 namespace OHOS {
20 namespace MiscServices {
21 enum class RequestType : int32_t {
22     NORMAL = 0,
23     START_INPUT,
24     STOP_INPUT,
25     REQUEST_SHOW,
26     REQUEST_HIDE
27 };
28 class ImeStateManager {
29 public:
ImeStateManager(pid_t pid)30     explicit ImeStateManager(pid_t pid) : pid_(pid) { }
31     virtual ~ImeStateManager() = default;
32     static void SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler> &eventHandler);
33     bool IsIpcNeeded(RequestType type);
34     void BeforeIpc(RequestType type);
35     void AfterIpc(RequestType type, bool isSuccess);
36     bool IsImeInUse();
TemporaryActiveIme()37     virtual void TemporaryActiveIme() { };
38 
39 protected:
40     std::mutex mutex_;
41     static std::shared_ptr<AppExecFwk::EventHandler> eventHandler_;
42     pid_t pid_;
43     bool isFrozen_ { true };
44 
45 private:
46     virtual void ControlIme(bool shouldApply) = 0;
47     bool isImeInUse_ { false };
48 };
49 } // namespace MiscServices
50 } // namespace OHOS
51 #endif // IME_STATE_MANAGER_H