• 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 #include "insight_intent_execute_param.h"
27 
28 namespace OHOS::AVSession {
29 class AbilityConnectHelper {
30 public:
31     static AbilityConnectHelper& GetInstance();
32 
33     int32_t StartAbilityForegroundByCall(const std::string& bundleName, const std::string& abilityName);
34 
35     int32_t StartAbilityByCall(const std::string &bundleName, const std::string &abilityName);
36 
37     int32_t StartAVPlayback(AppExecFwk::InsightIntentExecuteParam &executeParam);
38 
39 private:
40    sptr<IRemoteObject> GetSystemAbility();
41 
42    const std::u16string ABILITY_MANAGER_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
43 };
44 
45 class AbilityConnectionStub : public IRemoteStub<AAFwk::IAbilityConnection> {
46 public:
47     AbilityConnectionStub();
48     virtual ~AbilityConnectionStub();
49 
50     int OnRemoteRequest(
51         uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
52 
53 private:
54     DISALLOW_COPY_AND_MOVE(AbilityConnectionStub);
55 };
56 
57 class AbilityConnectCallback : public AbilityConnectionStub {
58 public:
AbilityConnectCallback()59     AbilityConnectCallback() {};
60     ~AbilityConnectCallback() override;
61 
62     void OnAbilityConnectDone(
63         const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) override;
64     void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) override;
65 };
66 } // namespace OHOS::AVSession
67 #endif /* ABILITY_CONNECT_HELPER_H */