• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2   * Copyright (C) 2019 The Android Open Source Project
3   *
4   * Licensed under the Apache License, Version 2.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *      http://www.apache.org/licenses/LICENSE-2.0
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  #define STATSD_DEBUG false  // STOPSHIP if true
18  #include "Log.h"
19  
20  #include "external/StatsPuller.h"
21  
22  #include "TrainInfoPuller.h"
23  #include "logd/LogEvent.h"
24  #include "stats_log_util.h"
25  #include "statslog_statsd.h"
26  #include "storage/StorageManager.h"
27  
28  using std::make_shared;
29  using std::shared_ptr;
30  
31  namespace android {
32  namespace os {
33  namespace statsd {
34  
TrainInfoPuller()35  TrainInfoPuller::TrainInfoPuller() :
36      StatsPuller(util::TRAIN_INFO) {
37  }
38  
PullInternal(vector<shared_ptr<LogEvent>> * data)39  PullErrorCode TrainInfoPuller::PullInternal(vector<shared_ptr<LogEvent>>* data) {
40      vector<InstallTrainInfo> trainInfoList =
41          StorageManager::readAllTrainInfo();
42      if (trainInfoList.empty()) {
43          ALOGW("Train info was empty.");
44          return PULL_SUCCESS;
45      }
46      for (InstallTrainInfo& trainInfo : trainInfoList) {
47          auto event = make_shared<LogEvent>(getWallClockNs(), getElapsedRealtimeNs(), trainInfo);
48          data->push_back(event);
49      }
50      return PULL_SUCCESS;
51  }
52  
53  }  // namespace statsd
54  }  // namespace os
55  }  // namespace android
56