1 /*
2 * Copyright (c) 2022-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 #include "quick_fix_manager_service_ability.h"
17
18 #include "hilog_tag_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
~QuickFixManagerServiceAbility()29 QuickFixManagerServiceAbility::~QuickFixManagerServiceAbility()
30 {
31 TAG_LOGD(AAFwkTag::QUICKFIX, "called");
32 }
33
OnStart()34 void QuickFixManagerServiceAbility::OnStart()
35 {
36 TAG_LOGI(AAFwkTag::QUICKFIX, "called");
37 if (service_ != nullptr) {
38 TAG_LOGD(AAFwkTag::QUICKFIX, "Quick fix manager service has started");
39 return;
40 }
41
42 service_ = QuickFixManagerService::GetInstance();
43 if (service_ == nullptr) {
44 TAG_LOGE(AAFwkTag::QUICKFIX, "instance is nullptr");
45 return;
46 }
47
48 if (!service_->Init()) {
49 TAG_LOGE(AAFwkTag::QUICKFIX, "init failed");
50 return;
51 }
52
53 if (!Publish(service_)) {
54 TAG_LOGE(AAFwkTag::QUICKFIX, "Publish failed");
55 return;
56 }
57 }
58
OnStop()59 void QuickFixManagerServiceAbility::OnStop()
60 {
61 service_ = nullptr;
62 }
63 } // namespace AAFwk
64 } // namespace OHOS
65