blob: ee072f80aa4ad17515073cb55ce51c2a6f21584c [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
Joe Onorato9fc9edf2017-10-15 20:08:52 -070017#include "Log.h"
18
Chenjie Yu1a317ba2017-10-05 16:05:32 -070019#include <android/os/IStatsCompanionService.h>
20#include <binder/IPCThreadState.h>
Chenjie Yu1a317ba2017-10-05 16:05:32 -070021#include <private/android_filesystem_config.h>
Chenjie Yu1a317ba2017-10-05 16:05:32 -070022#include "StatsService.h"
Joe Onorato9fc9edf2017-10-15 20:08:52 -070023#include "external/KernelWakelockPuller.h"
24#include "external/StatsPuller.h"
Chenjie Yu1a317ba2017-10-05 16:05:32 -070025
26using namespace android;
27using namespace android::base;
28using namespace android::binder;
29using namespace android::os;
30using namespace std;
31
32namespace android {
33namespace os {
34namespace statsd {
35
36const 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 Chen1481fe12017-10-16 13:16:34 -070040vector<StatsLogEventWrapper> KernelWakelockPuller::pull() {
Chenjie Yu1a317ba2017-10-05 16:05:32 -070041 sp<IStatsCompanionService> statsCompanion = StatsService::getStatsCompanionService();
David Chen1481fe12017-10-16 13:16:34 -070042 vector<StatsLogEventWrapper> returned_value;
Chenjie Yu1a317ba2017-10-05 16:05:32 -070043 if (statsCompanion != NULL) {
Joe Onorato9fc9edf2017-10-15 20:08:52 -070044 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 Onorato9fc9edf2017-10-15 20:08:52 -070050 return returned_value;
Chenjie Yu1a317ba2017-10-05 16:05:32 -070051 } else {
52 ALOGW("statsCompanion not found!");
David Chen1481fe12017-10-16 13:16:34 -070053 return returned_value;
Chenjie Yu1a317ba2017-10-05 16:05:32 -070054 }
55}
56
57} // namespace statsd
58} // namespace os
59} // namespace android