• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 #include "iremote_proxy.h"
21 
22 namespace OHOS {
23 class MessageParcel;
24 namespace AAFwk {
25 enum class AbilityManagerInterfaceCode;
26 /**
27  * @class ExtensionManagerProxy
28  * ExtensionManagerProxy.
29  */
30 class ExtensionManagerProxy : public IRemoteProxy<IExtensionManager> {
31 public:
ExtensionManagerProxy(const sptr<IRemoteObject> & impl)32     explicit ExtensionManagerProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IExtensionManager>(impl) {}
33     virtual ~ExtensionManagerProxy() = default;
34 
35     /**
36      * ConnectAbility, connect session with service ability.
37      *
38      * @param want, Special want for service type's ability.
39      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
40      * @param callerToken, caller ability token.
41      * @param userId, Designation User ID.
42      * @return Returns ERR_OK on success, others on failure.
43      */
44     virtual int ConnectAbilityCommon(const Want &want, sptr<IRemoteObject> connect,
45         const sptr<IRemoteObject> &callerToken, AppExecFwk::ExtensionAbilityType extensionType,
46         int32_t userId = DEFAULT_INVALID_USER_ID, bool isQueryExtensionOnly = true) override;
47 
48     /**
49      * Disconnect session with extension ability.
50      *
51      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
52      * @return Returns ERR_OK on success, others on failure.
53      */
54     virtual int DisconnectAbility(const sptr<IRemoteObject> &connect) override;
55 
56     /**
57      * @brief Get the extension running information.
58      *
59      * @param upperLimit The maximum limit of information wish to get.
60      * @param info Extension running information.
61      * @return Returns ERR_OK on success, others on failure.
62      */
63     virtual int GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) override;
64 
65     /**
66      * Transfer resultCode & want to ability manager service.
67      *
68      * @param callerToken caller ability token.
69      * @param requestCode the resultCode of the ability to start.
70      * @param want Indicates the ability to start.
71      * @return Returns ERR_OK on success, others on failure.
72      */
73     virtual int32_t TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken, int32_t resultCode,
74         const Want &want) override;
75 private:
76     bool WriteInterfaceToken(MessageParcel &data);
77     ErrCode SendRequest(AbilityManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply,
78         MessageOption &option);
79     template <typename T>
80     int GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos);
81 private:
82     static inline BrokerDelegator<ExtensionManagerProxy> delegator_;
83 };
84 }  // namespace AAFwk
85 }  // namespace OHOS
86 #endif  // OHOS_ABILITY_RUNTIME_EXTENSION_MANAGER_PROXY_H
87