13c3173acSopenharmony_ci/* 23c3173acSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 33c3173acSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 43c3173acSopenharmony_ci * you may not use this file except in compliance with the License. 53c3173acSopenharmony_ci * You may obtain a copy of the License at 63c3173acSopenharmony_ci * 73c3173acSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 83c3173acSopenharmony_ci * 93c3173acSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 103c3173acSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 113c3173acSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 123c3173acSopenharmony_ci * See the License for the specific language governing permissions and 133c3173acSopenharmony_ci * limitations under the License. 143c3173acSopenharmony_ci */ 153c3173acSopenharmony_ci 163c3173acSopenharmony_ci#include "concurrent_task_service_ability.h" 173c3173acSopenharmony_ci#include "concurrent_task_log.h" 183c3173acSopenharmony_ci#include "concurrent_task_controller.h" 193c3173acSopenharmony_ci#include "concurrent_task_service.h" 203c3173acSopenharmony_ci#include "system_ability_definition.h" 213c3173acSopenharmony_ci 223c3173acSopenharmony_cinamespace OHOS { 233c3173acSopenharmony_cinamespace ConcurrentTask { 243c3173acSopenharmony_ciREGISTER_SYSTEM_ABILITY_BY_ID(ConcurrentTaskServiceAbility, CONCURRENT_TASK_SERVICE_ID, true); 253c3173acSopenharmony_ci 263c3173acSopenharmony_civoid ConcurrentTaskServiceAbility::OnStart() 273c3173acSopenharmony_ci{ 283c3173acSopenharmony_ci TaskController::GetInstance().Init(); 293c3173acSopenharmony_ci if (!service_) { 303c3173acSopenharmony_ci try { 313c3173acSopenharmony_ci service_ = new ConcurrentTaskService(); 323c3173acSopenharmony_ci } catch (const std::bad_alloc& e) { 333c3173acSopenharmony_ci CONCUR_LOGE("ConcurrentTaskServiceAbility:: new ConcurentTaskService failed."); 343c3173acSopenharmony_ci } 353c3173acSopenharmony_ci } 363c3173acSopenharmony_ci if (!Publish(service_)) { 373c3173acSopenharmony_ci CONCUR_LOGE("ConcurrentTaskServiceAbility:: Register service failed."); 383c3173acSopenharmony_ci } 393c3173acSopenharmony_ci CONCUR_LOGI("ConcurrentTaskServiceAbility ::OnStart."); 403c3173acSopenharmony_ci} 413c3173acSopenharmony_ci 423c3173acSopenharmony_civoid ConcurrentTaskServiceAbility::OnStop() 433c3173acSopenharmony_ci{ 443c3173acSopenharmony_ci TaskController::GetInstance().Release(); 453c3173acSopenharmony_ci CONCUR_LOGI("ConcurrentTaskServiceAbility::OnStop!"); 463c3173acSopenharmony_ci} 473c3173acSopenharmony_ci 483c3173acSopenharmony_civoid ConcurrentTaskServiceAbility::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) 493c3173acSopenharmony_ci{ 503c3173acSopenharmony_ci CONCUR_LOGI("ConcurrentTaskServiceAbility::Add"); 513c3173acSopenharmony_ci} 523c3173acSopenharmony_ci 533c3173acSopenharmony_civoid ConcurrentTaskServiceAbility::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) 543c3173acSopenharmony_ci{ 553c3173acSopenharmony_ci CONCUR_LOGI("ConcurrentTaskServiceAbility::Remove"); 563c3173acSopenharmony_ci} 573c3173acSopenharmony_ci} // namespace ConcurrentTask 583c3173acSopenharmony_ci} // namespace OHOS 59