1 /* 2 * Copyright (c) 2024 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_FULL_IME_INFO_MANAGER_H 17 #define SERVICES_INCLUDE_FULL_IME_INFO_MANAGER_H 18 19 #include "event_handler.h" 20 #include "input_method_property.h" 21 #include "timer.h" 22 namespace OHOS { 23 namespace MiscServices { 24 25 class FullImeInfoManager { 26 public: 27 static FullImeInfoManager &GetInstance(); 28 int32_t RegularInit(); 29 int32_t Init(); // regular Init/boot complete/data share ready 30 int32_t Switch(int32_t userId); // user switched 31 int32_t Update(); // language change 32 int32_t Delete(int32_t userId); // user removed 33 int32_t Add(int32_t userId, const std::string &bundleName); // package added 34 int32_t Delete(int32_t userId, const std::string &bundleName); // package removed 35 int32_t Update(int32_t userId, const std::string &bundleName); // package changed 36 std::string Get(int32_t userId, uint32_t tokenId); 37 bool Get(int32_t userId, const std::string &bundleName, FullImeInfo &fullImeInfo); 38 bool Has(int32_t userId, const std::string &bundleName); 39 int32_t Get(int32_t userId, std::vector<Property> &props); 40 41 private: 42 FullImeInfoManager(); 43 ~FullImeInfoManager(); 44 int32_t Init(std::map<int32_t, std::vector<FullImeInfo>> &fullImeInfos); 45 int32_t AddUser(int32_t userId, std::vector<FullImeInfo> &infos); 46 int32_t AddPackage(int32_t userId, const std::string &bundleName, FullImeInfo &info); 47 int32_t DeletePackage(int32_t userId, const std::string &bundleName); 48 std::mutex lock_; 49 std::map<int32_t, std::vector<FullImeInfo>> fullImeInfos_; 50 Utils::Timer timer_{ "imeInfoCacheInitTimer" }; 51 uint32_t timerId_{ 0 }; 52 std::shared_ptr<AppExecFwk::EventHandler> serviceHandler_{ nullptr }; 53 }; 54 } // namespace MiscServices 55 } // namespace OHOS 56 #endif // SERVICES_INCLUDE_FULL_IME_INFO_MANAGER_H 57