Bookatz | c68a9d2 | 2017-09-27 14:09:55 -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 | |
| 17 | #define LOG_TAG "StatsPuller" |
| 18 | #define DEBUG true |
| 19 | |
| 20 | #include "StatsPuller.h" |
| 21 | #include "StatsService.h" |
| 22 | #include <android/os/IStatsCompanionService.h> |
| 23 | #include <cutils/log.h> |
| 24 | |
| 25 | using namespace android; |
| 26 | |
| 27 | namespace android { |
| 28 | namespace os { |
| 29 | namespace statsd { |
| 30 | |
| 31 | String16 StatsPuller::pull(int pullCode) { |
| 32 | if (DEBUG) ALOGD("Initiating pulling %d", pullCode); |
| 33 | |
| 34 | switch (pullCode) { |
| 35 | // All stats_companion_service cases go here with fallthroughs |
| 36 | case PULL_CODE_KERNEL_WAKELOCKS: { |
| 37 | // TODO: Consider caching the statsCompanion service |
| 38 | sp <IStatsCompanionService> |
| 39 | statsCompanion = StatsService::getStatsCompanionService(); |
| 40 | String16 returned_value(""); |
| 41 | Status status = statsCompanion->pullData(pullCode, &returned_value); |
| 42 | if (DEBUG) ALOGD("Finished pulling the data"); |
| 43 | if (!status.isOk()) { |
| 44 | ALOGW("error pulling data of type %d", pullCode); |
| 45 | } |
| 46 | return returned_value; |
| 47 | } |
| 48 | |
| 49 | // case OTHER_TYPES: etc. |
| 50 | |
| 51 | default: { |
| 52 | ALOGE("invalid pull code %d", pullCode); |
| 53 | return String16(""); |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | } // namespace statsd |
| 59 | } // namespace os |
| 60 | } // namespace android |