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 "concurrent_task_service_ability.h"
17 #include "concurrent_task_log.h"
18 #include "concurrent_task_controller.h"
19 #include "concurrent_task_service.h"
20 #include "system_ability_definition.h"
21
22 namespace OHOS {
23 namespace ConcurrentTask {
24 REGISTER_SYSTEM_ABILITY_BY_ID(ConcurrentTaskServiceAbility, CONCURRENT_TASK_SERVICE_ID, true);
25
OnStart()26 void ConcurrentTaskServiceAbility::OnStart()
27 {
28 TaskController::GetInstance().Init();
29 if (!service_) {
30 try {
31 service_ = new ConcurrentTaskService();
32 } catch (const std::bad_alloc& e) {
33 CONCUR_LOGE("ConcurrentTaskServiceAbility:: new ConcurentTaskService failed.");
34 }
35 }
36 if (!Publish(service_)) {
37 CONCUR_LOGE("ConcurrentTaskServiceAbility:: Register service failed.");
38 }
39 CONCUR_LOGI("ConcurrentTaskServiceAbility ::OnStart.");
40 }
41
OnStop()42 void ConcurrentTaskServiceAbility::OnStop()
43 {
44 TaskController::GetInstance().Release();
45 CONCUR_LOGI("ConcurrentTaskServiceAbility::OnStop!");
46 }
47
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)48 void ConcurrentTaskServiceAbility::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
49 {
50 CONCUR_LOGI("ConcurrentTaskServiceAbility::Add");
51 }
52
OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)53 void ConcurrentTaskServiceAbility::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
54 {
55 CONCUR_LOGI("ConcurrentTaskServiceAbility::Remove");
56 }
57 } // namespace ConcurrentTask
58 } // namespace OHOS
59