• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 FOUNDATION_APPEXECFWK_SERVICES_DBMS_INCLUDE_DISTRIBUTED_BMS_PROXY_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_DBMS_INCLUDE_DISTRIBUTED_BMS_PROXY_H
18 
19 #include <string>
20 
21 #include "distributed_bms_interface.h"
22 #include "iremote_proxy.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 class DistributedBmsProxy : public IRemoteProxy<IDistributedBms> {
27 public:
28     explicit DistributedBmsProxy(const sptr<IRemoteObject> &object);
29     virtual ~DistributedBmsProxy() override;
30 
31     /**
32      * @brief get remote ability info
33      * @param elementName Indicates the elementName.
34      * @param remoteAbilityInfo Indicates the remote ability info.
35      * @return Returns result code when get ability info.
36      */
37     int32_t GetRemoteAbilityInfo(
38         const OHOS::AppExecFwk::ElementName &elementName, RemoteAbilityInfo &remoteAbilityInfo) override;
39 
40     /**
41      * @brief get remote ability info
42      * @param elementName Indicates the elementName.
43      * @param localeInfo Indicates the localeInfo.
44      * @param remoteAbilityInfo Indicates the remote ability info.
45      * @return Returns result code when get remote ability info.
46      */
47     int32_t GetRemoteAbilityInfo(const OHOS::AppExecFwk::ElementName &elementName, const std::string &localeInfo,
48         RemoteAbilityInfo &remoteAbilityInfo) override;
49 
50     /**
51      * @brief get remote ability infos
52      * @param elementNames Indicates the elementNames.
53      * @param remoteAbilityInfos Indicates the remote ability infos.
54      * @return Returns result code when get remote ability infos.
55      */
56     int32_t GetRemoteAbilityInfos(
57         const std::vector<ElementName> &elementNames, std::vector<RemoteAbilityInfo> &remoteAbilityInfos) override;
58 
59     /**
60      * @brief get remote ability infos
61      * @param elementNames Indicates the elementNames.
62      * @param localeInfo Indicates the localeInfo.
63      * @param remoteAbilityInfos Indicates the remote ability infos.
64      * @return Returns result code when get remote ability infos.
65      */
66     int32_t GetRemoteAbilityInfos(const std::vector<ElementName> &elementNames, const std::string &localeInfo,
67         std::vector<RemoteAbilityInfo> &remoteAbilityInfos) override;
68 
69     /**
70      * @brief get ability info
71      * @param elementName Indicates the elementName.
72      * @param remoteAbilityInfo Indicates the remote ability info.
73      * @return Returns result code when get ability info.
74      */
75     int32_t GetAbilityInfo(
76         const OHOS::AppExecFwk::ElementName &elementName, RemoteAbilityInfo &remoteAbilityInfo) override;
77 
78     /**
79      * @brief get ability info
80      * @param elementName Indicates the elementName.
81      * @param localeInfo Indicates the localeInfo.
82      * @param remoteAbilityInfo Indicates the remote ability info.
83      * @return Returns result code when get ability info.
84      */
85     int32_t GetAbilityInfo(const OHOS::AppExecFwk::ElementName &elementName, const std::string &localeInfo,
86         RemoteAbilityInfo &remoteAbilityInfo) override;
87 
88     /**
89      * @brief get ability infos
90      * @param elementNames Indicates the elementNames.
91      * @param remoteAbilityInfos Indicates the remote ability infos.
92      * @return Returns result code when get ability infos.
93      */
94     int32_t GetAbilityInfos(
95         const std::vector<ElementName> &elementNames, std::vector<RemoteAbilityInfo> &remoteAbilityInfos) override;
96 
97     /**
98      * @brief get ability infos
99      * @param elementNames Indicates the elementNames.
100      * @param localeInfo Indicates the localeInfo.
101      * @param remoteAbilityInfos Indicates the remote ability infos.
102      * @return Returns result code when get ability infos.
103      */
104     int32_t GetAbilityInfos(const std::vector<ElementName> &elementNames, const std::string &localeInfo,
105         std::vector<RemoteAbilityInfo> &remoteAbilityInfos) override;
106 
107     bool GetDistributedBundleInfo(const std::string &networkId, const std::string &bundleName,
108         DistributedBundleInfo &distributedBundleInfo) override;
109 private:
110     int32_t SendRequest(IDistributedBms::Message code, MessageParcel &data, MessageParcel &reply);
111     template<typename T>
112     bool WriteParcelableVector(const std::vector<T> &parcelableVector, Parcel &data);
113     template <typename T>
114     int32_t GetParcelableInfo(IDistributedBms::Message code, MessageParcel &data, T &parcelableInfo);
115     template <typename T>
116     int32_t GetParcelableInfos(IDistributedBms::Message code, MessageParcel &data, std::vector<T> &parcelableInfos);
117     int32_t CheckElementName(const ElementName &elementName);
118     static inline BrokerDelegator<DistributedBmsProxy> delegator_;
119 };
120 }  // namespace AppExecFwk
121 }  // namespace OHOS
122 #endif  // FOUNDATION_APPEXECFWK_SERVICES_DBMS_INCLUDE_DISTRIBUTED_BMS_PROXY_H