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_SERVICE_ROUTER_FRAMEWORK_INCLUDE_SERVICE_ROUTER_MGR_PROXY_H
17 #define OHOS_ABILITY_RUNTIME_SERVICE_ROUTER_FRAMEWORK_INCLUDE_SERVICE_ROUTER_MGR_PROXY_H
18 
19 #include "iremote_proxy.h"
20 #include "service_router_mgr_interface.h"
21 
22 namespace OHOS {
23 namespace AbilityRuntime {
24 /**
25  * @class ServiceRouterMgrProxy
26  * ServiceRouterMgrProxy.
27  */
28 class ServiceRouterMgrProxy : public IRemoteProxy<IServiceRouterManager> {
29 public:
30     explicit ServiceRouterMgrProxy(const sptr<IRemoteObject> &object);
31 
32     virtual ~ServiceRouterMgrProxy() override;
33 
34     /**
35      * @brief Query the business ability info of list by the given filter.
36      * @param filter Indicates the filter containing the business ability info to be queried.
37      * @param businessAbilityInfos Indicates the obtained business ability info objects
38      * @return Returns ERR_OK on success, others on failure.
39      */
40     int32_t QueryBusinessAbilityInfos(const BusinessAbilityFilter &filter,
41         std::vector<BusinessAbilityInfo> &businessAbilityInfos) override;
42 
43     /**
44      * @brief Query the PurposeInfo of list by the given Want.
45      * @param want Indicates the information of the purpose.
46      * @param purposeName Indicates the  purposeName.
47      * @param purposeInfos Indicates the obtained PurposeInfos object.
48      * @return Returns ERR_OK on success, others on failure.
49      */
50     int32_t QueryPurposeInfos(const Want &want, const std::string purposeName,
51         std::vector<PurposeInfo> &purposeInfos) override;
52 
53     /**
54      * Start ui extension ability with extension session info, send extension session info to ability manager service.
55      *
56      * @param sessionInfo the extension session info of the ability to start.
57      * @param userId, Designation User ID.
58      * @return Returns ERR_OK on success, others on failure.
59      */
60     int32_t StartUIExtensionAbility(const sptr<SessionInfo> &sessionInfo,
61         int32_t userId = DEFAULT_INVAL_VALUE) override;
62 
63     /**
64      * Connect ui extension ability with want, connect session with service ability.
65      *
66      * @param want, Special want for service type's ability.
67      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
68      * @param sessionInfo the extension session info of the ability to start.
69      * @param userId, Designation User ID.
70      * @return Returns ERR_OK on success, others on failure.
71      */
72     int32_t ConnectUIExtensionAbility(const Want &want, const sptr<IAbilityConnection> &connect,
73         const sptr<SessionInfo> &sessionInfo, int32_t userId = DEFAULT_INVAL_VALUE) override;
74 
75 private:
76     int32_t SendRequest(IServiceRouterManager::Message code, MessageParcel &data,
77         MessageParcel &reply, MessageOption &option);
78 
79     template <typename T>
80     int32_t GetParcelableInfos(IServiceRouterManager::Message code, MessageParcel &data,
81         std::vector<T> &parcelableInfos);
82 
83     static inline BrokerDelegator<ServiceRouterMgrProxy> delegator_;
84 };
85 }  // namespace AbilityRuntime
86 }  // namespace OHOS
87 #endif // namespace OHOS_ABILITY_RUNTIME_SERVICE_ROUTER_FRAMEWORK_INCLUDE_SERVICE_ROUTER_MGR_PROXY_H
88