powerstats: Add EnergyConsumer API
Also clean up rest of PowerStats HAL 2.0 API and type names
Bug: 168831183
Test: atest VtsHalPowerStatsTargetTest
Change-Id: I987f984bf717b107cf55213c7063ac9f310f8d54
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/ChannelInfo.aidl
similarity index 93%
copy from powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyData.aidl
copy to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/ChannelInfo.aidl
index 2e384da..6681df1 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/ChannelInfo.aidl
@@ -17,8 +17,7 @@
package android.hardware.powerstats;
@VintfStability
-parcelable EnergyData {
- int railIndex;
- long timestampMs;
- long energyUWs;
+parcelable ChannelInfo {
+ int channelId;
+ String channelName;
}
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/EnergyConsumerId.aidl
similarity index 91%
copy from powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyData.aidl
copy to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyConsumerId.aidl
index 2e384da..21e7057 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/EnergyConsumerId.aidl
@@ -16,9 +16,8 @@
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.powerstats;
-@VintfStability
-parcelable EnergyData {
- int railIndex;
- long timestampMs;
- long energyUWs;
+@Backing(type="int") @VintfStability
+enum EnergyConsumerId {
+ DISPLAY = 0,
+ GPS = 1,
}
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/EnergyConsumerResult.aidl
similarity index 91%
copy from powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyData.aidl
copy to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyConsumerResult.aidl
index 2e384da..4794898 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/EnergyConsumerResult.aidl
@@ -17,8 +17,8 @@
package android.hardware.powerstats;
@VintfStability
-parcelable EnergyData {
- int railIndex;
+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 2e384da..3b1031b 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 6772f6f..2f251f3 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 016af91..105bab7 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 @@
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/PowerEntityStateInfo.aidl b/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateInfo.aidl
deleted file mode 100644
index 9de66ba..0000000
--- a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateInfo.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// 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 PowerEntityStateInfo {
- int powerEntityStateId;
- String powerEntityStateName;
-}
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/PowerEntityStateResidencyResult.aidl
deleted file mode 100644
index fbe567e..0000000
--- a/powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/PowerEntityStateResidencyResult.aidl
+++ /dev/null
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// 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 PowerEntityStateResidencyResult {
- int powerEntityId;
- android.hardware.powerstats.PowerEntityStateResidencyData[] stateResidencyData;
-}
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/StateInfo.aidl
similarity index 93%
copy from powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/EnergyData.aidl
copy to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateInfo.aidl
index 2e384da..6ad3418 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/StateInfo.aidl
@@ -17,8 +17,7 @@
package android.hardware.powerstats;
@VintfStability
-parcelable EnergyData {
- int railIndex;
- long timestampMs;
- long energyUWs;
+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 8a3b227..c87547c 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/RailInfo.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/RailInfo.aidl
rename to powerstats/aidl/aidl_api/android.hardware.powerstats/current/android/hardware/powerstats/StateResidencyResult.aidl
index 413ea0d..b57d965 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/StateResidencyResult.aidl
@@ -17,9 +17,7 @@
package android.hardware.powerstats;
@VintfStability
-parcelable RailInfo {
- int railIndex;
- String railName;
- String subsysName;
- int samplingRateHz;
+parcelable StateResidencyResult {
+ int powerEntityId;
+ android.hardware.powerstats.StateResidency[] stateResidencyData;
}
diff --git a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateInfo.aidl b/powerstats/aidl/android/hardware/powerstats/ChannelInfo.aidl
similarity index 75%
copy from powerstats/aidl/android/hardware/powerstats/PowerEntityStateInfo.aidl
copy to powerstats/aidl/android/hardware/powerstats/ChannelInfo.aidl
index 69fc798..77d2289 100644
--- a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateInfo.aidl
+++ b/powerstats/aidl/android/hardware/powerstats/ChannelInfo.aidl
@@ -17,14 +17,16 @@
package android.hardware.powerstats;
@VintfStability
-parcelable PowerEntityStateInfo {
+parcelable ChannelInfo {
/**
- * ID corresponding to the state. Unique for a given PowerEntityStateSpace
+ * Unique ID
*/
- int powerEntityStateId;
+ int channelId;
/**
- * Name of the state (opaque to the framework)
+ * Unique name of the ChannelInfo:
+ *
+ * Vendor/device specific. Opaque to framework
*/
- String powerEntityStateName;
+ String channelName;
}
diff --git a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateInfo.aidl b/powerstats/aidl/android/hardware/powerstats/EnergyConsumerId.aidl
similarity index 72%
copy from powerstats/aidl/android/hardware/powerstats/PowerEntityStateInfo.aidl
copy to powerstats/aidl/android/hardware/powerstats/EnergyConsumerId.aidl
index 69fc798..2839a19 100644
--- a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateInfo.aidl
+++ b/powerstats/aidl/android/hardware/powerstats/EnergyConsumerId.aidl
@@ -17,14 +17,8 @@
package android.hardware.powerstats;
@VintfStability
-parcelable PowerEntityStateInfo {
- /**
- * ID corresponding to the state. Unique for a given PowerEntityStateSpace
- */
- int powerEntityStateId;
- /**
- * Name of the state (opaque to the framework)
- */
- String powerEntityStateName;
-}
-
+@Backing(type="int")
+enum EnergyConsumerId {
+ DISPLAY = 0,
+ GPS = 1,
+}
\ No newline at end of file
diff --git a/powerstats/aidl/android/hardware/powerstats/EnergyData.aidl b/powerstats/aidl/android/hardware/powerstats/EnergyConsumerResult.aidl
similarity index 78%
copy from powerstats/aidl/android/hardware/powerstats/EnergyData.aidl
copy to powerstats/aidl/android/hardware/powerstats/EnergyConsumerResult.aidl
index ec12c5e..2c4e9e4 100644
--- a/powerstats/aidl/android/hardware/powerstats/EnergyData.aidl
+++ b/powerstats/aidl/android/hardware/powerstats/EnergyConsumerResult.aidl
@@ -16,15 +16,16 @@
package android.hardware.powerstats;
+import android.hardware.powerstats.EnergyConsumerId;
+
@VintfStability
-parcelable EnergyData {
+parcelable EnergyConsumerResult {
/**
- * Index corresponding to the rail. This index matches
- * the index returned in RailInfo
+ * Unique ID associated with the given EnergyMeterInfo
*/
- int railIndex;
+ EnergyConsumerId energyConsumerId;
/**
- * Time since device boot(CLOCK_BOOTTIME) in milli-seconds
+ * Time since device boot in milliseconds
*/
long timestampMs;
/**
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 ec12c5e..3b31b46 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 93d1448..9943605 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 @@
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 72222a6..a8ca0f6 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 @@
*/
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/RailInfo.aidl b/powerstats/aidl/android/hardware/powerstats/RailInfo.aidl
deleted file mode 100644
index 4c05bfe..0000000
--- a/powerstats/aidl/android/hardware/powerstats/RailInfo.aidl
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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 RailInfo {
- /**
- * Index corresponding to the rail
- */
- int railIndex;
- /**
- * Name of the rail (opaque to the framework)
- */
- String railName;
- /**
- * Name of the subsystem to which this rail belongs (opaque to the framework)
- */
- String subsysName;
- /**
- * Hardware sampling rate in Hz
- */
- int samplingRateHz;
-}
-
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 69fc798..756fd87 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 a738457..882ba5b 100644
--- a/powerstats/aidl/android/hardware/powerstats/PowerEntityStateResidencyData.aidl
+++ b/powerstats/aidl/android/hardware/powerstats/StateResidency.aidl
@@ -20,25 +20,22 @@
* 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 555ae4c..d6ac4ea 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 8d6a0ee..9f3e76e 100644
--- a/powerstats/aidl/default/PowerStats.cpp
+++ b/powerstats/aidl/default/PowerStats.cpp
@@ -23,27 +23,40 @@
namespace hardware {
namespace powerstats {
-ndk::ScopedAStatus PowerStats::getEnergyData(const std::vector<int32_t>& in_railIndices,
- std::vector<EnergyData>* _aidl_return) {
- (void)in_railIndices;
- (void)_aidl_return;
- return ndk::ScopedAStatus::ok();
-}
-
ndk::ScopedAStatus PowerStats::getPowerEntityInfo(std::vector<PowerEntityInfo>* _aidl_return) {
(void)_aidl_return;
return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus PowerStats::getPowerEntityStateResidencyData(
+ndk::ScopedAStatus PowerStats::getPowerEntityStateResidency(
const std::vector<int32_t>& in_powerEntityIds,
- std::vector<PowerEntityStateResidencyResult>* _aidl_return) {
+ std::vector<StateResidencyResult>* _aidl_return) {
(void)in_powerEntityIds;
(void)_aidl_return;
return ndk::ScopedAStatus::ok();
}
-ndk::ScopedAStatus PowerStats::getRailInfo(std::vector<RailInfo>* _aidl_return) {
+ndk::ScopedAStatus PowerStats::getEnergyConsumerInfo(std::vector<EnergyConsumerId>* _aidl_return) {
+ (void)_aidl_return;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus PowerStats::getEnergyConsumed(
+ const std::vector<EnergyConsumerId>& in_energyConsumerIds,
+ std::vector<EnergyConsumerResult>* _aidl_return) {
+ (void)in_energyConsumerIds;
+ (void)_aidl_return;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus PowerStats::getEnergyMeterInfo(std::vector<ChannelInfo>* _aidl_return) {
+ (void)_aidl_return;
+ return ndk::ScopedAStatus::ok();
+}
+
+ndk::ScopedAStatus PowerStats::readEnergyMeters(const std::vector<int32_t>& in_channelIds,
+ std::vector<EnergyMeasurement>* _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 49240cb..0007efa 100644
--- a/powerstats/aidl/default/PowerStats.h
+++ b/powerstats/aidl/default/PowerStats.h
@@ -26,13 +26,17 @@
class PowerStats : public BnPowerStats {
public:
PowerStats() = default;
- ndk::ScopedAStatus getEnergyData(const std::vector<int32_t>& in_railIndices,
- std::vector<EnergyData>* _aidl_return) override;
+ // Methods from aidl::android::hardware::powerstats::IPowerStats
ndk::ScopedAStatus getPowerEntityInfo(std::vector<PowerEntityInfo>* _aidl_return) override;
- ndk::ScopedAStatus getPowerEntityStateResidencyData(
+ ndk::ScopedAStatus getPowerEntityStateResidency(
const std::vector<int32_t>& in_powerEntityIds,
- std::vector<PowerEntityStateResidencyResult>* _aidl_return) override;
- ndk::ScopedAStatus getRailInfo(std::vector<RailInfo>* _aidl_return) override;
+ std::vector<StateResidencyResult>* _aidl_return) override;
+ ndk::ScopedAStatus getEnergyConsumerInfo(std::vector<EnergyConsumerId>* _aidl_return) override;
+ ndk::ScopedAStatus getEnergyConsumed(const std::vector<EnergyConsumerId>& in_energyConsumerIds,
+ std::vector<EnergyConsumerResult>* _aidl_return) override;
+ ndk::ScopedAStatus getEnergyMeterInfo(std::vector<ChannelInfo>* _aidl_return) override;
+ ndk::ScopedAStatus readEnergyMeters(const std::vector<int32_t>& in_channelIds,
+ std::vector<EnergyMeasurement>* _aidl_return) override;
};
} // namespace powerstats
diff --git a/powerstats/aidl/vts/VtsHalPowerStatsTargetTest.cpp b/powerstats/aidl/vts/VtsHalPowerStatsTargetTest.cpp
index b3cd233..34d1b22 100644
--- a/powerstats/aidl/vts/VtsHalPowerStatsTargetTest.cpp
+++ b/powerstats/aidl/vts/VtsHalPowerStatsTargetTest.cpp
@@ -21,11 +21,12 @@
#include <android/binder_manager.h>
#include <android/binder_process.h>
-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<std::string> {
@@ -39,9 +40,9 @@
std::shared_ptr<IPowerStats> powerstats;
};
-TEST_P(PowerStatsAidl, TestGetEnergyData) {
- std::vector<EnergyData> data;
- ASSERT_TRUE(powerstats->getEnergyData({}, &data).isOk());
+TEST_P(PowerStatsAidl, TestReadEnergyMeter) {
+ std::vector<EnergyMeasurement> data;
+ ASSERT_TRUE(powerstats->readEnergyMeters({}, &data).isOk());
}
// Each PowerEntity must have a valid name
@@ -83,7 +84,7 @@
for (auto info : infos) {
for (auto state : info.states) {
- EXPECT_NE(state.powerEntityStateName, "");
+ EXPECT_NE(state.stateName, "");
}
}
}
@@ -96,7 +97,7 @@
for (auto info : infos) {
std::set<std::string> stateNames;
for (auto state : info.states) {
- EXPECT_TRUE(stateNames.insert(state.powerEntityStateName).second);
+ EXPECT_TRUE(stateNames.insert(state.stateName).second);
}
}
}
@@ -107,21 +108,21 @@
ASSERT_TRUE(powerstats->getPowerEntityInfo(&infos).isOk());
for (auto info : infos) {
- std::set<uint32_t> stateIds;
+ std::set<int32_t> 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<PowerEntityStateResidencyResult> data;
- ASSERT_TRUE(powerstats->getPowerEntityStateResidencyData({}, &data).isOk());
+TEST_P(PowerStatsAidl, TestGetStateResidencyData) {
+ std::vector<StateResidencyResult> data;
+ ASSERT_TRUE(powerstats->getPowerEntityStateResidency({}, &data).isOk());
}
-TEST_P(PowerStatsAidl, TestGetRailInfo) {
- std::vector<RailInfo> info;
- ASSERT_TRUE(powerstats->getRailInfo(&info).isOk());
+TEST_P(PowerStatsAidl, TestGetEnergyMeterInfo) {
+ std::vector<ChannelInfo> info;
+ ASSERT_TRUE(powerstats->getEnergyMeterInfo(&info).isOk());
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(PowerStatsAidl);