blob: f4cf1ceaf18abe474ea06b7eb730da91ea2abadb [file] [log] [blame]
Chenjie Yu1a317ba2017-10-05 16:05:32 -07001/*
2 * Copyright (C) 2017 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 LOG_TAG "StatsPullerManager"
18#define DEBUG true
19
20#include "StatsPullerManager.h"
21#include <android/os/IStatsCompanionService.h>
22#include <cutils/log.h>
23#include "StatsService.h"
24#include "KernelWakelockPuller.h"
25
26
27using namespace android;
28
29namespace android {
30namespace os {
31namespace statsd {
32
33const int StatsPullerManager::KERNEL_WAKELOCKS = 1;
34
35StatsPullerManager::StatsPullerManager() {
36 mStatsPullers.insert(
37 {static_cast<int>(KERNEL_WAKELOCKS), std::make_unique<KernelWakelockPuller>()});
38}
39
40String16 StatsPullerManager::pull(int pullCode) {
41 if (DEBUG) ALOGD("Initiating pulling %d", pullCode);
42 if (mStatsPullers.find(pullCode) != mStatsPullers.end()) {
43 return (mStatsPullers.find(pullCode)->second)->pull();
44 } else {
45 ALOGD("Unknown pull code %d", pullCode);
46 return String16();
47 }
48}
49
50} // namespace statsd
51} // namespace os
52} // namespace android