1 /*
2 * Copyright (c) 2021-2024 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 "storage_daemon_communication/storage_daemon_communication.h"
17
18 #include <iservice_registry.h>
19 #include <system_ability_definition.h>
20
21 #include "ipc/istorage_daemon.h"
22 #include "ipc/storage_daemon.h"
23 #include "ipc/storage_daemon_proxy.h"
24 #include "os_account_manager.h"
25 #ifdef ENABLE_SCREENLOCK_MANAGER
26 #include "screenlock_manager.h"
27 #endif
28 #include "storage_service_errno.h"
29 #include "storage_service_log.h"
30
31 namespace OHOS {
32 namespace StorageManager {
StorageDaemonCommunication()33 StorageDaemonCommunication::StorageDaemonCommunication()
34 {
35 LOGI("DEBUG StorageDaemonCommunication constructer");
36 storageDaemon_ = nullptr;
37 }
38
~StorageDaemonCommunication()39 StorageDaemonCommunication::~StorageDaemonCommunication()
40 {
41 LOGI("DEBUG ~StorageDaemonCommunication destructer ~");
42 }
43
Connect()44 int32_t StorageDaemonCommunication::Connect()
45 {
46 LOGD("StorageDaemonCommunication::Connect start");
47 std::lock_guard<std::mutex> lock(mutex_);
48 if (storageDaemon_ == nullptr) {
49 auto sam = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
50 if (sam == nullptr) {
51 LOGE("StorageDaemonCommunication::Connect samgr nullptr");
52 return E_SA_IS_NULLPTR;
53 }
54 auto object = sam->GetSystemAbility(STORAGE_MANAGER_DAEMON_ID);
55 if (object == nullptr) {
56 LOGE("StorageDaemonCommunication::Connect object nullptr");
57 return E_REMOTE_IS_NULLPTR;
58 }
59 storageDaemon_ = iface_cast<OHOS::StorageDaemon::IStorageDaemon>(object);
60 if (storageDaemon_ == nullptr) {
61 LOGE("StorageDaemonCommunication::Connect service nullptr");
62 return E_SERVICE_IS_NULLPTR;
63 }
64 deathRecipient_ = new (std::nothrow) SdDeathRecipient();
65 if (!deathRecipient_) {
66 LOGE("StorageDaemonCommunication::Connect failed to create death recipient");
67 return E_DEATH_RECIPIENT_IS_NULLPTR;
68 }
69
70 storageDaemon_->AsObject()->AddDeathRecipient(deathRecipient_);
71 }
72 LOGD("StorageDaemonCommunication::Connect end");
73 return E_OK;
74 }
75
PrepareAddUser(int32_t userId,uint32_t flags)76 int32_t StorageDaemonCommunication::PrepareAddUser(int32_t userId, uint32_t flags)
77 {
78 LOGI("StorageDaemonCommunication::PrepareAddUser start");
79 int32_t err = Connect();
80 if (err != E_OK) {
81 LOGE("StorageDaemonCommunication::PrepareAddUser connect failed");
82 return err;
83 }
84 if (storageDaemon_ == nullptr) {
85 LOGE("StorageDaemonCommunication::Connect service nullptr");
86 return E_SERVICE_IS_NULLPTR;
87 }
88 return storageDaemon_->PrepareUserDirs(userId, flags);
89 }
90
RemoveUser(int32_t userId,uint32_t flags)91 int32_t StorageDaemonCommunication::RemoveUser(int32_t userId, uint32_t flags)
92 {
93 LOGI("StorageDaemonCommunication::RemoveUser start");
94 int32_t err = Connect();
95 if (err != E_OK) {
96 LOGE("StorageDaemonCommunication::RemoveUser connect failed");
97 return err;
98 }
99 if (storageDaemon_ == nullptr) {
100 LOGE("StorageDaemonCommunication::Connect service nullptr");
101 return E_SERVICE_IS_NULLPTR;
102 }
103 return storageDaemon_->DestroyUserDirs(userId, flags);
104 }
105
PrepareStartUser(int32_t userId)106 int32_t StorageDaemonCommunication::PrepareStartUser(int32_t userId)
107 {
108 LOGI("StorageDaemonCommunication::PrepareStartUser start");
109 int32_t err = Connect();
110 if (err != E_OK) {
111 LOGE("StorageDaemonCommunication::PrepareStartUser connect failed");
112 return err;
113 }
114 if (storageDaemon_ == nullptr) {
115 LOGE("StorageDaemonCommunication::Connect service nullptr");
116 return E_SERVICE_IS_NULLPTR;
117 }
118 return storageDaemon_->StartUser(userId);
119 }
120
StopUser(int32_t userId)121 int32_t StorageDaemonCommunication::StopUser(int32_t userId)
122 {
123 LOGI("StorageDaemonCommunication::StopUser start");
124 int32_t err = Connect();
125 if (err != E_OK) {
126 LOGE("StorageDaemonCommunication::StopUser connect failed");
127 return err;
128 }
129 if (storageDaemon_ == nullptr) {
130 LOGE("StorageDaemonCommunication::Connect service nullptr");
131 return E_SERVICE_IS_NULLPTR;
132 }
133 return storageDaemon_->StopUser(userId);
134 }
135
CompleteAddUser(int32_t userId)136 int32_t StorageDaemonCommunication::CompleteAddUser(int32_t userId)
137 {
138 LOGI("StorageDaemonCommunication::CompleteAddUser start");
139 int32_t err = Connect();
140 if (err != E_OK) {
141 LOGE("StorageDaemonCommunication::CompleteAddUser connect failed");
142 return err;
143 }
144 if (storageDaemon_ == nullptr) {
145 LOGE("StorageDaemonCommunication::CompleteAddUser service nullptr");
146 return E_SERVICE_IS_NULLPTR;
147 }
148 return storageDaemon_->CompleteAddUser(userId);
149 }
150
Mount(std::string volumeId,int32_t flag)151 int32_t StorageDaemonCommunication::Mount(std::string volumeId, int32_t flag)
152 {
153 LOGI("StorageDaemonCommunication::mount start");
154 int32_t err = Connect();
155 if (err != E_OK) {
156 LOGE("StorageDaemonCommunication::mount connect failed");
157 return err;
158 }
159 if (storageDaemon_ == nullptr) {
160 LOGE("StorageDaemonCommunication::Connect service nullptr");
161 return E_SERVICE_IS_NULLPTR;
162 }
163 return storageDaemon_->Mount(volumeId, flag);
164 }
165
Unmount(std::string volumeId)166 int32_t StorageDaemonCommunication::Unmount(std::string volumeId)
167 {
168 LOGI("StorageDaemonCommunication::unmount start");
169 int32_t err = Connect();
170 if (err != E_OK) {
171 LOGE("StorageDaemonCommunication::unmount connect failed");
172 return err;
173 }
174 if (storageDaemon_ == nullptr) {
175 LOGE("StorageDaemonCommunication::Connect service nullptr");
176 return E_SERVICE_IS_NULLPTR;
177 }
178 return storageDaemon_->UMount(volumeId);
179 }
180
Check(std::string volumeId)181 int32_t StorageDaemonCommunication::Check(std::string volumeId)
182 {
183 LOGI("StorageDaemonCommunication::check start");
184 int32_t err = Connect();
185 if (err != E_OK) {
186 LOGE("StorageDaemonCommunication::check connect failed");
187 return err;
188 }
189 if (storageDaemon_ == nullptr) {
190 LOGE("StorageDaemonCommunication::Connect service nullptr");
191 return E_SERVICE_IS_NULLPTR;
192 }
193 return storageDaemon_->Check(volumeId);
194 }
195
Partition(std::string diskId,int32_t type)196 int32_t StorageDaemonCommunication::Partition(std::string diskId, int32_t type)
197 {
198 LOGI("StorageDaemonCommunication::Partition start");
199 int32_t err = Connect();
200 if (err != E_OK) {
201 LOGE("StorageDaemonCommunication::Partition connect failed");
202 return err;
203 }
204 if (storageDaemon_ == nullptr) {
205 LOGE("StorageDaemonCommunication::Connect service nullptr");
206 return E_SERVICE_IS_NULLPTR;
207 }
208 return storageDaemon_->Partition(diskId, type);
209 }
210
Format(std::string volumeId,std::string type)211 int32_t StorageDaemonCommunication::Format(std::string volumeId, std::string type)
212 {
213 LOGI("StorageDaemonCommunication::Format start");
214 int32_t err = Connect();
215 if (err != E_OK) {
216 LOGE("StorageDaemonCommunication::Format connect failed");
217 return err;
218 }
219 if (storageDaemon_ == nullptr) {
220 LOGE("StorageDaemonCommunication::Connect service nullptr");
221 return E_SERVICE_IS_NULLPTR;
222 }
223 return storageDaemon_->Format(volumeId, type);
224 }
225
SetVolumeDescription(std::string volumeId,std::string description)226 int32_t StorageDaemonCommunication::SetVolumeDescription(std::string volumeId, std::string description)
227 {
228 LOGI("StorageDaemonCommunication::SetVolumeDescription start");
229 int32_t err = Connect();
230 if (err != E_OK) {
231 LOGE("StorageDaemonCommunication::SetVolumeDescription connect failed");
232 return err;
233 }
234 if (storageDaemon_ == nullptr) {
235 LOGE("StorageDaemonCommunication::Connect service nullptr");
236 return E_SERVICE_IS_NULLPTR;
237 }
238 return storageDaemon_->SetVolumeDescription(volumeId, description);
239 }
240
GenerateUserKeys(uint32_t userId,uint32_t flags)241 int32_t StorageDaemonCommunication::GenerateUserKeys(uint32_t userId, uint32_t flags)
242 {
243 LOGI("enter");
244 int32_t err = Connect();
245 if (err != E_OK) {
246 LOGE("Connect failed");
247 return err;
248 }
249 if (storageDaemon_ == nullptr) {
250 LOGE("StorageDaemonCommunication::Connect service nullptr");
251 return E_SERVICE_IS_NULLPTR;
252 }
253 return storageDaemon_->GenerateUserKeys(userId, flags);
254 }
255
DeleteUserKeys(uint32_t userId)256 int32_t StorageDaemonCommunication::DeleteUserKeys(uint32_t userId)
257 {
258 LOGI("enter");
259 int32_t err = Connect();
260 if (err != E_OK) {
261 LOGE("Connect failed");
262 return err;
263 }
264 if (storageDaemon_ == nullptr) {
265 LOGE("StorageDaemonCommunication::Connect service nullptr");
266 return E_SERVICE_IS_NULLPTR;
267 }
268 return storageDaemon_->DeleteUserKeys(userId);
269 }
270
UpdateUserAuth(uint32_t userId,uint64_t secureUid,const std::vector<uint8_t> & token,const std::vector<uint8_t> & oldSecret,const std::vector<uint8_t> & newSecret)271 int32_t StorageDaemonCommunication::UpdateUserAuth(uint32_t userId, uint64_t secureUid,
272 const std::vector<uint8_t> &token,
273 const std::vector<uint8_t> &oldSecret,
274 const std::vector<uint8_t> &newSecret)
275 {
276 LOGI("enter");
277 int32_t err = Connect();
278 if (err != E_OK) {
279 LOGE("Connect failed");
280 return err;
281 }
282 if (storageDaemon_ == nullptr) {
283 LOGE("StorageDaemonCommunication::Connect service nullptr");
284 return E_SERVICE_IS_NULLPTR;
285 }
286 return storageDaemon_->UpdateUserAuth(userId, secureUid, token, oldSecret, newSecret);
287 }
288
ActiveUserKey(uint32_t userId,const std::vector<uint8_t> & token,const std::vector<uint8_t> & secret)289 int32_t StorageDaemonCommunication::ActiveUserKey(uint32_t userId,
290 const std::vector<uint8_t> &token,
291 const std::vector<uint8_t> &secret)
292 {
293 LOGI("enter");
294 int32_t err = Connect();
295 if (err != E_OK) {
296 LOGE("Connect failed");
297 return err;
298 }
299 if (storageDaemon_ == nullptr) {
300 LOGE("StorageDaemonCommunication::Connect service nullptr");
301 return E_SERVICE_IS_NULLPTR;
302 }
303 return storageDaemon_->ActiveUserKey(userId, token, secret);
304 }
305
InactiveUserKey(uint32_t userId)306 int32_t StorageDaemonCommunication::InactiveUserKey(uint32_t userId)
307 {
308 LOGI("enter");
309 int32_t err = Connect();
310 if (err != E_OK) {
311 LOGE("Connect failed");
312 return err;
313 }
314 if (storageDaemon_ == nullptr) {
315 LOGE("StorageDaemonCommunication::Connect service nullptr");
316 return E_SERVICE_IS_NULLPTR;
317 }
318 return storageDaemon_->InactiveUserKey(userId);
319 }
320
LockUserScreen(uint32_t userId)321 int32_t StorageDaemonCommunication::LockUserScreen(uint32_t userId)
322 {
323 LOGD("enter");
324 int32_t err = Connect();
325 if (err != E_OK) {
326 LOGE("Connect failed");
327 return err;
328 }
329 if (storageDaemon_ == nullptr) {
330 LOGE("StorageDaemonCommunication::Connect service nullptr");
331 return E_SERVICE_IS_NULLPTR;
332 }
333 return storageDaemon_->LockUserScreen(userId);
334 }
335
GetFileEncryptStatus(uint32_t userId,bool & isEncrypted,bool needCheckDirMount)336 int32_t StorageDaemonCommunication::GetFileEncryptStatus(uint32_t userId, bool &isEncrypted, bool needCheckDirMount)
337 {
338 LOGD("enter");
339 int32_t err = Connect();
340 if (err != E_OK) {
341 LOGE("Connect failed");
342 return err;
343 }
344 if (storageDaemon_ == nullptr) {
345 LOGE("StorageDaemonCommunication::Connect service nullptr");
346 return E_SERVICE_IS_NULLPTR;
347 }
348 return storageDaemon_->GetFileEncryptStatus(userId, isEncrypted, needCheckDirMount);
349 }
350
UnlockUserScreen(uint32_t userId,const std::vector<uint8_t> & token,const std::vector<uint8_t> & secret)351 int32_t StorageDaemonCommunication::UnlockUserScreen(uint32_t userId,
352 const std::vector<uint8_t> &token,
353 const std::vector<uint8_t> &secret)
354 {
355 LOGI("enter");
356 int32_t err = Connect();
357 if (err != E_OK) {
358 LOGE("Connect failed");
359 return err;
360 }
361 if (storageDaemon_ == nullptr) {
362 LOGE("StorageDaemonCommunication::Connect service nullptr");
363 return E_SERVICE_IS_NULLPTR;
364 }
365 return storageDaemon_->UnlockUserScreen(userId, token, secret);
366 }
367
GetLockScreenStatus(uint32_t userId,bool & lockScreenStatus)368 int32_t StorageDaemonCommunication::GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus)
369 {
370 LOGI("enter");
371 int32_t err = Connect();
372 if (err != E_OK) {
373 LOGE("Connect failed");
374 return err;
375 }
376 if (storageDaemon_ == nullptr) {
377 LOGE("StorageDaemonCommunication::Connect service nullptr");
378 return E_SERVICE_IS_NULLPTR;
379 }
380 return storageDaemon_->GetLockScreenStatus(userId, lockScreenStatus);
381 }
382
UpdateKeyContext(uint32_t userId)383 int32_t StorageDaemonCommunication::UpdateKeyContext(uint32_t userId)
384 {
385 LOGI("enter");
386 int32_t err = Connect();
387 if (err != E_OK) {
388 LOGE("Connect failed");
389 return err;
390 }
391 if (storageDaemon_ == nullptr) {
392 LOGE("StorageDaemonCommunication::Connect service nullptr");
393 return E_SERVICE_IS_NULLPTR;
394 }
395 return storageDaemon_->UpdateKeyContext(userId);
396 }
397
ResetSdProxy()398 int32_t StorageDaemonCommunication::ResetSdProxy()
399 {
400 LOGD("enter");
401 std::lock_guard<std::mutex> lock(mutex_);
402 if ((storageDaemon_ != nullptr) && (storageDaemon_->AsObject() != nullptr)) {
403 storageDaemon_->AsObject()->RemoveDeathRecipient(deathRecipient_);
404 }
405 storageDaemon_ = nullptr;
406
407 return E_OK;
408 }
409
ForceLockUserScreen()410 void StorageDaemonCommunication::ForceLockUserScreen()
411 {
412 LOGI("StorageDaemonCommunication::ForceLockUserScreen, storage_daemon process maybe has died.");
413 #ifdef ENABLE_SCREENLOCK_MANAGER
414 std::vector<int32_t> ids;
415 int32_t ret = AccountSA::OsAccountManager::QueryActiveOsAccountIds(ids);
416 if (ret != ERR_OK || ids.empty()) {
417 LOGE("Query active userid failed, ret = %{public}u", ret);
418 return;
419 }
420 int reasonFlag = static_cast<int>(ScreenLock::StrongAuthReasonFlags::ACTIVE_REQUEST);
421 ret = ScreenLock::ScreenLockManager::GetInstance()->RequestStrongAuth(reasonFlag, ids[0]);
422 if (ret != ScreenLock::E_SCREENLOCK_OK) {
423 LOGE("Request strong auth by screen lock manager failed.");
424 return;
425 }
426 ret = ScreenLock::ScreenLockManager::GetInstance()->Lock(ids[0]);
427 if (ret != ScreenLock::E_SCREENLOCK_OK) {
428 LOGE("Lock user screen by screen lock manager failed.");
429 }
430 LOGI("Force lock user screen and request strong auth success for userId = %{public}d.", ids[0]);
431 #endif
432 }
433
OnRemoteDied(const wptr<IRemoteObject> & remote)434 void SdDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
435 {
436 LOGE("StorageDaemonCommunication::OnRemoteDied, storage_daemon process has died.");
437 DelayedSingleton<StorageDaemonCommunication>::GetInstance()->ResetSdProxy();
438 DelayedSingleton<StorageDaemonCommunication>::GetInstance()->ForceLockUserScreen();
439 }
440
CreateShareFile(const std::vector<std::string> & uriList,uint32_t tokenId,uint32_t flag)441 std::vector<int32_t> StorageDaemonCommunication::CreateShareFile(const std::vector<std::string> &uriList,
442 uint32_t tokenId, uint32_t flag)
443 {
444 LOGI("enter");
445 int32_t err = Connect();
446 if (err != E_OK) {
447 LOGE("Connect failed");
448 return std::vector<int32_t>{err};
449 }
450 if (storageDaemon_ == nullptr) {
451 LOGE("StorageDaemonCommunication::Connect service nullptr");
452 return std::vector<int32_t>{err};
453 }
454 return storageDaemon_->CreateShareFile(uriList, tokenId, flag);
455 }
456
DeleteShareFile(uint32_t tokenId,const std::vector<std::string> & uriList)457 int32_t StorageDaemonCommunication::DeleteShareFile(uint32_t tokenId, const std::vector<std::string> &uriList)
458 {
459 LOGI("enter");
460 int32_t err = Connect();
461 if (err != E_OK) {
462 LOGE("Connect failed");
463 return err;
464 }
465 if (storageDaemon_ == nullptr) {
466 LOGE("StorageDaemonCommunication::Connect service nullptr");
467 return E_SERVICE_IS_NULLPTR;
468 }
469 return storageDaemon_->DeleteShareFile(tokenId, uriList);
470 }
471
SetBundleQuota(const std::string & bundleName,int32_t uid,const std::string & bundleDataDirPath,int32_t limitSizeMb)472 int32_t StorageDaemonCommunication::SetBundleQuota(const std::string &bundleName, int32_t uid,
473 const std::string &bundleDataDirPath, int32_t limitSizeMb)
474 {
475 LOGI("enter");
476 int32_t err = Connect();
477 if (err != E_OK) {
478 LOGE("Connect failed");
479 return err;
480 }
481 if (storageDaemon_ == nullptr) {
482 LOGE("StorageDaemonCommunication::Connect service nullptr");
483 return E_SERVICE_IS_NULLPTR;
484 }
485 return storageDaemon_->SetBundleQuota(bundleName, uid, bundleDataDirPath, limitSizeMb);
486 }
487
GetOccupiedSpace(int32_t idType,int32_t id,int64_t & size)488 int32_t StorageDaemonCommunication::GetOccupiedSpace(int32_t idType, int32_t id, int64_t &size)
489 {
490 LOGI("enter");
491 int32_t err = Connect();
492 if (err != E_OK) {
493 LOGE("Connect failed");
494 return err;
495 }
496 if (storageDaemon_ == nullptr) {
497 LOGE("StorageDaemonCommunication::Connect service nullptr");
498 return E_SERVICE_IS_NULLPTR;
499 }
500 return storageDaemon_->GetOccupiedSpace(idType, id, size);
501 }
502
MountCryptoPathAgain(int32_t userId)503 int32_t StorageDaemonCommunication::MountCryptoPathAgain(int32_t userId)
504 {
505 int32_t err = Connect();
506 if (err != E_OK) {
507 LOGE("Connect failed");
508 return err;
509 }
510 if (storageDaemon_ == nullptr) {
511 LOGE("StorageDaemonCommunication::Connect service nullptr");
512 return E_SERVICE_IS_NULLPTR;
513 }
514 return storageDaemon_->MountCryptoPathAgain(userId);
515 }
516
GenerateAppkey(uint32_t userId,uint32_t hashId,std::string & keyId)517 int32_t StorageDaemonCommunication::GenerateAppkey(uint32_t userId, uint32_t hashId, std::string &keyId)
518 {
519 int32_t err = Connect();
520 if (err != E_OK) {
521 LOGE("Connect failed");
522 return err;
523 }
524 if (storageDaemon_ == nullptr) {
525 LOGE("StorageDaemonCommunication::Connect service nullptr");
526 return E_SERVICE_IS_NULLPTR;
527 }
528 return storageDaemon_->GenerateAppkey(userId, hashId, keyId);
529 }
530
DeleteAppkey(uint32_t userId,const std::string keyId)531 int32_t StorageDaemonCommunication::DeleteAppkey(uint32_t userId, const std::string keyId)
532 {
533 int32_t err = Connect();
534 if (err != E_OK) {
535 LOGE("Connect failed");
536 return err;
537 }
538 if (storageDaemon_ == nullptr) {
539 LOGE("StorageDaemonCommunication::Connect service nullptr");
540 return E_SERVICE_IS_NULLPTR;
541 }
542 return storageDaemon_->DeleteAppkey(userId, keyId);
543 }
544
GetBundleStatsForIncrease(uint32_t userId,const std::vector<std::string> & bundleNames,const std::vector<int64_t> & incrementalBackTimes,std::vector<int64_t> & pkgFileSizes,std::vector<int64_t> & incPkgFileSizes)545 int32_t StorageDaemonCommunication::GetBundleStatsForIncrease(uint32_t userId,
546 const std::vector<std::string> &bundleNames, const std::vector<int64_t> &incrementalBackTimes,
547 std::vector<int64_t> &pkgFileSizes, std::vector<int64_t> &incPkgFileSizes)
548 {
549 int32_t err = Connect();
550 if (err != E_OK) {
551 LOGE("Connect failed");
552 return err;
553 }
554 if (storageDaemon_ == nullptr) {
555 LOGE("StorageDaemonCommunication::Connect service nullptr");
556 return E_SERVICE_IS_NULLPTR;
557 }
558 return storageDaemon_->GetBundleStatsForIncrease(userId, bundleNames, incrementalBackTimes, pkgFileSizes,
559 incPkgFileSizes);
560 }
561
UpdateMemoryPara(int32_t size,int32_t & oldSize)562 int32_t StorageDaemonCommunication::UpdateMemoryPara(int32_t size, int32_t &oldSize)
563 {
564 LOGI("StorageDaemonCommunication::UpdateMemoryPara");
565 int32_t err = Connect();
566 if (err != E_OK) {
567 LOGE("Connect failed");
568 return err;
569 }
570 if (storageDaemon_ == nullptr) {
571 LOGE("StorageDaemonCommunication::Connect service nullptr");
572 return E_SERVICE_IS_NULLPTR;
573 }
574 return storageDaemon_->UpdateMemoryPara(size, oldSize);
575 }
576
MountDfsDocs(int32_t userId,const std::string & relativePath,const std::string & networkId,const std::string & deviceId)577 int32_t StorageDaemonCommunication::MountDfsDocs(int32_t userId, const std::string &relativePath,
578 const std::string &networkId, const std::string &deviceId)
579 {
580 LOGI("StorageDaemonCommunication::MountDfsDocs start.");
581 int32_t err = Connect();
582 if (err != E_OK) {
583 LOGE("Connect failed");
584 return err;
585 }
586 if (storageDaemon_ == nullptr) {
587 LOGE("StorageDaemonCommunication::Connect service nullptr");
588 return E_SERVICE_IS_NULLPTR;
589 }
590 return storageDaemon_->MountDfsDocs(userId, relativePath, networkId, deviceId);
591 }
592
UMountDfsDocs(int32_t userId,const std::string & relativePath,const std::string & networkId,const std::string & deviceId)593 int32_t StorageDaemonCommunication::UMountDfsDocs(int32_t userId, const std::string &relativePath,
594 const std::string &networkId, const std::string &deviceId)
595 {
596 LOGI("StorageDaemonCommunication::UMountDfsDocs start.");
597 int32_t err = Connect();
598 if (err != E_OK) {
599 LOGE("Connect failed");
600 return err;
601 }
602 if (storageDaemon_ == nullptr) {
603 LOGE("StorageDaemonCommunication::Connect service nullptr");
604 return E_SERVICE_IS_NULLPTR;
605 }
606 return storageDaemon_->UMountDfsDocs(userId, relativePath, networkId, deviceId);
607 }
608
609 } // namespace StorageManager
610 } // namespace OHOS
611