1 /*
2 * Copyright (c) 2021-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 #include "distributed_device_profile_stub_new.h"
17
18 #include <string>
19
20 #include "ipc_skeleton.h"
21 #include "ipc_utils.h"
22
23 #include "distributed_device_profile_enums.h"
24 #include "distributed_device_profile_errors.h"
25 #include "distributed_device_profile_log.h"
26 #include "distributed_device_profile_service_new.h"
27 #include "profile_utils.h"
28
29 namespace OHOS {
30 namespace DistributedDeviceProfile {
31 namespace {
32 const std::string TAG = "DistributedDeviceProfileStubNew";
33 }
34
DistributedDeviceProfileStubNew()35 DistributedDeviceProfileStubNew::DistributedDeviceProfileStubNew()
36 {
37 InitAclAndSubscribe();
38 }
39
InitAclAndSubscribe()40 void DistributedDeviceProfileStubNew::InitAclAndSubscribe()
41 {
42 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_ACL_PROFILE));
43 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::UPDATE_ACL_PROFILE));
44 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::GET_TRUST_DEVICE_PROFILE));
45 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::GET_ALL_TRUST_DEVICE_PROFILE));
46 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::GET_ACL_PROFILE));
47 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::GET_ALL_ACL_PROFILE));
48 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::GET_ALL_ACL_INCLUDE_LNN_ACL));
49 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::DELETE_ACL_PROFILE));
50 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE));
51 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE));
52 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::SEND_SUBSCRIBE_INFOS));
53 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_SERVICE_PROFILE));
54 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_SERVICE_PROFILE_BATCH));
55 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_CHAR_PROFILE));
56 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_CHAR_PROFILE_BATCH));
57 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE_INITED));
58 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE_INITED));
59 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_ALL_TRUSTED_DEVICES));
60 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_DEVICE_PROFILE_BATCH));
61 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::GET_DEVICE_PROFILES));
62 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::DELETE_DEVICE_PROFILE_BATCH));
63 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::GET_DEVICE_ICON_INFOS));
64 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_DEVICE_ICON_INFO_BATCH));
65 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_PRODUCT_INFO_BATCH));
66 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::PUT_SESSION_KEY));
67 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::GET_SESSION_KEY));
68 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::UPDATE_SESSION_KEY));
69 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::DELETE_SESSION_KEY));
70 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::SUBSCRIBE_PINCODE_INVALID));
71 aclAndSubscribeFuncs_.insert(static_cast<uint32_t>(DPInterfaceCode::UNSUBSCRIBE_PINCODE_INVALID));
72 }
73
~DistributedDeviceProfileStubNew()74 DistributedDeviceProfileStubNew::~DistributedDeviceProfileStubNew()
75 {
76 HILOGI("destructor!");
77 }
78
IsInterfaceTokenValid(MessageParcel & data)79 bool DistributedDeviceProfileStubNew::IsInterfaceTokenValid(MessageParcel& data)
80 {
81 return data.ReadInterfaceToken() == IDistributedDeviceProfile::GetDescriptor();
82 }
83
84
NotifyAclEventInner(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)85 int32_t DistributedDeviceProfileStubNew::NotifyAclEventInner(uint32_t code, MessageParcel& data,
86 MessageParcel& reply, MessageOption& option)
87 {
88 switch (code) {
89 case static_cast<uint32_t>(DPInterfaceCode::PUT_ACL_PROFILE):
90 return PutAccessControlProfileInner(data, reply);
91 case static_cast<uint32_t>(DPInterfaceCode::UPDATE_ACL_PROFILE):
92 return UpdateAccessControlProfileInner(data, reply);
93 case static_cast<uint32_t>(DPInterfaceCode::GET_TRUST_DEVICE_PROFILE):
94 return GetTrustDeviceProfileInner(data, reply);
95 case static_cast<uint32_t>(DPInterfaceCode::GET_ALL_TRUST_DEVICE_PROFILE):
96 return GetAllTrustDeviceProfileInner(data, reply);
97 case static_cast<uint32_t>(DPInterfaceCode::GET_ACL_PROFILE):
98 return GetAccessControlProfileInner(data, reply);
99 case static_cast<uint32_t>(DPInterfaceCode::GET_ALL_ACL_PROFILE):
100 return GetAllAccessControlProfileInner(data, reply);
101 case static_cast<uint32_t>(DPInterfaceCode::GET_ALL_ACL_INCLUDE_LNN_ACL):
102 return GetAllAclIncludeLnnAclInner(data, reply);
103 case static_cast<uint32_t>(DPInterfaceCode::DELETE_ACL_PROFILE):
104 return DeleteAccessControlProfileInner(data, reply);
105 case static_cast<uint32_t>(DPInterfaceCode::PUT_SESSION_KEY):
106 return PutSessionKeyInner(data, reply);
107 case static_cast<uint32_t>(DPInterfaceCode::GET_SESSION_KEY):
108 return GetSessionKeyInner(data, reply);
109 case static_cast<uint32_t>(DPInterfaceCode::UPDATE_SESSION_KEY):
110 return UpdateSessionKeyInner(data, reply);
111 case static_cast<uint32_t>(DPInterfaceCode::DELETE_SESSION_KEY):
112 return DeleteSessionKeyInner(data, reply);
113 default:
114 return NotifyProfileDataEventInner(code, data, reply, option);
115 }
116 }
117
NotifyProfileDataEventInner(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)118 int32_t DistributedDeviceProfileStubNew::NotifyProfileDataEventInner(
119 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
120 {
121 switch (code) {
122 case static_cast<uint32_t>(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE):
123 return SubscribeDeviceProfileInner(data, reply);
124 case static_cast<uint32_t>(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE):
125 return UnSubscribeDeviceProfileInner(data, reply);
126 case static_cast<uint32_t>(DPInterfaceCode::SEND_SUBSCRIBE_INFOS):
127 return SendSubscribeInfosInner(data, reply);
128 case static_cast<uint32_t>(DPInterfaceCode::PUT_SERVICE_PROFILE):
129 return PutServiceProfileInner(data, reply);
130 case static_cast<uint32_t>(DPInterfaceCode::PUT_SERVICE_PROFILE_BATCH):
131 return PutServiceProfileBatchInner(data, reply);
132 case static_cast<uint32_t>(DPInterfaceCode::PUT_CHAR_PROFILE):
133 return PutCharacteristicProfileInner(data, reply);
134 case static_cast<uint32_t>(DPInterfaceCode::PUT_CHAR_PROFILE_BATCH):
135 return PutCharacteristicProfileBatchInner(data, reply);
136 case static_cast<uint32_t>(DPInterfaceCode::SUBSCRIBE_DEVICE_PROFILE_INITED):
137 return SubscribeDeviceProfileInitedInner(data, reply);
138 case static_cast<uint32_t>(DPInterfaceCode::UNSUBSCRIBE_DEVICE_PROFILE_INITED):
139 return UnSubscribeDeviceProfileInitedInner(data, reply);
140 case static_cast<uint32_t>(DPInterfaceCode::PUT_ALL_TRUSTED_DEVICES):
141 return PutAllTrustedDevicesInner(data, reply);
142 case static_cast<uint32_t>(DPInterfaceCode::PUT_DEVICE_PROFILE_BATCH):
143 return PutDeviceProfileBatchInner(data, reply);
144 case static_cast<uint32_t>(DPInterfaceCode::GET_DEVICE_PROFILES):
145 return GetDeviceProfilesInner(data, reply);
146 case static_cast<uint32_t>(DPInterfaceCode::GET_DEVICE_ICON_INFOS):
147 return GetDeviceIconInfosInner(data, reply);
148 case static_cast<uint32_t>(DPInterfaceCode::PUT_DEVICE_ICON_INFO_BATCH):
149 return PutDeviceIconInfoBatchInner(data, reply);
150 case static_cast<uint32_t>(DPInterfaceCode::PUT_PRODUCT_INFO_BATCH):
151 return PutProductInfoBatchInner(data, reply);
152 case static_cast<uint32_t>(DPInterfaceCode::DELETE_DEVICE_PROFILE_BATCH):
153 return DeleteDeviceProfileBatchInner(data, reply);
154 case static_cast<uint32_t>(DPInterfaceCode::SUBSCRIBE_PINCODE_INVALID):
155 return SubscribePinCodeInvalidInner(data, reply);
156 case static_cast<uint32_t>(DPInterfaceCode::UNSUBSCRIBE_PINCODE_INVALID):
157 return UnSubscribePinCodeInvalidInner(data, reply);
158 default:
159 HILOGE("unknown request code, please check, code = %{public}u", code);
160 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
161 }
162 }
163
NotifyEventInner(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)164 int32_t DistributedDeviceProfileStubNew::NotifyEventInner(uint32_t code, MessageParcel& data,
165 MessageParcel& reply, MessageOption& option)
166 {
167 switch (code) {
168 case static_cast<uint32_t>(DPInterfaceCode::GET_DEVICE_PROFILE_NEW):
169 return GetDeviceProfileInner(data, reply);
170 case static_cast<uint32_t>(DPInterfaceCode::GET_SERVICE_PROFILE):
171 return GetServiceProfileInner(data, reply);
172 case static_cast<uint32_t>(DPInterfaceCode::GET_CHAR_PROFILE):
173 return GetCharacteristicProfileInner(data, reply);
174 case static_cast<uint32_t>(DPInterfaceCode::DEL_SERVICE_PROFILE):
175 return DeleteServiceProfileInner(data, reply);
176 case static_cast<uint32_t>(DPInterfaceCode::DEL_CHAR_PROFILE):
177 return DeleteCharacteristicProfileInner(data, reply);
178 case static_cast<uint32_t>(DPInterfaceCode::SYNC_DEVICE_PROFILE_NEW):
179 return SyncDeviceProfileInner(data, reply);
180 case static_cast<uint32_t>(DPInterfaceCode::PUT_SERVICE_INFO_PROFILE):
181 return PutServiceInfoProfileInner(data, reply);
182 case static_cast<uint32_t>(DPInterfaceCode::DELETE_SERVICE_INFO_PROFILE):
183 return DeleteServiceInfoProfileInner(data, reply);
184 case static_cast<uint32_t>(DPInterfaceCode::UPDATE_SERVICE_INFO_PROFILE):
185 return UpdateServiceInfoProfileInner(data, reply);
186 case static_cast<uint32_t>(DPInterfaceCode::GET_SERVICE_INFO_PROFILE_BY_UNIQUE_KEY):
187 return GetServiceInfoProfileByUniqueKeyInner(data, reply);
188 case static_cast<uint32_t>(DPInterfaceCode::GET_SERVICE_INFO_PROFILE_LIST_BY_TOKEN_ID):
189 return GetServiceInfoProfileListByTokenIdInner(data, reply);
190 case static_cast<uint32_t>(DPInterfaceCode::GET_ALL_SERVICE_INFO_PROFILE_LIST):
191 return GetAllServiceInfoProfileListInner(data, reply);
192 case static_cast<uint32_t>(DPInterfaceCode::GET_SERVICE_INFO_PROFILE_LIST_BY_BUNDLE_NAME):
193 return GetServiceInfoProfileListByBundleNameInner(data, reply);
194 default:
195 return NotifyLocalServiceEventInner(code, data, reply, option);
196 }
197 }
198
NotifyLocalServiceEventInner(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)199 int32_t DistributedDeviceProfileStubNew::NotifyLocalServiceEventInner(uint32_t code, MessageParcel& data,
200 MessageParcel& reply, MessageOption& option)
201 {
202 switch (code) {
203 case static_cast<uint32_t>(DPInterfaceCode::PUT_LOCAL_SERVICE_INFO):
204 return PutLocalServiceInfoInner(data, reply);
205 case static_cast<uint32_t>(DPInterfaceCode::UPDATE_LOCAL_SERVICE_INFO):
206 return UpdateLocalServiceInfoInner(data, reply);
207 case static_cast<uint32_t>(DPInterfaceCode::GET_LOCAL_SERVICE_INFO_BY_BINDLE_AND_PINTYPE):
208 return GetLocalServiceInfoByBundleAndPinTypeInner(data, reply);
209 case static_cast<uint32_t>(DPInterfaceCode::DELETE_LOCAL_SERVICE_INFO):
210 return DeleteLocalServiceInfoInner(data, reply);
211 case static_cast<uint32_t>(DPInterfaceCode::REGISTER_BUSINESS_CALLBACK):
212 return RegisterBusinessCallbackInner(data, reply);
213 case static_cast<uint32_t>(DPInterfaceCode::UNREGISTER_BUSINESS_CALLBACK):
214 return UnRegisterBusinessCallbackInner(data, reply);
215 case static_cast<uint32_t>(DPInterfaceCode::PUT_BUSINESS_EVENT):
216 return PutBusinessEventInner(data, reply);
217 case static_cast<uint32_t>(DPInterfaceCode::GET_BUSINESS_EVENT):
218 return GetBusinessEventInner(data, reply);
219 default:
220 HILOGW("unknown request code, please check, code = %{public}u", code);
221 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
222 }
223 }
224
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)225 int32_t DistributedDeviceProfileStubNew::OnRemoteRequest(uint32_t code, MessageParcel& data,
226 MessageParcel& reply, MessageOption& option)
227 {
228 HILOGI("code = %{public}u, CallingPid = %{public}u", code, IPCSkeleton::GetCallingPid());
229 if (DistributedDeviceProfileServiceNew::GetInstance().IsStopped()) {
230 HILOGE("dp service has stopped");
231 return DP_SERVICE_STOPPED;
232 }
233 bool exitIdleStateResult = DistributedDeviceProfileServiceNew::GetInstance().ExitIdleState();
234 if (!exitIdleStateResult) {
235 HILOGE("CancelIdle failed, ExitIdleState = %{public}d", exitIdleStateResult);
236 return DP_SERVICE_ON_IDLE;
237 }
238 DistributedDeviceProfileServiceNew::GetInstance().AddRunningIpcCount();
239 DelayUnloadTask();
240 if (!IsInterfaceTokenValid(data)) {
241 HILOGE("check interface token failed");
242 DistributedDeviceProfileServiceNew::GetInstance().SubtractRunningIpcCount();
243 return DP_INTERFACE_CHECK_FAILED;
244 }
245 if (aclAndSubscribeFuncs_.find(code) != aclAndSubscribeFuncs_.end()) {
246 int32_t aclRet = NotifyAclEventInner(code, data, reply, option);
247 DistributedDeviceProfileServiceNew::GetInstance().SubtractRunningIpcCount();
248 return aclRet;
249 }
250 if (!IsInited()) {
251 HILOGE("DP not finish init");
252 DistributedDeviceProfileServiceNew::GetInstance().SubtractRunningIpcCount();
253 return DP_LOAD_SERVICE_ERR;
254 }
255 int32_t ret = NotifyEventInner(code, data, reply, option);
256 DistributedDeviceProfileServiceNew::GetInstance().SubtractRunningIpcCount();
257 return ret;
258 }
259
PutAccessControlProfileInner(MessageParcel & data,MessageParcel & reply)260 int32_t DistributedDeviceProfileStubNew::PutAccessControlProfileInner(MessageParcel& data, MessageParcel& reply)
261 {
262 HILOGI("called");
263 AccessControlProfile accessControlProfile;
264 if (!accessControlProfile.UnMarshalling(data)) {
265 HILOGE("read parcel fail!");
266 return DP_READ_PARCEL_FAIL;
267 }
268 int32_t ret = PutAccessControlProfile(accessControlProfile);
269 if (!reply.WriteInt32(ret)) {
270 HILOGE("Write reply failed");
271 return DP_WRITE_PARCEL_FAIL;
272 }
273 return DP_SUCCESS;
274 }
275
UpdateAccessControlProfileInner(MessageParcel & data,MessageParcel & reply)276 int32_t DistributedDeviceProfileStubNew::UpdateAccessControlProfileInner(MessageParcel& data, MessageParcel& reply)
277 {
278 HILOGI("called");
279 AccessControlProfile accessControlProfile;
280 if (!accessControlProfile.UnMarshalling(data)) {
281 HILOGE("read parcel fail!");
282 return DP_READ_PARCEL_FAIL;
283 }
284 int32_t ret = UpdateAccessControlProfile(accessControlProfile);
285 if (!reply.WriteInt32(ret)) {
286 HILOGE("Write reply failed");
287 return ERR_FLATTEN_OBJECT;
288 }
289 return DP_SUCCESS;
290 }
291
GetTrustDeviceProfileInner(MessageParcel & data,MessageParcel & reply)292 int32_t DistributedDeviceProfileStubNew::GetTrustDeviceProfileInner(MessageParcel& data, MessageParcel& reply)
293 {
294 HILOGD("called");
295 std::string deviceId;
296 READ_HELPER(data, String, deviceId);
297 TrustDeviceProfile trustDeviceProfile;
298 int32_t ret = GetTrustDeviceProfile(deviceId, trustDeviceProfile);
299 if (!reply.WriteInt32(ret)) {
300 HILOGE("Write reply failed");
301 return ERR_FLATTEN_OBJECT;
302 }
303 if (!trustDeviceProfile.Marshalling(reply)) {
304 HILOGE("write parcel fail!");
305 return DP_WRITE_PARCEL_FAIL;
306 }
307 return DP_SUCCESS;
308 }
309
GetAllTrustDeviceProfileInner(MessageParcel & data,MessageParcel & reply)310 int32_t DistributedDeviceProfileStubNew::GetAllTrustDeviceProfileInner(MessageParcel& data, MessageParcel& reply)
311 {
312 HILOGI("called");
313 std::vector<TrustDeviceProfile> trustDeviceProfiles;
314 int32_t ret = GetAllTrustDeviceProfile(trustDeviceProfiles);
315 if (!reply.WriteInt32(ret)) {
316 HILOGE("Write reply failed");
317 return ERR_FLATTEN_OBJECT;
318 }
319 if (!IpcUtils::Marshalling(reply, trustDeviceProfiles)) {
320 HILOGE("read parcel fail!");
321 return DP_READ_PARCEL_FAIL;
322 }
323 return DP_SUCCESS;
324 }
325
GetAccessControlProfileInner(MessageParcel & data,MessageParcel & reply)326 int32_t DistributedDeviceProfileStubNew::GetAccessControlProfileInner(MessageParcel& data, MessageParcel& reply)
327 {
328 HILOGI("called");
329 std::map<std::string, std::string> queryParams;
330 if (!IpcUtils::UnMarshalling(data, queryParams)) {
331 HILOGE("read parcel fail!");
332 return DP_READ_PARCEL_FAIL;
333 }
334 std::vector<AccessControlProfile> accessControlProfiles;
335 int32_t ret = GetAccessControlProfile(queryParams, accessControlProfiles);
336 if (!reply.WriteInt32(ret)) {
337 HILOGE("Write reply failed");
338 return ERR_FLATTEN_OBJECT;
339 }
340 if (!IpcUtils::Marshalling(reply, accessControlProfiles)) {
341 HILOGE("write parcel fail!");
342 return DP_WRITE_PARCEL_FAIL;
343 }
344 return DP_SUCCESS;
345 }
346
GetAllAccessControlProfileInner(MessageParcel & data,MessageParcel & reply)347 int32_t DistributedDeviceProfileStubNew::GetAllAccessControlProfileInner(MessageParcel& data, MessageParcel& reply)
348 {
349 HILOGI("called");
350 std::vector<AccessControlProfile> accessControlProfiles;
351 int32_t ret = GetAllAccessControlProfile(accessControlProfiles);
352 if (!reply.WriteInt32(ret)) {
353 HILOGE("Write reply failed");
354 return ERR_FLATTEN_OBJECT;
355 }
356 if (!IpcUtils::Marshalling(reply, accessControlProfiles)) {
357 HILOGE("write parcel fail!");
358 return DP_WRITE_PARCEL_FAIL;
359 }
360 return DP_SUCCESS;
361 }
362
GetAllAclIncludeLnnAclInner(MessageParcel & data,MessageParcel & reply)363 int32_t DistributedDeviceProfileStubNew::GetAllAclIncludeLnnAclInner(MessageParcel& data, MessageParcel& reply)
364 {
365 HILOGI("called");
366 std::vector<AccessControlProfile> accessControlProfiles;
367 int32_t ret = GetAllAclIncludeLnnAcl(accessControlProfiles);
368 if (!reply.WriteInt32(ret)) {
369 HILOGE("Write reply failed");
370 return ERR_FLATTEN_OBJECT;
371 }
372 if (!IpcUtils::Marshalling(reply, accessControlProfiles)) {
373 HILOGE("write parcel fail!");
374 return DP_WRITE_PARCEL_FAIL;
375 }
376 return DP_SUCCESS;
377 }
378
DeleteAccessControlProfileInner(MessageParcel & data,MessageParcel & reply)379 int32_t DistributedDeviceProfileStubNew::DeleteAccessControlProfileInner(MessageParcel& data, MessageParcel& reply)
380 {
381 HILOGI("called");
382 int32_t accessControlId;
383 READ_HELPER(data, Int32, accessControlId);
384 int32_t ret = DeleteAccessControlProfile(accessControlId);
385 if (!reply.WriteInt32(ret)) {
386 HILOGE("Write reply failed");
387 return ERR_FLATTEN_OBJECT;
388 }
389 return DP_SUCCESS;
390 }
391
PutSessionKeyInner(MessageParcel & data,MessageParcel & reply)392 int32_t DistributedDeviceProfileStubNew::PutSessionKeyInner(MessageParcel& data, MessageParcel& reply)
393 {
394 HILOGI("called");
395 uint32_t userId = 0;
396 std::vector<uint8_t> sessionKey;
397 int32_t sessionKeyId = 0;
398 READ_HELPER(data, Uint32, userId);
399 if (!IpcUtils::UnMarshalling(data, sessionKey)) {
400 sessionKey.clear();
401 HILOGE("dp ipc write parcel fail");
402 return DP_WRITE_PARCEL_FAIL;
403 }
404 int32_t ret = PutSessionKey(userId, sessionKey, sessionKeyId);
405 if (!reply.WriteInt32(ret)) {
406 sessionKey.clear();
407 HILOGE("Write reply failed");
408 return DP_WRITE_PARCEL_FAIL;
409 }
410 WRITE_HELPER(reply, Int32, sessionKeyId);
411 sessionKey.clear();
412 return DP_SUCCESS;
413 }
414
GetSessionKeyInner(MessageParcel & data,MessageParcel & reply)415 int32_t DistributedDeviceProfileStubNew::GetSessionKeyInner(MessageParcel& data, MessageParcel& reply)
416 {
417 HILOGI("called");
418 uint32_t userId = 0;
419 int32_t sessionKeyId = 0;
420 std::vector<uint8_t> sessionKey;
421 READ_HELPER(data, Uint32, userId);
422 READ_HELPER(data, Int32, sessionKeyId);
423 int32_t ret = GetSessionKey(userId, sessionKeyId, sessionKey);
424 if (!reply.WriteInt32(ret)) {
425 sessionKey.clear();
426 HILOGE("Write reply failed");
427 return DP_WRITE_PARCEL_FAIL;
428 }
429 if (!IpcUtils::Marshalling(reply, sessionKey)) {
430 sessionKey.clear();
431 HILOGE("dp ipc write parcel fail");
432 return DP_WRITE_PARCEL_FAIL;
433 }
434 sessionKey.clear();
435 return DP_SUCCESS;
436 }
437
UpdateSessionKeyInner(MessageParcel & data,MessageParcel & reply)438 int32_t DistributedDeviceProfileStubNew::UpdateSessionKeyInner(MessageParcel& data, MessageParcel& reply)
439 {
440 HILOGI("called");
441 uint32_t userId = 0;
442 std::vector<uint8_t> sessionKey;
443 int32_t sessionKeyId = 0;
444 READ_HELPER(data, Uint32, userId);
445 READ_HELPER(data, Int32, sessionKeyId);
446 if (!IpcUtils::UnMarshalling(data, sessionKey)) {
447 sessionKey.clear();
448 HILOGE("dp ipc write parcel fail");
449 return DP_WRITE_PARCEL_FAIL;
450 }
451 int32_t ret = UpdateSessionKey(userId, sessionKeyId, sessionKey);
452 if (!reply.WriteInt32(ret)) {
453 sessionKey.clear();
454 HILOGE("Write reply failed");
455 return DP_WRITE_PARCEL_FAIL;
456 }
457 sessionKey.clear();
458 return DP_SUCCESS;
459 }
460
DeleteSessionKeyInner(MessageParcel & data,MessageParcel & reply)461 int32_t DistributedDeviceProfileStubNew::DeleteSessionKeyInner(MessageParcel& data, MessageParcel& reply)
462 {
463 HILOGI("called");
464 uint32_t userId = 0;
465 int32_t sessionKeyId = 0;
466 READ_HELPER(data, Uint32, userId);
467 READ_HELPER(data, Int32, sessionKeyId);
468 int32_t ret = DeleteSessionKey(userId, sessionKeyId);
469 if (!reply.WriteInt32(ret)) {
470 HILOGE("Write reply failed");
471 return DP_WRITE_PARCEL_FAIL;
472 }
473 return DP_SUCCESS;
474 }
475
PutServiceProfileInner(MessageParcel & data,MessageParcel & reply)476 int32_t DistributedDeviceProfileStubNew::PutServiceProfileInner(MessageParcel& data, MessageParcel& reply)
477 {
478 HILOGI("called");
479 ServiceProfile serviceProfile;
480 if (!serviceProfile.UnMarshalling(data)) {
481 HILOGE("read parcel fail!");
482 return DP_READ_PARCEL_FAIL;
483 }
484 int32_t ret = PutServiceProfile(serviceProfile);
485 if (!reply.WriteInt32(ret)) {
486 HILOGE("Write reply failed");
487 return ERR_FLATTEN_OBJECT;
488 }
489 return DP_SUCCESS;
490 }
491
PutServiceProfileBatchInner(MessageParcel & data,MessageParcel & reply)492 int32_t DistributedDeviceProfileStubNew::PutServiceProfileBatchInner(MessageParcel& data, MessageParcel& reply)
493 {
494 std::vector<ServiceProfile> serviceProfiles;
495 if (!IpcUtils::UnMarshalling(data, serviceProfiles)) {
496 HILOGE("read parcel fail!");
497 return DP_READ_PARCEL_FAIL;
498 }
499 int32_t ret = PutServiceProfileBatch(serviceProfiles);
500 if (!reply.WriteInt32(ret)) {
501 HILOGE("Write reply failed");
502 return ERR_FLATTEN_OBJECT;
503 }
504 return DP_SUCCESS;
505 }
506
PutCharacteristicProfileInner(MessageParcel & data,MessageParcel & reply)507 int32_t DistributedDeviceProfileStubNew::PutCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply)
508 {
509 CharacteristicProfile charProfile;
510 if (!charProfile.UnMarshalling(data)) {
511 HILOGE("read parcel fail!");
512 return DP_READ_PARCEL_FAIL;
513 }
514 int32_t ret = PutCharacteristicProfile(charProfile);
515 if (!reply.WriteInt32(ret)) {
516 HILOGE("Write reply failed");
517 return ERR_FLATTEN_OBJECT;
518 }
519 return DP_SUCCESS;
520 }
521
PutCharacteristicProfileBatchInner(MessageParcel & data,MessageParcel & reply)522 int32_t DistributedDeviceProfileStubNew::PutCharacteristicProfileBatchInner(MessageParcel& data, MessageParcel& reply)
523 {
524 std::vector<CharacteristicProfile> charProfiles;
525 if (!IpcUtils::UnMarshalling(data, charProfiles)) {
526 HILOGE("read parcel fail!");
527 return DP_READ_PARCEL_FAIL;
528 }
529 int32_t ret = PutCharacteristicProfileBatch(charProfiles);
530 if (!reply.WriteInt32(ret)) {
531 HILOGE("Write reply failed");
532 return ERR_FLATTEN_OBJECT;
533 }
534 return DP_SUCCESS;
535 }
536
GetDeviceProfileInner(MessageParcel & data,MessageParcel & reply)537 int32_t DistributedDeviceProfileStubNew::GetDeviceProfileInner(MessageParcel& data, MessageParcel& reply)
538 {
539 std::string deviceId;
540 bool isMultiUser = false;
541 int32_t userId = DEFAULT_USER_ID;
542 DeviceProfile deviceProfile;
543 READ_HELPER(data, String, deviceId);
544 READ_HELPER(data, Bool, isMultiUser);
545 READ_HELPER(data, Int32, userId);
546 deviceProfile.SetIsMultiUser(isMultiUser);
547 deviceProfile.SetUserId(userId);
548 int32_t ret = GetDeviceProfile(deviceId, deviceProfile);
549 if (!reply.WriteInt32(ret)) {
550 HILOGE("Write reply failed");
551 return ERR_FLATTEN_OBJECT;
552 }
553 if (!deviceProfile.Marshalling(reply)) {
554 HILOGE("write parcel fail!");
555 return DP_WRITE_PARCEL_FAIL;
556 }
557 return DP_SUCCESS;
558 }
559
GetServiceProfileInner(MessageParcel & data,MessageParcel & reply)560 int32_t DistributedDeviceProfileStubNew::GetServiceProfileInner(MessageParcel& data, MessageParcel& reply)
561 {
562 std::string deviceId;
563 std::string serviceName;
564 bool isMultiUser = false;
565 int32_t userId = DEFAULT_USER_ID;
566 ServiceProfile serviceProfile;
567 READ_HELPER(data, String, deviceId);
568 READ_HELPER(data, String, serviceName);
569 READ_HELPER(data, Bool, isMultiUser);
570 READ_HELPER(data, Int32, userId);
571 serviceProfile.SetIsMultiUser(isMultiUser);
572 serviceProfile.SetUserId(userId);
573 int32_t ret = GetServiceProfile(deviceId, serviceName, serviceProfile);
574 if (!reply.WriteInt32(ret)) {
575 HILOGE("Write reply failed");
576 return ERR_FLATTEN_OBJECT;
577 }
578 if (!serviceProfile.Marshalling(reply)) {
579 HILOGE("write parcel fail!");
580 return DP_WRITE_PARCEL_FAIL;
581 }
582 return DP_SUCCESS;
583 }
584
GetCharacteristicProfileInner(MessageParcel & data,MessageParcel & reply)585 int32_t DistributedDeviceProfileStubNew::GetCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply)
586 {
587 std::string deviceId;
588 std::string serviceName;
589 std::string characteristicKey;
590 bool isMultiUser = false;
591 int32_t userId = DEFAULT_USER_ID;
592 READ_HELPER(data, String, deviceId);
593 READ_HELPER(data, String, serviceName);
594 READ_HELPER(data, String, characteristicKey);
595 READ_HELPER(data, Bool, isMultiUser);
596 READ_HELPER(data, Int32, userId);
597 CharacteristicProfile charProfile;
598 charProfile.SetIsMultiUser(isMultiUser);
599 charProfile.SetUserId(userId);
600 int32_t ret = GetCharacteristicProfile(deviceId, serviceName, characteristicKey, charProfile);
601 if (!reply.WriteInt32(ret)) {
602 HILOGE("Write reply failed");
603 return ERR_FLATTEN_OBJECT;
604 }
605 if (!charProfile.Marshalling(reply)) {
606 HILOGE("write parcel fail!");
607 return DP_WRITE_PARCEL_FAIL;
608 }
609 return DP_SUCCESS;
610 }
611
DeleteServiceProfileInner(MessageParcel & data,MessageParcel & reply)612 int32_t DistributedDeviceProfileStubNew::DeleteServiceProfileInner(MessageParcel& data, MessageParcel& reply)
613 {
614 std::string deviceId;
615 std::string serviceName;
616 bool isMultiUser = false;
617 int32_t userId = DEFAULT_USER_ID;
618 READ_HELPER(data, String, deviceId);
619 READ_HELPER(data, String, serviceName);
620 READ_HELPER(data, Bool, isMultiUser);
621 READ_HELPER(data, Int32, userId);
622 int32_t ret = DeleteServiceProfile(deviceId, serviceName, isMultiUser, userId);
623 if (!reply.WriteInt32(ret)) {
624 HILOGE("Write reply failed");
625 return ERR_FLATTEN_OBJECT;
626 }
627 return DP_SUCCESS;
628 }
629
DeleteCharacteristicProfileInner(MessageParcel & data,MessageParcel & reply)630 int32_t DistributedDeviceProfileStubNew::DeleteCharacteristicProfileInner(MessageParcel& data, MessageParcel& reply)
631 {
632 std::string deviceId;
633 std::string serviceName;
634 std::string characteristicKey;
635 bool isMultiUser = false;
636 int32_t userId = DEFAULT_USER_ID;
637 READ_HELPER(data, String, deviceId);
638 READ_HELPER(data, String, serviceName);
639 READ_HELPER(data, String, characteristicKey);
640 READ_HELPER(data, Bool, isMultiUser);
641 READ_HELPER(data, Int32, userId);
642 int32_t ret = DeleteCharacteristicProfile(deviceId, serviceName, characteristicKey, isMultiUser, userId);
643 if (!reply.WriteInt32(ret)) {
644 HILOGE("Write reply failed");
645 return ERR_FLATTEN_OBJECT;
646 }
647 return DP_SUCCESS;
648 }
649
SubscribeDeviceProfileInner(MessageParcel & data,MessageParcel & reply)650 int32_t DistributedDeviceProfileStubNew::SubscribeDeviceProfileInner(MessageParcel& data, MessageParcel& reply)
651 {
652 SubscribeInfo subscribeInfo;
653 if (!subscribeInfo.UnMarshalling(data)) {
654 HILOGE("read parcel fail!");
655 return DP_READ_PARCEL_FAIL;
656 }
657 int32_t ret = SubscribeDeviceProfile(subscribeInfo);
658 if (!reply.WriteInt32(ret)) {
659 HILOGE("Write reply failed");
660 return ERR_FLATTEN_OBJECT;
661 }
662 return DP_SUCCESS;
663 }
664
UnSubscribeDeviceProfileInner(MessageParcel & data,MessageParcel & reply)665 int32_t DistributedDeviceProfileStubNew::UnSubscribeDeviceProfileInner(MessageParcel& data, MessageParcel& reply)
666 {
667 SubscribeInfo subscribeInfo;
668 if (!subscribeInfo.UnMarshalling(data)) {
669 HILOGE("read parcel fail!");
670 return DP_READ_PARCEL_FAIL;
671 }
672 int32_t ret = UnSubscribeDeviceProfile(subscribeInfo);
673 if (!reply.WriteInt32(ret)) {
674 HILOGE("Write reply failed");
675 return ERR_FLATTEN_OBJECT;
676 }
677 return DP_SUCCESS;
678 }
679
SyncDeviceProfileInner(MessageParcel & data,MessageParcel & reply)680 int32_t DistributedDeviceProfileStubNew::SyncDeviceProfileInner(MessageParcel& data, MessageParcel& reply)
681 {
682 DistributedDeviceProfile::DpSyncOptions syncOptions;
683 if (!syncOptions.UnMarshalling(data)) {
684 HILOGE("read parcel fail!");
685 return DP_READ_PARCEL_FAIL;
686 }
687 sptr<IRemoteObject> syncCompletedCallback = data.ReadRemoteObject();
688 int32_t ret = SyncDeviceProfile(syncOptions, syncCompletedCallback);
689 if (!reply.WriteInt32(ret)) {
690 HILOGE("Write reply failed");
691 return ERR_FLATTEN_OBJECT;
692 }
693 return DP_SUCCESS;
694 }
695
SendSubscribeInfosInner(MessageParcel & data,MessageParcel & reply)696 int32_t DistributedDeviceProfileStubNew::SendSubscribeInfosInner(MessageParcel& data, MessageParcel& reply)
697 {
698 std::map<std::string, SubscribeInfo> listenerMap;
699 if (!IpcUtils::UnMarshalling(data, listenerMap)) {
700 HILOGE("read parcel fail!");
701 return DP_READ_PARCEL_FAIL;
702 }
703 int32_t ret = SendSubscribeInfos(listenerMap);
704 if (!reply.WriteInt32(ret)) {
705 HILOGE("Write reply failed");
706 return ERR_FLATTEN_OBJECT;
707 }
708 return DP_SUCCESS;
709 }
710
SubscribeDeviceProfileInitedInner(MessageParcel & data,MessageParcel & reply)711 int32_t DistributedDeviceProfileStubNew::SubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply)
712 {
713 int32_t saId = -1;
714 READ_HELPER(data, Int32, saId);
715 sptr<IRemoteObject> dpInitedCallback = data.ReadRemoteObject();
716 if (dpInitedCallback == nullptr) {
717 HILOGE("read remoteObject failed!");
718 return ERR_FLATTEN_OBJECT;
719 }
720 int32_t ret = SubscribeDeviceProfileInited(saId, dpInitedCallback);
721 if (!reply.WriteInt32(ret)) {
722 HILOGE("Write reply failed");
723 return ERR_FLATTEN_OBJECT;
724 }
725 return DP_SUCCESS;
726 }
727
UnSubscribeDeviceProfileInitedInner(MessageParcel & data,MessageParcel & reply)728 int32_t DistributedDeviceProfileStubNew::UnSubscribeDeviceProfileInitedInner(MessageParcel& data, MessageParcel& reply)
729 {
730 int32_t saId = -1;
731 READ_HELPER(data, Int32, saId);
732 int32_t ret = UnSubscribeDeviceProfileInited(saId);
733 if (!reply.WriteInt32(ret)) {
734 HILOGE("Write reply failed");
735 return ERR_FLATTEN_OBJECT;
736 }
737 return DP_SUCCESS;
738 }
739
PutAllTrustedDevicesInner(MessageParcel & data,MessageParcel & reply)740 int32_t DistributedDeviceProfileStubNew::PutAllTrustedDevicesInner(MessageParcel& data, MessageParcel& reply)
741 {
742 std::vector<TrustedDeviceInfo> deviceInfos;
743 if (!IpcUtils::UnMarshalling(data, deviceInfos)) {
744 HILOGE("read parcel fail!");
745 return DP_READ_PARCEL_FAIL;
746 }
747 int32_t ret = PutAllTrustedDevices(deviceInfos);
748 if (!reply.WriteInt32(ret)) {
749 HILOGE("Write reply failed");
750 return ERR_FLATTEN_OBJECT;
751 }
752 return DP_SUCCESS;
753 }
754
PutLocalServiceInfoInner(MessageParcel & data,MessageParcel & reply)755 int32_t DistributedDeviceProfileStubNew::PutLocalServiceInfoInner(MessageParcel& data, MessageParcel& reply)
756 {
757 HILOGI("called");
758 LocalServiceInfo localServiceInfo;
759 if (!localServiceInfo.UnMarshalling(data)) {
760 HILOGE("read parcel fail!");
761 return DP_READ_PARCEL_FAIL;
762 }
763 int32_t ret = PutLocalServiceInfo(localServiceInfo);
764 if (!reply.WriteInt32(ret)) {
765 HILOGE("Write reply failed");
766 return DP_WRITE_PARCEL_FAIL;
767 }
768 return DP_SUCCESS;
769 }
770
UpdateLocalServiceInfoInner(MessageParcel & data,MessageParcel & reply)771 int32_t DistributedDeviceProfileStubNew::UpdateLocalServiceInfoInner(MessageParcel& data, MessageParcel& reply)
772 {
773 HILOGI("called");
774 LocalServiceInfo localServiceInfo;
775 if (!localServiceInfo.UnMarshalling(data)) {
776 HILOGE("read parcel fail!");
777 return DP_READ_PARCEL_FAIL;
778 }
779 int32_t ret = UpdateLocalServiceInfo(localServiceInfo);
780 if (!reply.WriteInt32(ret)) {
781 HILOGE("Write reply failed");
782 return DP_WRITE_PARCEL_FAIL;
783 }
784 return DP_SUCCESS;
785 }
786
GetLocalServiceInfoByBundleAndPinTypeInner(MessageParcel & data,MessageParcel & reply)787 int32_t DistributedDeviceProfileStubNew::GetLocalServiceInfoByBundleAndPinTypeInner(MessageParcel& data,
788 MessageParcel& reply)
789 {
790 LocalServiceInfo localServiceInfo;
791 int32_t pinExchangeType = 0;
792 std::string bundleName = "";
793 READ_HELPER(data, String, bundleName);
794 READ_HELPER(data, Int32, pinExchangeType);
795 int32_t ret = GetLocalServiceInfoByBundleAndPinType(bundleName, pinExchangeType, localServiceInfo);
796 if (!reply.WriteInt32(ret)) {
797 HILOGE("Write reply failed");
798 return ERR_FLATTEN_OBJECT;
799 }
800 if (!localServiceInfo.Marshalling(reply)) {
801 HILOGE("write parcel fail!");
802 return DP_WRITE_PARCEL_FAIL;
803 }
804 return DP_SUCCESS;
805 }
806
DeleteLocalServiceInfoInner(MessageParcel & data,MessageParcel & reply)807 int32_t DistributedDeviceProfileStubNew::DeleteLocalServiceInfoInner(MessageParcel& data, MessageParcel& reply)
808 {
809 int32_t pinExchangeType = 0;
810 std::string bundleName = "";
811 READ_HELPER(data, String, bundleName);
812 READ_HELPER(data, Int32, pinExchangeType);
813 int32_t ret = DeleteLocalServiceInfo(bundleName, pinExchangeType);
814 if (!reply.WriteInt32(ret)) {
815 HILOGE("Write reply failed");
816 return DP_WRITE_PARCEL_FAIL;
817 }
818 return DP_SUCCESS;
819 }
820
PutDeviceProfileBatchInner(MessageParcel & data,MessageParcel & reply)821 int32_t DistributedDeviceProfileStubNew::PutDeviceProfileBatchInner(MessageParcel& data, MessageParcel& reply)
822 {
823 std::vector<DeviceProfile> deviceProfiles;
824 if (!IpcUtils::UnMarshalling(data, deviceProfiles)) {
825 HILOGE("read parcel fail!");
826 return DP_READ_PARCEL_FAIL;
827 }
828 int32_t ret = PutDeviceProfileBatch(deviceProfiles);
829 if (!reply.WriteInt32(ret)) {
830 HILOGE("Write reply failed");
831 return ERR_FLATTEN_OBJECT;
832 }
833 return DP_SUCCESS;
834 }
835
GetDeviceProfilesInner(MessageParcel & data,MessageParcel & reply)836 int32_t DistributedDeviceProfileStubNew::GetDeviceProfilesInner(MessageParcel& data, MessageParcel& reply)
837 {
838 DeviceProfileFilterOptions options;
839 std::vector<DeviceProfile> deviceProfiles;
840 if (!options.UnMarshalling(data)) {
841 HILOGE("read parcel fail!");
842 return DP_READ_PARCEL_FAIL;
843 }
844 int32_t ret = GetDeviceProfiles(options, deviceProfiles);
845 if (!reply.WriteInt32(ret)) {
846 HILOGE("Write reply failed");
847 return ERR_FLATTEN_OBJECT;
848 }
849 if (!IpcUtils::Marshalling(reply, deviceProfiles)) {
850 HILOGE("write parcel fail!");
851 return DP_WRITE_PARCEL_FAIL;
852 }
853 return DP_SUCCESS;
854 }
855
SubscribePinCodeInvalidInner(MessageParcel & data,MessageParcel & reply)856 int32_t DistributedDeviceProfileStubNew::SubscribePinCodeInvalidInner(MessageParcel& data, MessageParcel& reply)
857 {
858 std::string bundleName = "";
859 int32_t pinExchangeType = DEFAULT_PIN_EXCHANGE_TYPE;
860 READ_HELPER(data, String, bundleName);
861 READ_HELPER(data, Int32, pinExchangeType);
862 sptr<IRemoteObject> pincodeInvalidCallback = data.ReadRemoteObject();
863 if (pincodeInvalidCallback == nullptr) {
864 HILOGE("read remoteObject failed!");
865 return ERR_FLATTEN_OBJECT;
866 }
867 int32_t ret = SubscribePinCodeInvalid(bundleName,
868 pinExchangeType, pincodeInvalidCallback);
869 if (!reply.WriteInt32(ret)) {
870 HILOGE("Write reply failed");
871 return ERR_FLATTEN_OBJECT;
872 }
873 return DP_SUCCESS;
874 }
875
UnSubscribePinCodeInvalidInner(MessageParcel & data,MessageParcel & reply)876 int32_t DistributedDeviceProfileStubNew::UnSubscribePinCodeInvalidInner(MessageParcel& data, MessageParcel& reply)
877 {
878 std::string bundleName = "";
879 int32_t pinExchangeType = DEFAULT_PIN_EXCHANGE_TYPE;
880 READ_HELPER(data, String, bundleName);
881 READ_HELPER(data, Int32, pinExchangeType);
882 int32_t ret = UnSubscribePinCodeInvalid(bundleName,
883 pinExchangeType);
884 if (!reply.WriteInt32(ret)) {
885 HILOGE("Write reply failed");
886 return ERR_FLATTEN_OBJECT;
887 }
888 return DP_SUCCESS;
889 }
890
PutProductInfoBatchInner(MessageParcel & data,MessageParcel & reply)891 int32_t DistributedDeviceProfileStubNew::PutProductInfoBatchInner(MessageParcel& data, MessageParcel& reply)
892 {
893 std::vector<ProductInfo> productInfos;
894 if (!IpcUtils::UnMarshalling(data, productInfos)) {
895 HILOGE("read parcel fail!");
896 return DP_READ_PARCEL_FAIL;
897 }
898 int32_t ret = PutProductInfoBatch(productInfos);
899 if (!reply.WriteInt32(ret)) {
900 HILOGE("Write reply failed");
901 return ERR_FLATTEN_OBJECT;
902 }
903 return DP_SUCCESS;
904 }
905
PutDeviceIconInfoBatchInner(MessageParcel & data,MessageParcel & reply)906 int32_t DistributedDeviceProfileStubNew::PutDeviceIconInfoBatchInner(MessageParcel& data, MessageParcel& reply)
907 {
908 std::vector<DeviceIconInfo> deviceIconInfos;
909 if (!IpcUtils::UnMarshalling(data, deviceIconInfos)) {
910 HILOGE("read parcel fail!");
911 return DP_READ_PARCEL_FAIL;
912 }
913 int32_t ret = PutDeviceIconInfoBatch(deviceIconInfos);
914 if (!reply.WriteInt32(ret)) {
915 HILOGE("Write reply failed");
916 return ERR_FLATTEN_OBJECT;
917 }
918 return DP_SUCCESS;
919 }
920
GetDeviceIconInfosInner(MessageParcel & data,MessageParcel & reply)921 int32_t DistributedDeviceProfileStubNew::GetDeviceIconInfosInner(MessageParcel& data, MessageParcel& reply)
922 {
923 DeviceIconInfoFilterOptions filterOptions;
924 std::vector<DeviceIconInfo> deviceIconInfos;
925 if (!filterOptions.UnMarshalling(data)) {
926 HILOGE("read parcel fail!");
927 return DP_READ_PARCEL_FAIL;
928 }
929 int32_t ret = GetDeviceIconInfos(filterOptions,
930 deviceIconInfos);
931 if (!reply.WriteInt32(ret)) {
932 HILOGE("Write reply failed");
933 return ERR_FLATTEN_OBJECT;
934 }
935 if (!IpcUtils::Marshalling(reply, deviceIconInfos)) {
936 HILOGE("Write parcel fail!");
937 return DP_READ_PARCEL_FAIL;
938 }
939 return DP_SUCCESS;
940 }
941
PutServiceInfoProfileInner(MessageParcel & data,MessageParcel & reply)942 int32_t DistributedDeviceProfileStubNew::PutServiceInfoProfileInner(MessageParcel& data, MessageParcel& reply)
943 {
944 HILOGI("called");
945 ServiceInfoProfile serviceInfoProfile;
946 if (!serviceInfoProfile.UnMarshalling(data)) {
947 HILOGE("read parcel fail!");
948 return DP_READ_PARCEL_FAIL;
949 }
950 int32_t ret = PutServiceInfoProfile(serviceInfoProfile);
951 if (!reply.WriteInt32(ret)) {
952 HILOGE("Write reply failed");
953 return DP_WRITE_PARCEL_FAIL;
954 }
955 return DP_SUCCESS;
956 }
957
DeleteServiceInfoProfileInner(MessageParcel & data,MessageParcel & reply)958 int32_t DistributedDeviceProfileStubNew::DeleteServiceInfoProfileInner(MessageParcel& data, MessageParcel& reply)
959 {
960 HILOGI("called");
961 ServiceInfoUniqueKey key;
962 if (!key.UnMarshalling(data)) {
963 HILOGE("read parcel fail!");
964 return DP_READ_PARCEL_FAIL;
965 }
966 int32_t ret = DeleteServiceInfoProfile(key);
967 if (!reply.WriteInt32(ret)) {
968 HILOGE("Write reply failed");
969 return DP_WRITE_PARCEL_FAIL;
970 }
971 return DP_SUCCESS;
972 }
973
UpdateServiceInfoProfileInner(MessageParcel & data,MessageParcel & reply)974 int32_t DistributedDeviceProfileStubNew::UpdateServiceInfoProfileInner(MessageParcel& data, MessageParcel& reply)
975 {
976 HILOGI("called");
977 ServiceInfoProfile serviceInfoProfile;
978 if (!serviceInfoProfile.UnMarshalling(data)) {
979 HILOGE("read parcel fail!");
980 return DP_READ_PARCEL_FAIL;
981 }
982 int32_t ret = UpdateServiceInfoProfile(serviceInfoProfile);
983 if (!reply.WriteInt32(ret)) {
984 HILOGE("Write reply failed");
985 return DP_WRITE_PARCEL_FAIL;
986 }
987 return DP_SUCCESS;
988 }
989
GetServiceInfoProfileByUniqueKeyInner(MessageParcel & data,MessageParcel & reply)990 int32_t DistributedDeviceProfileStubNew::GetServiceInfoProfileByUniqueKeyInner(MessageParcel& data,
991 MessageParcel& reply)
992 {
993 ServiceInfoUniqueKey key;
994 ServiceInfoProfile serviceInfoProfile;
995 if (!key.UnMarshalling(data)) {
996 HILOGE("read parcel fail!");
997 return DP_READ_PARCEL_FAIL;
998 }
999 int32_t ret = GetServiceInfoProfileByUniqueKey(key,
1000 serviceInfoProfile);
1001 if (!reply.WriteInt32(ret)) {
1002 HILOGE("Write reply failed");
1003 return ERR_FLATTEN_OBJECT;
1004 }
1005 if (!serviceInfoProfile.Marshalling(reply)) {
1006 HILOGE("write parcel fail!");
1007 return DP_READ_PARCEL_FAIL;
1008 }
1009 return DP_SUCCESS;
1010 }
1011
GetServiceInfoProfileListByTokenIdInner(MessageParcel & data,MessageParcel & reply)1012 int32_t DistributedDeviceProfileStubNew::GetServiceInfoProfileListByTokenIdInner(MessageParcel& data,
1013 MessageParcel& reply)
1014 {
1015 ServiceInfoUniqueKey key;
1016 std::vector<ServiceInfoProfile> serviceInfoProfiles;
1017 if (!key.UnMarshalling(data)) {
1018 HILOGE("read parcel fail!");
1019 return DP_READ_PARCEL_FAIL;
1020 }
1021 int32_t ret = GetServiceInfoProfileListByTokenId(key,
1022 serviceInfoProfiles);
1023 if (!reply.WriteInt32(ret)) {
1024 HILOGE("Write reply failed");
1025 return ERR_FLATTEN_OBJECT;
1026 }
1027
1028 if (!IpcUtils::Marshalling(reply, serviceInfoProfiles)) {
1029 HILOGE("Write parcel fail!");
1030 return DP_READ_PARCEL_FAIL;
1031 }
1032 return DP_SUCCESS;
1033 }
1034
GetAllServiceInfoProfileListInner(MessageParcel & data,MessageParcel & reply)1035 int32_t DistributedDeviceProfileStubNew::GetAllServiceInfoProfileListInner(MessageParcel& data,
1036 MessageParcel& reply)
1037 {
1038 std::vector<ServiceInfoProfile> serviceInfoProfiles;
1039 int32_t ret = GetAllServiceInfoProfileList(serviceInfoProfiles);
1040 if (!reply.WriteInt32(ret)) {
1041 HILOGE("Write reply failed");
1042 return ERR_FLATTEN_OBJECT;
1043 }
1044
1045 if (!IpcUtils::Marshalling(reply, serviceInfoProfiles)) {
1046 HILOGE("Write parcel fail!");
1047 return DP_READ_PARCEL_FAIL;
1048 }
1049 return DP_SUCCESS;
1050 }
1051
GetServiceInfoProfileListByBundleNameInner(MessageParcel & data,MessageParcel & reply)1052 int32_t DistributedDeviceProfileStubNew::GetServiceInfoProfileListByBundleNameInner(MessageParcel& data,
1053 MessageParcel& reply)
1054 {
1055 ServiceInfoUniqueKey key;
1056 std::vector<ServiceInfoProfile> serviceInfoProfiles;
1057 if (!key.UnMarshalling(data)) {
1058 HILOGE("read parcel fail!");
1059 return DP_READ_PARCEL_FAIL;
1060 }
1061 int32_t ret = GetServiceInfoProfileListByBundleName(key,
1062 serviceInfoProfiles);
1063 if (!reply.WriteInt32(ret)) {
1064 HILOGE("Write reply failed");
1065 return ERR_FLATTEN_OBJECT;
1066 }
1067
1068 if (!IpcUtils::Marshalling(reply, serviceInfoProfiles)) {
1069 HILOGE("Write parcel fail!");
1070 return DP_READ_PARCEL_FAIL;
1071 }
1072 return DP_SUCCESS;
1073 }
1074
DeleteDeviceProfileBatchInner(MessageParcel & data,MessageParcel & reply)1075 int32_t DistributedDeviceProfileStubNew::DeleteDeviceProfileBatchInner(MessageParcel& data, MessageParcel& reply)
1076 {
1077 std::vector<DeviceProfile> deviceProfiles;
1078 if (!IpcUtils::UnMarshalling(data, deviceProfiles)) {
1079 HILOGE("Write parcel fail!");
1080 return DP_READ_PARCEL_FAIL;
1081 }
1082 int32_t ret = DeleteDeviceProfileBatch(deviceProfiles);
1083 if (!reply.WriteInt32(ret)) {
1084 HILOGE("Write reply failed");
1085 return ERR_FLATTEN_OBJECT;
1086 }
1087 return DP_SUCCESS;
1088 }
1089
RegisterBusinessCallbackInner(MessageParcel & data,MessageParcel & reply)1090 int32_t DistributedDeviceProfileStubNew::RegisterBusinessCallbackInner(MessageParcel& data, MessageParcel& reply)
1091 {
1092 std::string saId = "";
1093 std::string businessKey = "";
1094 READ_HELPER(data, String, saId);
1095 READ_HELPER(data, String, businessKey);
1096 sptr<IRemoteObject> businessCallback = data.ReadRemoteObject();
1097 if (businessCallback == nullptr) {
1098 HILOGE("read remoteObject failed!");
1099 return ERR_FLATTEN_OBJECT;
1100 }
1101 int32_t ret = RegisterBusinessCallback(saId, businessKey, businessCallback);
1102 if (!reply.WriteInt32(ret)) {
1103 HILOGE("Write reply failed");
1104 return ERR_FLATTEN_OBJECT;
1105 }
1106 return DP_SUCCESS;
1107 }
1108
UnRegisterBusinessCallbackInner(MessageParcel & data,MessageParcel & reply)1109 int32_t DistributedDeviceProfileStubNew::UnRegisterBusinessCallbackInner(MessageParcel& data, MessageParcel& reply)
1110 {
1111 std::string saId = "";
1112 std::string businessKey = "";
1113 READ_HELPER(data, String, saId);
1114 READ_HELPER(data, String, businessKey);
1115 int32_t ret = UnRegisterBusinessCallback(saId, businessKey);
1116 if (!reply.WriteInt32(ret)) {
1117 HILOGE("Write reply failed");
1118 return ERR_FLATTEN_OBJECT;
1119 }
1120 return DP_SUCCESS;
1121 }
1122
PutBusinessEventInner(MessageParcel & data,MessageParcel & reply)1123 int32_t DistributedDeviceProfileStubNew::PutBusinessEventInner(MessageParcel& data, MessageParcel& reply)
1124 {
1125 HILOGI("called");
1126 BusinessEvent event;
1127 if (!event.UnMarshalling(data)) {
1128 HILOGE("read parcel fail!");
1129 return DP_READ_PARCEL_FAIL;
1130 }
1131 int32_t ret = PutBusinessEvent(event);
1132 if (!reply.WriteInt32(ret)) {
1133 HILOGE("Write reply failed");
1134 return DP_WRITE_PARCEL_FAIL;
1135 }
1136 return DP_SUCCESS;
1137 }
1138
GetBusinessEventInner(MessageParcel & data,MessageParcel & reply)1139 int32_t DistributedDeviceProfileStubNew::GetBusinessEventInner(MessageParcel& data, MessageParcel& reply)
1140 {
1141 HILOGI("called");
1142 BusinessEvent event;
1143 if (!event.UnMarshalling(data)) {
1144 HILOGE("read parcel fail!");
1145 return DP_READ_PARCEL_FAIL;
1146 }
1147 int32_t ret = GetBusinessEvent(event);
1148 if (!reply.WriteInt32(ret)) {
1149 HILOGE("Write reply failed");
1150 return DP_WRITE_PARCEL_FAIL;
1151 }
1152 if (!event.Marshalling(reply)) {
1153 HILOGE("write parcel fail!");
1154 return DP_WRITE_PARCEL_FAIL;
1155 }
1156 return DP_SUCCESS;
1157 }
1158 } // namespace DeviceProfile
1159 } // namespace OHOS
1160