• 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_ENABLED_INFO_MANAGER_H
17 #define IME_ENABLED_INFO_MANAGER_H
18 
19 #include <functional>
20 #include <map>
21 #include <mutex>
22 #include <set>
23 #include <string>
24 #include <unordered_map>
25 #include <vector>
26 
27 #include "event_handler.h"
28 #include "input_method_property.h"
29 #include "input_method_status.h"
30 
31 namespace OHOS {
32 namespace MiscServices {
33 // old ime enabled cfg
34 struct EnabledImeCfg {
35 };
36 // old ime full experience cfg
37 struct SecurityModeCfg {
38 };
39 
40 struct ImeEnabledInfo {
41 };
42 struct ImeEnabledCfg {
43 };
44 using CurrentImeStatusChangedHandler =
45     std::function<void(int32_t userId, const std::string &bundleName, EnabledStatus oldStatus)>;
46 class ImeEnabledInfoManager {
47 public:
48     static ImeEnabledInfoManager &GetInstance();
49     void SetCurrentImeStatusChangedHandler(CurrentImeStatusChangedHandler handler);
50     void SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler> &eventHandler);
51     int32_t RegularInit(const std::map<int32_t, std::vector<FullImeInfo>> &fullImeInfos);
52     int32_t Init(const std::map<int32_t, std::vector<FullImeInfo>> &fullImeInfos);
53     int32_t Switch(int32_t userId, const std::vector<FullImeInfo> &imeInfos);
54     int32_t Delete(int32_t userId);
55     int32_t Add(int32_t userId, const FullImeInfo &imeInfo);
56     int32_t Delete(int32_t userId, const std::string &bundleName);
57     int32_t Update(
58         int32_t userId, const std::string &bundleName, const std::string &extensionName, EnabledStatus status);
59     int32_t GetEnabledState(int32_t userId, const std::string &bundleName, EnabledStatus &status);
60     int32_t GetEnabledStates(int32_t userId, std::vector<Property> &props); // props not has sysSpecialIme
61     bool IsDefaultFullMode(int32_t userId, const std::string &bundleName);
62     /* add for compatibility that sys ime mod full experience table in it's full experience switch changed */
63     void OnFullExperienceTableChanged(int32_t userId);
64 private:
65     ImeEnabledInfoManager() = default;
66     ~ImeEnabledInfoManager();
67 };
68 } // namespace MiscServices
69 } // namespace OHOS
70 
71 #endif // IME_ENABLED_INFO_MANAGER_H