1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.power;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.hardware.power.stats.Channel;
22 import android.hardware.power.stats.EnergyConsumer;
23 import android.hardware.power.stats.EnergyConsumerResult;
24 import android.hardware.power.stats.EnergyMeasurement;
25 import android.hardware.power.stats.PowerEntity;
26 import android.hardware.power.stats.StateResidencyResult;
27 
28 import java.util.concurrent.CompletableFuture;
29 
30 /**
31  * Power stats local system service interface.
32  *
33  * @hide Only for use within Android OS.
34  */
35 public abstract class PowerStatsInternal {
36     /**
37      * Returns the energy consumer info for all available {@link EnergyConsumer}
38      *
39      * @return List of available {@link EnergyConsumer}, or null if {@link EnergyConsumer} not
40      * supported
41      */
42     @Nullable
getEnergyConsumerInfo()43     public abstract EnergyConsumer[] getEnergyConsumerInfo();
44 
45     /**
46      * Returns a CompletableFuture that will get an {@link EnergyConsumerResult} array for the
47      * available requested energy consumers (power models).
48      *
49      * @param energyConsumerIds Array of {@link EnergyConsumerId} for which energy consumed is being
50      *                          requested.
51      *
52      * @return A Future containing a list of {@link EnergyConsumerResult} objects containing energy
53      *         consumer results for all listed {@link EnergyConsumerId}. null if
54      *         {@link EnergyConsumer} not supported
55      */
56     @NonNull
getEnergyConsumedAsync( int[] energyConsumerIds)57     public abstract CompletableFuture<EnergyConsumerResult[]> getEnergyConsumedAsync(
58             int[] energyConsumerIds);
59 
60     /**
61      * Returns the power entity info for all available {@link PowerEntity}
62      *
63      * @return List of available {@link PowerEntity} or null if {@link PowerEntity} not
64      * supported
65      */
66     @Nullable
getPowerEntityInfo()67     public abstract PowerEntity[] getPowerEntityInfo();
68 
69     /**
70      * Returns a CompletableFuture that will get a {@link StateResidencyResult} array for the
71      * available requested power entities.
72      *
73      * @param powerEntityIds Array of {@link PowerEntity.id} for which state residency is being
74      *                          requested.
75      *
76      * @return A Future containing a list of {@link StateResidencyResult} objects containing state
77      *         residency results for all listed {@link PowerEntity.id}. null if {@link PowerEntity}
78      *         not supported
79      */
80     @NonNull
getStateResidencyAsync( int[] powerEntityIds)81     public abstract CompletableFuture<StateResidencyResult[]> getStateResidencyAsync(
82             int[] powerEntityIds);
83 
84     /**
85      * Returns the channel info for all available {@link Channel}
86      *
87      * @return List of available {@link Channel} or null if {@link Channel} not supported
88      */
89     @Nullable
getEnergyMeterInfo()90     public abstract Channel[] getEnergyMeterInfo();
91 
92     /**
93      * Returns a CompletableFuture that will get a {@link EnergyMeasurement} array for the
94      * available requested channels.
95      *
96      * @param channelIds Array of {@link Channel.id} for accumulated energy is being requested.
97      *
98      * @return A Future containing a list of {@link EnergyMeasurement} objects containing
99      *         accumulated energy measurements for all listed {@link Channel.id}. null if
100      *         {@link Channel} not supported
101      */
102     @NonNull
readEnergyMeterAsync( int[] channelIds)103     public abstract CompletableFuture<EnergyMeasurement[]> readEnergyMeterAsync(
104             int[] channelIds);
105 }
106