From 3c712491cfde063ce72b76132f6eded08a2c8da9 Mon Sep 17 00:00:00 2001 From: Benjamin Schwartz Date: Thu, 18 Mar 2021 17:57:13 -0700 Subject: [PATCH] Move power stats service to device specific folders Bug: 183052760 Test: dumpsys android.hardware.power.stats.IPowerStats/default Change-Id: I4d4881e227982aa17b88af8844c82dc448ef5b6f Merged-In: I4d4881e227982aa17b88af8844c82dc448ef5b6f --- powerstats/Android.bp | 29 +++++-------------- ...rvice.cpp => Gs101CommonDataProviders.cpp} | 20 ++----------- ...roid.hardware.power.stats-service.pixel.rc | 4 --- ...oid.hardware.power.stats-service.pixel.xml | 6 ---- powerstats/include/Gs101CommonDataProviders.h | 23 +++++++++++++++ 5 files changed, 33 insertions(+), 49 deletions(-) rename powerstats/{service.cpp => Gs101CommonDataProviders.cpp} (97%) delete mode 100644 powerstats/android.hardware.power.stats-service.pixel.rc delete mode 100644 powerstats/android.hardware.power.stats-service.pixel.xml create mode 100644 powerstats/include/Gs101CommonDataProviders.h diff --git a/powerstats/Android.bp b/powerstats/Android.bp index 7c7066c1..10ecbede 100644 --- a/powerstats/Android.bp +++ b/powerstats/Android.bp @@ -22,30 +22,17 @@ package { ], } -cc_binary { - name: "android.hardware.power.stats-service.pixel", - init_rc: ["android.hardware.power.stats-service.pixel.rc"], - vintf_fragments: ["android.hardware.power.stats-service.pixel.xml"], +cc_library { + name: "android.hardware.power.stats-impl.gs101", + vendor_available: true, + export_include_dirs: ["include"], + defaults: ["powerstats_pixel_defaults"], + srcs: [ "*.cpp", ], - cflags: [ - "-Wall", - "-Werror", - ], - static_libs: [ + + shared_libs: [ "android.hardware.power.stats-impl.pixel", ], - shared_libs: [ - "libbase", - "libcutils", - "liblog", - "libutils", - "libbinder_ndk", - "pixel_stateresidency_provider_aidl_interface-ndk_platform", - "android.hardware.power.stats-V1-ndk_platform", - ], - relative_install_path: "hw", - vendor: true, - proprietary: true, } diff --git a/powerstats/service.cpp b/powerstats/Gs101CommonDataProviders.cpp similarity index 97% rename from powerstats/service.cpp rename to powerstats/Gs101CommonDataProviders.cpp index 16953ee5..a47f93a3 100644 --- a/powerstats/service.cpp +++ b/powerstats/Gs101CommonDataProviders.cpp @@ -14,9 +14,8 @@ * limitations under the License. */ -#define LOG_TAG "android.hardware.power.stats-service.pixel" - #include +#include #include "AocStateResidencyDataProvider.h" #include "DvfsStateResidencyDataProvider.h" #include "UfsStateResidencyDataProvider.h" @@ -41,7 +40,6 @@ using aidl::android::hardware::power::stats::EnergyConsumerType; using aidl::android::hardware::power::stats::GenericStateResidencyDataProvider; using aidl::android::hardware::power::stats::IioEnergyMeterDataProvider; using aidl::android::hardware::power::stats::PixelStateResidencyDataProvider; -using aidl::android::hardware::power::stats::PowerStats; using aidl::android::hardware::power::stats::PowerStatsEnergyConsumer; constexpr char kBootHwSoCRev[] = "ro.boot.hw.soc.rev"; @@ -575,14 +573,7 @@ void addPixelStateResidencyDataProvider(std::shared_ptr p) { p->addStateResidencyDataProvider(std::move(pixelSdp)); } -int main() { - LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; - - // single thread - ABinderProcess_setThreadPoolMaxThreadCount(0); - - std::shared_ptr p = ndk::SharedRefBase::make(); - +void addGs101CommonDataProviders(std::shared_ptr p) { setEnergyMeter(p); addPixelStateResidencyDataProvider(p); @@ -602,11 +593,4 @@ int main() { // TODO (b/181070764) (b/182941084): // Remove this when Wifi/BT energy consumption models are available or revert before ship addPlaceholderEnergyConsumers(p); - - const std::string instance = std::string() + PowerStats::descriptor + "/default"; - binder_status_t status = AServiceManager_addService(p->asBinder().get(), instance.c_str()); - LOG_ALWAYS_FATAL_IF(status != STATUS_OK); - - ABinderProcess_joinThreadPool(); - return EXIT_FAILURE; // should not reach } diff --git a/powerstats/android.hardware.power.stats-service.pixel.rc b/powerstats/android.hardware.power.stats-service.pixel.rc deleted file mode 100644 index f044b05e..00000000 --- a/powerstats/android.hardware.power.stats-service.pixel.rc +++ /dev/null @@ -1,4 +0,0 @@ -service vendor.power.stats.pixel /vendor/bin/hw/android.hardware.power.stats-service.pixel - class hal - user system - group system diff --git a/powerstats/android.hardware.power.stats-service.pixel.xml b/powerstats/android.hardware.power.stats-service.pixel.xml deleted file mode 100644 index 3fade2ac..00000000 --- a/powerstats/android.hardware.power.stats-service.pixel.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - android.hardware.power.stats - IPowerStats/default - - \ No newline at end of file diff --git a/powerstats/include/Gs101CommonDataProviders.h b/powerstats/include/Gs101CommonDataProviders.h new file mode 100644 index 00000000..983650c4 --- /dev/null +++ b/powerstats/include/Gs101CommonDataProviders.h @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2021 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. + */ + +#pragma once + +#include + +using aidl::android::hardware::power::stats::PowerStats; + +void addGs101CommonDataProviders(std::shared_ptr p);