From 53bb0ffd1434d5b90031a4c1ee3c5edf10b4c4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=9B=BD=E5=87=AF?= Date: Thu, 13 Jun 2024 14:23:20 +0800 Subject: [PATCH 1/5] xuguokai1@huawei.com add report sysevent cycletask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 徐国凯 --- .../src/data_sync_manager.cpp | 5 +++ .../cloud_file_kit_inner/data_sync_manager.h | 1 + .../cycle_task/tasks/repot_statistics_task.h | 33 +++++++++++++++ .../tasks/report_statistics_task.cpp | 40 +++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 services/cloudsyncservice/include/cycle_task/tasks/repot_statistics_task.h create mode 100644 services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp 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 7d0f0f163..000c85e2f 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_manager.h b/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_manager.h index e9bd9a02e..f210a74cf 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/include/cycle_task/tasks/repot_statistics_task.h b/services/cloudsyncservice/include/cycle_task/tasks/repot_statistics_task.h new file mode 100644 index 000000000..dcc1a056d --- /dev/null +++ b/services/cloudsyncservice/include/cycle_task/tasks/repot_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: + ReportSysEventStat(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/tasks/report_statistics_task.cpp b/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp new file mode 100644 index 000000000..0ea6194bb --- /dev/null +++ b/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp @@ -0,0 +1,40 @@ +/* + * 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 "repot_statistics_task.h" +#include "parameters.h" +#include "utils_log.h" + +namespace OHOS { +namespace FileManagement { +namespace CloudSync { +static const std::string FILEMANAGER_KEY = "persist.kernel.bundle_name.filemanager"; +ReportStatisticsTask::ReportStatisticsTask(std::shared_ptr dataSyncManager) + : CycleTask(ReportStatisticsTaskName, {"com.ohos.photos", system::GetParameter(FILEMANAGER_KEY, "")}, + 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", bundleName.c_str()); + } + return ret; +} +} // namespace CloudSync +} // namespace FileManagement +} // namespace OHOS \ No newline at end of file -- Gitee From b3529f4eec80c6141804184a44908025e56c7d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=9B=BD=E5=87=AF?= Date: Thu, 13 Jun 2024 17:56:41 +0800 Subject: [PATCH 2/5] --amend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 徐国凯 --- services/cloudsyncservice/BUILD.gn | 2 ++ .../include/cycle_task/tasks/repot_statistics_task.h | 2 +- .../src/cycle_task/cycle_task_runner.cpp | 1 + .../src/cycle_task/tasks/report_statistics_task.cpp | 9 +++------ test/unittests/cloudsync_sa/ipc/BUILD.gn | 1 + 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/services/cloudsyncservice/BUILD.gn b/services/cloudsyncservice/BUILD.gn index ef71932ca..46bca3290 100644 --- a/services/cloudsyncservice/BUILD.gn +++ b/services/cloudsyncservice/BUILD.gn @@ -51,6 +51,7 @@ ohos_shared_library("cloudsync_sa") { "src/cycle_task/tasks/optimize_storage_task.cpp", "src/cycle_task/tasks/periodic_check_task.cpp", "src/cycle_task/tasks/save_subscription_task.cpp", + "src/cycle_task/tasks/report_statistics_task.cpp", ] transport = [ @@ -154,6 +155,7 @@ ohos_static_library("cloudsync_sa_static") { "src/cycle_task/tasks/optimize_storage_task.cpp", "src/cycle_task/tasks/periodic_check_task.cpp", "src/cycle_task/tasks/save_subscription_task.cpp", + "src/cycle_task/tasks/report_statistics_task.cpp", ] transport = [ diff --git a/services/cloudsyncservice/include/cycle_task/tasks/repot_statistics_task.h b/services/cloudsyncservice/include/cycle_task/tasks/repot_statistics_task.h index dcc1a056d..14604184a 100644 --- a/services/cloudsyncservice/include/cycle_task/tasks/repot_statistics_task.h +++ b/services/cloudsyncservice/include/cycle_task/tasks/repot_statistics_task.h @@ -24,7 +24,7 @@ namespace CloudSync { class ReportStatisticsTask : public CycleTask { public: - ReportSysEventStat(std::shared_ptr dataSyncManager); + ReportStatisticsTask(std::shared_ptr dataSyncManager); int32_t RunTaskForBundle(int32_t userId, std::string bundleName) override; }; } // namespace CloudSync diff --git a/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp b/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp index 52712ea86..8bb4ff957 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" diff --git a/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp b/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp index 0ea6194bb..31355b51c 100644 --- a/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp +++ b/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp @@ -12,18 +12,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "repot_statistics_task.h" +#include "report_statistics_task.h" #include "parameters.h" #include "utils_log.h" namespace OHOS { namespace FileManagement { namespace CloudSync { -static const std::string FILEMANAGER_KEY = "persist.kernel.bundle_name.filemanager"; ReportStatisticsTask::ReportStatisticsTask(std::shared_ptr dataSyncManager) - : CycleTask(ReportStatisticsTaskName, {"com.ohos.photos", system::GetParameter(FILEMANAGER_KEY, "")}, - ONE_WEEK, - dataSyncManager) + : CycleTask(ReportStatisticsTaskName, {"com.ohos.photos"}, ONE_WEEK, dataSyncManager) { } @@ -31,7 +28,7 @@ int32_t ReportStatisticsTask::RunTaskForBundle(int32_t userId, std::string bundl { int32_t ret = dataSyncManager_->ReportDownloadStat(bundleName, userId); if (ret != E_OK) { - LOGE("report download file stat failed", bundleName.c_str()); + LOGE("report download file stat failed"); } return ret; } diff --git a/test/unittests/cloudsync_sa/ipc/BUILD.gn b/test/unittests/cloudsync_sa/ipc/BUILD.gn index 0b9c4d60c..c34dd24df 100644 --- a/test/unittests/cloudsync_sa/ipc/BUILD.gn +++ b/test/unittests/cloudsync_sa/ipc/BUILD.gn @@ -74,6 +74,7 @@ ohos_unittest("cloud_sync_service_test") { "${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/save_subscription_task.cpp", + "${services_path}/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp", "${services_path}/cloudsyncservice/src/ipc/cloud_sync_service.cpp", "${services_path}/cloudsyncservice/src/ipc/cloud_sync_service_stub.cpp", "${services_path}/cloudsyncservice/src/ipc/download_asset_callback_manager.cpp", -- Gitee From e39b643b5b3a0e72e86b68d935dc93b0fb8a1db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=9B=BD=E5=87=AF?= Date: Fri, 14 Jun 2024 11:48:59 +0800 Subject: [PATCH 3/5] --amend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 徐国凯 --- services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp b/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp index 8bb4ff957..29a39feda 100644 --- a/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp +++ b/services/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp @@ -63,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) -- Gitee From 48943e3ccad679af121f3df77f1283253e1d6d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=9B=BD=E5=87=AF?= Date: Fri, 14 Jun 2024 15:29:13 +0800 Subject: [PATCH 4/5] --amend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 徐国凯 --- .../src/cycle_task/tasks/report_statistics_task.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp b/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp index 31355b51c..08034542f 100644 --- a/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp +++ b/services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp @@ -20,7 +20,7 @@ namespace OHOS { namespace FileManagement { namespace CloudSync { ReportStatisticsTask::ReportStatisticsTask(std::shared_ptr dataSyncManager) - : CycleTask(ReportStatisticsTaskName, {"com.ohos.photos"}, ONE_WEEK, dataSyncManager) + : CycleTask("report_statistics_task", {"com.ohos.photos"}, ONE_WEEK, dataSyncManager) { } -- Gitee From d97294f2e18b4ea011eafcad9949e72e56353e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=9B=BD=E5=87=AF?= Date: Sat, 15 Jun 2024 16:32:03 +0800 Subject: [PATCH 5/5] xuguokai1@huawei.com add cloud hisysevent report cycle task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 徐国凯 --- .../src/data_sync_manager.cpp | 5 +++ .../cloud_file_kit_inner/data_sync_manager.h | 1 + services/cloudsyncservice/BUILD.gn | 2 + .../cycle_task/tasks/report_statistics_task.h | 33 ++++++++++++++++ .../src/cycle_task/cycle_task_runner.cpp | 2 + .../tasks/report_statistics_task.cpp | 38 +++++++++++++++++++ test/unittests/cloudsync_sa/ipc/BUILD.gn | 1 + 7 files changed, 82 insertions(+) create mode 100644 services/cloudsyncservice/include/cycle_task/tasks/report_statistics_task.h create mode 100644 services/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp 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 7d0f0f163..000c85e2f 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_manager.h b/interfaces/inner_api/native/cloud_file_kit_inner/data_sync_manager.h index e9bd9a02e..f210a74cf 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 ef71932ca..46bca3290 100644 --- a/services/cloudsyncservice/BUILD.gn +++ b/services/cloudsyncservice/BUILD.gn @@ -51,6 +51,7 @@ ohos_shared_library("cloudsync_sa") { "src/cycle_task/tasks/optimize_storage_task.cpp", "src/cycle_task/tasks/periodic_check_task.cpp", "src/cycle_task/tasks/save_subscription_task.cpp", + "src/cycle_task/tasks/report_statistics_task.cpp", ] transport = [ @@ -154,6 +155,7 @@ ohos_static_library("cloudsync_sa_static") { "src/cycle_task/tasks/optimize_storage_task.cpp", "src/cycle_task/tasks/periodic_check_task.cpp", "src/cycle_task/tasks/save_subscription_task.cpp", + "src/cycle_task/tasks/report_statistics_task.cpp", ] transport = [ 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 000000000..14604184a --- /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 52712ea86..29a39feda 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 000000000..93f7bbb1d --- /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 0b9c4d60c..c34dd24df 100644 --- a/test/unittests/cloudsync_sa/ipc/BUILD.gn +++ b/test/unittests/cloudsync_sa/ipc/BUILD.gn @@ -74,6 +74,7 @@ ohos_unittest("cloud_sync_service_test") { "${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/save_subscription_task.cpp", + "${services_path}/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp", "${services_path}/cloudsyncservice/src/ipc/cloud_sync_service.cpp", "${services_path}/cloudsyncservice/src/ipc/cloud_sync_service_stub.cpp", "${services_path}/cloudsyncservice/src/ipc/download_asset_callback_manager.cpp", -- Gitee