• 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 FONT_SERVICE_LOAD_MANAGER_H
17 #define FONT_SERVICE_LOAD_MANAGER_H
18 
19 #include <mutex>
20 #include <unistd.h>
21 #include <singleton.h>
22 
23 #include "ifont_service.h"
24 #include "iremote_object.h"
25 #include "iservice_registry.h"
26 
27 namespace OHOS {
28 namespace Global {
29 namespace FontManager {
30 enum class LoadSaStatus {
31     WAIT_RESULT = 0,
32     SUCCESS,
33     FAIL,
34 };
35 
36 class FontServiceLoadManager : public DelayedSingleton<FontServiceLoadManager> {
37 public:
38     FontServiceLoadManager();
39     ~FontServiceLoadManager();
40     sptr<IFontService> GetFontServiceAbility(int32_t systemAbilityId);
41     void OnLoadSystemAbilitySuccess();
42     void OnLoadSystemAbilityFail();
43     bool UnloadFontService(int32_t systemAbilityId);
44 
45 private:
46     void InitStatus();
47     bool LoadSa(int systemAbilityId);
48 
49     LoadSaStatus loadSaStatus_ = LoadSaStatus::WAIT_RESULT;
50     std::condition_variable proxyConVar_;
51     std::mutex serviceLock_;
52 };
53 } // namespace FontManager
54 } // namespace Global
55 } // namespace OHOS
56 #endif // FONT_SERVICE_LOAD_MANAGER_H