• 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 GLOBAL_FONT_MANAGER_FONT_SERVER_H
17 #define GLOBAL_FONT_MANAGER_FONT_SERVER_H
18 
19 #include "event_handler.h"
20 #include "font_service_stub.h"
21 #include "system_ability.h"
22 #include "system_ability_ondemand_reason.h"
23 
24 namespace OHOS {
25 namespace Global {
26 namespace FontManager {
27 class FontManagerServer : public SystemAbility, public FontServiceStub {
28     DECLARE_SYSTEM_ABILITY(FontManagerServer);
29 public:
30     DISALLOW_COPY_AND_MOVE(FontManagerServer);
31 
32     FontManagerServer(int32_t saId, bool runOnCreate);
33 
34     ~FontManagerServer() override = default;
35 
36     int32_t InstallFont(const int32_t fd, int32_t &outValue) override;
37 
38     int32_t UninstallFont(const std::string &fontName, int32_t &outValue) override;
39 
40 protected:
41     void OnStart(const SystemAbilityOnDemandReason &startReason) override;
42 
43     void OnStop(const SystemAbilityOnDemandReason &startReason) override;
44 
45 private:
46     void AddUnloadFontServiceTask();
47     void RemoveUnloadFontServiceTask();
48     int32_t CheckPermission();
49     // font service unload event handler.
50     std::shared_ptr <AppExecFwk::EventHandler> handler_;
51 };
52 } // namespace FontManager
53 } // namespace Global
54 } // namespace OHOS
55 #endif // GLOBAL_FONT_MANAGER_FONT_SERVER_H
56