• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 "ipc/storage_manager_proxy.h"
17 #include "storage_service_errno.h"
18 #include "storage_service_log.h"
19 
20 namespace OHOS {
21 namespace StorageManager {
PrepareAddUser(int32_t userId,uint32_t flags)22 int32_t StorageManagerProxy::PrepareAddUser(int32_t userId, uint32_t flags)
23 {
24     LOGI("StorageManagerProxy::PrepareAddUser, userId:%{public}d", userId);
25     MessageParcel data, reply;
26     MessageOption option(MessageOption::TF_SYNC);
27     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
28         LOGE("StorageManagerProxy::PrepareAddUser, WriteInterfaceToken failed");
29         return E_IPC_ERROR;
30     }
31     if (!data.WriteInt32(userId)) {
32         LOGE("StorageManagerProxy::PrepareAddUser, WriteInt32 failed");
33         return E_IPC_ERROR;
34     }
35     if (!data.WriteUint32(flags)) {
36         LOGE("StorageManagerProxy::PrepareAddUser, WriteUint32 failed");
37         return E_IPC_ERROR;
38     }
39     int err = Remote()->SendRequest(PREPARE_ADD_USER, data, reply, option);
40     if (err != E_OK) {
41         LOGE("StorageManagerProxy::PrepareAddUser, SendRequest failed");
42         return E_IPC_ERROR;
43     }
44     return reply.ReadUint32();
45 }
46 
RemoveUser(int32_t userId,uint32_t flags)47 int32_t StorageManagerProxy::RemoveUser(int32_t userId, uint32_t flags)
48 {
49     LOGI("StorageManagerProxy::RemoveUser, userId:%{public}d", userId);
50     MessageParcel data, reply;
51     MessageOption option(MessageOption::TF_SYNC);
52     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
53         LOGE("StorageManagerProxy::RemoveUser, WriteInterfaceToken failed");
54         return E_IPC_ERROR;
55     }
56     if (!data.WriteInt32(userId)) {
57         LOGE("StorageManagerProxy::RemoveUser, WriteInt32 failed");
58         return E_IPC_ERROR;
59     }
60     if (!data.WriteUint32(flags)) {
61         LOGE("StorageManagerProxy::RemoveUser, WriteUint32 failed");
62         return E_IPC_ERROR;
63     }
64     int err = Remote()->SendRequest(REMOVE_USER, data, reply, option);
65     if (err != E_OK) {
66         LOGE("StorageManagerProxy::RemoveUser, SendRequest failed");
67         return E_IPC_ERROR;
68     }
69     return reply.ReadUint32();
70 }
71 
PrepareStartUser(int32_t userId)72 int32_t StorageManagerProxy::PrepareStartUser(int32_t userId)
73 {
74     LOGI("StorageManagerProxy::PrepareStartUser, userId:%{public}d", userId);
75     MessageParcel data, reply;
76     MessageOption option(MessageOption::TF_SYNC);
77     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
78         LOGE("StorageManagerProxy::PrepareStartUser, WriteInterfaceToken failed");
79         return E_IPC_ERROR;
80     }
81     if (!data.WriteInt32(userId)) {
82         LOGE("StorageManagerProxy::PrepareStartUser, WriteInt32 failed");
83         return E_IPC_ERROR;
84     }
85     int err = Remote()->SendRequest(PREPARE_START_USER, data, reply, option);
86     if (err != E_OK) {
87         LOGE("StorageManagerProxy::PrepareStartUser, SendRequest failed");
88         return E_IPC_ERROR;
89     }
90     return reply.ReadUint32();
91 }
92 
StopUser(int32_t userId)93 int32_t StorageManagerProxy::StopUser(int32_t userId)
94 {
95     LOGI("StorageManagerProxy::StopUser, userId:%{public}d", userId);
96     MessageParcel data, reply;
97     MessageOption option(MessageOption::TF_SYNC);
98     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
99         LOGE("StorageManagerProxy::StopUser, WriteInterfaceToken failed");
100         return E_IPC_ERROR;
101     }
102     if (!data.WriteInt32(userId)) {
103         LOGE("StorageManagerProxy::StopUser, WriteInt32 failed");
104         return E_IPC_ERROR;
105     }
106     int err = Remote()->SendRequest(STOP_USER, data, reply, option);
107     if (err != E_OK) {
108         LOGE("StorageManagerProxy::StopUser, SendRequest failed");
109         return E_IPC_ERROR;
110     }
111     return reply.ReadUint32();
112 }
113 
GenerateUserKeys(uint32_t userId,uint32_t flags)114 int32_t StorageManagerProxy::GenerateUserKeys(uint32_t userId, uint32_t flags)
115 {
116     LOGI("user ID: %{public}u, flags: %{public}u", userId, flags);
117     MessageParcel data, reply;
118     MessageOption option(MessageOption::TF_SYNC);
119     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
120         LOGE("WriteInterfaceToken failed");
121         return E_IPC_ERROR;
122     }
123     if (!data.WriteUint32(userId)) {
124         LOGE("Write user ID failed");
125         return E_IPC_ERROR;
126     }
127     if (!data.WriteUint32(flags)) {
128         LOGE("Write key flags failed");
129         return E_IPC_ERROR;
130     }
131     int err = Remote()->SendRequest(CREATE_USER_KEYS, data, reply, option);
132     if (err != E_OK) {
133         LOGE("SendRequest failed");
134         return E_IPC_ERROR;
135     }
136 
137     return reply.ReadInt32();
138 }
139 
DeleteUserKeys(uint32_t userId)140 int32_t StorageManagerProxy::DeleteUserKeys(uint32_t userId)
141 {
142     LOGI("user ID: %{public}u", userId);
143     MessageParcel data, reply;
144     MessageOption option(MessageOption::TF_SYNC);
145     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
146         LOGE("WriteInterfaceToken failed");
147         return E_IPC_ERROR;
148     }
149     if (!data.WriteUint32(userId)) {
150         LOGE("Write user ID failed");
151         return E_IPC_ERROR;
152     }
153     int err = Remote()->SendRequest(DELETE_USER_KEYS, data, reply, option);
154     if (err != E_OK) {
155         LOGE("SendRequest failed");
156         return E_IPC_ERROR;
157     }
158 
159     return reply.ReadInt32();
160 }
161 
UpdateUserAuth(uint32_t userId,std::string auth,std::string compSecret)162 int32_t StorageManagerProxy::UpdateUserAuth(uint32_t userId, std::string auth, std::string compSecret)
163 {
164     LOGI("user ID: %{public}u", userId);
165     MessageParcel data, reply;
166     MessageOption option(MessageOption::TF_SYNC);
167     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
168         LOGE("WriteInterfaceToken failed");
169         return E_IPC_ERROR;
170     }
171     if (!data.WriteUint32(userId)) {
172         LOGE("Write user ID failed");
173         return E_IPC_ERROR;
174     }
175     if (!data.WriteString(auth)) {
176         LOGE("Write user auth failed");
177         return E_IPC_ERROR;
178     }
179     if (!data.WriteString(compSecret)) {
180         LOGE("Write user secret failed");
181         return E_IPC_ERROR;
182     }
183     int err = Remote()->SendRequest(UPDATE_USER_AUTH, data, reply, option);
184     if (err != E_OK) {
185         LOGE("SendRequest failed");
186         return E_IPC_ERROR;
187     }
188 
189     return reply.ReadInt32();
190 }
191 
ActiveUserKey(uint32_t userId,std::string auth,std::string compSecret)192 int32_t StorageManagerProxy::ActiveUserKey(uint32_t userId, std::string auth, std::string compSecret)
193 {
194     LOGI("user ID: %{public}u", userId);
195     MessageParcel data, reply;
196     MessageOption option(MessageOption::TF_SYNC);
197     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
198         LOGE("WriteInterfaceToken failed");
199         return E_IPC_ERROR;
200     }
201     if (!data.WriteUint32(userId)) {
202         LOGE("Write user ID failed");
203         return E_IPC_ERROR;
204     }
205     if (!data.WriteString(auth)) {
206         LOGE("Write user auth failed");
207         return E_IPC_ERROR;
208     }
209     if (!data.WriteString(compSecret)) {
210         LOGE("Write user secret failed");
211         return E_IPC_ERROR;
212     }
213     int err = Remote()->SendRequest(ACTIVE_USER_KEY, data, reply, option);
214     if (err != E_OK) {
215         LOGE("SendRequest failed");
216         return E_IPC_ERROR;
217     }
218 
219     return reply.ReadInt32();
220 }
221 
InactiveUserKey(uint32_t userId)222 int32_t StorageManagerProxy::InactiveUserKey(uint32_t userId)
223 {
224     LOGI("user ID: %{public}u", userId);
225     MessageParcel data, reply;
226     MessageOption option(MessageOption::TF_SYNC);
227     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
228         LOGE("WriteInterfaceToken failed");
229         return E_IPC_ERROR;
230     }
231     if (!data.WriteUint32(userId)) {
232         LOGE("Write user ID failed");
233         return E_IPC_ERROR;
234     }
235     int err = Remote()->SendRequest(INACTIVE_USER_KEY, data, reply, option);
236     if (err != E_OK) {
237         LOGE("SendRequest failed");
238         return E_IPC_ERROR;
239     }
240 
241     return reply.ReadInt32();
242 }
243 
UpdateKeyContext(uint32_t userId)244 int32_t StorageManagerProxy::UpdateKeyContext(uint32_t userId)
245 {
246     LOGI("user ID: %{public}u", userId);
247     MessageParcel data, reply;
248     MessageOption option(MessageOption::TF_SYNC);
249     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
250         LOGE("WriteInterfaceToken failed");
251         return E_IPC_ERROR;
252     }
253     if (!data.WriteUint32(userId)) {
254         LOGE("Write user ID failed");
255         return E_IPC_ERROR;
256     }
257     int err = Remote()->SendRequest(UPDATE_KEY_CONTEXT, data, reply, option);
258     if (err != E_OK) {
259         LOGE("SendRequest failed");
260         return E_IPC_ERROR;
261     }
262 
263     return reply.ReadInt32();
264 }
265 
GetFreeSizeOfVolume(std::string volumeUuid)266 int64_t StorageManagerProxy::GetFreeSizeOfVolume(std::string volumeUuid)
267 {
268     LOGI("StorageManagerProxy::GetFreeSizeOfVolume, volumeUuid:%{public}s", volumeUuid.c_str());
269     MessageParcel data, reply;
270     MessageOption option(MessageOption::TF_SYNC);
271     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
272         LOGE("StorageManagerProxy::GetFreeSizeOfVolume, WriteInterfaceToken failed");
273         return E_IPC_ERROR;
274     }
275 
276     if (!data.WriteString(volumeUuid)) {
277         LOGE("StorageManagerProxy::GetFreeSizeOfVolume, WriteInterfaceToken failed");
278         return E_IPC_ERROR;
279     }
280     int err = Remote()->SendRequest(GET_FREE, data, reply, option);
281     if (err != E_OK) {
282         LOGE("StorageManagerProxy::GetFreeSizeOfVolume, SendRequest failed");
283         return E_IPC_ERROR;
284     }
285     return reply.ReadInt64();
286 }
287 
GetTotalSizeOfVolume(std::string volumeUuid)288 int64_t StorageManagerProxy::GetTotalSizeOfVolume(std::string volumeUuid)
289 {
290     LOGI("StorageManagerProxy::GetTotalSizeOfVolume, volumeUuid:%{public}s", volumeUuid.c_str());
291     MessageParcel data, reply;
292     MessageOption option(MessageOption::TF_SYNC);
293     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
294         LOGE("StorageManagerProxy::GetTotalSizeOfVolume, WriteInterfaceToken failed");
295         return E_IPC_ERROR;
296     }
297 
298     if (!data.WriteString(volumeUuid)) {
299         LOGE("StorageManagerProxy::GetTotalSizeOfVolume, WriteInterfaceToken failed");
300         return E_IPC_ERROR;
301     }
302     int err = Remote()->SendRequest(GET_TOTAL, data, reply, option);
303     if (err != E_OK) {
304         LOGE("StorageManagerProxy::GetTotalSizeOfVolume, SendRequest failed");
305         return E_IPC_ERROR;
306     }
307     return reply.ReadInt64();
308 }
309 
GetBundleStats(std::string pkgName)310 std::vector<int64_t> StorageManagerProxy::GetBundleStats(std::string pkgName)
311 {
312     std::vector<int64_t> result = {};
313     MessageParcel data, reply;
314     MessageOption option(MessageOption::TF_SYNC);
315     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
316         return result;
317     }
318 
319     if (!data.WriteString(pkgName)) {
320         return result;
321     }
322     int err = Remote()->SendRequest(GET_BUNDLE_STATUS, data, reply, option);
323     if (err != E_OK) {
324         return result;
325     }
326     std::vector<int64_t> val;
327     if (!reply.ReadInt64Vector(&val)) {
328         val = {};
329     }
330     return val;
331 }
332 
NotifyVolumeCreated(VolumeCore vc)333 void StorageManagerProxy::NotifyVolumeCreated(VolumeCore vc)
334 {
335     LOGI("StorageManagerProxy::NotifyVolumeCreated, volumeUuid:%{public}s", vc.GetId().c_str());
336     MessageParcel data, reply;
337     MessageOption option(MessageOption::TF_SYNC);
338     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
339         LOGE("StorageManagerProxy::NotifyVolumeCreated, WriteInterfaceToken failed");
340         return;
341     }
342 
343     vc.Marshalling(data);
344     int err = Remote()->SendRequest(NOTIFY_VOLUME_CREATED, data, reply, option);
345     if (err != E_OK) {
346         LOGE("StorageManagerProxy::NotifyVolumeCreated, SendRequest failed");
347     }
348 }
349 
NotifyVolumeMounted(std::string volumeId,int32_t fsType,std::string fsUuid,std::string path,std::string description)350 void StorageManagerProxy::NotifyVolumeMounted(std::string volumeId, int32_t fsType, std::string fsUuid,
351                                               std::string path, std::string description)
352 {
353     LOGI("StorageManagerProxy::NotifyVolumeMounted, volumeUuid:%{public}s", volumeId.c_str());
354     MessageParcel data, reply;
355     MessageOption option(MessageOption::TF_SYNC);
356     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
357         LOGE("StorageManagerProxy::NotifyVolumeMounted, WriteInterfaceToken failed");
358         return;
359     }
360 
361     if (!data.WriteString(volumeId)) {
362         LOGE("StorageManagerProxy::NotifyVolumeMounted, WriteInterfaceToken failed");
363         return;
364     }
365 
366     if (!data.WriteInt32(fsType)) {
367         LOGE("StorageManagerProxy::NotifyVolumeMounted, WriteInterfaceToken failed");
368         return;
369     }
370 
371     if (!data.WriteString(fsUuid)) {
372         LOGE("StorageManagerProxy::NotifyVolumeMounted, WriteInterfaceToken failed");
373         return;
374     }
375 
376     if (!data.WriteString(path)) {
377         LOGE("StorageManagerProxy::NotifyVolumeMounted, WriteInterfaceToken failed");
378         return;
379     }
380 
381     if (!data.WriteString(description)) {
382         LOGE("StorageManagerProxy::NotifyVolumeMounted, WriteInterfaceToken failed");
383         return;
384     }
385 
386     int err = Remote()->SendRequest(NOTIFY_VOLUME_MOUNTED, data, reply, option);
387     if (err != E_OK) {
388         LOGE("StorageManagerProxy::NotifyVolumeMounted, SendRequest failed");
389     }
390 }
NotifyVolumeDestroyed(std::string volumeId)391 void StorageManagerProxy::NotifyVolumeDestroyed(std::string volumeId)
392 {
393     LOGI("StorageManagerProxy::NotifyVolumedestroyed, volumeId:%{public}s", volumeId.c_str());
394     MessageParcel data, reply;
395     MessageOption option(MessageOption::TF_SYNC);
396     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
397         LOGE("StorageManagerProxy::NotifyVolumedestroyed, WriteInterfaceToken failed");
398         return;
399     }
400 
401     if (!data.WriteString(volumeId)) {
402         LOGE("StorageManagerProxy::NotifyVolumedestroyed, WriteInterfaceToken failed");
403         return;
404     }
405     int err = Remote()->SendRequest(NOTIFY_VOLUME_DESTROYED, data, reply, option);
406     if (err != E_OK) {
407         LOGE("StorageManagerProxy::NotifyVolumeDestroyed, SendRequest failed");
408     }
409 }
410 
Mount(std::string volumeId)411 int32_t StorageManagerProxy::Mount(std::string volumeId)
412 {
413     LOGI("StorageManagerProxy::Mount, volumeId:%{public}s", volumeId.c_str());
414     MessageParcel data, reply;
415     MessageOption option(MessageOption::TF_SYNC);
416     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
417         LOGE("StorageManagerProxy::Mount, WriteInterfaceToken failed");
418         return E_IPC_ERROR;
419     }
420 
421     if (!data.WriteString(volumeId)) {
422         LOGE("StorageManagerProxy::Mount, WriteInterfaceToken failed");
423         return E_IPC_ERROR;
424     }
425     int err = Remote()->SendRequest(MOUNT, data, reply, option);
426     if (err != E_OK) {
427         LOGE("StorageManagerProxy::Mount, SendRequest failed");
428         return E_IPC_ERROR;
429     }
430     return reply.ReadInt32();
431 }
432 
Unmount(std::string volumeId)433 int32_t StorageManagerProxy::Unmount(std::string volumeId)
434 {
435     LOGI("StorageManagerProxy::Unmount, volumeId:%{public}s", volumeId.c_str());
436     MessageParcel data, reply;
437     MessageOption option(MessageOption::TF_SYNC);
438     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
439         LOGE("StorageManagerProxy::Unmount, WriteInterfaceToken failed");
440         return E_IPC_ERROR;
441     }
442 
443     if (!data.WriteString(volumeId)) {
444         LOGE("StorageManagerProxy::Unmount, WriteInterfaceToken failed");
445         return E_IPC_ERROR;
446     }
447     int err = Remote()->SendRequest(UNMOUNT, data, reply, option);
448     if (err != E_OK) {
449         LOGE("StorageManagerProxy::Unmount, SendRequest failed");
450         return E_IPC_ERROR;
451     }
452     return reply.ReadInt32();
453 }
454 
GetAllVolumes()455 std::vector<VolumeExternal> StorageManagerProxy::GetAllVolumes()
456 {
457     std::vector<VolumeExternal> result = {};
458     LOGI("StorageManagerProxy::GetAllVolumes");
459     MessageParcel data, reply;
460     MessageOption option(MessageOption::TF_SYNC);
461     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
462         LOGE("StorageManagerProxy::GetAllVolumes, WriteInterfaceToken failed");
463         return result;
464     }
465 
466     int err = Remote()->SendRequest(GET_ALL_VOLUMES, data, reply, option);
467     if (err != E_OK) {
468         LOGE("StorageManagerProxy::GetAllVolumes, SendRequest failed");
469         return result;
470     }
471     uint size = reply.ReadUint32();
472     if (size == 0) {
473         return result;
474     }
475     for (uint i = 0; i < size; i++) {
476         std::unique_ptr<VolumeExternal> ve = VolumeExternal::Unmarshalling(reply);
477         LOGI("StorageManagerProxy::GetAllVolumes push %{public}s", ve->GetId().c_str());
478         result.push_back(*ve);
479     }
480     return result;
481 }
482 
NotifyDiskCreated(Disk disk)483 void StorageManagerProxy::NotifyDiskCreated(Disk disk)
484 {
485     LOGI("StorageManagerProxy::NotifyDiskCreate, diskId:%{public}s", disk.GetDiskId().c_str());
486     MessageParcel data, reply;
487     MessageOption option(MessageOption::TF_SYNC);
488     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
489         LOGE("StorageManagerProxy::NotifyDiskCreate, WriteInterfaceToken failed");
490         return;
491     }
492     disk.Marshalling(data);
493     int err = Remote()->SendRequest(NOTIFY_DISK_CREATED, data, reply, option);
494     if (err != E_OK) {
495         LOGE("StorageManagerProxy::NotifyDiskCreate, SendRequest failed");
496         return;
497     }
498 }
499 
NotifyDiskDestroyed(std::string diskId)500 void StorageManagerProxy::NotifyDiskDestroyed(std::string diskId)
501 {
502     LOGI("StorageManagerProxy::NotifyDiskDestroyed, diskId:%{public}s", diskId.c_str());
503     MessageParcel data, reply;
504     MessageOption option(MessageOption::TF_SYNC);
505     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
506         LOGE("StorageManagerProxy::NotifyDiskDestroyed, WriteInterfaceToken failed");
507         return;
508     }
509     if (!data.WriteString(diskId)) {
510         LOGE("StorageManagerProxy::NotifyDiskDestroyed, WriteString failed");
511         return;
512     }
513     int err = Remote()->SendRequest(NOTIFY_DISK_DESTROYED, data, reply, option);
514     if (err != E_OK) {
515         LOGE("StorageManagerProxy::NotifyDiskDestroyed, SendRequest failed");
516         return;
517     }
518 }
519 
Partition(std::string diskId,int32_t type)520 int32_t StorageManagerProxy::Partition(std::string diskId, int32_t type)
521 {
522     LOGI("StorageManagerProxy::Partition, diskId:%{public}s", diskId.c_str());
523     MessageParcel data, reply;
524     MessageOption option(MessageOption::TF_SYNC);
525     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
526         LOGE("StorageManagerProxy::Partition, WriteInterfaceToken failed");
527         return E_IPC_ERROR;
528     }
529     if (!data.WriteString(diskId)) {
530         LOGE("StorageManagerProxy::Partition, WriteString failed");
531         return E_IPC_ERROR;
532     }
533     if (!data.WriteInt32(type)) {
534         LOGE("StorageManagerProxy::Partition WriteInt32 failed");
535         return E_IPC_ERROR;
536     }
537     int err = Remote()->SendRequest(PARTITION, data, reply, option);
538     if (err != E_OK) {
539         LOGE("StorageManagerProxy::Partition, SendRequest failed");
540         return E_IPC_ERROR;
541     }
542     return reply.ReadInt32();
543 }
544 
GetAllDisks()545 std::vector<Disk> StorageManagerProxy::GetAllDisks()
546 {
547     LOGI("StorageManagerProxy::GetAllDisks");
548     std::vector<Disk> result = {};
549     MessageParcel data, reply;
550     MessageOption option(MessageOption::TF_SYNC);
551     if (!data.WriteInterfaceToken(StorageManagerProxy::GetDescriptor())) {
552         LOGE("StorageManagerProxy::GetAllDisks, WriteInterfaceToken failed");
553         return result;
554     }
555 
556     int err = Remote()->SendRequest(GET_ALL_DISKS, data, reply, option);
557     if (err != E_OK) {
558         LOGE("StorageManagerProxy::GetAllDisks, SendRequest failed");
559         return result;
560     }
561     uint size = reply.ReadUint32();
562     if (size == 0) {
563         return result;
564     }
565     for (uint i = 0; i < size; i++) {
566         std::unique_ptr<Disk> disk = Disk::Unmarshalling(reply);
567         LOGI("StorageManagerProxy::GetAllDisks push %{public}s", disk->GetDiskId().c_str());
568         result.push_back(*disk);
569     }
570     return result;
571 }
572 } // StorageManager
573 } // OHOS
574 
575