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_FORM_FWK_PROVIDER_CONNECT_PROXY_H 17 #define OHOS_FORM_FWK_PROVIDER_CONNECT_PROXY_H 18 19 #include "ability_connect_callback_interface.h" 20 #include "iremote_proxy.h" 21 22 namespace OHOS { 23 namespace AppExecFwk { 24 using IAbilityConnection = OHOS::AAFwk::IAbilityConnection; 25 26 /** 27 * @class ProviderConnectProxy 28 * Provider connect proxy is used to connect form ability service. 29 */ 30 class ProviderConnectProxy : public IRemoteProxy<IAbilityConnection> { 31 public: ProviderConnectProxy(const sptr<IRemoteObject> & impl)32 explicit ProviderConnectProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAbilityConnection>(impl) 33 {} 34 35 virtual ~ProviderConnectProxy() = default; 36 37 /** 38 * @brief OnAbilityConnectDone, AbilityMs notify caller ability the result of connect. 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 * @brief OnAbilityDisconnectDone, AbilityMs notify caller ability the result of disconnect. 48 * @param element service ability's ElementName. 49 * @param resultCode ERR_OK on success, others on failure. 50 */ 51 virtual void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; 52 53 private: 54 bool WriteInterfaceToken(MessageParcel &data); 55 bool SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 56 57 private: 58 static inline BrokerDelegator<ProviderConnectProxy> delegator_; 59 }; 60 } // namespace AppExecFwk 61 } // namespace OHOS 62 #endif // OHOS_FORM_FWK_PROVIDER_CONNECT_PROXY_H 63