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