Merge "PowerHAL: add debug support for low power stats"

This commit is contained in:
Kelly Rossmoyer
2018-10-23 21:23:30 +00:00
committed by Android (Google) Code Review
4 changed files with 43 additions and 0 deletions

17
Android.bp Normal file
View File

@@ -0,0 +1,17 @@
//
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
soong_namespace {
imports: ["hardware/google/pixel"],
}

View File

@@ -14,6 +14,10 @@
# limitations under the License.
#
PRODUCT_SOONG_NAMESPACES += \
device/google/wahoo \
hardware/google/pixel
ifneq (,$(filter 27, $(PRODUCT_EXTRA_VNDK_VERSIONS)))
_vndk_test := true
endif

View File

@@ -21,6 +21,9 @@ cc_binary {
"-Wall",
"-Werror",
],
static_libs: [
"libpixelpowerstats",
],
shared_libs: [
"libbase",
"libhidlbase",

View File

@@ -23,6 +23,8 @@
#include <android-base/strings.h>
#include <android-base/stringprintf.h>
#include <pixelpowerstats/Debugging.h>
#include <mutex>
#include <utils/Log.h>
@@ -50,6 +52,8 @@ using ::android::hardware::power::V1_1::PowerStateSubsystemSleepState;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::hardware::google::pixel::powerstats::DumpPowerHal1_0PlatStatsToFd;
using ::hardware::google::pixel::powerstats::DumpPowerHal1_1SubsysStatsToFd;
Power::Power() :
mHintManager(nullptr),
@@ -545,6 +549,21 @@ Return<void> Power::debug(const hidl_handle& handle, const hidl_vec<hidl_string>
if (!android::base::WriteStringToFd(buf, fd)) {
PLOG(ERROR) << "Failed to dump state to fd";
}
// Dump platform low power stats
getPlatformLowPowerStats([fd](const auto& platStats, const auto result) {
if (!DumpPowerHal1_0PlatStatsToFd(result, platStats, fd)) {
PLOG(ERROR) << "Failed to dump platform low power stats to fd";
}
});
// Dump subsystem low power stats
getSubsystemLowPowerStats([fd](const auto& subsysStats, const auto result) {
if (!DumpPowerHal1_1SubsysStatsToFd(result, subsysStats, fd)) {
PLOG(ERROR) << "Failed to dump subsystem low power stats to fd";
}
});
fsync(fd);
}
return Void();