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 <chrono> 20 #include <map> 21 22 #include "input_method_property.h" 23 #include "timer.h" 24 namespace OHOS { 25 namespace MiscServices { 26 27 class FullImeInfoManager { 28 public: 29 static FullImeInfoManager &GetInstance(); 30 int32_t Init(); // osAccount start/bundle scan finished/regular update 31 int32_t Add(int32_t userId); // user switched 32 int32_t Update(); // language change 33 int32_t Delete(int32_t userId); // user removed 34 int32_t Add(int32_t userId, const std::string &bundleName); // package added 35 int32_t Delete(int32_t userId, const std::string &bundleName); // package removed 36 int32_t Update(int32_t userId, const std::string &bundleName); // package changed 37 std::vector<FullImeInfo> Get(int32_t userId); 38 std::string Get(int32_t userId, uint32_t tokenId); 39 bool Get(const std::string &bundleName, int32_t userId, FullImeInfo &fullImeInfo); 40 bool Has(int32_t userId, const std::string &bundleName); 41 42 private: 43 FullImeInfoManager(); 44 ~FullImeInfoManager(); 45 std::mutex lock_; 46 std::map<int32_t, std::vector<FullImeInfo>> fullImeInfos_; 47 Utils::Timer timer_{ "imeInfoCacheInitTimer" }; 48 uint32_t timerId_{ 0 }; 49 }; 50 } // namespace MiscServices 51 } // namespace OHOS 52 #endif // SERVICES_INCLUDE_FULL_IME_INFO_MANAGER_H 53