1 /*
2 * Copyright (c) 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 "quick_fix_manager_service_ability.h"
17
18 #include "hilog_wrapper.h"
19 #include "system_ability_definition.h"
20
21 namespace OHOS {
22 namespace AAFwk {
23 REGISTER_SYSTEM_ABILITY_BY_ID(QuickFixManagerServiceAbility, QUICK_FIX_MGR_SERVICE_ID, true);
24
QuickFixManagerServiceAbility(const int32_t systemAbilityId,bool runOnCreate)25 QuickFixManagerServiceAbility::QuickFixManagerServiceAbility(const int32_t systemAbilityId, bool runOnCreate)
26 : SystemAbility(systemAbilityId, runOnCreate), service_(nullptr)
27 {
28 HILOG_DEBUG("function called.");
29 }
30
~QuickFixManagerServiceAbility()31 QuickFixManagerServiceAbility::~QuickFixManagerServiceAbility()
32 {
33 HILOG_DEBUG("function called.");
34 }
35
OnStart()36 void QuickFixManagerServiceAbility::OnStart()
37 {
38 HILOG_INFO("function called.");
39 if (service_ != nullptr) {
40 HILOG_DEBUG("Quick fix manager service has started.");
41 return;
42 }
43
44 service_ = QuickFixManagerService::GetInstance();
45 if (service_ == nullptr) {
46 HILOG_ERROR("instance is nullptr.");
47 return;
48 }
49
50 if (!service_->Init()) {
51 HILOG_ERROR("init failed.");
52 return;
53 }
54
55 if (!Publish(service_)) {
56 HILOG_ERROR("Publish failed.");
57 return;
58 }
59
60 HILOG_INFO("Quick fix manager service start succeed.");
61 }
62
OnStop()63 void QuickFixManagerServiceAbility::OnStop()
64 {
65 HILOG_INFO("function called.");
66 service_ = nullptr;
67 }
68 } // namespace AAFwk
69 } // namespace OHOS
70