• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef ABILITY_CONNECT_HELPER_H
17 #define ABILITY_CONNECT_HELPER_H
18 
19 #include <string>
20 
21 #include "ability_connect_callback_interface.h"
22 #include "ability_connect_callback_stub.h"
23 #include "element_name.h"
24 #include "iremote_stub.h"
25 #include "want.h"
26 
27 namespace OHOS::AVSession {
28 class AbilityConnectHelper {
29 public:
30     static AbilityConnectHelper& GetInstance();
31 
32     int32_t StartAbilityByCall(const std::string &bundleName, const std::string &abilityName);
33 
34 private:
35    sptr<IRemoteObject> GetSystemAbility();
36 
37    const std::u16string ABILITY_MANAGER_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
38 };
39 
40 class AbilityConnectionStub : public IRemoteStub<AAFwk::IAbilityConnection> {
41 public:
42     AbilityConnectionStub();
43     virtual ~AbilityConnectionStub();
44 
45     int OnRemoteRequest(
46         uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
47 
48 private:
49     DISALLOW_COPY_AND_MOVE(AbilityConnectionStub);
50 };
51 
52 class AbilityConnectCallback : public AbilityConnectionStub {
53 public:
AbilityConnectCallback()54     AbilityConnectCallback() {};
55     ~AbilityConnectCallback() override;
56 
57     void OnAbilityConnectDone(
58         const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) override;
59     void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) override;
60 };
61 } // namespace OHOS::AVSession
62 #endif /* ABILITY_CONNECT_HELPER_H */