diff --git a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateInfo.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/ChannelInfo.aidl similarity index 92% rename from powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateInfo.aidl rename to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/ChannelInfo.aidl index 9de66ba8bc..6681df1875 100644 --- a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateInfo.aidl +++ b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/ChannelInfo.aidl @@ -17,7 +17,7 @@ package android.hardware.powerstats; @VintfStability -parcelable PowerEntityStateInfo { - int powerEntityStateId; - String powerEntityStateName; +parcelable ChannelInfo { + int channelId; + String channelName; } diff --git a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyConsumerId.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyConsumerId.aidl new file mode 100644 index 0000000000..21e7057684 --- /dev/null +++ b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyConsumerId.aidl @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL interface (or parcelable). Do not try to +// edit this file. It looks like you are doing that because you have modified +// an AIDL interface in a backward-incompatible way, e.g., deleting a function +// from an interface or a field from a parcelable and it broke the build. That +// breakage is intended. +// +// You must not make a backward incompatible changes to the AIDL files built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.powerstats; +@Backing(type="int") @VintfStability +enum EnergyConsumerId { + DISPLAY = 0, + GPS = 1, +} diff --git a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyConsumerResult.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyConsumerResult.aidl new file mode 100644 index 0000000000..47948982de --- /dev/null +++ b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyConsumerResult.aidl @@ -0,0 +1,24 @@ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL interface (or parcelable). Do not try to +// edit this file. It looks like you are doing that because you have modified +// an AIDL interface in a backward-incompatible way, e.g., deleting a function +// from an interface or a field from a parcelable and it broke the build. That +// breakage is intended. +// +// You must not make a backward incompatible changes to the AIDL files built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.powerstats; +@VintfStability +parcelable EnergyConsumerResult { + android.hardware.powerstats.EnergyConsumerId energyConsumerId; + long timestampMs; + long energyUWs; +} diff --git a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyData.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyMeasurement.aidl similarity index 95% rename from powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyData.aidl rename to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyMeasurement.aidl index 2e384da5ca..3b1031b1a9 100644 --- a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyData.aidl +++ b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyMeasurement.aidl @@ -17,8 +17,8 @@ package android.hardware.powerstats; @VintfStability -parcelable EnergyData { - int railIndex; +parcelable EnergyMeasurement { + int channelId; long timestampMs; long energyUWs; } diff --git a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/IPowerStats.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/IPowerStats.aidl index 6772f6f3c4..2f251f345d 100644 --- a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/IPowerStats.aidl +++ b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/IPowerStats.aidl @@ -18,8 +18,10 @@ package android.hardware.powerstats; @VintfStability interface IPowerStats { - android.hardware.powerstats.EnergyData[] getEnergyData(in int[] railIndices); android.hardware.powerstats.PowerEntityInfo[] getPowerEntityInfo(); - android.hardware.powerstats.PowerEntityStateResidencyResult[] getPowerEntityStateResidencyData(in int[] powerEntityIds); - android.hardware.powerstats.RailInfo[] getRailInfo(); + android.hardware.powerstats.StateResidencyResult[] getPowerEntityStateResidency(in int[] powerEntityIds); + android.hardware.powerstats.EnergyConsumerId[] getEnergyConsumerInfo(); + android.hardware.powerstats.EnergyConsumerResult[] getEnergyConsumed(in android.hardware.powerstats.EnergyConsumerId[] energyConsumerIds); + android.hardware.powerstats.ChannelInfo[] getEnergyMeterInfo(); + android.hardware.powerstats.EnergyMeasurement[] readEnergyMeters(in int[] channelIds); } diff --git a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityInfo.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityInfo.aidl index 016af91839..105bab781b 100644 --- a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityInfo.aidl +++ b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityInfo.aidl @@ -20,5 +20,5 @@ package android.hardware.powerstats; parcelable PowerEntityInfo { int powerEntityId; String powerEntityName; - android.hardware.powerstats.PowerEntityStateInfo[] states; + android.hardware.powerstats.StateInfo[] states; } diff --git a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/RailInfo.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateInfo.aidl similarity index 91% rename from powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/RailInfo.aidl rename to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateInfo.aidl index 413ea0dd80..6ad3418450 100644 --- a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/RailInfo.aidl +++ b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateInfo.aidl @@ -17,9 +17,7 @@ package android.hardware.powerstats; @VintfStability -parcelable RailInfo { - int railIndex; - String railName; - String subsysName; - int samplingRateHz; +parcelable StateInfo { + int stateId; + String stateName; } diff --git a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateResidencyData.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateResidency.aidl similarity index 94% rename from powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateResidencyData.aidl rename to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateResidency.aidl index 8a3b227ed6..c87547cc03 100644 --- a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateResidencyData.aidl +++ b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateResidency.aidl @@ -17,8 +17,8 @@ package android.hardware.powerstats; @VintfStability -parcelable PowerEntityStateResidencyData { - int powerEntityStateId; +parcelable StateResidency { + int stateId; long totalTimeInStateMs; long totalStateEntryCount; long lastEntryTimestampMs; diff --git a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateResidencyResult.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateResidencyResult.aidl similarity index 89% rename from powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateResidencyResult.aidl rename to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateResidencyResult.aidl index fbe567ea83..b57d965d57 100644 --- a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateResidencyResult.aidl +++ b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateResidencyResult.aidl @@ -17,7 +17,7 @@ package android.hardware.powerstats; @VintfStability -parcelable PowerEntityStateResidencyResult { +parcelable StateResidencyResult { int powerEntityId; - android.hardware.powerstats.PowerEntityStateResidencyData[] stateResidencyData; + android.hardware.powerstats.StateResidency[] stateResidencyData; } diff --git a/powerstats/aidl/android/hardware/powerstats/ChannelInfo.aidl b/powerstats/aidl/android/hardware/powerstats/ChannelInfo.aidl new file mode 100644 index 0000000000..77d2289887 --- /dev/null +++ b/powerstats/aidl/android/hardware/powerstats/ChannelInfo.aidl @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 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. + */ + +package android.hardware.powerstats; + +@VintfStability +parcelable ChannelInfo { + /** + * Unique ID + */ + int channelId; + /** + * Unique name of the ChannelInfo: + * + * Vendor/device specific. Opaque to framework + */ + String channelName; +} + diff --git a/powerstats/aidl/android/hardware/powerstats/EnergyConsumerId.aidl b/powerstats/aidl/android/hardware/powerstats/EnergyConsumerId.aidl new file mode 100644 index 0000000000..2839a193fd --- /dev/null +++ b/powerstats/aidl/android/hardware/powerstats/EnergyConsumerId.aidl @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2020 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. + */ + +package android.hardware.powerstats; + +@VintfStability +@Backing(type="int") +enum EnergyConsumerId { + DISPLAY = 0, + GPS = 1, +} \ No newline at end of file diff --git a/powerstats/aidl/android/hardware/powerstats/RailInfo.aidl b/powerstats/aidl/android/hardware/powerstats/EnergyConsumerResult.aidl similarity index 67% rename from powerstats/aidl/android/hardware/powerstats/RailInfo.aidl rename to powerstats/aidl/android/hardware/powerstats/EnergyConsumerResult.aidl index 4c05bfec87..2c4e9e472a 100644 --- a/powerstats/aidl/android/hardware/powerstats/RailInfo.aidl +++ b/powerstats/aidl/android/hardware/powerstats/EnergyConsumerResult.aidl @@ -16,23 +16,21 @@ package android.hardware.powerstats; +import android.hardware.powerstats.EnergyConsumerId; + @VintfStability -parcelable RailInfo { +parcelable EnergyConsumerResult { /** - * Index corresponding to the rail + * Unique ID associated with the given EnergyMeterInfo */ - int railIndex; + EnergyConsumerId energyConsumerId; /** - * Name of the rail (opaque to the framework) + * Time since device boot in milliseconds */ - String railName; + long timestampMs; /** - * Name of the subsystem to which this rail belongs (opaque to the framework) + * Accumulated energy since device boot in microwatt-seconds (uWs) */ - String subsysName; - /** - * Hardware sampling rate in Hz - */ - int samplingRateHz; + long energyUWs; } diff --git a/powerstats/aidl/android/hardware/powerstats/EnergyData.aidl b/powerstats/aidl/android/hardware/powerstats/EnergyMeasurement.aidl similarity index 86% rename from powerstats/aidl/android/hardware/powerstats/EnergyData.aidl rename to powerstats/aidl/android/hardware/powerstats/EnergyMeasurement.aidl index ec12c5e0b2..3b31b46916 100644 --- a/powerstats/aidl/android/hardware/powerstats/EnergyData.aidl +++ b/powerstats/aidl/android/hardware/powerstats/EnergyMeasurement.aidl @@ -17,12 +17,11 @@ package android.hardware.powerstats; @VintfStability -parcelable EnergyData { +parcelable EnergyMeasurement { /** - * Index corresponding to the rail. This index matches - * the index returned in RailInfo + * Unique ID corresponding to the given ChannelInfo */ - int railIndex; + int channelId; /** * Time since device boot(CLOCK_BOOTTIME) in milli-seconds */ diff --git a/powerstats/aidl/android/hardware/powerstats/IPowerStats.aidl b/powerstats/aidl/android/hardware/powerstats/IPowerStats.aidl index 93d1448376..9943605332 100644 --- a/powerstats/aidl/android/hardware/powerstats/IPowerStats.aidl +++ b/powerstats/aidl/android/hardware/powerstats/IPowerStats.aidl @@ -16,26 +16,16 @@ package android.hardware.powerstats; -import android.hardware.powerstats.EnergyData; +import android.hardware.powerstats.ChannelInfo; +import android.hardware.powerstats.EnergyConsumerId; +import android.hardware.powerstats.EnergyConsumerResult; +import android.hardware.powerstats.EnergyMeasurement; import android.hardware.powerstats.PowerEntityInfo; -import android.hardware.powerstats.PowerEntityStateResidencyResult; -import android.hardware.powerstats.RailInfo; +import android.hardware.powerstats.StateResidencyResult; @VintfStability interface IPowerStats { /** - * Rail level energy measurements for low frequency clients: - * Reports accumulated energy since boot on each rail. - * - * @param railIndices Indices of rails for which data is required. - * To get data for all rails pass an empty vector. Rail name to - * index mapping can be queried from getRailInfo() API. - * @return Energy values since boot for all requested rails. - */ - EnergyData[] getEnergyData(in int[] railIndices); - - /** - * PowerEntity information: * Reports information related to all supported PowerEntity(s) for which * data is available. A PowerEntity is defined as a platform subsystem, * peripheral, or power domain that impacts the total device power @@ -46,29 +36,64 @@ interface IPowerStats { PowerEntityInfo[] getPowerEntityInfo(); /** - * PowerEntity residencies for low frequency clients: * Reports accumulated residency data for each specified PowerEntity. * Each PowerEntity may reside in one of multiple states. It may also - * transition to another state. Residency data is an accumulation of time - * that a specified PowerEntity resided in each of its possible states, - * the number of times that each state was entered, and a timestamp - * corresponding to the last time that state was entered. Data is - * accumulated starting from the last time the PowerEntity was reset. + * transition from one state to another. StateResidency is defined as + * an accumulation of time that a PowerEntity resided in each + * of its possible states, the number of times that each state was + * entered, and a timestamp corresponding to the last time that state + * was entered. Data is accumulated starting from the last time the + * PowerEntity was reset. * - * @param powerEntityId collection of IDs of PowerEntity(s) for which - * residency data is requested. PowerEntity name to ID mapping may - * be queried from getPowerEntityInfo(). To get state residency - * data for all PowerEntity(s) pass an empty vector. - * @return state residency data for each specified - * PowerEntity that provides state residency data. + * @param powerEntityIds IDs of PowerEntities for which data is required. + * To get data for all PowerEntities pass an empty vector. PowerEntity name to + * ID mapping can be queried from getPowerEntityInfo() API. + * @return StateResidency since boot for all requested PowerEntity(s). */ - PowerEntityStateResidencyResult[] getPowerEntityStateResidencyData(in int[] powerEntityIds); + StateResidencyResult[] getPowerEntityStateResidency(in int[] powerEntityIds); /** - * Rail information: - * Reports information related to the rails being monitored. + * Reports a list of IDs corresponding to all enabled EnergyConsumers. * - * @return Information about monitored rails. + * @return list of EnergyConsumersIds that are available. */ - RailInfo[] getRailInfo(); + EnergyConsumerId[] getEnergyConsumerInfo(); + + /** + * Returns any available energy consumption results. + * + * @param energyConsumerIds IDs of EnergyConsumers for which data is requested. + * To get data for all EnergyConsumers pass an empty list. + * @return List of EnergyConsumerResults reporting energy consumed since boot for each requested + * EnergyConsumerId. + * + * Returns the following service-specific exceptions: + * STATUS_FAILED_TRANSACTION if any of the requested energy results is unavailable + * STATUS_BAD_VALUE if an invalid EnergyConsumer Id is provided + */ + EnergyConsumerResult[] getEnergyConsumed(in EnergyConsumerId[] energyConsumerIds); + + /** + * Reports channels monitored by Energy Meters. + * Each channel has a name, which may correspond to the name of a power rail on the device, + * and an Id which is used to relate EnergyMeasurements returned by readEnergyMeters() with a + * given ChannelInfo. + * + * @return Information about channels monitored by Energy Meters. + */ + ChannelInfo[] getEnergyMeterInfo(); + + /** + * Reports accumulated energy since boot for each specified channel. + * + * @param channelIds IDs of channels for which data is requested. + * To get data for all channels pass an empty list. Channel name to + * ID mapping can be queried from getEnergyMeterInfo() API. + * @return Energy measured since boot for all requested channels. + * + * Returns the following service-specific exceptions: + * STATUS_FAILED_TRANSACTION if any of the requested energy measurements are unavailable + * STATUS_BAD_VALUE if an invalid channelId is provided + */ + EnergyMeasurement[] readEnergyMeters(in int[] channelIds); } \ No newline at end of file diff --git a/powerstats/aidl/android/hardware/powerstats/PowerEntityInfo.aidl b/powerstats/aidl/android/hardware/powerstats/PowerEntityInfo.aidl index 72222a627e..a8ca0f62ca 100644 --- a/powerstats/aidl/android/hardware/powerstats/PowerEntityInfo.aidl +++ b/powerstats/aidl/android/hardware/powerstats/PowerEntityInfo.aidl @@ -16,7 +16,7 @@ package android.hardware.powerstats; -import android.hardware.powerstats.PowerEntityStateInfo; +import android.hardware.powerstats.StateInfo; /** * PowerEntityInfo contains information, such as the ID, name, and type of a @@ -29,11 +29,11 @@ parcelable PowerEntityInfo { */ int powerEntityId; /** - * Name of the PowerEntity (opaque to the framework) + * Unique name of the PowerEntity. Vendor/device specific. Opaque to framework. */ String powerEntityName; /** * List of states that the PowerEntity may reside in */ - PowerEntityStateInfo[] states; + StateInfo[] states; } \ No newline at end of file diff --git a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateInfo.aidl b/powerstats/aidl/android/hardware/powerstats/StateInfo.aidl similarity index 80% rename from powerstats/aidl/android/hardware/powerstats/PowerEntityStateInfo.aidl rename to powerstats/aidl/android/hardware/powerstats/StateInfo.aidl index 69fc79828d..756fd873b6 100644 --- a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateInfo.aidl +++ b/powerstats/aidl/android/hardware/powerstats/StateInfo.aidl @@ -17,14 +17,15 @@ package android.hardware.powerstats; @VintfStability -parcelable PowerEntityStateInfo { +parcelable StateInfo { /** - * ID corresponding to the state. Unique for a given PowerEntityStateSpace + * ID corresponding to the state. Unique for a given PowerEntityInfo */ - int powerEntityStateId; + int stateId; /** - * Name of the state (opaque to the framework) + * Unique (for a given PowerEntityInfo) name of the state. Vendor/device specific. + * Opaque to framework. */ - String powerEntityStateName; + String stateName; } diff --git a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateResidencyData.aidl b/powerstats/aidl/android/hardware/powerstats/StateResidency.aidl similarity index 74% rename from powerstats/aidl/android/hardware/powerstats/PowerEntityStateResidencyData.aidl rename to powerstats/aidl/android/hardware/powerstats/StateResidency.aidl index a738457fe9..882ba5b318 100644 --- a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateResidencyData.aidl +++ b/powerstats/aidl/android/hardware/powerstats/StateResidency.aidl @@ -20,25 +20,22 @@ package android.hardware.powerstats; * Contains residency data for a single state */ @VintfStability -parcelable PowerEntityStateResidencyData { +parcelable StateResidency { /** - * Unique ID of the corresponding PowerEntityStateInfo + * ID of the corresponding StateInfo */ - int powerEntityStateId; + int stateId; /** * Total time in milliseconds that the corresponding PowerEntity resided - * in this state since the PowerEntity was reset + * in since device boot */ long totalTimeInStateMs; /** - * Total number of times that the state was entered since the corresponding - * PowerEntity was reset + * Total number of times that the state was entered since device boot */ long totalStateEntryCount; /** - * Last time this state was entered. Time in milliseconds since the - * corresponding PowerEntity was reset + * Last time this state was entered. Time in milliseconds since device boot */ long lastEntryTimestampMs; -} - +} \ No newline at end of file diff --git a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateResidencyResult.aidl b/powerstats/aidl/android/hardware/powerstats/StateResidencyResult.aidl similarity index 78% rename from powerstats/aidl/android/hardware/powerstats/PowerEntityStateResidencyResult.aidl rename to powerstats/aidl/android/hardware/powerstats/StateResidencyResult.aidl index 555ae4c78e..d6ac4eaee0 100644 --- a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateResidencyResult.aidl +++ b/powerstats/aidl/android/hardware/powerstats/StateResidencyResult.aidl @@ -16,17 +16,17 @@ package android.hardware.powerstats; -import android.hardware.powerstats.PowerEntityStateResidencyData; +import android.hardware.powerstats.StateResidency; @VintfStability -parcelable PowerEntityStateResidencyResult { +parcelable StateResidencyResult { /** - * Unique ID of the corresponding PowerEntity + * ID of the corresponding PowerEntity */ int powerEntityId; /** * Residency data for each state the PowerEntity's state space */ - PowerEntityStateResidencyData[] stateResidencyData; + StateResidency[] stateResidencyData; } diff --git a/powerstats/aidl/default/PowerStats.cpp b/powerstats/aidl/default/PowerStats.cpp index 8d6a0ee4aa..9f3e76e380 100644 --- a/powerstats/aidl/default/PowerStats.cpp +++ b/powerstats/aidl/default/PowerStats.cpp @@ -23,27 +23,40 @@ namespace android { namespace hardware { namespace powerstats { -ndk::ScopedAStatus PowerStats::getEnergyData(const std::vector& in_railIndices, - std::vector* _aidl_return) { - (void)in_railIndices; - (void)_aidl_return; - return ndk::ScopedAStatus::ok(); -} - ndk::ScopedAStatus PowerStats::getPowerEntityInfo(std::vector* _aidl_return) { (void)_aidl_return; return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus PowerStats::getPowerEntityStateResidencyData( +ndk::ScopedAStatus PowerStats::getPowerEntityStateResidency( const std::vector& in_powerEntityIds, - std::vector* _aidl_return) { + std::vector* _aidl_return) { (void)in_powerEntityIds; (void)_aidl_return; return ndk::ScopedAStatus::ok(); } -ndk::ScopedAStatus PowerStats::getRailInfo(std::vector* _aidl_return) { +ndk::ScopedAStatus PowerStats::getEnergyConsumerInfo(std::vector* _aidl_return) { + (void)_aidl_return; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus PowerStats::getEnergyConsumed( + const std::vector& in_energyConsumerIds, + std::vector* _aidl_return) { + (void)in_energyConsumerIds; + (void)_aidl_return; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus PowerStats::getEnergyMeterInfo(std::vector* _aidl_return) { + (void)_aidl_return; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus PowerStats::readEnergyMeters(const std::vector& in_channelIds, + std::vector* _aidl_return) { + (void)in_channelIds; (void)_aidl_return; return ndk::ScopedAStatus::ok(); } diff --git a/powerstats/aidl/default/PowerStats.h b/powerstats/aidl/default/PowerStats.h index 49240cb718..0007efae2b 100644 --- a/powerstats/aidl/default/PowerStats.h +++ b/powerstats/aidl/default/PowerStats.h @@ -26,13 +26,17 @@ namespace powerstats { class PowerStats : public BnPowerStats { public: PowerStats() = default; - ndk::ScopedAStatus getEnergyData(const std::vector& in_railIndices, - std::vector* _aidl_return) override; + // Methods from aidl::android::hardware::powerstats::IPowerStats ndk::ScopedAStatus getPowerEntityInfo(std::vector* _aidl_return) override; - ndk::ScopedAStatus getPowerEntityStateResidencyData( + ndk::ScopedAStatus getPowerEntityStateResidency( const std::vector& in_powerEntityIds, - std::vector* _aidl_return) override; - ndk::ScopedAStatus getRailInfo(std::vector* _aidl_return) override; + std::vector* _aidl_return) override; + ndk::ScopedAStatus getEnergyConsumerInfo(std::vector* _aidl_return) override; + ndk::ScopedAStatus getEnergyConsumed(const std::vector& in_energyConsumerIds, + std::vector* _aidl_return) override; + ndk::ScopedAStatus getEnergyMeterInfo(std::vector* _aidl_return) override; + ndk::ScopedAStatus readEnergyMeters(const std::vector& in_channelIds, + std::vector* _aidl_return) override; }; } // namespace powerstats diff --git a/powerstats/aidl/vts/VtsHalPowerStatsTargetTest.cpp b/powerstats/aidl/vts/VtsHalPowerStatsTargetTest.cpp index b3cd233945..34d1b22587 100644 --- a/powerstats/aidl/vts/VtsHalPowerStatsTargetTest.cpp +++ b/powerstats/aidl/vts/VtsHalPowerStatsTargetTest.cpp @@ -21,11 +21,12 @@ #include #include -using aidl::android::hardware::powerstats::EnergyData; +using aidl::android::hardware::powerstats::ChannelInfo; +using aidl::android::hardware::powerstats::EnergyMeasurement; using aidl::android::hardware::powerstats::IPowerStats; using aidl::android::hardware::powerstats::PowerEntityInfo; -using aidl::android::hardware::powerstats::PowerEntityStateResidencyResult; -using aidl::android::hardware::powerstats::RailInfo; +using aidl::android::hardware::powerstats::StateResidencyResult; + using ndk::SpAIBinder; class PowerStatsAidl : public testing::TestWithParam { @@ -39,9 +40,9 @@ class PowerStatsAidl : public testing::TestWithParam { std::shared_ptr powerstats; }; -TEST_P(PowerStatsAidl, TestGetEnergyData) { - std::vector data; - ASSERT_TRUE(powerstats->getEnergyData({}, &data).isOk()); +TEST_P(PowerStatsAidl, TestReadEnergyMeter) { + std::vector data; + ASSERT_TRUE(powerstats->readEnergyMeters({}, &data).isOk()); } // Each PowerEntity must have a valid name @@ -83,7 +84,7 @@ TEST_P(PowerStatsAidl, ValidateStateNames) { for (auto info : infos) { for (auto state : info.states) { - EXPECT_NE(state.powerEntityStateName, ""); + EXPECT_NE(state.stateName, ""); } } } @@ -96,7 +97,7 @@ TEST_P(PowerStatsAidl, ValidateStateUniqueNames) { for (auto info : infos) { std::set stateNames; for (auto state : info.states) { - EXPECT_TRUE(stateNames.insert(state.powerEntityStateName).second); + EXPECT_TRUE(stateNames.insert(state.stateName).second); } } } @@ -107,21 +108,21 @@ TEST_P(PowerStatsAidl, ValidateStateUniqueIds) { ASSERT_TRUE(powerstats->getPowerEntityInfo(&infos).isOk()); for (auto info : infos) { - std::set stateIds; + std::set stateIds; for (auto state : info.states) { - EXPECT_TRUE(stateIds.insert(state.powerEntityStateId).second); + EXPECT_TRUE(stateIds.insert(state.stateId).second); } } } -TEST_P(PowerStatsAidl, TestGetPowerEntityStateResidencyData) { - std::vector data; - ASSERT_TRUE(powerstats->getPowerEntityStateResidencyData({}, &data).isOk()); +TEST_P(PowerStatsAidl, TestGetStateResidencyData) { + std::vector data; + ASSERT_TRUE(powerstats->getPowerEntityStateResidency({}, &data).isOk()); } -TEST_P(PowerStatsAidl, TestGetRailInfo) { - std::vector info; - ASSERT_TRUE(powerstats->getRailInfo(&info).isOk()); +TEST_P(PowerStatsAidl, TestGetEnergyMeterInfo) { + std::vector info; + ASSERT_TRUE(powerstats->getEnergyMeterInfo(&info).isOk()); } GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PowerStatsAidl);