1 /*
2 * Copyright (c) 2021-2022 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 #include "display_system_ability.h"
17 #include "delayed_sp_singleton.h"
18 #include "iremote_object.h"
19 #include "new"
20 #include "system_ability_definition.h"
21 #include "display_log.h"
22
23 namespace OHOS {
24 namespace DisplayPowerMgr {
25 namespace {
26 REGISTER_SYSTEM_ABILITY_BY_ID(DisplaySystemAbility, DISPLAY_MANAGER_SERVICE_ID, true);
27 }
OnStart()28 void DisplaySystemAbility::OnStart()
29 {
30 DISPLAY_HILOGI(COMP_SVC, "Start service");
31 auto service = DelayedSpSingleton<DisplayPowerMgrService>::GetInstance();
32 service->Init();
33 if (!Publish(service)) {
34 DISPLAY_HILOGE(COMP_SVC, "Failed to publish service");
35 }
36 }
37
OnStop()38 void DisplaySystemAbility::OnStop()
39 {
40 DISPLAY_HILOGW(COMP_SVC, "Stop service");
41 auto service = DelayedSpSingleton<DisplayPowerMgrService>::GetInstance();
42 service->Deinit();
43 }
44 } // OHOS
45 } // DisplayPowerMgr