1 /*
2 * Copyright (c) 2020 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 "ability_context.h"
17
18 #include "ability_service_interface.h"
19 #include "ability_service_manager.h"
20 #include "abilityms_client.h"
21
22 namespace OHOS {
StartAbility(const Want & want)23 int AbilityContext::StartAbility(const Want &want)
24 {
25 return AbilityMsClient::GetInstance().ScheduleAms(&want, 0, nullptr, START_ABILITY);
26 }
27
TerminateAbility()28 int AbilityContext::TerminateAbility()
29 {
30 return AbilityMsClient::GetInstance().ScheduleAms(nullptr, token_, nullptr, TERMINATE_ABILITY);
31 }
32
StopAbility(const Want & want)33 int AbilityContext::StopAbility(const Want &want)
34 {
35 return AbilityMsClient::GetInstance().ScheduleAms(&want, 0, nullptr, TERMINATE_SERVICE);
36 }
37
ConnectAbility(const Want & want,const IAbilityConnection & conn,void * storeArg)38 int AbilityContext::ConnectAbility(const Want &want, const IAbilityConnection &conn, void *storeArg)
39 {
40 return AbilityServiceManager::GetInstance().ConnectAbility(want, conn, token_, storeArg);
41 }
42
DisconnectAbility(const IAbilityConnection & conn)43 int AbilityContext::DisconnectAbility(const IAbilityConnection &conn)
44 {
45 return AbilityServiceManager::GetInstance().DisconnectAbility(conn, token_);
46 }
47 } // namespace OHOS