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 7d0f0f163f42ef5ab795ddba3c5c039629449da1..000c85e2ff66372b177a1d81b2258d3b7657a361 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 @@ -114,4 +114,9 @@ int32_t DataSyncManager::SaveSubscription(const std::string &bundleName, const i { return E_OK; } + +int32_t DataSyncManager::ReportDownloadStat(const std::string &bundleName, const int32_t userId) +{ + return E_OK; +} } // namespace OHOS::FileManagement::CloudFile \ No newline at end of file diff --git a/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_const.h b/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_const.h index a119e5a4b26cbf1c002e7ef1cd86ff4f55827856..0733e676e0508a31817d75c5539d2f06dd333088 100644 --- a/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_const.h +++ b/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_const.h @@ -69,7 +69,7 @@ static inline uint64_t GetCurrentTimeStamp() { struct timespec t; clock_gettime(CLOCK_REALTIME, &t); - return t.tv_sec * MILLISECOND_TO_NANOSECOND + t.tv_nsec / MILLISECOND_TO_NANOSECOND; + return t.tv_sec * MILLISECOND_TO_NANOSECOND + t.tv_nsec / SECOND_TO_MILLISECOND; } } // namespace OHOS::FileManagement::CloudSync #endif // OHOS_CLOUD_SYNC_SERVICE_DATA_SYNC_CONST_H 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 e9bd9a02e362bcfe9580b3e3874c6327a8b09d46..f210a74cf9ed25f3515dbbf3fe962ef7489b5fa0 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 @@ -52,6 +52,7 @@ public: virtual int32_t DisableCloud(const int32_t userId); virtual int32_t GetUserId(int32_t &userId); virtual int32_t SaveSubscription(const std::string &bundleName, const int32_t userId); + virtual int32_t ReportDownloadStat(const std::string &bundleName, const int32_t userId); }; } // namespace OHOS::FileManagement::CloudSync diff --git a/services/cloudsyncservice/BUILD.gn b/services/cloudsyncservice/BUILD.gn index ef71932ca539948dad5c44091b650433a4088120..4115859cb7df9ebc8530136c7174b651862b67d2 100644 --- a/services/cloudsyncservice/BUILD.gn +++ b/services/cloudsyncservice/BUILD.gn @@ -50,6 +50,7 @@ ohos_shared_library("cloudsync_sa") { "src/cycle_task/cycle_task_runner.cpp", "src/cycle_task/tasks/optimize_storage_task.cpp", "src/cycle_task/tasks/periodic_check_task.cpp", + "src/cycle_task/tasks/report_statistics_task.cpp", "src/cycle_task/tasks/save_subscription_task.cpp", ] @@ -153,6 +154,7 @@ ohos_static_library("cloudsync_sa_static") { "src/cycle_task/cycle_task_runner.cpp", "src/cycle_task/tasks/optimize_storage_task.cpp", "src/cycle_task/tasks/periodic_check_task.cpp", + "src/cycle_task/tasks/report_statistics_task.cpp", "src/cycle_task/tasks/save_subscription_task.cpp", ] diff --git a/services/cloudsyncservice/include/cycle_task/tasks/report_statistics_task.h b/services/cloudsyncservice/include/cycle_task/tasks/report_statistics_task.h new file mode 100644 index 0000000000000000000000000000000000000000..14604184a209c0720e63185a03e1c08f24f69421 --- /dev/null +++ b/services/cloudsyncservice/include/cycle_task/tasks/report_statistics_task.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_CLOUD_SYNC_SERVICE_REPORT_STATISTICS_TASK_H +#define OHOS_CLOUD_SYNC_SERVICE_REPORT_STATISTICS_TASK_H +#include "cloud_pref_impl.h" +#include "cycle_task.h" + +namespace OHOS { +namespace FileManagement { +namespace CloudSync { + +class ReportStatisticsTask : public CycleTask { +public: + ReportStatisticsTask(std::shared_ptr dataSyncManager); + int32_t RunTaskForBundle(int32_t userId, std::string bundleName) override; +}; +} // namespace CloudSync +} // namespace FileManagement +} // namespace OHOS +#endif // OHOS_CLOUD_SYNC_SERVICE_SERVICE_REPORT_STATISTICS_TASK_H \ No newline at end of file diff --git a/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp b/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp index 52712ea86412c10d4c101e30d488a6d25a9f852d..29a39fedad4b56f6f35cf5df292a08eb11bec538 100644 --- a/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp +++ b/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp @@ -21,6 +21,7 @@ #include "tasks/optimize_storage_task.h" #include "tasks/periodic_check_task.h" #include "tasks/save_subscription_task.h" +#include "tasks/report_statistics_task.h" #include "cloud_status.h" #include "utils_log.h" #include "os_account_manager.h" @@ -62,6 +63,7 @@ void CycleTaskRunner::InitTasks() cycleTasks_.push_back(std::make_shared(dataSyncManager_)); cycleTasks_.push_back(std::make_shared(dataSyncManager_)); cycleTasks_.push_back(std::make_shared(dataSyncManager_)); + cycleTasks_.push_back(std::make_shared(dataSyncManager_)); } static int32_t GetString(const string &key, string &val, NativeRdb::ResultSet &resultSet) diff --git a/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp b/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp new file mode 100644 index 0000000000000000000000000000000000000000..93f7bbb1d76d5f4245586ca56ca91cdf666d7217 --- /dev/null +++ b/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "report_statistics_task.h" + +#include "parameters.h" +#include "utils_log.h" + +namespace OHOS { +namespace FileManagement { +namespace CloudSync { +ReportStatisticsTask::ReportStatisticsTask(std::shared_ptr dataSyncManager) + : CycleTask("report_statistics_task", {"com.ohos.photos"}, ONE_WEEK, dataSyncManager) +{ +} + +int32_t ReportStatisticsTask::RunTaskForBundle(int32_t userId, std::string bundleName) +{ + int32_t ret = dataSyncManager_->ReportDownloadStat(bundleName, userId); + if (ret != E_OK) { + LOGE("report download file stat failed"); + } + return ret; +} +} // namespace CloudSync +} // namespace FileManagement +} // namespace OHOS \ No newline at end of file diff --git a/test/unittests/cloudsync_sa/ipc/BUILD.gn b/test/unittests/cloudsync_sa/ipc/BUILD.gn index 0b9c4d60c01ea152b6985549dcf70a3a434a50f8..9fc44d42be307ce13cc04ee0330545035503aa87 100644 --- a/test/unittests/cloudsync_sa/ipc/BUILD.gn +++ b/test/unittests/cloudsync_sa/ipc/BUILD.gn @@ -73,6 +73,7 @@ ohos_unittest("cloud_sync_service_test") { "${services_path}/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp", "${services_path}/cloudsyncservice/src/cycle_task/tasks/optimize_storage_task.cpp", "${services_path}/cloudsyncservice/src/cycle_task/tasks/periodic_check_task.cpp", + "${services_path}/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp", "${services_path}/cloudsyncservice/src/cycle_task/tasks/save_subscription_task.cpp", "${services_path}/cloudsyncservice/src/ipc/cloud_sync_service.cpp", "${services_path}/cloudsyncservice/src/ipc/cloud_sync_service_stub.cpp",