• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifdef RESOURCE_REQUEST_REQUEST
16 #include "download_upload_observer.h"
17 #include "nlohmann/json.hpp"
18 #include "res_sched_log.h"
19 #include "res_sched_mgr.h"
20 #include "res_type.h"
21 namespace OHOS {
22 namespace ResourceSchedule {
OnRunningTaskCountUpdate(int count)23 void DownLoadUploadObserver::OnRunningTaskCountUpdate(int count)
24 {
25     RESSCHED_LOGD("download upload on running task count %{public}d", count);
26     const nlohmann::json payload = nlohmann::json::object();
27     if (count > 0 && !isReportScene) {
28         ResSchedMgr::GetInstance().ReportData(ResType::RES_TYPE_UPLOAD_DOWNLOAD,
29             ResType::KeyUploadOrDownloadStatus::ENTER_UPLOAD_DOWNLOAD_SCENE, payload);
30         isReportScene = true;
31         return;
32     }
33     if (count == 0 && isReportScene) {
34         ResSchedMgr::GetInstance().ReportData(ResType::RES_TYPE_UPLOAD_DOWNLOAD,
35             ResType::KeyUploadOrDownloadStatus::EXIT_UPLOAD_DOWNLOAD_SCENE, payload);
36         isReportScene = false;
37     }
38 }
39 } // namespace ResourceSchedule
40 } // namespace OHOS
41 #endif
42