1 /* 2 * Copyright (c) 2022 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 SERVICES_INCLUDE_IME_CFG_MANAGER_H 17 #define SERVICES_INCLUDE_IME_CFG_MANAGER_H 18 19 #include <mutex> 20 21 #include "input_method_utils.h" 22 #include "serializable.h" 23 #include "event_handler.h" 24 #include "ime_enabled_info_manager.h" 25 #include "enable_upgrade_manager.h" 26 27 namespace OHOS { 28 namespace MiscServices { 29 30 class ImeCfgManager { 31 public: 32 static ImeCfgManager &GetInstance(); 33 void Init(); 34 void AddImeCfg(const ImePersistInfo &cfg); 35 void ModifyImeCfg(const ImePersistInfo &cfg); 36 void ModifyTempScreenLockImeCfg(int32_t userId, const std::string &ime); 37 void DeleteImeCfg(int32_t userId); 38 std::shared_ptr<ImeNativeCfg> GetCurrentImeCfg(int32_t userId); // Return value is never nullptr. 39 bool IsDefaultImeSet(int32_t userId); 40 void SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler> &eventHandler); 41 42 private: 43 ImeCfgManager() = default; 44 ~ImeCfgManager() = default; 45 void ReadImeCfg(); 46 void WriteImeCfg(); 47 ImePersistInfo GetImeCfg(int32_t userId); 48 bool ParseImeCfg(const std::string &content); 49 std::string PackageImeCfg(); 50 std::recursive_mutex imeCfgLock_; 51 std::vector<ImePersistInfo> imeConfigs_; 52 static std::shared_ptr<AppExecFwk::EventHandler> serviceHandler_; 53 }; 54 } // namespace MiscServices 55 } // namespace OHOS 56 #endif // SERVICES_INCLUDE_IME_CFG_MANAGER_H 57