blob: a7d8d4ebebae3c6060571b0757221963901c0bf7 [file] [log] [blame]
Chenjie Yu97dbb202019-02-13 16:42:04 -08001/*
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 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.h"
26#include "storage/StorageManager.h"
27
28using std::make_shared;
29using std::shared_ptr;
30
31namespace android {
32namespace os {
33namespace statsd {
34
35TrainInfoPuller::TrainInfoPuller() :
36 StatsPuller(android::util::TRAIN_INFO) {
37}
38
39bool TrainInfoPuller::PullInternal(vector<shared_ptr<LogEvent>>* data) {
Jonathan Nguyen703c42f2020-02-04 15:54:26 -080040 vector<InstallTrainInfo> trainInfoList =
41 StorageManager::readAllTrainInfo();
42 if (trainInfoList.empty()) {
43 ALOGW("Train info was empty.");
44 return true;
Chenjie Yu97dbb202019-02-13 16:42:04 -080045 }
Jonathan Nguyen703c42f2020-02-04 15:54:26 -080046 for (InstallTrainInfo& trainInfo : trainInfoList) {
47 auto event = make_shared<LogEvent>(getWallClockNs(), getElapsedRealtimeNs(), trainInfo);
48 data->push_back(event);
49 }
Chenjie Yu97dbb202019-02-13 16:42:04 -080050 return true;
51}
52
53} // namespace statsd
54} // namespace os
55} // namespace android