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
GetUserNeedActiveStatus(uint32_t userId,bool & needActive)351 int32_t StorageDaemonCommunication::GetUserNeedActiveStatus(uint32_t userId, bool &needActive)
352 {
353 LOGD("enter");
354 int32_t err = Connect();
355 if (err != E_OK) {
356 LOGE("Connect failed");
357 return err;
358 }
359 if (storageDaemon_ == nullptr) {
360 LOGE("StorageDaemonCommunication::Connect service nullptr");
361 return E_SERVICE_IS_NULLPTR;
362 }
363 return storageDaemon_->GetUserNeedActiveStatus(userId, needActive);
364 }
365
UnlockUserScreen(uint32_t userId,const std::vector<uint8_t> & token,const std::vector<uint8_t> & secret)366 int32_t StorageDaemonCommunication::UnlockUserScreen(uint32_t userId,
367 const std::vector<uint8_t> &token,
368 const std::vector<uint8_t> &secret)
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_->UnlockUserScreen(userId, token, secret);
381 }
382
GetLockScreenStatus(uint32_t userId,bool & lockScreenStatus)383 int32_t StorageDaemonCommunication::GetLockScreenStatus(uint32_t userId, bool &lockScreenStatus)
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_->GetLockScreenStatus(userId, lockScreenStatus);
396 }
397
UpdateKeyContext(uint32_t userId)398 int32_t StorageDaemonCommunication::UpdateKeyContext(uint32_t userId)
399 {
400 LOGI("enter");
401 int32_t err = Connect();
402 if (err != E_OK) {
403 LOGE("Connect failed");
404 return err;
405 }
406 if (storageDaemon_ == nullptr) {
407 LOGE("StorageDaemonCommunication::Connect service nullptr");
408 return E_SERVICE_IS_NULLPTR;
409 }
410 return storageDaemon_->UpdateKeyContext(userId);
411 }
412
ResetSdProxy()413 int32_t StorageDaemonCommunication::ResetSdProxy()
414 {
415 LOGD("enter");
416 std::lock_guard<std::mutex> lock(mutex_);
417 if ((storageDaemon_ != nullptr) && (storageDaemon_->AsObject() != nullptr)) {
418 storageDaemon_->AsObject()->RemoveDeathRecipient(deathRecipient_);
419 }
420 storageDaemon_ = nullptr;
421
422 return E_OK;
423 }
424
ForceLockUserScreen()425 void StorageDaemonCommunication::ForceLockUserScreen()
426 {
427 LOGI("StorageDaemonCommunication::ForceLockUserScreen, storage_daemon process maybe has died.");
428 #ifdef ENABLE_SCREENLOCK_MANAGER
429 std::vector<int32_t> ids;
430 int32_t ret = AccountSA::OsAccountManager::QueryActiveOsAccountIds(ids);
431 if (ret != ERR_OK || ids.empty()) {
432 LOGE("Query active userid failed, ret = %{public}u", ret);
433 return;
434 }
435 int reasonFlag = static_cast<int>(ScreenLock::StrongAuthReasonFlags::ACTIVE_REQUEST);
436 ret = ScreenLock::ScreenLockManager::GetInstance()->RequestStrongAuth(reasonFlag, ids[0]);
437 if (ret != ScreenLock::E_SCREENLOCK_OK) {
438 LOGE("Request strong auth by screen lock manager failed.");
439 return;
440 }
441 ret = ScreenLock::ScreenLockManager::GetInstance()->Lock(ids[0]);
442 if (ret != ScreenLock::E_SCREENLOCK_OK) {
443 LOGE("Lock user screen by screen lock manager failed.");
444 }
445 LOGI("Force lock user screen and request strong auth success for userId = %{public}d.", ids[0]);
446 #endif
447 }
448
OnRemoteDied(const wptr<IRemoteObject> & remote)449 void SdDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
450 {
451 LOGE("StorageDaemonCommunication::OnRemoteDied, storage_daemon process has died.");
452 DelayedSingleton<StorageDaemonCommunication>::GetInstance()->ResetSdProxy();
453 DelayedSingleton<StorageDaemonCommunication>::GetInstance()->ForceLockUserScreen();
454 }
455
CreateShareFile(const std::vector<std::string> & uriList,uint32_t tokenId,uint32_t flag)456 std::vector<int32_t> StorageDaemonCommunication::CreateShareFile(const std::vector<std::string> &uriList,
457 uint32_t tokenId, uint32_t flag)
458 {
459 LOGI("enter");
460 int32_t err = Connect();
461 if (err != E_OK) {
462 LOGE("Connect failed");
463 return std::vector<int32_t>{err};
464 }
465 if (storageDaemon_ == nullptr) {
466 LOGE("StorageDaemonCommunication::Connect service nullptr");
467 return std::vector<int32_t>{err};
468 }
469 return storageDaemon_->CreateShareFile(uriList, tokenId, flag);
470 }
471
DeleteShareFile(uint32_t tokenId,const std::vector<std::string> & uriList)472 int32_t StorageDaemonCommunication::DeleteShareFile(uint32_t tokenId, const std::vector<std::string> &uriList)
473 {
474 LOGI("enter");
475 int32_t err = Connect();
476 if (err != E_OK) {
477 LOGE("Connect failed");
478 return err;
479 }
480 if (storageDaemon_ == nullptr) {
481 LOGE("StorageDaemonCommunication::Connect service nullptr");
482 return E_SERVICE_IS_NULLPTR;
483 }
484 return storageDaemon_->DeleteShareFile(tokenId, uriList);
485 }
486
SetBundleQuota(const std::string & bundleName,int32_t uid,const std::string & bundleDataDirPath,int32_t limitSizeMb)487 int32_t StorageDaemonCommunication::SetBundleQuota(const std::string &bundleName, int32_t uid,
488 const std::string &bundleDataDirPath, int32_t limitSizeMb)
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_->SetBundleQuota(bundleName, uid, bundleDataDirPath, limitSizeMb);
501 }
502
GetOccupiedSpace(int32_t idType,int32_t id,int64_t & size)503 int32_t StorageDaemonCommunication::GetOccupiedSpace(int32_t idType, int32_t id, int64_t &size)
504 {
505 LOGI("enter");
506 int32_t err = Connect();
507 if (err != E_OK) {
508 LOGE("Connect failed");
509 return err;
510 }
511 if (storageDaemon_ == nullptr) {
512 LOGE("StorageDaemonCommunication::Connect service nullptr");
513 return E_SERVICE_IS_NULLPTR;
514 }
515 return storageDaemon_->GetOccupiedSpace(idType, id, size);
516 }
517
MountCryptoPathAgain(int32_t userId)518 int32_t StorageDaemonCommunication::MountCryptoPathAgain(int32_t userId)
519 {
520 int32_t err = Connect();
521 if (err != E_OK) {
522 LOGE("Connect failed");
523 return err;
524 }
525 if (storageDaemon_ == nullptr) {
526 LOGE("StorageDaemonCommunication::Connect service nullptr");
527 return E_SERVICE_IS_NULLPTR;
528 }
529 return storageDaemon_->MountCryptoPathAgain(userId);
530 }
531
GenerateAppkey(uint32_t userId,uint32_t hashId,std::string & keyId)532 int32_t StorageDaemonCommunication::GenerateAppkey(uint32_t userId, uint32_t hashId, std::string &keyId)
533 {
534 int32_t err = Connect();
535 if (err != E_OK) {
536 LOGE("Connect failed");
537 return err;
538 }
539 if (storageDaemon_ == nullptr) {
540 LOGE("StorageDaemonCommunication::Connect service nullptr");
541 return E_SERVICE_IS_NULLPTR;
542 }
543 return storageDaemon_->GenerateAppkey(userId, hashId, keyId);
544 }
545
DeleteAppkey(uint32_t userId,const std::string keyId)546 int32_t StorageDaemonCommunication::DeleteAppkey(uint32_t userId, const std::string keyId)
547 {
548 int32_t err = Connect();
549 if (err != E_OK) {
550 LOGE("Connect failed");
551 return err;
552 }
553 if (storageDaemon_ == nullptr) {
554 LOGE("StorageDaemonCommunication::Connect service nullptr");
555 return E_SERVICE_IS_NULLPTR;
556 }
557 return storageDaemon_->DeleteAppkey(userId, keyId);
558 }
559
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)560 int32_t StorageDaemonCommunication::GetBundleStatsForIncrease(uint32_t userId,
561 const std::vector<std::string> &bundleNames, const std::vector<int64_t> &incrementalBackTimes,
562 std::vector<int64_t> &pkgFileSizes, std::vector<int64_t> &incPkgFileSizes)
563 {
564 int32_t err = Connect();
565 if (err != E_OK) {
566 LOGE("Connect failed");
567 return err;
568 }
569 if (storageDaemon_ == nullptr) {
570 LOGE("StorageDaemonCommunication::Connect service nullptr");
571 return E_SERVICE_IS_NULLPTR;
572 }
573 return storageDaemon_->GetBundleStatsForIncrease(userId, bundleNames, incrementalBackTimes, pkgFileSizes,
574 incPkgFileSizes);
575 }
576
UpdateMemoryPara(int32_t size,int32_t & oldSize)577 int32_t StorageDaemonCommunication::UpdateMemoryPara(int32_t size, int32_t &oldSize)
578 {
579 LOGI("StorageDaemonCommunication::UpdateMemoryPara");
580 int32_t err = Connect();
581 if (err != E_OK) {
582 LOGE("Connect failed");
583 return err;
584 }
585 if (storageDaemon_ == nullptr) {
586 LOGE("StorageDaemonCommunication::Connect service nullptr");
587 return E_SERVICE_IS_NULLPTR;
588 }
589 return storageDaemon_->UpdateMemoryPara(size, oldSize);
590 }
591
MountDfsDocs(int32_t userId,const std::string & relativePath,const std::string & networkId,const std::string & deviceId)592 int32_t StorageDaemonCommunication::MountDfsDocs(int32_t userId, const std::string &relativePath,
593 const std::string &networkId, const std::string &deviceId)
594 {
595 LOGI("StorageDaemonCommunication::MountDfsDocs start.");
596 int32_t err = Connect();
597 if (err != E_OK) {
598 LOGE("Connect failed");
599 return err;
600 }
601 if (storageDaemon_ == nullptr) {
602 LOGE("StorageDaemonCommunication::Connect service nullptr");
603 return E_SERVICE_IS_NULLPTR;
604 }
605 return storageDaemon_->MountDfsDocs(userId, relativePath, networkId, deviceId);
606 }
607
UMountDfsDocs(int32_t userId,const std::string & relativePath,const std::string & networkId,const std::string & deviceId)608 int32_t StorageDaemonCommunication::UMountDfsDocs(int32_t userId, const std::string &relativePath,
609 const std::string &networkId, const std::string &deviceId)
610 {
611 LOGI("StorageDaemonCommunication::UMountDfsDocs start.");
612 int32_t err = Connect();
613 if (err != E_OK) {
614 LOGE("Connect failed");
615 return err;
616 }
617 if (storageDaemon_ == nullptr) {
618 LOGE("StorageDaemonCommunication::Connect service nullptr");
619 return E_SERVICE_IS_NULLPTR;
620 }
621 return storageDaemon_->UMountDfsDocs(userId, relativePath, networkId, deviceId);
622 }
623
624 } // namespace StorageManager
625 } // namespace OHOS
626