From c798cb39a0f76bcf4efd384477fb926e2178954d Mon Sep 17 00:00:00 2001 From: Benjamin Schwartz Date: Thu, 18 Mar 2021 17:55:40 -0700 Subject: [PATCH] Add power stats service for specific device Bug: 183052760 Test: dumpsys android.hardware.power.stats.IPowerStats/default Change-Id: I20fa0e1b369f9b5f15e7881eea87ef699176dccc Merged-In: I20fa0e1b369f9b5f15e7881eea87ef699176dccc --- Android.bp | 1 + device-oriole.mk | 3 +++ device-raven.mk | 3 +++ device-slider.mk | 3 +++ device-whitefin.mk | 3 +++ powerstats/oriole/Android.bp | 33 +++++++++++++++++++++++++ powerstats/oriole/service.cpp | 44 +++++++++++++++++++++++++++++++++ powerstats/raven/Android.bp | 33 +++++++++++++++++++++++++ powerstats/raven/service.cpp | 44 +++++++++++++++++++++++++++++++++ powerstats/slider/Android.bp | 33 +++++++++++++++++++++++++ powerstats/slider/service.cpp | 44 +++++++++++++++++++++++++++++++++ powerstats/whitefin/Android.bp | 33 +++++++++++++++++++++++++ powerstats/whitefin/service.cpp | 44 +++++++++++++++++++++++++++++++++ 13 files changed, 321 insertions(+) create mode 100644 powerstats/oriole/Android.bp create mode 100644 powerstats/oriole/service.cpp create mode 100644 powerstats/raven/Android.bp create mode 100644 powerstats/raven/service.cpp create mode 100644 powerstats/slider/Android.bp create mode 100644 powerstats/slider/service.cpp create mode 100644 powerstats/whitefin/Android.bp create mode 100644 powerstats/whitefin/service.cpp diff --git a/Android.bp b/Android.bp index e1800a0..893d2c6 100644 --- a/Android.bp +++ b/Android.bp @@ -2,6 +2,7 @@ soong_namespace { imports: [ "hardware/google/interfaces", "hardware/google/pixel", + "device/google/gs101", ], } diff --git a/device-oriole.mk b/device-oriole.mk index 0445f01..353bfac 100644 --- a/device-oriole.mk +++ b/device-oriole.mk @@ -87,6 +87,9 @@ PRODUCT_COPY_FILES += \ device/google/raviole/tts/es-es/es-es-x-ana-r22.zvoice:product/tts/google/es-es/es-es-x-ana-r22.zvoice\ device/google/raviole/tts/es-es/es-es-x-multi-r22.zvoice:product/tts/google/es-es/es-es-x-multi-r22.zvoice +# PowerStats HAL +PRODUCT_SOONG_NAMESPACES += device/google/raviole/powerstats/oriole + # Keyboard bottom padding in dp for portrait mode PRODUCT_PRODUCT_PROPERTIES += ro.com.google.ime.kb_pad_port_b=10 diff --git a/device-raven.mk b/device-raven.mk index 8f2f382..26f1943 100644 --- a/device-raven.mk +++ b/device-raven.mk @@ -93,3 +93,6 @@ PRODUCT_COPY_FILES += \ # Display LBE PRODUCT_DEFAULT_PROPERTY_OVERRIDES += vendor.display.lbe.supported=1 + +# PowerStats HAL +PRODUCT_SOONG_NAMESPACES += device/google/raviole/powerstats/raven diff --git a/device-slider.mk b/device-slider.mk index 1f77af9..2e977c4 100644 --- a/device-slider.mk +++ b/device-slider.mk @@ -73,3 +73,6 @@ PRODUCT_COPY_FILES += \ DEVICE_MANIFEST_FILE += \ device/google/gs101/nfc/manifest_se_gs101.xml + +# PowerStats HAL +PRODUCT_SOONG_NAMESPACES += device/google/raviole/powerstats/slider diff --git a/device-whitefin.mk b/device-whitefin.mk index cd31bf4..c11f7e5 100644 --- a/device-whitefin.mk +++ b/device-whitefin.mk @@ -54,3 +54,6 @@ PRODUCT_PROPERTY_OVERRIDES += \ # NFC PRODUCT_COPY_FILES += \ device/google/gs101/nfc/libnfc-hal-st.conf:$(TARGET_COPY_OUT_VENDOR)/etc/libnfc-hal-st.conf + +# PowerStats HAL +PRODUCT_SOONG_NAMESPACES += device/google/raviole/powerstats/whitefin diff --git a/powerstats/oriole/Android.bp b/powerstats/oriole/Android.bp new file mode 100644 index 0000000..e081c84 --- /dev/null +++ b/powerstats/oriole/Android.bp @@ -0,0 +1,33 @@ +// 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. + +soong_namespace { + imports: [ + "hardware/google/pixel", + "device/google/gs101", + ] +} + +cc_binary { + name: "android.hardware.power.stats-service.pixel", + defaults: ["powerstats_pixel_binary_defaults"], + + srcs: [ + "*.cpp", + ], + + shared_libs: [ + "android.hardware.power.stats-impl.gs101", + ], +} diff --git a/powerstats/oriole/service.cpp b/powerstats/oriole/service.cpp new file mode 100644 index 0000000..d7c7599 --- /dev/null +++ b/powerstats/oriole/service.cpp @@ -0,0 +1,44 @@ +/* + * 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. + */ + +#define LOG_TAG "android.hardware.power.stats-service.pixel" + +#include +#include + +#include +#include +#include +#include +#include + +int main() { + LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; + + // single thread + ABinderProcess_setThreadPoolMaxThreadCount(0); + + std::shared_ptr p = ndk::SharedRefBase::make(); + + addGs101CommonDataProviders(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/raven/Android.bp b/powerstats/raven/Android.bp new file mode 100644 index 0000000..e081c84 --- /dev/null +++ b/powerstats/raven/Android.bp @@ -0,0 +1,33 @@ +// 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. + +soong_namespace { + imports: [ + "hardware/google/pixel", + "device/google/gs101", + ] +} + +cc_binary { + name: "android.hardware.power.stats-service.pixel", + defaults: ["powerstats_pixel_binary_defaults"], + + srcs: [ + "*.cpp", + ], + + shared_libs: [ + "android.hardware.power.stats-impl.gs101", + ], +} diff --git a/powerstats/raven/service.cpp b/powerstats/raven/service.cpp new file mode 100644 index 0000000..d7c7599 --- /dev/null +++ b/powerstats/raven/service.cpp @@ -0,0 +1,44 @@ +/* + * 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. + */ + +#define LOG_TAG "android.hardware.power.stats-service.pixel" + +#include +#include + +#include +#include +#include +#include +#include + +int main() { + LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; + + // single thread + ABinderProcess_setThreadPoolMaxThreadCount(0); + + std::shared_ptr p = ndk::SharedRefBase::make(); + + addGs101CommonDataProviders(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/slider/Android.bp b/powerstats/slider/Android.bp new file mode 100644 index 0000000..e081c84 --- /dev/null +++ b/powerstats/slider/Android.bp @@ -0,0 +1,33 @@ +// 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. + +soong_namespace { + imports: [ + "hardware/google/pixel", + "device/google/gs101", + ] +} + +cc_binary { + name: "android.hardware.power.stats-service.pixel", + defaults: ["powerstats_pixel_binary_defaults"], + + srcs: [ + "*.cpp", + ], + + shared_libs: [ + "android.hardware.power.stats-impl.gs101", + ], +} diff --git a/powerstats/slider/service.cpp b/powerstats/slider/service.cpp new file mode 100644 index 0000000..d7c7599 --- /dev/null +++ b/powerstats/slider/service.cpp @@ -0,0 +1,44 @@ +/* + * 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. + */ + +#define LOG_TAG "android.hardware.power.stats-service.pixel" + +#include +#include + +#include +#include +#include +#include +#include + +int main() { + LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; + + // single thread + ABinderProcess_setThreadPoolMaxThreadCount(0); + + std::shared_ptr p = ndk::SharedRefBase::make(); + + addGs101CommonDataProviders(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/whitefin/Android.bp b/powerstats/whitefin/Android.bp new file mode 100644 index 0000000..e081c84 --- /dev/null +++ b/powerstats/whitefin/Android.bp @@ -0,0 +1,33 @@ +// 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. + +soong_namespace { + imports: [ + "hardware/google/pixel", + "device/google/gs101", + ] +} + +cc_binary { + name: "android.hardware.power.stats-service.pixel", + defaults: ["powerstats_pixel_binary_defaults"], + + srcs: [ + "*.cpp", + ], + + shared_libs: [ + "android.hardware.power.stats-impl.gs101", + ], +} diff --git a/powerstats/whitefin/service.cpp b/powerstats/whitefin/service.cpp new file mode 100644 index 0000000..d7c7599 --- /dev/null +++ b/powerstats/whitefin/service.cpp @@ -0,0 +1,44 @@ +/* + * 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. + */ + +#define LOG_TAG "android.hardware.power.stats-service.pixel" + +#include +#include + +#include +#include +#include +#include +#include + +int main() { + LOG(INFO) << "Pixel PowerStats HAL AIDL Service is starting."; + + // single thread + ABinderProcess_setThreadPoolMaxThreadCount(0); + + std::shared_ptr p = ndk::SharedRefBase::make(); + + addGs101CommonDataProviders(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 +}