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 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 17 | #include "Log.h" |
| 18 | |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 19 | #include <android/os/IStatsCompanionService.h> |
| 20 | #include <binder/IPCThreadState.h> |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 21 | #include <private/android_filesystem_config.h> |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 22 | #include "StatsService.h" |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 23 | #include "external/KernelWakelockPuller.h" |
| 24 | #include "external/StatsPuller.h" |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 25 | |
| 26 | using namespace android; |
| 27 | using namespace android::base; |
| 28 | using namespace android::binder; |
| 29 | using namespace android::os; |
| 30 | using namespace std; |
| 31 | |
| 32 | namespace android { |
| 33 | namespace os { |
| 34 | namespace statsd { |
| 35 | |
| 36 | const int KernelWakelockPuller::PULL_CODE_KERNEL_WAKELOCKS = 20; |
| 37 | |
| 38 | // The reading and parsing are implemented in Java. It is not difficult to port over. But for now |
| 39 | // let StatsCompanionService handle that and send the data back. |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame^] | 40 | vector<StatsLogEventWrapper> KernelWakelockPuller::pull() { |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 41 | sp<IStatsCompanionService> statsCompanion = StatsService::getStatsCompanionService(); |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame^] | 42 | vector<StatsLogEventWrapper> returned_value; |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 43 | if (statsCompanion != NULL) { |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 44 | Status status = statsCompanion->pullData(KernelWakelockPuller::PULL_CODE_KERNEL_WAKELOCKS, |
| 45 | &returned_value); |
| 46 | if (!status.isOk()) { |
| 47 | ALOGW("error pulling kernel wakelock"); |
| 48 | } |
| 49 | ALOGD("KernelWakelockPuller::pull succeeded!"); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 50 | return returned_value; |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 51 | } else { |
| 52 | ALOGW("statsCompanion not found!"); |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame^] | 53 | return returned_value; |
Chenjie Yu | 1a317ba | 2017-10-05 16:05:32 -0700 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
| 57 | } // namespace statsd |
| 58 | } // namespace os |
| 59 | } // namespace android |