• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
16 #include "bundle_active_stats_combiner.h"
17 
18 namespace OHOS {
19 namespace DeviceUsageStats {
combine(const std::shared_ptr<BundleActivePeriodStats> & stats,std::vector<BundleActivePackageStats> & accumulatedResult,int64_t beginTime)20 void BundleActiveStatsCombiner<BundleActivePackageStats>::combine(
21     const std::shared_ptr<BundleActivePeriodStats>& stats, std::vector<BundleActivePackageStats>& accumulatedResult,
22     int64_t beginTime)
23 {
24     BUNDLE_ACTIVE_LOGI("BundleActivePackageStats combine called");
25     for (auto it : stats->bundleStats_) {
26         if (it.second != nullptr) {
27             accumulatedResult.push_back(*(it.second));
28         }
29     }
30 }
31 
combine(const std::shared_ptr<BundleActivePeriodStats> & stats,std::vector<BundleActiveEvent> & accumulatedResult,int64_t beginTime)32 void BundleActiveStatsCombiner<BundleActiveEvent>::combine(const std::shared_ptr<BundleActivePeriodStats>& stats,
33     std::vector<BundleActiveEvent>& accumulatedResult, int64_t beginTime)
34 {
35     BUNDLE_ACTIVE_LOGI("BundleActiveEvent combine called");
36     int32_t startIndex = stats->events_.FindBestIndex(beginTime);
37     int32_t size = static_cast<int32_t>(stats->events_.events_.size());
38     for (int32_t i = startIndex; i < size; i++) {
39         accumulatedResult.push_back(stats->events_.events_[i]);
40     }
41 }
42 }  // namespace DeviceUsageStats
43 }  // namespace OHOS
44 
45