diff --git a/frameworks/native/cloud_file_kit_inner/src/data_sync_manager.cpp b/frameworks/native/cloud_file_kit_inner/src/data_sync_manager.cpp index 9b998bf013b3e49cdda3233672d4e7eefe737cda..2960c4b45794f9ae15d8a174c97cca5d86733046 100644 --- a/frameworks/native/cloud_file_kit_inner/src/data_sync_manager.cpp +++ b/frameworks/native/cloud_file_kit_inner/src/data_sync_manager.cpp @@ -59,7 +59,7 @@ int32_t DataSyncManager::TriggerRecoverySync(SyncTriggerType triggerType) return E_OK; } -int32_t DataSyncManager::ResetCursor(const std::string &bundleName, const int32_t &userId) +int32_t DataSyncManager::ResetCursor(const std::string &bundleName, const int32_t &userId, bool flag) { return E_OK; } diff --git a/frameworks/native/cloudsync_kit_inner/include/cloud_sync_manager_impl.h b/frameworks/native/cloudsync_kit_inner/include/cloud_sync_manager_impl.h index de592796b6b47a2b1651974753c7b307027cef9a..0fbafdc195cd091a48d89b5a1e61c211d43e41cf 100644 --- a/frameworks/native/cloudsync_kit_inner/include/cloud_sync_manager_impl.h +++ b/frameworks/native/cloudsync_kit_inner/include/cloud_sync_manager_impl.h @@ -45,6 +45,7 @@ public: int32_t StopSync(const std::string &bundleName = "", bool forceFlag = false) override; int32_t StopFileSync(const std::string &bundleName = "", bool forceFlag = false) override; int32_t ResetCursor(const std::string &bundleName = "") override; + int32_t ResetCursor(bool flag, const std::string &bundleName = "") override; int32_t ChangeAppSwitch(const std::string &accoutId, const std::string &bundleName, bool status) override; int32_t OptimizeStorage(const OptimizeSpaceOptions &optimizeOptions, const std::shared_ptr optimizeCallback = nullptr) override; diff --git a/frameworks/native/cloudsync_kit_inner/src/cloud_sync_manager_impl.cpp b/frameworks/native/cloudsync_kit_inner/src/cloud_sync_manager_impl.cpp index 3d9545568c026cb68a501eba539393658b73e4a0..0ada7d33ab6a5d008e724d4e8ae1ff2a3ad67b31 100644 --- a/frameworks/native/cloudsync_kit_inner/src/cloud_sync_manager_impl.cpp +++ b/frameworks/native/cloudsync_kit_inner/src/cloud_sync_manager_impl.cpp @@ -271,7 +271,18 @@ int32_t CloudSyncManagerImpl::ResetCursor(const std::string &bundleName) return E_SA_LOAD_FAILED; } SetDeathRecipient(CloudSyncServiceProxy->AsObject()); - return CloudSyncServiceProxy->ResetCursor(bundleName); + return CloudSyncServiceProxy->ResetCursor(false, bundleName); +} + +int32_t CloudSyncManagerImpl::ResetCursor(bool flag, const std::string &bundleName) +{ + auto CloudSyncServiceProxy = ServiceProxy::GetInstance(); + if (!CloudSyncServiceProxy) { + LOGE("proxy is null"); + return E_SA_LOAD_FAILED; + } + SetDeathRecipient(CloudSyncServiceProxy->AsObject()); + return CloudSyncServiceProxy->ResetCursor(flag, bundleName); } int32_t CloudSyncManagerImpl::ChangeAppSwitch(const std::string &accoutId, const std::string &bundleName, bool status) diff --git a/frameworks/native/cloudsync_kit_inner_lite/src/cloud_sync_service_proxy_lite.cpp b/frameworks/native/cloudsync_kit_inner_lite/src/cloud_sync_service_proxy_lite.cpp index 5f8931edac7a1f2b210bb7237f674ffccf1fda9e..9a4e7087319e5618b6836e6462e8ded5ef00a787 100644 --- a/frameworks/native/cloudsync_kit_inner_lite/src/cloud_sync_service_proxy_lite.cpp +++ b/frameworks/native/cloudsync_kit_inner_lite/src/cloud_sync_service_proxy_lite.cpp @@ -194,7 +194,7 @@ int32_t CloudSyncServiceProxy::StopFileSyncInner(const std::string &bundleName, return E_OK; } -int32_t CloudSyncServiceProxy::ResetCursor(const std::string &bundleName) +int32_t CloudSyncServiceProxy::ResetCursor(bool flag, const std::string &bundleName) { return E_OK; } diff --git a/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_manager.h b/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_manager.h index aef152d431e8dc74f59a3fd7544bda446712e22f..fe98a18130f68b08b8e1c3c95e303ba72a9daf46 100644 --- a/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_manager.h +++ b/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_manager.h @@ -43,7 +43,7 @@ public: bool forceFlag, SyncTriggerType triggerType); virtual int32_t TriggerRecoverySync(SyncTriggerType triggerType); virtual int32_t StopUploadTask(const std::string &bundleName, const int32_t userId); - virtual int32_t ResetCursor(const std::string &bundleName, const int32_t &userId); + virtual int32_t ResetCursor(const std::string &bundleName, const int32_t &userId, bool flag = false); virtual void RegisterCloudSyncCallback(const std::string &bundleName, const std::string &callerBundleName, const int32_t userId, diff --git a/interfaces/inner_api/native/cloudsync_kit_inner/cloud_sync_manager.h b/interfaces/inner_api/native/cloudsync_kit_inner/cloud_sync_manager.h index c221ba9771979ac670f14a4464fe4755695e2174..fd52e59c7022c8aaecd6c71f17c0a04292bcda1c 100644 --- a/interfaces/inner_api/native/cloudsync_kit_inner/cloud_sync_manager.h +++ b/interfaces/inner_api/native/cloudsync_kit_inner/cloud_sync_manager.h @@ -82,6 +82,14 @@ public: * @return int32_t 同步返回执行结果 */ virtual int32_t ResetCursor(const std::string &bundleName = "") = 0; + /** + * @brief 清理水位 + * + * @param flag 状态位 + * @param bundleName 应用包名 + * @return int32_t 同步返回执行结果 + */ + virtual int32_t ResetCursor(bool flag, const std::string &bundleName = "") = 0; /** * @brief 切换应用云同步开关 * diff --git a/services/cloudsyncservice/ICloudSyncService.idl b/services/cloudsyncservice/ICloudSyncService.idl index fd6bef38b552c820b5087594be57f48cc8575433..2891a3c90a53778ff23afe306978234ef1a90548 100644 --- a/services/cloudsyncservice/ICloudSyncService.idl +++ b/services/cloudsyncservice/ICloudSyncService.idl @@ -35,7 +35,7 @@ interface OHOS.FileManagement.CloudSync.ICloudSyncService void TriggerSyncInner([in] String bundleName, [in] int userId); void StopSyncInner([in] String bundleName, [in] boolean forceFlag); void StopFileSyncInner([in] String bundleName, [in] boolean forceFlag); - void ResetCursor([in] String bundleName); + void ResetCursor([in] boolean flag, [in] String bundleName); void ChangeAppSwitch([in] String accoutId, [in] String bundleName, [in] boolean status); void OptimizeStorage([in] OptimizeSpaceOptions optimizeOptions, [in] boolean isCallbackValid, [in] IRemoteObject optimizeCallback); diff --git a/services/cloudsyncservice/include/ipc/cloud_sync_service.h b/services/cloudsyncservice/include/ipc/cloud_sync_service.h index e19c0abe332d0b47d10e512a8a8b3e7cd0281924..e2ff2d4c5544c236aee143738802fce7ea88e589 100644 --- a/services/cloudsyncservice/include/ipc/cloud_sync_service.h +++ b/services/cloudsyncservice/include/ipc/cloud_sync_service.h @@ -52,7 +52,7 @@ public: ErrCode TriggerSyncInner(const std::string &bundleName, int32_t userId) override; ErrCode StopSyncInner(const std::string &bundleName = "", bool forceFlag = false) override; ErrCode StopFileSyncInner(const std::string &bundleName = "", bool forceFlag = false) override; - ErrCode ResetCursor(const std::string &bundleName = "") override; + ErrCode ResetCursor(bool flag = false, const std::string &bundleName = "") override; ErrCode OptimizeStorage(const OptimizeSpaceOptions &optimizeOptions, bool isCallbackValid, const sptr &optimizeCallback) override; diff --git a/services/cloudsyncservice/src/ipc/cloud_sync_service.cpp b/services/cloudsyncservice/src/ipc/cloud_sync_service.cpp index 77acfd7d704e22e57b1dbdac843492902322dd32..e69e673681bc568d20321d9ba14cfb54c064cdfe 100644 --- a/services/cloudsyncservice/src/ipc/cloud_sync_service.cpp +++ b/services/cloudsyncservice/src/ipc/cloud_sync_service.cpp @@ -561,7 +561,7 @@ int32_t CloudSyncService::StopFileSyncInner(const string &bundleName, bool force return ret; } -int32_t CloudSyncService::ResetCursor(const string &bundleName) +int32_t CloudSyncService::ResetCursor(bool flag, const string &bundleName) { LOGI("Begin ResetCursor"); RETURN_ON_ERR(CheckPermissions(PERM_CLOUD_SYNC, true)); @@ -574,7 +574,7 @@ int32_t CloudSyncService::ResetCursor(const string &bundleName) return ret; } auto callerUserId = DfsuAccessTokenHelper::GetUserId(); - ret = dataSyncManager_->ResetCursor(targetBundleName, callerUserId); + ret = dataSyncManager_->ResetCursor(targetBundleName, callerUserId, flag); LOGI("End ResetCursor"); return ret; } diff --git a/test/unittests/ani_core/cloud_sync_manager_mock.h b/test/unittests/ani_core/cloud_sync_manager_mock.h index 9e5b7323245326af637d7a7d73d43736fb7bdaa4..db3ddff09edefc103fe7fb8fc552d6a08301e45f 100644 --- a/test/unittests/ani_core/cloud_sync_manager_mock.h +++ b/test/unittests/ani_core/cloud_sync_manager_mock.h @@ -41,6 +41,7 @@ public: MOCK_METHOD2(StopSync, int32_t(const std::string &bundleName, bool forceFlag)); MOCK_METHOD2(StopFileSync, int32_t(const std::string &bundleName, bool forceFlag)); MOCK_METHOD1(ResetCursor, int32_t(const std::string &bundleName)); + MOCK_METHOD2(ResetCursor, int32_t(bool flag, const std::string &bundleName)); MOCK_METHOD3(ChangeAppSwitch, int32_t(const std::string &accoutId, const std::string &bundleName, bool status)); MOCK_METHOD2(OptimizeStorage, int32_t(const OptimizeSpaceOptions &optimizeOptions, const std::shared_ptr optimizeCallback)); diff --git a/test/unittests/cloudsync_api/cloudsync_impl/cloud_sync_manager_impl_test.cpp b/test/unittests/cloudsync_api/cloudsync_impl/cloud_sync_manager_impl_test.cpp index ec2f9db67406f21406e24c26ec08faa322b22213..b8686d15a8fbfff07efd4eee23b891e0957ecb75 100644 --- a/test/unittests/cloudsync_api/cloudsync_impl/cloud_sync_manager_impl_test.cpp +++ b/test/unittests/cloudsync_api/cloudsync_impl/cloud_sync_manager_impl_test.cpp @@ -581,11 +581,29 @@ HWTEST_F(CloudSyncManagerImplTest, ResetCursorTest, TestSize.Level1) { string bundleName = "com.ohos.photos"; EXPECT_CALL(*proxy_, GetInstance()).WillOnce(Return(serviceProxy_)); - EXPECT_CALL(*serviceProxy_, ResetCursor(_)).WillOnce(Return(E_PERMISSION_DENIED)); + EXPECT_CALL(*serviceProxy_, ResetCursor(_, _)).WillOnce(Return(E_PERMISSION_DENIED)); int res = CloudSyncManagerImpl::GetInstance().ResetCursor(bundleName); EXPECT_EQ(res, E_PERMISSION_DENIED); } +HWTEST_F(CloudSyncManagerImplTest, ResetCursorTest002, TestSize.Level1) +{ + string bundleName = "com.ohos.photos"; + EXPECT_CALL(*proxy_, GetInstance()).WillOnce(Return(serviceProxy_)); + EXPECT_CALL(*serviceProxy_, ResetCursor(_, _)).WillOnce(Return(E_PERMISSION_DENIED)); + int res = CloudSyncManagerImpl::GetInstance().ResetCursor(false, bundleName); + EXPECT_EQ(res, E_PERMISSION_DENIED); +} + +HWTEST_F(CloudSyncManagerImplTest, ResetCursorTest003, TestSize.Level1) +{ + string bundleName = "com.ohos.photos"; + EXPECT_CALL(*proxy_, GetInstance()).WillOnce(Return(nullptr)); + EXPECT_CALL(*serviceProxy_, ResetCursor(_, _)).Times(0); + int res = CloudSyncManagerImpl::GetInstance().ResetCursor(false, bundleName); + EXPECT_EQ(res, E_SA_LOAD_FAILED); +} + HWTEST_F(CloudSyncManagerImplTest, DownloadThumbTest, TestSize.Level1) { EXPECT_CALL(*proxy_, GetInstance()).WillOnce(Return(serviceProxy_)); diff --git a/test/unittests/cloudsync_api/cloudsync_impl/include/i_cloud_sync_service_mock.h b/test/unittests/cloudsync_api/cloudsync_impl/include/i_cloud_sync_service_mock.h index ecfe4a624155727c4a3610f653a7ef4a35a9525f..c90a9a99d1e8540f6b6e07e826186a780dcc83c6 100644 --- a/test/unittests/cloudsync_api/cloudsync_impl/include/i_cloud_sync_service_mock.h +++ b/test/unittests/cloudsync_api/cloudsync_impl/include/i_cloud_sync_service_mock.h @@ -87,7 +87,7 @@ public: return E_OK; } - int32_t ResetCursor(const std::string &bundleName = "") override + int32_t ResetCursor(bool flag = false, const std::string &bundleName = "") override { return E_OK; } diff --git a/test/unittests/cloudsync_api/cloudsync_impl/include/service_proxy_mock.h b/test/unittests/cloudsync_api/cloudsync_impl/include/service_proxy_mock.h index 99ac86a605bc7a2e8b2240efd688e8842d27a1ad..854705877420cda83af796c3310f45fa6cbc9c09 100644 --- a/test/unittests/cloudsync_api/cloudsync_impl/include/service_proxy_mock.h +++ b/test/unittests/cloudsync_api/cloudsync_impl/include/service_proxy_mock.h @@ -43,7 +43,7 @@ public: MOCK_METHOD2(TriggerSyncInner, int32_t(const std::string &bundleName, int32_t userId)); MOCK_METHOD2(StopSyncInner, int32_t(const std::string &bundleName, bool forceFlag)); MOCK_METHOD2(StopFileSyncInner, int32_t(const std::string &bundleName, bool forceFlag)); - MOCK_METHOD1(ResetCursor, int32_t(const std::string &bundleName)); + MOCK_METHOD2(ResetCursor, int32_t(bool flag, const std::string &bundleName)); MOCK_METHOD3(ChangeAppSwitch, int32_t(const std::string &accoutId, const std::string &bundleName, bool status)); MOCK_METHOD3(OptimizeStorage, int32_t(const OptimizeSpaceOptions &optimizeOptions, diff --git a/test/unittests/cloudsync_sa/ipc/cloud_sync_service_stub_test.cpp b/test/unittests/cloudsync_sa/ipc/cloud_sync_service_stub_test.cpp index 136cc449828e2ed2a23ea1e14ccb1ec0a31cd515..94fec32d3ae86822277a6c7743b0dca09e41a39e 100644 --- a/test/unittests/cloudsync_sa/ipc/cloud_sync_service_stub_test.cpp +++ b/test/unittests/cloudsync_sa/ipc/cloud_sync_service_stub_test.cpp @@ -42,7 +42,7 @@ public: MOCK_METHOD2(TriggerSyncInner, int32_t(const std::string &bundleName, const int32_t &userId)); MOCK_METHOD2(StopSyncInner, int32_t(const std::string &bundleName, bool forceFlag)); MOCK_METHOD2(StopFileSyncInner, int32_t(const std::string &bundleName, bool forceFlag)); - MOCK_METHOD1(ResetCursor, int32_t(const std::string &bundleName)); + MOCK_METHOD2(ResetCursor, int32_t(bool flag, const std::string &bundleName)); MOCK_METHOD3(ChangeAppSwitch, int32_t(const std::string &accoutId, const std::string &bundleName, bool status)); MOCK_METHOD2(Clean, int32_t(const std::string &accountId, const CleanOptions &cleanOptions)); MOCK_METHOD2(NotifyDataChange, int32_t(const std::string &accoutId, const std::string &bundleName));