| Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 1 | /* |
| 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 Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 17 | #define DEBUG true |
| Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame^] | 18 | #include "Log.h" |
| Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 19 | |
| Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 20 | #include <android/os/IStatsCompanionService.h> |
| Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 21 | #include "KernelWakelockPuller.h" |
| Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame^] | 22 | #include "StatsService.h" |
| 23 | #include "external/StatsPullerManager.h" |
| Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 24 | |
| 25 | using namespace android; |
| 26 | |
| 27 | namespace android { |
| 28 | namespace os { |
| 29 | namespace statsd { |
| 30 | |
| 31 | const int StatsPullerManager::KERNEL_WAKELOCKS = 1; |
| 32 | |
| 33 | StatsPullerManager::StatsPullerManager() { |
| 34 | mStatsPullers.insert( |
| 35 | {static_cast<int>(KERNEL_WAKELOCKS), std::make_unique<KernelWakelockPuller>()}); |
| 36 | } |
| 37 | |
| 38 | String16 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 |