1 /*
2  * Copyright (c) 2021-2023 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 OHOS_ABILITY_RUNTIME_ABILITY_CONNECT_CALLBACK_PROXY_H
17 #define OHOS_ABILITY_RUNTIME_ABILITY_CONNECT_CALLBACK_PROXY_H
18 
19 #include "ability_connect_callback_interface.h"
20 #include "iremote_proxy.h"
21 
22 namespace OHOS {
23 namespace AAFwk {
24 /**
25  * @class AbilityConnectProxy
26  * AbilityConnect proxy.
27  */
28 class AbilityConnectionProxy : public IRemoteProxy<IAbilityConnection> {
29 public:
AbilityConnectionProxy(const sptr<IRemoteObject> & impl)30     explicit AbilityConnectionProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAbilityConnection>(impl)
31     {}
32 
~AbilityConnectionProxy()33     virtual ~AbilityConnectionProxy()
34     {}
35 
36     /**
37      * OnAbilityConnectDone, AbilityMs notify caller ability the result of connect.
38      *
39      * @param element,.service ability's ElementName.
40      * @param remoteObject,.the session proxy of service ability.
41      * @param resultCode, ERR_OK on success, others on failure.
42      */
43     virtual void OnAbilityConnectDone(
44         const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode) override;
45 
46     /**
47      * OnAbilityDisconnectDone, AbilityMs notify caller ability the result of disconnect.
48      *
49      * @param element,.service ability's ElementName.
50      * @param resultCode, ERR_OK on success, others on failure.
51      */
52     virtual void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override;
53 
54 private:
55     bool WriteInterfaceToken(MessageParcel &data);
56     int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);
57 
58 private:
59     static inline BrokerDelegator<AbilityConnectionProxy> delegator_;
60 };
61 }  // namespace AAFwk
62 }  // namespace OHOS
63 #endif  // OHOS_ABILITY_RUNTIME_ABILITY_CONNECT_CALLBACK_PROXY_H
64