blob: 6e8d58bc33adb6373928415b81f5c6b17547eb15 [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
Chenjie Yu1a317ba2017-10-05 16:05:32 -070017#define DEBUG true
Joe Onorato9fc9edf2017-10-15 20:08:52 -070018#include "Log.h"
Chenjie Yu1a317ba2017-10-05 16:05:32 -070019
Chenjie Yu1a317ba2017-10-05 16:05:32 -070020#include <android/os/IStatsCompanionService.h>
Chenjie Yu1a317ba2017-10-05 16:05:32 -070021#include "KernelWakelockPuller.h"
Joe Onorato9fc9edf2017-10-15 20:08:52 -070022#include "StatsService.h"
23#include "external/StatsPullerManager.h"
Chenjie Yu1a317ba2017-10-05 16:05:32 -070024
25using namespace android;
26
27namespace android {
28namespace os {
29namespace statsd {
30
31const int StatsPullerManager::KERNEL_WAKELOCKS = 1;
32
33StatsPullerManager::StatsPullerManager() {
34 mStatsPullers.insert(
35 {static_cast<int>(KERNEL_WAKELOCKS), std::make_unique<KernelWakelockPuller>()});
36}
37
38String16 StatsPullerManager::pull(int pullCode) {
39 if (DEBUG) ALOGD("Initiating pulling %d", pullCode);
40 if (mStatsPullers.find(pullCode) != mStatsPullers.end()) {
41 return (mStatsPullers.find(pullCode)->second)->pull();
42 } else {
43 ALOGD("Unknown pull code %d", pullCode);
44 return String16();
45 }
46}
47
48} // namespace statsd
49} // namespace os
50} // namespace android