1 /* 2 * Copyright (c) 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_EXTENSION_MANAGER_PROXY_H 17 #define OHOS_ABILITY_RUNTIME_EXTENSION_MANAGER_PROXY_H 18 19 #include "extension_manager_interface.h" 20 21 #include "iremote_proxy.h" 22 23 namespace OHOS { 24 class MessageParcel; 25 namespace AAFwk { 26 enum class AbilityManagerInterfaceCode; 27 /** 28 * @class ExtensionManagerProxy 29 * ExtensionManagerProxy. 30 */ 31 class ExtensionManagerProxy : public IRemoteProxy<IExtensionManager> { 32 public: ExtensionManagerProxy(const sptr<IRemoteObject> & impl)33 explicit ExtensionManagerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IExtensionManager>(impl) {} 34 virtual ~ExtensionManagerProxy() = default; 35 36 /** 37 * ConnectAbility, connect session with service ability. 38 * 39 * @param want, Special want for service type's ability. 40 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 41 * @param callerToken, caller ability token. 42 * @param userId, Designation User ID. 43 * @return Returns ERR_OK on success, others on failure. 44 */ 45 virtual int ConnectAbilityCommon(const Want &want, const sptr<IRemoteObject> &connect, 46 const sptr<IRemoteObject> &callerToken, AppExecFwk::ExtensionAbilityType extensionType, 47 int32_t userId = DEFAULT_INVALID_USER_ID, bool isQueryExtensionOnly = true) override; 48 49 /** 50 * Disconnect session with extension ability. 51 * 52 * @param connect, Callback used to notify caller the result of connecting or disconnecting. 53 * @return Returns ERR_OK on success, others on failure. 54 */ 55 virtual int DisconnectAbility(const sptr<IRemoteObject> &connect) override; 56 57 private: 58 bool WriteInterfaceToken(MessageParcel &data); 59 ErrCode SendRequest(AbilityManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply, 60 MessageOption& option); 61 62 private: 63 static inline BrokerDelegator<ExtensionManagerProxy> delegator_; 64 }; 65 } // namespace AAFwk 66 } // namespace OHOS 67 #endif // OHOS_ABILITY_RUNTIME_EXTENSION_MANAGER_PROXY_H 68