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