已合并
modify filedescriptor ipc #2208
rainlost创建于 7月20日
modify filedescriptor ipc #2208
已合并
共 25 个文件变更+308-513
| @@ -104,8 +104,6 @@ class BackupExtExtension : public ExtensionStub { | |||
| 104 | friend class AncoBackupCallback; | 104 | friend class AncoBackupCallback; |
| 105 | friend class AncoRestoreCallback; | 105 | friend class AncoRestoreCallback; |
| 106 | public: | 106 | public: |
| 107 | - int32_t CallbackEnter([[maybe_unused]] uint32_t code) override; | ||
| 108 | - int32_t CallbackExit([[maybe_unused]] uint32_t code, [[maybe_unused]] int32_t result) override; | ||
| 109 | ErrCode GetFileHandleWithUniqueFd(const std::string &fileName, int32_t &errCode, int &fd) override; | 107 | ErrCode GetFileHandleWithUniqueFd(const std::string &fileName, int32_t &errCode, int &fd) override; |
| 110 | ErrCode HandleClear() override; | 108 | ErrCode HandleClear() override; |
| 111 | ErrCode PublishFile(const std::string &fileName) override; | 109 | ErrCode PublishFile(const std::string &fileName) override; |
| @@ -114,8 +112,6 @@ public: | |||
| 114 | ErrCode GetIncrementalFileHandle(const std::string &fileName, int &fd, int &reportFd, int32_t &fdErrCode) override; | 112 | ErrCode GetIncrementalFileHandle(const std::string &fileName, int &fd, int &reportFd, int32_t &fdErrCode) override; |
| 115 | ErrCode GetIncrementalRpFileHandle(const std::string &fileName, int32_t &fdErrCode) override; | 113 | ErrCode GetIncrementalRpFileHandle(const std::string &fileName, int32_t &fdErrCode) override; |
| 116 | ErrCode PublishIncrementalFile(const std::string &fileName) override; | 114 | ErrCode PublishIncrementalFile(const std::string &fileName) override; |
| 117 | - void GetIncrementalFileHandlesInner(const std::vector<std::string> &fileNames, std::vector<int> &fdList, | ||
| 118 | - std::vector<int32_t> &errCodes); | ||
| 119 | ErrCode HandleIncrementalBackup(int incrementalFd, int manifestFd) override; | 115 | ErrCode HandleIncrementalBackup(int incrementalFd, int manifestFd) override; |
| 120 | ErrCode IncrementalOnBackup(bool isClearData) override; | 116 | ErrCode IncrementalOnBackup(bool isClearData) override; |
| 121 | ErrCode GetIncrementalBackupFileHandle(int &fd, int &reportFd) override; | 117 | ErrCode GetIncrementalBackupFileHandle(int &fd, int &reportFd) override; |
| @@ -131,8 +127,7 @@ public: | |||
| 131 | ErrCode HandleGetCompatibilityInfo(const string &extInfo, int32_t scenario, bool isExist, | 127 | ErrCode HandleGetCompatibilityInfo(const string &extInfo, int32_t scenario, bool isExist, |
| 132 | string &compatibilityInfo) override; | 128 | string &compatibilityInfo) override; |
| 133 | ErrCode GetIncrementalFileHandles(const std::vector<std::string> &fileNames, | 129 | ErrCode GetIncrementalFileHandles(const std::vector<std::string> &fileNames, |
| 134 | - std::vector<int> &fdList, | 130 | + std::vector<FileOpenResult> &openResults) override; |
| 135 | - std::vector<int32_t> &errCodes) override; | ||
| 136 | public: | 131 | public: |
| 137 | explicit BackupExtExtension(const std::shared_ptr<Backup::ExtBackup> &extension, | 132 | explicit BackupExtExtension(const std::shared_ptr<Backup::ExtBackup> &extension, |
| 138 | const std::string &bundleName) : extension_(extension) | 133 | const std::string &bundleName) : extension_(extension) |
| @@ -424,7 +419,7 @@ private: | |||
| 424 | std::function<void(std::string, int)> ReportErrFileByProc(wptr<BackupExtExtension> obj, | 419 | std::function<void(std::string, int)> ReportErrFileByProc(wptr<BackupExtExtension> obj, |
| 425 | BackupRestoreScenario scenario); | 420 | BackupRestoreScenario scenario); |
| 426 | std::tuple<ErrCode, UniqueFd, UniqueFd> GetIncreFileHandleForNormalVersion(const std::string &fileName); | 421 | std::tuple<ErrCode, UniqueFd, UniqueFd> GetIncreFileHandleForNormalVersion(const std::string &fileName); |
| 427 | - std::tuple<ErrCode, UniqueFd> GetIncreFileHandleForUntarNormalVersion(const std::string &fileName); | 422 | + FileOpenResult GetIncreFileHandleForUntarNormalVersion(const std::string &fileName); |
| 428 | void RestoreOneBigFile(const std::string &path, const ExtManageInfo &item, const bool appendTargetPath); | 423 | void RestoreOneBigFile(const std::string &path, const ExtManageInfo &item, const bool appendTargetPath); |
| 429 | int DealIncreRestoreBigAndTarFile(); | 424 | int DealIncreRestoreBigAndTarFile(); |
| 430 | ErrCode IncrementalTarFileReady(const TarMap &bigFileInfo, const vector<struct ReportFileInfo> &srcFiles, | 425 | ErrCode IncrementalTarFileReady(const TarMap &bigFileInfo, const vector<struct ReportFileInfo> &srcFiles, |
| @@ -474,11 +469,11 @@ private: | |||
| 474 | set<string> DivideIncludesByCompatInfo(vector<string> &pathInclude, | 469 | set<string> DivideIncludesByCompatInfo(vector<string> &pathInclude, |
| 475 | const BJsonEntityExtensionConfig &usrConfig); | 470 | const BJsonEntityExtensionConfig &usrConfig); |
| 476 | void PathHasEl3OrEl4(const set<string> &includes, const vector<string> &excludes); | 471 | void PathHasEl3OrEl4(const set<string> &includes, const vector<string> &excludes); |
| 477 | - ErrCode ProcessReadysInfo(std::vector<std::shared_ptr<IFileInfo>> &allFiles, | 472 | + void ProcessReadysInfo(std::vector<std::shared_ptr<IFileInfo>> &allFiles, |
| 478 | - std::vector<std::string> &fileNames, | 473 | + std::vector<std::string> &fileNames, |
| 479 | - std::vector<int> &normalfds, | 474 | + std::vector<int> &normalfds, |
| 480 | - std::vector<std::string> &abnormalfileNames, | 475 | + std::vector<std::string> &abnormalfileNames, |
| 481 | - std::vector<int> &errCodes); | 476 | + std::vector<int> &errCodes); |
| 482 | private: | 477 | private: |
| 483 | TarMap GetIncrmentBigInfos(const vector<struct ReportFileInfo> &files); | 478 | TarMap GetIncrmentBigInfos(const vector<struct ReportFileInfo> &files); |
| 484 | void UpdateFileStat(std::string filePath, uint64_t fileSize); | 479 | void UpdateFileStat(std::string filePath, uint64_t fileSize); |
| @@ -564,8 +559,6 @@ private: | |||
| 564 | std::unordered_set<std::string> compatibleDirs_; // 无条件竞争风险, 多处调用存在先后顺序不会并发 | 559 | std::unordered_set<std::string> compatibleDirs_; // 无条件竞争风险, 多处调用存在先后顺序不会并发 |
| 565 | std::mutex updateFileStatLock_; | 560 | std::mutex updateFileStatLock_; |
| 566 | AncoRestoreResult ancoRestoreRes_; | 561 | AncoRestoreResult ancoRestoreRes_; |
| 567 | - std::map<pid_t, std::vector<UniqueFd>> fdLists_; | ||
| 568 | - std::mutex fdListsLock_; | ||
| 569 | std::mutex fileOpenLock_; | 562 | std::mutex fileOpenLock_; |
| 570 | std::condition_variable initManageJsonCon_; | 563 | std::condition_variable initManageJsonCon_; |
| 571 | std::mutex appendManageJsonLock_; | 564 | std::mutex appendManageJsonLock_; |
| @@ -211,30 +211,6 @@ static UniqueFd GetFileHandleForSpecialCloneCloud(const string &fileName) | |||
| 211 | return fd; | 211 | return fd; |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | -int32_t BackupExtExtension::CallbackEnter([[maybe_unused]] uint32_t code) | ||
| 215 | -{ | ||
| 216 | - return ERR_NONE; | ||
| 217 | -} | ||
| 218 | - | ||
| 219 | -int32_t BackupExtExtension::CallbackExit([[maybe_unused]] uint32_t code, [[maybe_unused]] int32_t result) | ||
| 220 | -{ | ||
| 221 | - switch (static_cast<IExtensionIpcCode>(code)) { | ||
| 222 | - case IExtensionIpcCode::COMMAND_GET_INCREMENTAL_FILE_HANDLES: { | ||
| 223 | - HILOGE("In COMMAND_GET_INCREMENTAL_FILE_HANDLES"); | ||
| 224 | - { | ||
| 225 | - std::unique_lock<std::mutex> lock_(fdListsLock_); | ||
| 226 | - auto tid = syscall(SYS_gettid); | ||
| 227 | - HILOGI("close fds of tid: %{public}ld", tid); | ||
| 228 | - fdLists_[tid].clear(); | ||
| 229 | - } | ||
| 230 | - break; | ||
| 231 | - } | ||
| 232 | - default: | ||
| 233 | - break; | ||
| 234 | - } | ||
| 235 | - return ERR_NONE; | ||
| 236 | -} | ||
| 237 | - | ||
| 238 | ErrCode BackupExtExtension::GetFileHandleWithUniqueFd(const std::string &fileName, | 214 | ErrCode BackupExtExtension::GetFileHandleWithUniqueFd(const std::string &fileName, |
| 239 | int32_t &getFileHandleErrCode, | 215 | int32_t &getFileHandleErrCode, |
| 240 | int &fd) | 216 | int &fd) |
| @@ -434,29 +410,27 @@ tuple<ErrCode, UniqueFd, UniqueFd> BackupExtExtension::GetIncreFileHandleForNorm | |||
| 434 | return {errCode, move(fd), move(reportFd)}; | 410 | return {errCode, move(fd), move(reportFd)}; |
| 435 | } | 411 | } |
| 436 | 412 | ||
| 437 | -tuple<ErrCode, UniqueFd> BackupExtExtension::GetIncreFileHandleForUntarNormalVersion( | 413 | +FileOpenResult BackupExtExtension::GetIncreFileHandleForUntarNormalVersion(const std::string &fileName) |
| 438 | - const std::string &fileName) | ||
| 439 | { | 414 | { |
| 440 | - HILOGI("extension: GetIncrementalFileHandle single to single Name:%{public}s", GetAnonyPath(fileName).c_str()); | ||
| 441 | - std::string realDir; | ||
| 442 | int32_t errCode = ERR_OK; | 415 | int32_t errCode = ERR_OK; |
| 443 | UniqueFd fd(BConstants::INVALID_FD_NUM); | 416 | UniqueFd fd(BConstants::INVALID_FD_NUM); |
| 444 | do { | 417 | do { |
| 445 | - std::string filePath = ""; | 418 | + std::string realDir; |
| 446 | - filePath = fileName; | 419 | + errCode = GetIncrementalFileHandleUntarPath(fileName, bundleName_, realDir); |
| 447 | - errCode = GetIncrementalFileHandleUntarPath(filePath, bundleName_, realDir); | ||
| 448 | if (errCode != ERR_OK) { | 420 | if (errCode != ERR_OK) { |
| 449 | - HILOGE("GetIncrementalFileHandleUntarPath failed, err = %{public}d", errCode); | 421 | + HILOGE("Failed to get incremental file handle path, fileName:%{public}s, errCode:%{public}d", |
| 422 | + GetAnonyPath(fileName).c_str(), errCode); | ||
| 450 | break; | 423 | break; |
| 451 | } | 424 | } |
| 452 | - fd = UniqueFd(open(realDir.data(), O_RDWR | O_CREAT | O_TRUNC | O_UNCACHE, S_IRUSR | S_IWUSR)); | 425 | + fd = UniqueFd(open(realDir.c_str(), O_RDWR | O_CREAT | O_TRUNC | O_UNCACHE, S_IRUSR | S_IWUSR)); |
| 453 | if (fd < 0) { | 426 | if (fd < 0) { |
| 454 | - HILOGE("Failed to open tar file = %{public}s, err = %{public}d", GetAnonyPath(realDir).c_str(), errno); | ||
| 455 | errCode = errno; | 427 | errCode = errno; |
| 428 | + HILOGE("Failed to open file, path:%{public}s, errno:%{public}d", GetAnonyPath(realDir).c_str(), | ||
| 429 | + errCode); | ||
| 456 | break; | 430 | break; |
| 457 | } | 431 | } |
| 458 | } while (0); | 432 | } while (0); |
| 459 | - return {errCode, move(fd)}; | 433 | + return FileOpenResult(errCode, std::move(fd)); |
| 460 | } | 434 | } |
| 461 | 435 | ||
| 462 | ErrCode BackupExtExtension::GetIncrementalFileHandle(const std::string &fileName, | 436 | ErrCode BackupExtExtension::GetIncrementalFileHandle(const std::string &fileName, |
| @@ -471,11 +445,11 @@ ErrCode BackupExtExtension::GetIncrementalFileHandle(const std::string &fileName | |||
| 471 | } | 445 | } |
| 472 | 446 | ||
| 473 | ErrCode BackupExtExtension::GetIncrementalFileHandles(const std::vector<std::string> &fileNames, | 447 | ErrCode BackupExtExtension::GetIncrementalFileHandles(const std::vector<std::string> &fileNames, |
| 474 | - std::vector<int> &fdList, | 448 | + std::vector<FileOpenResult> &openResults) |
| 475 | - std::vector<int32_t> &errCodes) | ||
| 476 | { | 449 | { |
| 477 | HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); | 450 | HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); |
| 478 | - HILOGI("GetIncrementalFileHandles enter fileNames"); | 451 | + HILOGI("Enter GetIncrementalFileHandles, input file count: %{public}zu, output container size: %{public}zu", |
| 452 | + fileNames.size(), openResults.size()); | ||
| 479 | try { | 453 | try { |
| 480 | if (extension_ == nullptr) { | 454 | if (extension_ == nullptr) { |
| 481 | HILOGE("Failed to get incremental file handle, extension is invalid"); | 455 | HILOGE("Failed to get incremental file handle, extension is invalid"); |
| @@ -502,8 +476,14 @@ ErrCode BackupExtExtension::GetIncrementalFileHandles(const std::vector<std::str | |||
| 502 | } | 476 | } |
| 503 | return BError(BError::Codes::EXT_INVAL_ARG).GetCode(); | 477 | return BError(BError::Codes::EXT_INVAL_ARG).GetCode(); |
| 504 | } | 478 | } |
| 505 | - GetIncrementalFileHandlesInner(fileNames, fdList, errCodes); | 479 | + { |
| 506 | - HILOGI("GetIncrementalFileHandles Exit"); | 480 | + std::unique_lock<std::mutex> lock_(fileOpenLock_); |
| 481 | + for (const auto &fileName : fileNames) { | ||
| 482 | + auto openResult = GetIncreFileHandleForUntarNormalVersion(fileName); | ||
| 483 | + openResults.push_back(openResult); | ||
| 484 | + } | ||
| 485 | + } | ||
| 486 | + HILOGI("Successfully processed %{public}zu files", fileNames.size()); | ||
| 507 | } catch (...) { | 487 | } catch (...) { |
| 508 | HILOGE("Failed to get incremental file handle"); | 488 | HILOGE("Failed to get incremental file handle"); |
| 509 | DoClear(); | 489 | DoClear(); |
| @@ -511,33 +491,6 @@ ErrCode BackupExtExtension::GetIncrementalFileHandles(const std::vector<std::str | |||
| 511 | } | 491 | } |
| 512 | return ERR_OK; | 492 | return ERR_OK; |
| 513 | } | 493 | } |
| 514 | - | ||
| 515 | -void BackupExtExtension::GetIncrementalFileHandlesInner(const std::vector<std::string> &fileNames, | ||
| 516 | - std::vector<int> &fdList, std::vector<int32_t> &errCodes) | ||
| 517 | -{ | ||
| 518 | - HITRACE_METER_NAME(HITRACE_TAG_FILEMANAGEMENT, __PRETTY_FUNCTION__); | ||
| 519 | - std::vector<UniqueFd> tmpfdList; | ||
| 520 | - { | ||
| 521 | - std::unique_lock<std::mutex> lock_(fileOpenLock_); | ||
| 522 | - for (const auto &fileName : fileNames) { | ||
| 523 | - auto [errCode, fdval] = GetIncreFileHandleForUntarNormalVersion(fileName); | ||
| 524 | - if (fdval < 0) { | ||
| 525 | - HILOGE("GetIncrementalFileHandlesInner fail, fileName:%{public}s, errCode:%{public}d", | ||
| 526 | - GetAnonyPath(fileName).c_str(), errCode); | ||
| 527 | - } | ||
| 528 | - fdList.push_back(fdval.Get()); | ||
| 529 | - errCodes.push_back(errCode); | ||
| 530 | - tmpfdList.push_back(std::move(fdval)); | ||
| 531 | - } | ||
| 532 | - } | ||
| 533 | - { | ||
| 534 | - std::unique_lock<std::mutex> lock_(fdListsLock_); | ||
| 535 | - auto tid = syscall(SYS_gettid); | ||
| 536 | - HILOGI("save fds of tid: %{public}ld", tid); | ||
| 537 | - fdLists_[tid] = std::move(tmpfdList); | ||
| 538 | - } | ||
| 539 | -} | ||
| 540 | - | ||
| 541 | 494 | ||
| 542 | tuple<ErrCode, UniqueFd, UniqueFd> BackupExtExtension::GetIncrementalFileHandle(const string &fileName) | 495 | tuple<ErrCode, UniqueFd, UniqueFd> BackupExtExtension::GetIncrementalFileHandle(const string &fileName) |
| 543 | { | 496 | { |
| @@ -770,13 +723,12 @@ ErrCode BackupExtExtension::ReportAncoAppFileReady(const string &filename, const | |||
| 770 | return proxy->AppAncoFileReady(filename, filePath, needDelete); | 723 | return proxy->AppAncoFileReady(filename, filePath, needDelete); |
| 771 | } | 724 | } |
| 772 | 725 | ||
| 773 | -ErrCode BackupExtExtension::ProcessReadysInfo(std::vector<std::shared_ptr<IFileInfo>> &allFiles, | 726 | +void BackupExtExtension::ProcessReadysInfo(std::vector<std::shared_ptr<IFileInfo>> &allFiles, |
| 774 | - vector<string> &fileNames, | 727 | + vector<string> &fileNames, |
| 775 | - vector<int> &normalfds, | 728 | + vector<int> &normalfds, |
| 776 | - vector<string> &abnormalfileNames, | 729 | + vector<string> &abnormalfileNames, |
| 777 | - vector<int> &errCodes) | 730 | + vector<int> &errCodes) |
| 778 | { | 731 | { |
| 779 | - ErrCode ret = ERR_OK; | ||
| 780 | for (auto it = allFiles.begin(); it != allFiles.end();) { | 732 | for (auto it = allFiles.begin(); it != allFiles.end();) { |
| 781 | const string &filePath = (*it)->filePath_; | 733 | const string &filePath = (*it)->filePath_; |
| 782 | std::string newPath = BExcepUltils::Canonicalize(filePath); | 734 | std::string newPath = BExcepUltils::Canonicalize(filePath); |
| @@ -791,7 +743,6 @@ ErrCode BackupExtExtension::ProcessReadysInfo(std::vector<std::shared_ptr<IFileI | |||
| 791 | } | 743 | } |
| 792 | abnormalfileNames.push_back(FileInfoToString(*it)); | 744 | abnormalfileNames.push_back(FileInfoToString(*it)); |
| 793 | errCodes.push_back(errCode); | 745 | errCodes.push_back(errCode); |
| 794 | - ret = errCode; | ||
| 795 | } else { | 746 | } else { |
| 796 | fileNames.push_back(FileInfoToString(*it)); | 747 | fileNames.push_back(FileInfoToString(*it)); |
| 797 | normalfds.push_back(fdval); | 748 | normalfds.push_back(fdval); |
| @@ -799,9 +750,8 @@ ErrCode BackupExtExtension::ProcessReadysInfo(std::vector<std::shared_ptr<IFileI | |||
| 799 | } | 750 | } |
| 800 | it++; | 751 | it++; |
| 801 | } | 752 | } |
| 802 | - return ret; | ||
| 803 | } | 753 | } |
| 804 | - | 754 | + |
| 805 | ErrCode BackupExtExtension::ReportAppFileReadys(std::vector<std::shared_ptr<IFileInfo>>& allFiles) | 755 | ErrCode BackupExtExtension::ReportAppFileReadys(std::vector<std::shared_ptr<IFileInfo>>& allFiles) |
| 806 | { | 756 | { |
| 807 | HILOGD("ReportAppFileReadys enter filenameSize: %{public}zu", allFiles.size()); | 757 | HILOGD("ReportAppFileReadys enter filenameSize: %{public}zu", allFiles.size()); |
| @@ -809,10 +759,8 @@ ErrCode BackupExtExtension::ReportAppFileReadys(std::vector<std::shared_ptr<IFil | |||
| 809 | vector<int> normalfds = {}; | 759 | vector<int> normalfds = {}; |
| 810 | vector<string> abnormalfileNames = {}; | 760 | vector<string> abnormalfileNames = {}; |
| 811 | vector<int> errCodes = {}; | 761 | vector<int> errCodes = {}; |
| 812 | - ErrCode errCode = ProcessReadysInfo(allFiles, fileNames, normalfds, abnormalfileNames, errCodes); | 762 | + ProcessReadysInfo(allFiles, fileNames, normalfds, abnormalfileNames, errCodes); |
| 813 | - if (errCode != ERR_OK) { | 763 | + |
| 814 | - return errCode; | ||
| 815 | - } | ||
| 816 | auto proxy = ServiceClient::GetInstance(); | 764 | auto proxy = ServiceClient::GetInstance(); |
| 817 | if (proxy == nullptr) { | 765 | if (proxy == nullptr) { |
| 818 | HILOGE("ServiceClient is null"); | 766 | HILOGE("ServiceClient is null"); |
| @@ -821,12 +769,12 @@ ErrCode BackupExtExtension::ReportAppFileReadys(std::vector<std::shared_ptr<IFil | |||
| 821 | } | 769 | } |
| 822 | return static_cast<int32_t>(BError::Codes::EXT_CLIENT_IS_NULL); | 770 | return static_cast<int32_t>(BError::Codes::EXT_CLIENT_IS_NULL); |
| 823 | } | 771 | } |
| 824 | - | 772 | + |
| 825 | int reportRsWithoutFd = ERR_OK; | 773 | int reportRsWithoutFd = ERR_OK; |
| 826 | if (!abnormalfileNames.empty()) { | 774 | if (!abnormalfileNames.empty()) { |
| 827 | reportRsWithoutFd = proxy->AppFileReadysWithoutFd(abnormalfileNames, errCodes); | 775 | reportRsWithoutFd = proxy->AppFileReadysWithoutFd(abnormalfileNames, errCodes); |
| 828 | } | 776 | } |
| 829 | - | 777 | + |
| 830 | vector<int> temp(normalfds.size(), ERR_OK); | 778 | vector<int> temp(normalfds.size(), ERR_OK); |
| 831 | HILOGI("send get file Names length %{public}zu", fileNames.size()); | 779 | HILOGI("send get file Names length %{public}zu", fileNames.size()); |
| 832 | int reportRs = proxy->AppFileReadys(fileNames, normalfds, temp); | 780 | int reportRs = proxy->AppFileReadys(fileNames, normalfds, temp); |
| @@ -95,17 +95,7 @@ public: | |||
| 95 | 95 | ||
| 96 | ErrCode IncrementalRestoreOnFileReadys(const std::string &bundleName, | 96 | ErrCode IncrementalRestoreOnFileReadys(const std::string &bundleName, |
| 97 | const std::vector<std::string> &fileNames, | 97 | const std::vector<std::string> &fileNames, |
| 98 | - const std::vector<int> &fdList, | 98 | + const std::vector<FileOpenResult> &openResults) override; |
| 99 | - const std::vector<int> &manifestfdList, | ||
| 100 | - const std::vector<int32_t> &errCodes) override; | ||
| 101 | - ErrCode IncrementalRestoreOnFileReadysWithoutRp(const std::string &bundleName, | ||
| 102 | - const std::vector<std::string> &fileNames, | ||
| 103 | - const std::vector<int> &fdList, | ||
| 104 | - const std::vector<int32_t> &errCodes) override; | ||
| 105 | - | ||
| 106 | - ErrCode IncrementalRestoreOnFileReadysWithoutFd(const std::string &bundleName, | ||
| 107 | - const std::vector<std::string> &fileListWithoutfd, | ||
| 108 | - const std::vector<int32_t> &errCodes) override; | ||
| 109 | 99 | ||
| 110 | ErrCode SetBatchSize(uint32_t size) override; | 100 | ErrCode SetBatchSize(uint32_t size) override; |
| 111 | 101 | ||
| @@ -135,9 +125,7 @@ private: | |||
| 135 | const std::vector<int32_t> &errCodes); | 125 | const std::vector<int32_t> &errCodes); |
| 136 | void AddIncrementalFileToBatch(const std::string &bundleName, | 126 | void AddIncrementalFileToBatch(const std::string &bundleName, |
| 137 | const std::vector<std::string> &fileNames, | 127 | const std::vector<std::string> &fileNames, |
| 138 | - const std::vector<int> &fds, | 128 | + const std::vector<FileOpenResult> &openResults); |
| 139 | - const std::vector<int> &manifestFds, | ||
| 140 | - const std::vector<int32_t> &errCodes); | ||
| 141 | 129 | ||
| 142 | Scenario scenario_ {Scenario::UNDEFINED}; | 130 | Scenario scenario_ {Scenario::UNDEFINED}; |
| 143 | BSessionBackup::Callbacks callbacksBackup_; | 131 | BSessionBackup::Callbacks callbacksBackup_; |
| @@ -16,6 +16,8 @@ | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | + | ||
| 20 | + | ||
| 19 | 21 | ||
| 20 | namespace OHOS { | 22 | namespace OHOS { |
| 21 | namespace FileManagement { | 23 | namespace FileManagement { |
| @@ -53,6 +55,130 @@ BFileInfo *BFileInfo::Unmarshalling(Parcel &parcel) | |||
| 53 | } | 55 | } |
| 54 | return nullptr; | 56 | return nullptr; |
| 55 | } | 57 | } |
| 58 | + | ||
| 59 | +int FileOpenResult::GetReleasedFd() const | ||
| 60 | +{ | ||
| 61 | + return fd ? fd->Release() : -1; | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +int FileOpenResult::GetReleasedManifestFd() const | ||
| 65 | +{ | ||
| 66 | + return manifestFd ? manifestFd->Release() : -1; | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +std::string FileOpenResult::ToString() | ||
| 70 | +{ | ||
| 71 | + std::ostringstream oss; | ||
| 72 | + oss << "FileOpenResult { " | ||
| 73 | + << "errCode=" << errCode << ", " | ||
| 74 | + << "fd=" << (fd ? fd->Get() : -1) << ", " | ||
| 75 | + << "manifestFd=" << (manifestFd ? manifestFd->Get() : -1) << " }"; | ||
| 76 | + return oss.str(); | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +bool FileOpenResult::Marshalling(Parcel &parcel) const | ||
| 80 | +{ | ||
| 81 | + auto messageParcel = static_cast<MessageParcel *>(&parcel); | ||
| 82 | + if (!messageParcel) { | ||
| 83 | + HILOGE("Failed to cast parcel to MessageParcel"); | ||
| 84 | + return false; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + if (!messageParcel->WriteInt32(errCode)) { | ||
| 88 | + HILOGE("Failed to write error code: %d", errCode); | ||
| 89 | + return false; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + int isMainFdValid = (fd != nullptr && fd->Get() >= 0) ? 1 : 0; | ||
| 93 | + if (!messageParcel->WriteInt32(isMainFdValid)) { | ||
| 94 | + HILOGE("Failed to write main file descriptor validity"); | ||
| 95 | + return false; | ||
| 96 | + } | ||
| 97 | + if (isMainFdValid) { | ||
| 98 | + if (!messageParcel->WriteFileDescriptor(fd->Get())) { | ||
| 99 | + HILOGE("Failed to write main file descriptor: fd=%d", fd->Get()); | ||
| 100 | + return false; | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + int isManifestFdValid = (manifestFd != nullptr && manifestFd->Get() >= 0) ? 1 : 0; | ||
| 105 | + if (!messageParcel->WriteInt32(isManifestFdValid)) { | ||
| 106 | + HILOGE("Failed to write manifest file descriptor validity"); | ||
| 107 | + return false; | ||
| 108 | + } | ||
| 109 | + if (isManifestFdValid) { | ||
| 110 | + if (!messageParcel->WriteFileDescriptor(manifestFd->Get())) { | ||
| 111 | + HILOGE("Failed to write manifest file descriptor: fd=%d", manifestFd->Get()); | ||
| 112 | + return false; | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + return true; | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +bool FileOpenResult::ReadFromParcel(Parcel &parcel) | ||
| 120 | +{ | ||
| 121 | + auto messageParcel = static_cast<MessageParcel *>(&parcel); | ||
| 122 | + if (!messageParcel) { | ||
| 123 | + HILOGE("Failed to cast parcel to MessageParcel"); | ||
| 124 | + return false; | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + if (!messageParcel->ReadInt32(errCode)) { | ||
| 128 | + HILOGE("Failed to read error code from parcel"); | ||
| 129 | + return false; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + int mainFdVal = -1; | ||
| 133 | + int isMainFdValid = 0; | ||
| 134 | + if (!messageParcel->ReadInt32(isMainFdValid)) { | ||
| 135 | + HILOGE("Failed to read main file descriptor validity"); | ||
| 136 | + return false; | ||
| 137 | + } | ||
| 138 | + if (isMainFdValid) { | ||
| 139 | + mainFdVal = messageParcel->ReadFileDescriptor(); | ||
| 140 | + if (mainFdVal < 0) { | ||
| 141 | + HILOGE("Failed to read main file descriptor from parcel"); | ||
| 142 | + return false; | ||
| 143 | + } | ||
| 144 | + fd = std::make_shared<UniqueFd>(mainFdVal); | ||
| 145 | + } else { | ||
| 146 | + fd = nullptr; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + int manifestFdVal = -1; | ||
| 150 | + int isManifestFdValid = 0; | ||
| 151 | + if (!messageParcel->ReadInt32(isManifestFdValid)) { | ||
| 152 | + HILOGE("Failed to read manifest file descriptor validity"); | ||
| 153 | + return false; | ||
| 154 | + } | ||
| 155 | + if (isManifestFdValid) { | ||
| 156 | + manifestFdVal = messageParcel->ReadFileDescriptor(); | ||
| 157 | + if (manifestFdVal < 0) { | ||
| 158 | + HILOGE("Failed to read manifest file descriptor from parcel"); | ||
| 159 | + return false; | ||
| 160 | + } | ||
| 161 | + manifestFd = std::make_shared<UniqueFd>(manifestFdVal); | ||
| 162 | + } else { | ||
| 163 | + manifestFd = nullptr; | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + return true; | ||
| 167 | +} | ||
| 168 | + | ||
| 169 | +FileOpenResult *FileOpenResult::Unmarshalling(Parcel &parcel) | ||
| 170 | +{ | ||
| 171 | + try { | ||
| 172 | + auto result = make_unique<FileOpenResult>(); | ||
| 173 | + if (!result->ReadFromParcel(parcel)) { | ||
| 174 | + return nullptr; | ||
| 175 | + } | ||
| 176 | + return result.release(); | ||
| 177 | + } catch (const bad_alloc &e) { | ||
| 178 | + HILOGE("Failed to unmarshall FileOpenResult because of %{public}s", e.what()); | ||
| 179 | + } | ||
| 180 | + return nullptr; | ||
| 181 | +} | ||
| 56 | } // namespace Backup | 182 | } // namespace Backup |
| 57 | } // namespace FileManagement | 183 | } // namespace FileManagement |
| 58 | } // namespace OHOS | 184 | } // namespace OHOS |
| @@ -26,52 +26,36 @@ using namespace std; | |||
| 26 | 26 | ||
| 27 | void ServiceReverse::FlushPendingIncrementalFiles() | 27 | void ServiceReverse::FlushPendingIncrementalFiles() |
| 28 | { | 28 | { |
| 29 | - HILOGI("FlushPendingIncrementalFiles %{public}zu ok", pendingFiles_.size()); | 29 | + std::vector<BackupFile> files; |
| 30 | - std::vector<BackupFile> filesToFlush; | ||
| 31 | - std::vector<BackupFile> errfilesToFlush; | ||
| 32 | { | 30 | { |
| 33 | std::lock_guard<std::mutex> lock(addIncrementalBatchLock_); | 31 | std::lock_guard<std::mutex> lock(addIncrementalBatchLock_); |
| 34 | - if (pendingIncrementalFiles_.empty()) { | 32 | + files = std::move(pendingIncrementalFiles_); |
| 35 | - return; | 33 | + HILOGI("FlushPendingIncrementalFiles %{public}zu ok", files.size()); |
| 36 | - } | ||
| 37 | - for (const auto &file : pendingIncrementalFiles_) { | ||
| 38 | - if (SUCCEEDED(file.errCode)) { | ||
| 39 | - filesToFlush.push_back(file); | ||
| 40 | - } else { | ||
| 41 | - errfilesToFlush.push_back(file); | ||
| 42 | - } | ||
| 43 | - } | ||
| 44 | - pendingIncrementalFiles_.clear(); | ||
| 45 | } | 34 | } |
| 46 | - if (!callbacksIncrementalRestore_.onFileReadyBatch) { | 35 | + if (!files.empty() && callbacksIncrementalRestore_.onFileReadyBatch) { |
| 47 | - HILOGE("callback is nullptr"); | 36 | + callbacksIncrementalRestore_.onFileReadyBatch(files); |
| 48 | - return; | ||
| 49 | - } | ||
| 50 | - if (!filesToFlush.empty()) { | ||
| 51 | - callbacksIncrementalRestore_.onFileReadyBatch(filesToFlush); | ||
| 52 | - } | ||
| 53 | - if (!errfilesToFlush.empty()) { | ||
| 54 | - callbacksIncrementalRestore_.onFileReadyBatch(errfilesToFlush); | ||
| 55 | } | 37 | } |
| 56 | } | 38 | } |
| 57 | 39 | ||
| 58 | -void ServiceReverse::AddIncrementalFileToBatch(const std::string &bundleName, const std::vector<std::string> &fileNames, | 40 | +void ServiceReverse::AddIncrementalFileToBatch(const std::string &bundleName, |
| 59 | - const std::vector<int> &fds, const std::vector<int> &manifestFds, | 41 | + const std::vector<std::string> &fileNames, |
| 60 | - const std::vector<int32_t> &errCodes) | 42 | + const std::vector<FileOpenResult> &openResults) |
| 61 | { | 43 | { |
| 62 | bool needFlush = false; | 44 | bool needFlush = false; |
| 63 | { | 45 | { |
| 64 | std::lock_guard<std::mutex> lock(addIncrementalBatchLock_); | 46 | std::lock_guard<std::mutex> lock(addIncrementalBatchLock_); |
| 65 | - for (size_t i = 0; i < fileNames.size(); ++i) { | 47 | + for (size_t i = 0; i < openResults.size(); ++i) { |
| 66 | BackupFile file; | 48 | BackupFile file; |
| 67 | file.bundleName = bundleName; | 49 | file.bundleName = bundleName; |
| 68 | file.uri = fileNames[i]; | 50 | file.uri = fileNames[i]; |
| 69 | - file.fd = fds[i]; | 51 | + file.fd = openResults[i].GetReleasedFd(); |
| 70 | - file.manifestFd = manifestFds[i]; | 52 | + file.manifestFd = openResults[i].GetReleasedManifestFd(); |
| 71 | - file.errCode = errCodes[i]; | 53 | + file.errCode = openResults[i].errCode; |
| 72 | pendingIncrementalFiles_.push_back(file); | 54 | pendingIncrementalFiles_.push_back(file); |
| 73 | } | 55 | } |
| 74 | needFlush = (pendingIncrementalFiles_.size() >= batchSize_); | 56 | needFlush = (pendingIncrementalFiles_.size() >= batchSize_); |
| 57 | + HILOGI("Current pending files: %{public}zu, batchSize: %{public}u, needFlush: %{public}d", | ||
| 58 | + pendingIncrementalFiles_.size(), batchSize_, needFlush); | ||
| 75 | } | 59 | } |
| 76 | if (needFlush) { | 60 | if (needFlush) { |
| 77 | FlushPendingIncrementalFiles(); | 61 | FlushPendingIncrementalFiles(); |
| @@ -245,42 +229,15 @@ ErrCode ServiceReverse::IncrementalRestoreOnFileReadyWithoutFd(const std::string | |||
| 245 | return BError(BError::Codes::OK); | 229 | return BError(BError::Codes::OK); |
| 246 | } | 230 | } |
| 247 | 231 | ||
| 248 | -ErrCode ServiceReverse::IncrementalRestoreOnFileReadysWithoutFd(const std::string &bundleName, | ||
| 249 | - const std::vector<std::string> &fileNames, | ||
| 250 | - const std::vector<int32_t> &errCodes) | ||
| 251 | -{ | ||
| 252 | - if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onFileReadyBatch) { | ||
| 253 | - HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); | ||
| 254 | - return BError(BError::Codes::OK); | ||
| 255 | - } | ||
| 256 | - const std::vector<int> invalidFds(fileNames.size(), INVALID_FD); | ||
| 257 | - AddIncrementalFileToBatch(bundleName, fileNames, invalidFds, invalidFds, errCodes); | ||
| 258 | - return BError(BError::Codes::OK); | ||
| 259 | -} | ||
| 260 | - | ||
| 261 | ErrCode ServiceReverse::IncrementalRestoreOnFileReadys(const std::string &bundleName, | 232 | ErrCode ServiceReverse::IncrementalRestoreOnFileReadys(const std::string &bundleName, |
| 262 | const std::vector<std::string> &fileNames, | 233 | const std::vector<std::string> &fileNames, |
| 263 | - const std::vector<int> &fdList, | 234 | + const std::vector<FileOpenResult> &openResults) |
| 264 | - const std::vector<int> &manifestfdList, | ||
| 265 | - const std::vector<int32_t> &errCodes) | ||
| 266 | { | 235 | { |
| 267 | if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onFileReadyBatch) { | 236 | if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onFileReadyBatch) { |
| 268 | HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); | 237 | HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); |
| 269 | return BError(BError::Codes::OK); | 238 | return BError(BError::Codes::OK); |
| 270 | } | 239 | } |
| 271 | - AddIncrementalFileToBatch(bundleName, fileNames, fdList, manifestfdList, errCodes); | 240 | + AddIncrementalFileToBatch(bundleName, fileNames, openResults); |
| 272 | - return BError(BError::Codes::OK); | ||
| 273 | -} | ||
| 274 | - | ||
| 275 | -ErrCode ServiceReverse::IncrementalRestoreOnFileReadysWithoutRp(const std::string &bundleName, | ||
| 276 | - const std::vector<std::string> &fileNames, const std::vector<int> &fdList, const std::vector<int32_t> &errCodes) | ||
| 277 | -{ | ||
| 278 | - if (scenario_ != Scenario::RESTORE || !callbacksIncrementalRestore_.onFileReadyBatch) { | ||
| 279 | - HILOGE("Error scenario or callback is nullptr, scenario = %{public}d", scenario_); | ||
| 280 | - return BError(BError::Codes::OK); | ||
| 281 | - } | ||
| 282 | - const std::vector<int> invalidFds(fileNames.size(), INVALID_FD); | ||
| 283 | - AddIncrementalFileToBatch(bundleName, fileNames, fdList, invalidFds, errCodes); | ||
| 284 | return BError(BError::Codes::OK); | 241 | return BError(BError::Codes::OK); |
| 285 | } | 242 | } |
| 286 | 243 | ||
| @@ -24,37 +24,21 @@ using namespace std; | |||
| 24 | 24 | ||
| 25 | void ServiceReverse::FlushPendingFiles() | 25 | void ServiceReverse::FlushPendingFiles() |
| 26 | { | 26 | { |
| 27 | - HILOGI("FlushPendingFiles %{public}zu ok", pendingFiles_.size()); | 27 | + std::vector<BackupFile> files; |
| 28 | - std::vector<BackupFile> filesToFlush; | ||
| 29 | - std::vector<BackupFile> errfilesToFlush; | ||
| 30 | { | 28 | { |
| 31 | std::lock_guard<std::mutex> lock(addBatchLock_); | 29 | std::lock_guard<std::mutex> lock(addBatchLock_); |
| 32 | - if (pendingFiles_.empty()) { | 30 | + files = std::move(pendingFiles_); |
| 33 | - return; | 31 | + HILOGI("FlushPendingFiles %{public}zu ok", files.size()); |
| 34 | - } | ||
| 35 | - for (const auto &file : pendingFiles_) { | ||
| 36 | - if (SUCCEEDED(file.errCode)) { | ||
| 37 | - filesToFlush.push_back(file); | ||
| 38 | - } else { | ||
| 39 | - errfilesToFlush.push_back(file); | ||
| 40 | - } | ||
| 41 | - } | ||
| 42 | - pendingFiles_.clear(); | ||
| 43 | } | 32 | } |
| 44 | - if (!callbacksBackup_.onFileReadyBatch) { | 33 | + if (!files.empty() && callbacksBackup_.onFileReadyBatch) { |
| 45 | - HILOGE("callback is nullptr"); | 34 | + callbacksBackup_.onFileReadyBatch(files); |
| 46 | - return; | ||
| 47 | - } | ||
| 48 | - if (!filesToFlush.empty()) { | ||
| 49 | - callbacksBackup_.onFileReadyBatch(filesToFlush); | ||
| 50 | - } | ||
| 51 | - if (!errfilesToFlush.empty()) { | ||
| 52 | - callbacksBackup_.onFileReadyBatch(errfilesToFlush); | ||
| 53 | } | 35 | } |
| 54 | } | 36 | } |
| 55 | 37 | ||
| 56 | -void ServiceReverse::AddFileToBatch(const std::string &bundleName, const std::vector<std::string> &fileNames, | 38 | +void ServiceReverse::AddFileToBatch(const std::string &bundleName, |
| 57 | - const std::vector<int> &fds, const std::vector<int> &manifestFds, | 39 | + const std::vector<std::string> &fileNames, |
| 40 | + const std::vector<int> &fds, | ||
| 41 | + const std::vector<int> &manifestFds, | ||
| 58 | const std::vector<int32_t> &errCodes) | 42 | const std::vector<int32_t> &errCodes) |
| 59 | { | 43 | { |
| 60 | bool needFlush = false; | 44 | bool needFlush = false; |
| @@ -70,6 +54,8 @@ void ServiceReverse::AddFileToBatch(const std::string &bundleName, const std::ve | |||
| 70 | pendingFiles_.push_back(file); | 54 | pendingFiles_.push_back(file); |
| 71 | } | 55 | } |
| 72 | needFlush = (pendingFiles_.size() >= batchSize_); | 56 | needFlush = (pendingFiles_.size() >= batchSize_); |
| 57 | + HILOGI("Current pending files: %{public}zu, batchSize: %{public}u, needFlush: %{public}d", pendingFiles_.size(), | ||
| 58 | + batchSize_, needFlush); | ||
| 73 | } | 59 | } |
| 74 | if (needFlush) { | 60 | if (needFlush) { |
| 75 | FlushPendingFiles(); | 61 | FlushPendingFiles(); |
| @@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + | ||
| 21 | 22 | ||
| 22 | 23 | ||
| 23 | 24 | ||
| @@ -39,6 +40,34 @@ struct BFileInfo : public Parcelable { | |||
| 39 | bool Marshalling(Parcel &parcel) const override; | 40 | bool Marshalling(Parcel &parcel) const override; |
| 40 | static BFileInfo *Unmarshalling(Parcel &parcel); | 41 | static BFileInfo *Unmarshalling(Parcel &parcel); |
| 41 | }; | 42 | }; |
| 43 | + | ||
| 44 | +struct FileOpenResult : public Parcelable { | ||
| 45 | + int32_t errCode = 0; | ||
| 46 | + std::shared_ptr<UniqueFd> fd; | ||
| 47 | + std::shared_ptr<UniqueFd> manifestFd; | ||
| 48 | + | ||
| 49 | + FileOpenResult() : errCode(0), fd(nullptr), manifestFd(nullptr) {} | ||
| 50 | + explicit FileOpenResult(int32_t errCode) : errCode(errCode), fd(nullptr), manifestFd(nullptr) {} | ||
| 51 | + FileOpenResult(int32_t errCode, UniqueFd fd) | ||
| 52 | + : errCode(errCode), fd(std::make_shared<UniqueFd>(std::move(fd))), manifestFd(nullptr) | ||
| 53 | + { | ||
| 54 | + } | ||
| 55 | + FileOpenResult(int32_t errCode, UniqueFd fd, UniqueFd manifestFd) | ||
| 56 | + : errCode(errCode), | ||
| 57 | + fd(std::make_shared<UniqueFd>(std::move(fd))), | ||
| 58 | + manifestFd(std::make_shared<UniqueFd>(std::move(manifestFd))) | ||
| 59 | + { | ||
| 60 | + } | ||
| 61 | + ~FileOpenResult() override = default; | ||
| 62 | + | ||
| 63 | + int GetReleasedFd() const; | ||
| 64 | + int GetReleasedManifestFd() const; | ||
| 65 | + std::string ToString(); | ||
| 66 | + | ||
| 67 | + bool ReadFromParcel(Parcel &parcel); | ||
| 68 | + bool Marshalling(Parcel &parcel) const override; | ||
| 69 | + static FileOpenResult *Unmarshalling(Parcel &parcel); | ||
| 70 | +}; | ||
| 42 | } // namespace OHOS::FileManagement::Backup | 71 | } // namespace OHOS::FileManagement::Backup |
| 43 | 72 | ||
| 44 | 73 | ||
| @@ -14,7 +14,7 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | package OHOS.FileManagement.Backup; | 16 | package OHOS.FileManagement.Backup; |
| 17 | -option_stub_hooks on; | 17 | +sequenceable BackupFileInfo..OHOS.FileManagement.Backup.FileOpenResult; |
| 18 | interface OHOS.FileManagement.Backup.IExtension{ | 18 | interface OHOS.FileManagement.Backup.IExtension{ |
| 19 | [ipccode 1] void GetFileHandleWithUniqueFd([in] String fileName, [out] int getFileHandleErrCode, [out] FileDescriptor fd); | 19 | [ipccode 1] void GetFileHandleWithUniqueFd([in] String fileName, [out] int getFileHandleErrCode, [out] FileDescriptor fd); |
| 20 | [ipccode 2] void HandleClear(); | 20 | [ipccode 2] void HandleClear(); |
| @@ -36,6 +36,5 @@ interface OHOS.FileManagement.Backup.IExtension{ | |||
| 36 | [ipccode 17] void HandleGetCompatibilityInfo([in] String extInfo, [in] int scenario, [in] boolean isExist, | 36 | [ipccode 17] void HandleGetCompatibilityInfo([in] String extInfo, [in] int scenario, [in] boolean isExist, |
| 37 | [out] String compatibilityInfo); | 37 | [out] String compatibilityInfo); |
| 38 | [ipccode 18] void GetIncrementalRpFileHandle([in] String fileName, [out] int fdErrCode); | 38 | [ipccode 18] void GetIncrementalRpFileHandle([in] String fileName, [out] int fdErrCode); |
| 39 | - [ipccode 19, ipcincapacity 131071] void GetIncrementalFileHandles([in] String[] fileNames, [out] FileDescriptor[] fdList, [out] int[] errs); | 39 | + [ipccode 19, ipcincapacity 131071] void GetIncrementalFileHandles([in] String[] fileNames, [out] FileOpenResult[] openResults); |
| 40 | - | ||
| 41 | } | 40 | } |
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | package OHOS.FileManagement.Backup; | 16 | package OHOS.FileManagement.Backup; |
| 17 | import ServiceReverseType; | 17 | import ServiceReverseType; |
| 18 | +sequenceable BackupFileInfo..OHOS.FileManagement.Backup.FileOpenResult; | ||
| 18 | interface OHOS.FileManagement.Backup.IServiceReverse{ | 19 | interface OHOS.FileManagement.Backup.IServiceReverse{ |
| 19 | [ipccode 999] void BackupOnBundleStarted([in] int backupOnBundleStartedErrCode, [in] String bundleName); | 20 | [ipccode 999] void BackupOnBundleStarted([in] int backupOnBundleStartedErrCode, [in] String bundleName); |
| 20 | [ipccode 1] void BackupOnFileReady([in] String bundleName, [in] String fileName, [in] FileDescriptor fd, | 21 | [ipccode 1] void BackupOnFileReady([in] String bundleName, [in] String fileName, [in] FileDescriptor fd, |
| @@ -74,17 +75,8 @@ interface OHOS.FileManagement.Backup.IServiceReverse{ | |||
| 74 | [ipccode 31] void IncrementalRestoreOnMigrateResult([in] int incrementalRestoreOnMigrateResultErrCode, [in] String bundleName); | 75 | [ipccode 31] void IncrementalRestoreOnMigrateResult([in] int incrementalRestoreOnMigrateResultErrCode, [in] String bundleName); |
| 75 | [ipccode 32, ipcincapacity 131071] void IncrementalRestoreOnFileReadys([in] String bundleName, | 76 | [ipccode 32, ipcincapacity 131071] void IncrementalRestoreOnFileReadys([in] String bundleName, |
| 76 | [in] String[] fileNames, | 77 | [in] String[] fileNames, |
| 77 | - [in] FileDescriptor[] fileList, | 78 | + [in] FileOpenResult[] openResults); |
| 78 | - [in] FileDescriptor[] manifestfdList, | 79 | + [ipccode 33] void SetBatchSize([in] unsigned int batchSize); |
| 79 | - [in] int[] errCodes); | 80 | + [ipccode 34, ipcincapacity 131071] void BackupOnFileReadys([in] String bundleName, [in] String[] fileNames, [in] FileDescriptor[] fds, [in] int[] errCodes); |
| 80 | - [ipccode 33, ipcincapacity 131071] void IncrementalRestoreOnFileReadysWithoutRp([in] String bundleName, | 81 | + [ipccode 35, ipcincapacity 131071] void BackupOnFileReadysWithoutFd([in] String bundleName, [in] String[] fileNames, [in] int[] errCodes); |
| 81 | - [in] String[] fileNames, | ||
| 82 | - [in] FileDescriptor[] fileList, | ||
| 83 | - [in] int[] errCodes); | ||
| 84 | - [ipccode 34, ipcincapacity 131071] void IncrementalRestoreOnFileReadysWithoutFd([in] String bundleName, | ||
| 85 | - [in] String[] fileListWithoutfd, | ||
| 86 | - [in] int[] errCodes); | ||
| 87 | - [ipccode 35] void SetBatchSize([in] unsigned int batchSize); | ||
| 88 | - [ipccode 36, ipcincapacity 131071] void BackupOnFileReadys([in] String bundleName, [in] String[] fileNames, [in] FileDescriptor[] fds, [in] int[] errCodes); | ||
| 89 | - [ipccode 37, ipcincapacity 131071] void BackupOnFileReadysWithoutFd([in] String bundleName, [in] String[] fileNames, [in] int[] errCodes); | ||
| 90 | } | 82 | } |
| @@ -142,21 +142,9 @@ public: | |||
| 142 | ErrCode SAResultReport(const std::string bundleName, const std::string resultInfo, | 142 | ErrCode SAResultReport(const std::string bundleName, const std::string resultInfo, |
| 143 | const ErrCode errCode, const BackupRestoreScenario sennario); | 143 | const ErrCode errCode, const BackupRestoreScenario sennario); |
| 144 | void StartGetFdTask(std::string bundleName, wptr<Service> ptr); | 144 | void StartGetFdTask(std::string bundleName, wptr<Service> ptr); |
| 145 | - void IncrementalRestoreOnFileReadys(const std::string &bundleName, | ||
| 146 | - const std::vector<std::string> &fileNames, const std::vector<UniqueFd> &fdList, | ||
| 147 | - const std::vector<UniqueFd> &manifestfdList, const std::vector<int32_t> &errCodes); | ||
| 148 | - void IncrementalRestoreOnFileReadysWithoutRp(const std::string &bundleName, | ||
| 149 | - const std::vector<std::string> &fileNames, const std::vector<UniqueFd> &fdList, | ||
| 150 | - const std::vector<int32_t> &errCodes); | ||
| 151 | ErrCode AppIncrementalFileReadys(const std::string &bundleName, | 145 | ErrCode AppIncrementalFileReadys(const std::string &bundleName, |
| 152 | const std::vector<std::string> &fileNames, | 146 | const std::vector<std::string> &fileNames, |
| 153 | - const std::vector<UniqueFd> &fdList, | 147 | + const std::vector<FileOpenResult> &openResults); |
| 154 | - const std::vector<UniqueFd> &manifestfdList, | ||
| 155 | - const std::vector<int32_t> &errCodes); | ||
| 156 | - ErrCode AppIncrementalFileReadysWithoutRp(const std::string &bundleName, | ||
| 157 | - const std::vector<std::string> &fileNames, | ||
| 158 | - const std::vector<UniqueFd> &fdList, | ||
| 159 | - const std::vector<int32_t> &errCodes); | ||
| 160 | ErrCode GetBackupDataSize(bool isPreciseScan, const std::vector<BIncrementalData>& bundleNameList) override; | 148 | ErrCode GetBackupDataSize(bool isPreciseScan, const std::vector<BIncrementalData>& bundleNameList) override; |
| 161 | ErrCode CleanBundleTempDir(const std::string &bundleName) override; | 149 | ErrCode CleanBundleTempDir(const std::string &bundleName) override; |
| 162 | ErrCode HandleExtDisconnect(BackupRestoreScenario scenario, bool isAppResultReport, ErrCode errCode) override; | 150 | ErrCode HandleExtDisconnect(BackupRestoreScenario scenario, bool isAppResultReport, ErrCode errCode) override; |
| @@ -884,7 +872,9 @@ private: | |||
| 884 | ErrCode ProcessReadyFiles(const std::vector<std::string> &fileNames, | 872 | ErrCode ProcessReadyFiles(const std::vector<std::string> &fileNames, |
| 885 | const std::vector<int> &errCodes, | 873 | const std::vector<int> &errCodes, |
| 886 | const std::string &callerName); | 874 | const std::string &callerName); |
| 887 | - ErrCode SendIncrementalFileHandlesByEnhance(const std::string &bundleName, const vector<std::string> &fileNames); | 875 | + ErrCode SendIncrementalFileHandlesByEnhance(const std::string &bundleName, |
| 876 | + const vector<std::string> &fileNames, | ||
| 877 | + std::vector<FileOpenResult> &openResults); | ||
| 888 | private: | 878 | private: |
| 889 | static sptr<Service> instance_; | 879 | static sptr<Service> instance_; |
| 890 | static std::mutex instanceLock_; | 880 | static std::mutex instanceLock_; |
| @@ -629,109 +629,30 @@ ErrCode Service::PublishSAIncrementalFile(const BFileInfo &fileInfo, UniqueFd fd | |||
| 629 | return saConnection->CallRestoreSA(move(fd)); | 629 | return saConnection->CallRestoreSA(move(fd)); |
| 630 | } | 630 | } |
| 631 | 631 | ||
| 632 | -void Service::IncrementalRestoreOnFileReadys(const std::string &bundleName, | ||
| 633 | - const std::vector<std::string> &fileNames, const std::vector<UniqueFd> &fdList, | ||
| 634 | - const std::vector<UniqueFd> &manifestfdList, const std::vector<int32_t> &errCodes) | ||
| 635 | -{ | ||
| 636 | - std::vector<std::string> specialFileNames; | ||
| 637 | - std::vector<int32_t> specialErrCodes; | ||
| 638 | - std::vector<std::string> normalFileNames; | ||
| 639 | - std::vector<int> normalFdList; | ||
| 640 | - std::vector<int> normalManifestfdList; | ||
| 641 | - std::vector<int32_t> normalErrCodes; | ||
| 642 | - for (size_t i = 0; i < fileNames.size(); i++) { | ||
| 643 | - if (fdList[i] >= 0) { | ||
| 644 | - normalFileNames.push_back(fileNames[i]); | ||
| 645 | - normalFdList.push_back(fdList[i]); | ||
| 646 | - normalManifestfdList.push_back(manifestfdList[i]); | ||
| 647 | - normalErrCodes.push_back(errCodes[i]); | ||
| 648 | - } else { | ||
| 649 | - specialFileNames.push_back(fileNames[i]); | ||
| 650 | - specialErrCodes.push_back(errCodes[i]); | ||
| 651 | - } | ||
| 652 | - } | ||
| 653 | - session_->GetServiceReverseProxy()->IncrementalRestoreOnFileReadysWithoutFd( | ||
| 654 | - bundleName, specialFileNames, specialErrCodes); | ||
| 655 | - session_->GetServiceReverseProxy()->IncrementalRestoreOnFileReadys( | ||
| 656 | - bundleName, normalFileNames, normalFdList, normalManifestfdList, normalErrCodes); | ||
| 657 | -} | ||
| 658 | - | ||
| 659 | ErrCode Service::AppIncrementalFileReadys(const std::string &bundleName, | 632 | ErrCode Service::AppIncrementalFileReadys(const std::string &bundleName, |
| 660 | const std::vector<std::string> &fileNames, | 633 | const std::vector<std::string> &fileNames, |
| 661 | - const std::vector<UniqueFd> &fdList, | 634 | + const std::vector<FileOpenResult> &openResults) |
| 662 | - const std::vector<UniqueFd> &manifestfdList, | ||
| 663 | - const std::vector<int32_t> &errCodes) | ||
| 664 | { | 635 | { |
| 665 | try { | 636 | try { |
| 666 | - HILOGI("%{public}zu,%{public}zu,%{public}zu,%{public}zu", | 637 | + HILOGI("Processing bundle: %{public}s, file count: %{public}zu, open result count: %{public}zu", |
| 667 | - fileNames.size(), fdList.size(), manifestfdList.size(), errCodes.size()); | 638 | + bundleName.c_str(), fileNames.size(), openResults.size()); |
| 668 | - BExcepUltils::BAssert(fileNames.size() == fdList.size(), BError::Codes::SA_INVAL_ARG, "size is not same"); | 639 | + BExcepUltils::BAssert(fileNames.size() == openResults.size(), BError::Codes::SA_INVAL_ARG, |
| 669 | - BExcepUltils::BAssert(fileNames.size() == manifestfdList.size(), | 640 | + "File names and open results size mismatch"); |
| 670 | - BError::Codes::SA_INVAL_ARG, "size is not same"); | ||
| 671 | - BExcepUltils::BAssert(fileNames.size() == errCodes.size(), BError::Codes::SA_INVAL_ARG, "size is not same"); | ||
| 672 | if (session_->GetScenario() == IServiceReverseType::Scenario::RESTORE) { | 641 | if (session_->GetScenario() == IServiceReverseType::Scenario::RESTORE) { |
| 673 | - session_->GetServiceReverseProxy()->SetBatchSize((unsigned int)fileNames.size()); | 642 | + session_->GetServiceReverseProxy()->SetBatchSize(static_cast<unsigned int>(fileNames.size())); |
| 674 | - IncrementalRestoreOnFileReadys(bundleName, fileNames, fdList, manifestfdList, errCodes); | 643 | + session_->GetServiceReverseProxy()->IncrementalRestoreOnFileReadys(bundleName, fileNames, openResults); |
| 675 | OnAllBundlesFinished(BError(BError::Codes::OK)); | 644 | OnAllBundlesFinished(BError(BError::Codes::OK)); |
| 676 | return BError(BError::Codes::OK); | 645 | return BError(BError::Codes::OK); |
| 677 | } | 646 | } |
| 647 | + HILOGI("No RESTORE scenario detected for bundle: %{public}s", bundleName.c_str()); | ||
| 678 | OnAllBundlesFinished(BError(BError::Codes::OK)); | 648 | OnAllBundlesFinished(BError(BError::Codes::OK)); |
| 679 | return BError(BError::Codes::OK); | 649 | return BError(BError::Codes::OK); |
| 680 | } catch (const BError &e) { | 650 | } catch (const BError &e) { |
| 681 | - HILOGE("AppIncrementalFileReadys exception"); | 651 | + HILOGE("Exception occurred during AppIncrementalFileReadys for bundle %{public}s: errCode:%{public}d", |
| 652 | + bundleName.c_str(), e.GetCode()); | ||
| 682 | return e.GetCode(); // 任意异常产生,终止监听该任务 | 653 | return e.GetCode(); // 任意异常产生,终止监听该任务 |
| 683 | } catch (...) { | 654 | } catch (...) { |
| 684 | - HILOGE("Unexpected exception"); | 655 | + HILOGE("Unexpected exception occurred for bundle %{public}s", bundleName.c_str()); |
| 685 | - return EPERM; | ||
| 686 | - } | ||
| 687 | -} | ||
| 688 | - | ||
| 689 | -void Service::IncrementalRestoreOnFileReadysWithoutRp(const std::string &bundleName, | ||
| 690 | - const std::vector<std::string> &fileNames, const std::vector<UniqueFd> &fdList, | ||
| 691 | - const std::vector<int32_t> &errCodes) | ||
| 692 | -{ | ||
| 693 | - std::vector<std::string> specialFileNames; | ||
| 694 | - std::vector<int32_t> specialErrCodes; | ||
| 695 | - std::vector<std::string> normalFileNames; | ||
| 696 | - std::vector<int> normalFdList; | ||
| 697 | - std::vector<int32_t> normalErrCodes; | ||
| 698 | - for (size_t i = 0; i < fileNames.size(); i++) { | ||
| 699 | - if (fdList[i] >= 0) { | ||
| 700 | - normalFileNames.push_back(fileNames[i]); | ||
| 701 | - normalFdList.push_back(fdList[i]); | ||
| 702 | - normalErrCodes.push_back(errCodes[i]); | ||
| 703 | - } else { | ||
| 704 | - specialFileNames.push_back(fileNames[i]); | ||
| 705 | - specialErrCodes.push_back(errCodes[i]); | ||
| 706 | - } | ||
| 707 | - } | ||
| 708 | - session_->GetServiceReverseProxy()->IncrementalRestoreOnFileReadysWithoutFd( | ||
| 709 | - bundleName, specialFileNames, specialErrCodes); | ||
| 710 | - session_->GetServiceReverseProxy()->IncrementalRestoreOnFileReadysWithoutRp( | ||
| 711 | - bundleName, normalFileNames, normalFdList, normalErrCodes); | ||
| 712 | -} | ||
| 713 | - | ||
| 714 | -ErrCode Service::AppIncrementalFileReadysWithoutRp(const std::string &bundleName, | ||
| 715 | - const std::vector<std::string> &fileNames, const std::vector<UniqueFd> &fdList, | ||
| 716 | - const std::vector<int32_t> &errCodes) | ||
| 717 | -{ | ||
| 718 | - try { | ||
| 719 | - HILOGI("%{public}zu,%{public}zu,%{public}zu",fileNames.size(), fdList.size(), errCodes.size()); | ||
| 720 | - BExcepUltils::BAssert(fileNames.size() == fdList.size(), BError::Codes::SA_INVAL_ARG, "size is not same"); | ||
| 721 | - BExcepUltils::BAssert(fileNames.size() == errCodes.size(), BError::Codes::SA_INVAL_ARG, "size is not same"); | ||
| 722 | - if (session_->GetScenario() == IServiceReverseType::Scenario::RESTORE) { | ||
| 723 | - session_->GetServiceReverseProxy()->SetBatchSize((unsigned int)fileNames.size()); | ||
| 724 | - IncrementalRestoreOnFileReadysWithoutRp(bundleName, fileNames, fdList, errCodes); | ||
| 725 | - OnAllBundlesFinished(BError(BError::Codes::OK)); | ||
| 726 | - return BError(BError::Codes::OK); | ||
| 727 | - } | ||
| 728 | - OnAllBundlesFinished(BError(BError::Codes::OK)); | ||
| 729 | - return BError(BError::Codes::OK); | ||
| 730 | - } catch (const BError &e) { | ||
| 731 | - HILOGE("AppIncrementalFileReadysWithoutRp exception"); | ||
| 732 | - return e.GetCode(); // 任意异常产生,终止监听该任务 | ||
| 733 | - } catch (...) { | ||
| 734 | - HILOGE("Unexpected exception"); | ||
| 735 | return EPERM; | 656 | return EPERM; |
| 736 | } | 657 | } |
| 737 | } | 658 | } |
| @@ -1044,51 +965,53 @@ ErrCode Service::SendIncrementalFileHandles(const std::string &bundleName, const | |||
| 1044 | } | 965 | } |
| 1045 | } | 966 | } |
| 1046 | 967 | ||
| 968 | + std::vector<std::string> finalFileNames; | ||
| 969 | + std::vector<FileOpenResult> openResults; | ||
| 1047 | ErrCode finalErr = ERR_OK; | 970 | ErrCode finalErr = ERR_OK; |
| 1048 | if (!saFileNames.empty()) { | 971 | if (!saFileNames.empty()) { |
| 1049 | - auto err = SendIncrementalFileHandlesByEnhance(bundleName, saFileNames); | 972 | + auto err = SendIncrementalFileHandlesByEnhance(bundleName, saFileNames, openResults); |
| 973 | + finalFileNames = std::move(saFileNames); | ||
| 1050 | finalErr = err == ERR_OK ? finalErr : err; | 974 | finalErr = err == ERR_OK ? finalErr : err; |
| 1051 | } | 975 | } |
| 1052 | if (!extFileNames.empty()) { | 976 | if (!extFileNames.empty()) { |
| 1053 | - std::vector<int> fdLists; | 977 | + std::vector<FileOpenResult> extOpenResults; |
| 1054 | - std::vector<int32_t> extErrCodes; | 978 | + proxy->GetIncrementalFileHandles(extFileNames, extOpenResults); |
| 1055 | - proxy->GetIncrementalFileHandles(extFileNames, fdLists, extErrCodes); | 979 | + finalFileNames.insert(finalFileNames.end(), extFileNames.begin(), extFileNames.end()); |
| 1056 | - std::vector<UniqueFd> extFdLists(fdLists.begin(), fdLists.end()); | 980 | + openResults.insert(openResults.end(), extOpenResults.begin(), extOpenResults.end()); |
| 1057 | - auto err = AppIncrementalFileReadysWithoutRp(bundleName, extFileNames, extFdLists, extErrCodes); | ||
| 1058 | - finalErr = err == ERR_OK ? finalErr : err; | ||
| 1059 | } | 981 | } |
| 982 | + | ||
| 983 | + auto err = AppIncrementalFileReadys(bundleName, finalFileNames, openResults); | ||
| 984 | + finalErr = err == ERR_OK ? finalErr : err; | ||
| 985 | + | ||
| 1060 | if (finalErr != ERR_OK) { | 986 | if (finalErr != ERR_OK) { |
| 1061 | - AppRadar::Info info (bundleName, "", ""); | 987 | + AppRadar::Info info(bundleName, "", ""); |
| 1062 | - AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::GetIncrementalFileHandles", | 988 | + AppRadar::GetInstance().RecordRestoreFuncRes(info, "Service::GetIncrementalFileHandles", GetUserIdDefault(), |
| 1063 | - GetUserIdDefault(), BizStageRestore::BIZ_STAGE_GET_FILE_HANDLE_FAIL, finalErr); | 989 | + BizStageRestore::BIZ_STAGE_GET_FILE_HANDLE_FAIL, finalErr); |
| 1064 | } | 990 | } |
| 1065 | return BError(BError::Codes::OK); | 991 | return BError(BError::Codes::OK); |
| 1066 | } | 992 | } |
| 1067 | 993 | ||
| 1068 | -ErrCode Service::SendIncrementalFileHandlesByEnhance( | 994 | +ErrCode Service::SendIncrementalFileHandlesByEnhance(const std::string &bundleName, |
| 1069 | - const std::string &bundleName, const vector<std::string> &fileNames) | 995 | + const vector<std::string> &fileNames, |
| 996 | + std::vector<FileOpenResult> &openResults) | ||
| 1070 | { | 997 | { |
| 1071 | std::vector<int32_t> errCodes; | 998 | std::vector<int32_t> errCodes; |
| 1072 | auto enhanceService = EnhanceServiceManager::GetInstance().GetServiceInstance(); | 999 | auto enhanceService = EnhanceServiceManager::GetInstance().GetServiceInstance(); |
| 1073 | if (!enhanceService) { | 1000 | if (!enhanceService) { |
| 1074 | - HILOGE("SendIncrementalFileHandles, enhance service is not loaded"); | 1001 | + HILOGE("SendIncrementalFileHandle, enhance service is not loaded"); |
| 1075 | - errCodes.resize(fileNames.size(), BError(BError::Codes::SA_ENHANCE_SERVICE_UNAVAILABLE).GetCode()); | 1002 | + auto errCode = BError(BError::Codes::SA_ENHANCE_SERVICE_UNAVAILABLE).GetCode(); |
| 1076 | - return session_->GetServiceReverseProxy()->IncrementalRestoreOnFileReadysWithoutFd( | 1003 | + openResults.insert(openResults.end(), fileNames.size(), FileOpenResult(errCode)); |
| 1077 | - bundleName, fileNames, errCodes); | 1004 | + return errCode; |
| 1078 | } | 1005 | } |
| 1079 | 1006 | ||
| 1080 | - std::vector<UniqueFd> fdLists; | ||
| 1081 | - std::vector<UniqueFd> manifestfdLists; | ||
| 1082 | for (const auto &fileName : fileNames) { | 1007 | for (const auto &fileName : fileNames) { |
| 1083 | int fdVal = BConstants::INVALID_FD_NUM; | 1008 | int fdVal = BConstants::INVALID_FD_NUM; |
| 1084 | int reportFdVal = BConstants::INVALID_FD_NUM; | 1009 | int reportFdVal = BConstants::INVALID_FD_NUM; |
| 1085 | int errCode = BConstants::INVALID_FD_NUM; | 1010 | int errCode = BConstants::INVALID_FD_NUM; |
| 1086 | enhanceService->GetIncrementalAncoFileHandle(bundleName, fileName, fdVal, reportFdVal, errCode); | 1011 | enhanceService->GetIncrementalAncoFileHandle(bundleName, fileName, fdVal, reportFdVal, errCode); |
| 1087 | - fdLists.push_back(UniqueFd(fdVal)); | 1012 | + openResults.push_back(FileOpenResult(errCode, UniqueFd(fdVal), UniqueFd(reportFdVal))); |
| 1088 | - manifestfdLists.push_back(UniqueFd(reportFdVal)); | ||
| 1089 | - errCodes.push_back(errCode); | ||
| 1090 | } | 1013 | } |
| 1091 | - return AppIncrementalFileReadys(bundleName, fileNames, fdLists, manifestfdLists, errCodes); | 1014 | + return BError(BError::Codes::OK).GetCode(); |
| 1092 | } | 1015 | } |
| 1093 | 1016 | ||
| 1094 | bool Service::IncrementalBackup(const string &bundleName) | 1017 | bool Service::IncrementalBackup(const string &bundleName) |
| @@ -69,10 +69,8 @@ public: | |||
| 69 | virtual ErrCode HandleOnRelease(int32_t scenario) = 0; | 69 | virtual ErrCode HandleOnRelease(int32_t scenario) = 0; |
| 70 | virtual ErrCode HandleGetCompatibilityInfo(const std::string &extInfo, int32_t scenario, bool isExist, | 70 | virtual ErrCode HandleGetCompatibilityInfo(const std::string &extInfo, int32_t scenario, bool isExist, |
| 71 | std::string &compatibilityInfo) = 0; | 71 | std::string &compatibilityInfo) = 0; |
| 72 | - virtual int32_t CallbackEnter(uint32_t code) = 0; | 72 | + virtual ErrCode GetIncrementalFileHandles(const std::vector<std::string> &fileNames, |
| 73 | - virtual int32_t CallbackExit(uint32_t code, int32_t result) = 0; | 73 | + std::vector<FileOpenResult> &openResults) = 0; |
| 74 | - virtual ErrCode GetIncrementalFileHandles(const std::vector<std::string> &fileNames, std::vector<int> &fdList, | ||
| 75 | - std::vector<int32_t> &errCodes) = 0; | ||
| 76 | public: | 74 | public: |
| 77 | BExtExtension() = default; | 75 | BExtExtension() = default; |
| 78 | virtual ~BExtExtension() = default; | 76 | virtual ~BExtExtension() = default; |
| @@ -117,10 +115,7 @@ public: | |||
| 117 | MOCK_METHOD((std::tuple<ErrCode, UniqueFd, UniqueFd>), GetIncrementalFileHandle, | 115 | MOCK_METHOD((std::tuple<ErrCode, UniqueFd, UniqueFd>), GetIncrementalFileHandle, |
| 118 | (const string &)); | 116 | (const string &)); |
| 119 | MOCK_METHOD(ErrCode, GetFileHandleWithUniqueFd, (const std::string &, int32_t &, int&)); | 117 | MOCK_METHOD(ErrCode, GetFileHandleWithUniqueFd, (const std::string &, int32_t &, int&)); |
| 120 | - MOCK_METHOD(int32_t, CallbackEnter, (uint32_t)); | 118 | + MOCK_METHOD(ErrCode, GetIncrementalFileHandles, (const std::vector<std::string> &, std::vector<FileOpenResult> &)); |
| 121 | - MOCK_METHOD(int32_t, CallbackExit, (uint32_t, int32_t)); | ||
| 122 | - MOCK_METHOD(ErrCode, GetIncrementalFileHandles, (const std::vector<std::string> &, std::vector<int> &, | ||
| 123 | - std::vector<int32_t> &)); | ||
| 124 | MOCK_METHOD(std::string, GetBackupInfo, ()); | 119 | MOCK_METHOD(std::string, GetBackupInfo, ()); |
| 125 | MOCK_METHOD(void, UpdateOnStartTime, ()); | 120 | MOCK_METHOD(void, UpdateOnStartTime, ()); |
| 126 | MOCK_METHOD(ErrCode, IncrementalTarFileReady, (const TarMap &, const vector<struct ReportFileInfo> &, | 121 | MOCK_METHOD(ErrCode, IncrementalTarFileReady, (const TarMap &, const vector<struct ReportFileInfo> &, |
| @@ -158,21 +158,11 @@ void BackupExtExtension::ReportAppStatistic(const std::string &func, ErrCode err | |||
| 158 | { | 158 | { |
| 159 | BExtExtension::extExtension->ReportAppStatistic(func, errCode); | 159 | BExtExtension::extExtension->ReportAppStatistic(func, errCode); |
| 160 | } | 160 | } |
| 161 | - | ||
| 162 | -int32_t BackupExtExtension::CallbackEnter(uint32_t code) | ||
| 163 | -{ | ||
| 164 | - return BExtExtension::extExtension->CallbackEnter(code); | ||
| 165 | -} | ||
| 166 | - | ||
| 167 | -int32_t BackupExtExtension::CallbackExit(uint32_t code, int32_t result) | ||
| 168 | -{ | ||
| 169 | - return BExtExtension::extExtension->CallbackExit(code, result); | ||
| 170 | -} | ||
| 171 | 161 | ||
| 172 | ErrCode BackupExtExtension::GetIncrementalFileHandles(const std::vector<std::string> &fileNames, | 162 | ErrCode BackupExtExtension::GetIncrementalFileHandles(const std::vector<std::string> &fileNames, |
| 173 | - std::vector<int> &fdList, std::vector<int32_t> &errCodes) | 163 | + std::vector<FileOpenResult> &openResults) |
| 174 | { | 164 | { |
| 175 | - return BExtExtension::extExtension->GetIncrementalFileHandles(fileNames, fdList, errCodes); | 165 | + return BExtExtension::extExtension->GetIncrementalFileHandles(fileNames, openResults); |
| 176 | } | 166 | } |
| 177 | 167 | ||
| 178 | void BackupExtExtension::UpdateOnStartTime() | 168 | void BackupExtExtension::UpdateOnStartTime() |
| @@ -63,13 +63,7 @@ public: | |||
| 63 | MOCK_METHOD(ErrCode, IncrementalRestoreOnProcessInfo, (const std::string &, const std::string &)); | 63 | MOCK_METHOD(ErrCode, IncrementalRestoreOnProcessInfo, (const std::string &, const std::string &)); |
| 64 | MOCK_METHOD(ErrCode, IncrementalRestoreOnMigrateResult, (int32_t, const std::string &)); | 64 | MOCK_METHOD(ErrCode, IncrementalRestoreOnMigrateResult, (int32_t, const std::string &)); |
| 65 | MOCK_METHOD(ErrCode, IncrementalRestoreOnFileReadys, | 65 | MOCK_METHOD(ErrCode, IncrementalRestoreOnFileReadys, |
| 66 | - (const std::string &, const std::vector<std::string> &, const std::vector<int> &, | 66 | + (const std::string &, const std::vector<std::string> &, const std::vector<FileOpenResult> &)); |
| 67 | - const std::vector<int> &, const std::vector<int32_t> &)); | ||
| 68 | - MOCK_METHOD(ErrCode, IncrementalRestoreOnFileReadysWithoutRp, | ||
| 69 | - (const std::string &, const std::vector<std::string> &, const std::vector<int> &, | ||
| 70 | - const std::vector<int32_t> &)); | ||
| 71 | - MOCK_METHOD(ErrCode, IncrementalRestoreOnFileReadysWithoutFd, | ||
| 72 | - (const std::string &, const std::vector<std::string> &, const std::vector<int32_t> &)); | ||
| 73 | MOCK_METHOD(ErrCode, SetBatchSize, (uint32_t)); | 67 | MOCK_METHOD(ErrCode, SetBatchSize, (uint32_t)); |
| 74 | MOCK_METHOD(ErrCode, BackupOnFileReadysWithoutFd, (const std::string &, const std::vector<std::string> &, | 68 | MOCK_METHOD(ErrCode, BackupOnFileReadysWithoutFd, (const std::string &, const std::vector<std::string> &, |
| 75 | const std::vector<int> &)); | 69 | const std::vector<int> &)); |
| @@ -45,8 +45,7 @@ MOCK_METHOD(ErrCode, UpdateDfxInfo, (int64_t, uint32_t, const std::string &)); | |||
| 45 | MOCK_METHOD(ErrCode, CleanBundleTempDir, ()); | 45 | MOCK_METHOD(ErrCode, CleanBundleTempDir, ()); |
| 46 | MOCK_METHOD(ErrCode, HandleOnRelease, (int32_t)); | 46 | MOCK_METHOD(ErrCode, HandleOnRelease, (int32_t)); |
| 47 | MOCK_METHOD(ErrCode, HandleGetCompatibilityInfo, (const std::string &, int32_t, bool, std::string &)); | 47 | MOCK_METHOD(ErrCode, HandleGetCompatibilityInfo, (const std::string &, int32_t, bool, std::string &)); |
| 48 | -MOCK_METHOD(int32_t, GetIncrementalFileHandles, (const std::vector<std::string> &, | 48 | +MOCK_METHOD(ErrCode, GetIncrementalFileHandles, (const std::vector<std::string> &, std::vector<FileOpenResult> &)); |
| 49 | - std::vector<int> &, std::vector<int32_t> &)); | ||
| 50 | }; | 49 | }; |
| 51 | } // namespace OHOS::FileManagement::Backup | 50 | } // namespace OHOS::FileManagement::Backup |
| 52 | 51 | ||
| @@ -206,20 +206,7 @@ ErrCode ServiceReverseProxy::IncrementalRestoreOnMigrateResult(int32_t errCode, | |||
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | ErrCode ServiceReverseProxy::IncrementalRestoreOnFileReadys(const std::string &bundleName, | 208 | ErrCode ServiceReverseProxy::IncrementalRestoreOnFileReadys(const std::string &bundleName, |
| 209 | - const std::vector<std::string> &fileNames, const std::vector<int> &fdList, const std::vector<int> &manifestfdList, | 209 | + const std::vector<std::string> &fileNames, const std::vector<FileOpenResult> &openResults) |
| 210 | - const std::vector<int32_t> &errCodes) | ||
| 211 | -{ | ||
| 212 | - return BError(BError::Codes::OK); | ||
| 213 | -} | ||
| 214 | - | ||
| 215 | -ErrCode ServiceReverseProxy::IncrementalRestoreOnFileReadysWithoutRp(const std::string &bundleName, | ||
| 216 | - const std::vector<std::string> &fileNames, const std::vector<int> &fdList, const std::vector<int32_t> &errCodes) | ||
| 217 | -{ | ||
| 218 | - return BError(BError::Codes::OK); | ||
| 219 | -} | ||
| 220 | - | ||
| 221 | -ErrCode ServiceReverseProxy::IncrementalRestoreOnFileReadysWithoutFd(const std::string &bundleName, | ||
| 222 | - const std::vector<std::string> &fileListWithoutfd, const std::vector<int32_t> &errCodes) | ||
| 223 | { | 210 | { |
| 224 | return BError(BError::Codes::OK); | 211 | return BError(BError::Codes::OK); |
| 225 | } | 212 | } |
| @@ -110,8 +110,8 @@ ErrCode ExtensionProxy::GetIncrementalRpFileHandle(const std::string &fileName, | |||
| 110 | return 0; | 110 | return 0; |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | -ErrCode ExtensionProxy::GetIncrementalFileHandles(const std::vector<std::string> &fileNames, std::vector<int> &fdList, | 113 | +ErrCode ExtensionProxy::GetIncrementalFileHandles(const std::vector<std::string> &fileNames, |
| 114 | - std::vector<int32_t> &errCodes) | 114 | + std::vector<FileOpenResult> &openResults) |
| 115 | { | 115 | { |
| 116 | return 0; | 116 | return 0; |
| 117 | } | 117 | } |
| @@ -94,5 +94,11 @@ public: | |||
| 94 | virtual ~Parcelable() = default; | 94 | virtual ~Parcelable() = default; |
| 95 | virtual bool Marshalling(Parcel &parcel) const = 0; | 95 | virtual bool Marshalling(Parcel &parcel) const = 0; |
| 96 | }; | 96 | }; |
| 97 | + | ||
| 98 | +class MessageParcel : public Parcel { | ||
| 99 | +public: | ||
| 100 | + bool WriteFileDescriptor(int fd); | ||
| 101 | + int ReadFileDescriptor(); | ||
| 102 | +}; | ||
| 97 | } // namespace OHOS::FileManagement::Backup | 103 | } // namespace OHOS::FileManagement::Backup |
| 98 | 104 | ||
| @@ -339,4 +339,14 @@ bool Parcel::ReadInt64(int64_t &value) | |||
| 339 | } | 339 | } |
| 340 | return isSuccess; | 340 | return isSuccess; |
| 341 | } | 341 | } |
| 342 | + | ||
| 343 | +bool MessageParcel::WriteFileDescriptor(int fd) | ||
| 344 | +{ | ||
| 345 | + return true; | ||
| 346 | +} | ||
| 347 | + | ||
| 348 | +int MessageParcel::ReadFileDescriptor() | ||
| 349 | +{ | ||
| 350 | + return -1; | ||
| 351 | +} | ||
| 342 | } // namespace OHOS::FileManagement::Backup | 352 | } // namespace OHOS::FileManagement::Backup |
| @@ -40,7 +40,11 @@ ohos_unittest("b_file_info_test") { | |||
| 40 | "${path_backup}/utils:backup_utils", | 40 | "${path_backup}/utils:backup_utils", |
| 41 | ] | 41 | ] |
| 42 | 42 | ||
| 43 | - external_deps = [ "hilog:libhilog" ] | 43 | + external_deps = [ |
| 44 | + "c_utils:utils", | ||
| 45 | + "hilog:libhilog", | ||
| 46 | + "ipc:ipc_core", | ||
| 47 | + ] | ||
| 44 | 48 | ||
| 45 | use_exceptions = true | 49 | use_exceptions = true |
| 46 | } | 50 | } |
| @@ -162,7 +166,11 @@ ohos_unittest("b_file_info_sub_test") { | |||
| 162 | "${path_backup}/utils:backup_utils", | 166 | "${path_backup}/utils:backup_utils", |
| 163 | ] | 167 | ] |
| 164 | 168 | ||
| 165 | - external_deps = [ "hilog:libhilog" ] | 169 | + external_deps = [ |
| 170 | + "c_utils:utils", | ||
| 171 | + "hilog:libhilog", | ||
| 172 | + "ipc:ipc_core", | ||
| 173 | + ] | ||
| 166 | 174 | ||
| 167 | use_exceptions = true | 175 | use_exceptions = true |
| 168 | } | 176 | } |
| @@ -190,8 +190,8 @@ public: | |||
| 190 | return BError(BError::Codes::OK); | 190 | return BError(BError::Codes::OK); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | - ErrCode GetIncrementalFileHandles(const std::vector<std::string> &fileNames, std::vector<int> &fdList, | 193 | + ErrCode GetIncrementalFileHandles(const std::vector<std::string> &fileNames, |
| 194 | - std::vector<int32_t> &errCodes) override | 194 | + std::vector<FileOpenResult> &openResults) override |
| 195 | { | 195 | { |
| 196 | return BError(BError::Codes::OK); | 196 | return BError(BError::Codes::OK); |
| 197 | } | 197 | } |
| @@ -231,23 +231,7 @@ public: | |||
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | ErrCode IncrementalRestoreOnFileReadys(const std::string &bundleName, const std::vector<std::string> &fileNames, | 233 | ErrCode IncrementalRestoreOnFileReadys(const std::string &bundleName, const std::vector<std::string> &fileNames, |
| 234 | - const std::vector<int> &fdList, const std::vector<int> &manifestfdList, | 234 | + const std::vector<FileOpenResult> &openResults) override |
| 235 | - const std::vector<int32_t> &errCodes) override | ||
| 236 | - { | ||
| 237 | - return BError(BError::Codes::OK); | ||
| 238 | - } | ||
| 239 | - | ||
| 240 | - ErrCode IncrementalRestoreOnFileReadysWithoutRp(const std::string &bundleName, | ||
| 241 | - const std::vector<std::string> &fileNames, | ||
| 242 | - const std::vector<int> &fdList, | ||
| 243 | - const std::vector<int32_t> &errCodes) override | ||
| 244 | - { | ||
| 245 | - return BError(BError::Codes::OK); | ||
| 246 | - } | ||
| 247 | - | ||
| 248 | - ErrCode IncrementalRestoreOnFileReadysWithoutFd(const std::string &bundleName, | ||
| 249 | - const std::vector<std::string> &fileListWithoutfd, | ||
| 250 | - const std::vector<int32_t> &errCodes) override | ||
| 251 | { | 235 | { |
| 252 | return BError(BError::Codes::OK); | 236 | return BError(BError::Codes::OK); |
| 253 | } | 237 | } |
| @@ -79,47 +79,6 @@ ohos_unittest("ext_extension_test") { | |||
| 79 | use_exceptions = true | 79 | use_exceptions = true |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | -ohos_unittest("ext_extension_stub_test") { | ||
| 83 | - module_out_path = path_module_out_tests | ||
| 84 | - | ||
| 85 | - sources = [ | ||
| 86 | - "${path_backup_mock}/module_ipc/message_parcel_mock.cpp", | ||
| 87 | - "${path_backup}/frameworks/native/backup_ext/src/ext_extension_stub.cpp", | ||
| 88 | - "ext_extension_stub_test.cpp", | ||
| 89 | - ] | ||
| 90 | - | ||
| 91 | - include_dirs = [ | ||
| 92 | - "${path_backup_mock}/module_ipc", | ||
| 93 | - "${path_backup}/frameworks/native/backup_ext/include", | ||
| 94 | - "${path_backup}/interfaces/inner_api/native/backup_kit_inner/impl", | ||
| 95 | - "${path_backup}/interfaces/common/include", | ||
| 96 | - "${path_backup}/utils/include", | ||
| 97 | - ] | ||
| 98 | - | ||
| 99 | - deps = [ "${path_backup}/utils:backup_utils" ] | ||
| 100 | - | ||
| 101 | - external_deps = [ | ||
| 102 | - "c_utils:utils", | ||
| 103 | - "googletest:gmock_main", | ||
| 104 | - "googletest:gtest_main", | ||
| 105 | - "hilog:libhilog", | ||
| 106 | - "ipc:ipc_core", | ||
| 107 | - "safwk:system_ability_fwk", | ||
| 108 | - ] | ||
| 109 | - | ||
| 110 | - cflags = [ "--coverage" ] | ||
| 111 | - ldflags = [ "--coverage" ] | ||
| 112 | - cflags_cc = [ "--coverage" ] | ||
| 113 | - | ||
| 114 | - defines = [ | ||
| 115 | - "LOG_TAG=\"app_file_service\"", | ||
| 116 | - "LOG_DOMAIN=0xD004303", | ||
| 117 | - "private=public", | ||
| 118 | - ] | ||
| 119 | - | ||
| 120 | - use_exceptions = true | ||
| 121 | -} | ||
| 122 | - | ||
| 123 | ohos_unittest("tar_file_test") { | 82 | ohos_unittest("tar_file_test") { |
| 124 | branch_protector_ret = "pac_ret" | 83 | branch_protector_ret = "pac_ret" |
| 125 | sanitize = { | 84 | sanitize = { |
| @@ -551,6 +510,7 @@ ohos_unittest("ext_extension_new_test") { | |||
| 551 | "${path_backup}/frameworks/native/backup_kit_inner/src/stat_info.cpp", | 510 | "${path_backup}/frameworks/native/backup_kit_inner/src/stat_info.cpp", |
| 552 | "${path_backup}/frameworks/native/backup_kit_inner/src/anco_scan_result.cpp", | 511 | "${path_backup}/frameworks/native/backup_kit_inner/src/anco_scan_result.cpp", |
| 553 | "${path_backup}/frameworks/native/backup_kit_inner/src/anco_restore_result.cpp", | 512 | "${path_backup}/frameworks/native/backup_kit_inner/src/anco_restore_result.cpp", |
| 513 | + "${path_backup}/frameworks/native/backup_kit_inner/src/b_file_info.cpp", | ||
| 554 | "ext_extension_new_test.cpp", | 514 | "ext_extension_new_test.cpp", |
| 555 | ] | 515 | ] |
| 556 | 516 | ||
| @@ -880,73 +880,4 @@ HWTEST_F(ExtExtensionSubTest, SUB_AncoRestoreCallback_ReportFileInfos_0000, test | |||
| 880 | extExtension->endFileInfos_.clear(); | 880 | extExtension->endFileInfos_.clear(); |
| 881 | extExtension->errFileInfos_.clear(); | 881 | extExtension->errFileInfos_.clear(); |
| 882 | GTEST_LOG_(INFO) << "ExtExtensionSubTest-end SUB_AncoRestoreCallback_ReportFileInfos_0000"; | 882 | GTEST_LOG_(INFO) << "ExtExtensionSubTest-end SUB_AncoRestoreCallback_ReportFileInfos_0000"; |
| 883 | -} | ||
| 884 | - | ||
| 885 | -/** | ||
| 886 | - * @tc.number: Ext_Extension_Sub_CallbackExit_Test_0100 | ||
| 887 | - * @tc.name: Ext_Extension_Sub_CallbackExit_Test_0100 | ||
| 888 | - * @tc.desc: 测试CallbackExit清空fdList | ||
| 889 | - * @tc.size: MEDIUM | ||
| 890 | - * @tc.type: FUNC | ||
| 891 | - * @tc.level Level 1 | ||
| 892 | - */ | ||
| 893 | -HWTEST_F(ExtExtensionSubTest, Ext_Extension_Sub_CallbackExit_Test_0100, testing::ext::TestSize.Level1) | ||
| 894 | -{ | ||
| 895 | - GTEST_LOG_(INFO) << "ExtExtensionSubTest-begin Ext_Extension_Sub_CallbackExit_Test_0100"; | ||
| 896 | - try { | ||
| 897 | - ASSERT_TRUE(extExtension != nullptr); | ||
| 898 | - | ||
| 899 | - // 先填充 fdList_ | ||
| 900 | - std::vector<UniqueFd> fds; | ||
| 901 | - fds.push_back(UniqueFd(open("/dev/null", O_RDONLY))); | ||
| 902 | - auto tid = syscall(SYS_gettid); | ||
| 903 | - extExtension->fdLists_.emplace(tid, std::move(fds)); | ||
| 904 | - | ||
| 905 | - // 调用CallbackExit,传入COMMAND_GET_INCREMENTAL_FILE_HANDLES | ||
| 906 | - int32_t ret = extExtension->CallbackExit( | ||
| 907 | - static_cast<uint32_t>(IExtensionIpcCode::COMMAND_GET_INCREMENTAL_FILE_HANDLES), 0); | ||
| 908 | - | ||
| 909 | - // 验证返回值 | ||
| 910 | - EXPECT_EQ(ret, ERR_NONE); | ||
| 911 | - } catch (...) { | ||
| 912 | - EXPECT_TRUE(false); | ||
| 913 | - GTEST_LOG_(INFO) << "ExtExtensionSubTest-an exception occurred."; | ||
| 914 | - } | ||
| 915 | - GTEST_LOG_(INFO) << "ExtExtensionSubTest-end Ext_Extension_Sub_CallbackExit_Test_0100"; | ||
| 916 | -} | ||
| 917 | - | ||
| 918 | -/** | ||
| 919 | - * @tc.number: Ext_Extension_Sub_CallbackExit_Test_0200 | ||
| 920 | - * @tc.name: Ext_Extension_Sub_CallbackExit_Test_0200 | ||
| 921 | - * @tc.desc: 测试CallbackExit对其他命令不做处理 | ||
| 922 | - * @tc.size: MEDIUM | ||
| 923 | - * @tc.type: FUNC | ||
| 924 | - * @tc.level Level 1 | ||
| 925 | - */ | ||
| 926 | -HWTEST_F(ExtExtensionSubTest, Ext_Extension_Sub_CallbackExit_Test_0200, testing::ext::TestSize.Level1) | ||
| 927 | -{ | ||
| 928 | - GTEST_LOG_(INFO) << "ExtExtensionSubTest-begin Ext_Extension_Sub_CallbackExit_Test_0200"; | ||
| 929 | - try { | ||
| 930 | - ASSERT_TRUE(extExtension != nullptr); | ||
| 931 | - | ||
| 932 | - // 先填充 fdList_ | ||
| 933 | - std::vector<UniqueFd> fds; | ||
| 934 | - fds.push_back(UniqueFd(open("/dev/null", O_RDONLY))); | ||
| 935 | - auto tid = syscall(SYS_gettid); | ||
| 936 | - extExtension->fdLists_.emplace(tid, std::move(fds)); | ||
| 937 | - size_t beforeSize = extExtension->fdLists_[tid].size(); | ||
| 938 | - | ||
| 939 | - // 调用CallbackExit,传入其他命令码(如COMMAND_HANDLE_BACKUP) | ||
| 940 | - int32_t ret = extExtension->CallbackExit( | ||
| 941 | - static_cast<uint32_t>(IExtensionIpcCode::COMMAND_HANDLE_BACKUP), 0); | ||
| 942 | - | ||
| 943 | - // 验证返回值 | ||
| 944 | - EXPECT_EQ(ret, ERR_NONE); | ||
| 945 | - // 验证fdList_大小不变 | ||
| 946 | - EXPECT_EQ(extExtension->fdLists_[tid].size(), beforeSize); | ||
| 947 | - } catch (...) { | ||
| 948 | - EXPECT_TRUE(false); | ||
| 949 | - GTEST_LOG_(INFO) << "ExtExtensionSubTest-an exception occurred."; | ||
| 950 | - } | ||
| 951 | - GTEST_LOG_(INFO) << "ExtExtensionSubTest-end Ext_Extension_Sub_CallbackExit_Test_0200"; | ||
| 952 | } | 883 | } |
| @@ -1702,7 +1702,7 @@ HWTEST_F(ServiceIncrementalTest, SUB_ServiceIncremental_GetIncrementalFileHandle | |||
| 1702 | EXPECT_CALL(*connect, GetBackupExtProxy()).WillOnce(Return(svcProxy)); | 1702 | EXPECT_CALL(*connect, GetBackupExtProxy()).WillOnce(Return(svcProxy)); |
| 1703 | EXPECT_CALL(*svcProxy, GetIncrementalFileHandle(_, _, _, _)).WillOnce(Return(0)); | 1703 | EXPECT_CALL(*svcProxy, GetIncrementalFileHandle(_, _, _, _)).WillOnce(Return(0)); |
| 1704 | EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverseType::Scenario::BACKUP)); | 1704 | EXPECT_CALL(*session, GetScenario()).WillOnce(Return(IServiceReverseType::Scenario::BACKUP)); |
| 1705 | - EXPECT_CALL(*session, GetServiceReverseProxy()).WillOnce(Return(srProxy)); | 1705 | + EXPECT_CALL(*session, GetServiceReverseProxy()).WillRepeatedly(Return(srProxy)); |
| 1706 | EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(true)); | 1706 | EXPECT_CALL(*session, OnBundleFileReady(_, _)).WillOnce(Return(true)); |
| 1707 | EXPECT_CALL(*srvMock, HandleCurBundleFileReady(_, _, _)) | 1707 | EXPECT_CALL(*srvMock, HandleCurBundleFileReady(_, _, _)) |
| 1708 | .WillOnce(Return(BError(BError::Codes::SA_INVAL_ARG).GetCode())); | 1708 | .WillOnce(Return(BError(BError::Codes::SA_INVAL_ARG).GetCode())); |