1 /*
2  * Copyright (C) 2008 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 com.android.internal.app;
18 
19 import com.android.internal.os.BatteryStatsImpl;
20 
21 import android.bluetooth.BluetoothActivityEnergyInfo;
22 import android.net.wifi.WifiActivityEnergyInfo;
23 import android.os.ParcelFileDescriptor;
24 import android.os.WorkSource;
25 import android.os.connectivity.CellularBatteryStats;
26 import android.os.connectivity.WifiBatteryStats;
27 import android.os.connectivity.GpsBatteryStats;
28 import android.os.health.HealthStatsParceler;
29 import android.telephony.DataConnectionRealTimeInfo;
30 import android.telephony.ModemActivityInfo;
31 import android.telephony.SignalStrength;
32 
33 interface IBatteryStats {
34     // These first methods are also called by native code, so must
35     // be kept in sync with frameworks/native/libs/binder/include/binder/IBatteryStats.h
noteStartSensor(int uid, int sensor)36     void noteStartSensor(int uid, int sensor);
noteStopSensor(int uid, int sensor)37     void noteStopSensor(int uid, int sensor);
noteStartVideo(int uid)38     void noteStartVideo(int uid);
noteStopVideo(int uid)39     void noteStopVideo(int uid);
noteStartAudio(int uid)40     void noteStartAudio(int uid);
noteStopAudio(int uid)41     void noteStopAudio(int uid);
noteResetVideo()42     void noteResetVideo();
noteResetAudio()43     void noteResetAudio();
noteFlashlightOn(int uid)44     void noteFlashlightOn(int uid);
noteFlashlightOff(int uid)45     void noteFlashlightOff(int uid);
noteStartCamera(int uid)46     void noteStartCamera(int uid);
noteStopCamera(int uid)47     void noteStopCamera(int uid);
noteResetCamera()48     void noteResetCamera();
noteResetFlashlight()49     void noteResetFlashlight();
50 
51     // Remaining methods are only used in Java.
getStatistics()52     byte[] getStatistics();
53 
getStatisticsStream()54     ParcelFileDescriptor getStatisticsStream();
55 
56     // Return true if we see the battery as currently charging.
isCharging()57     boolean isCharging();
58 
59     // Return the computed amount of time remaining on battery, in milliseconds.
60     // Returns -1 if nothing could be computed.
computeBatteryTimeRemaining()61     long computeBatteryTimeRemaining();
62 
63     // Return the computed amount of time remaining to fully charge, in milliseconds.
64     // Returns -1 if nothing could be computed.
computeChargeTimeRemaining()65     long computeChargeTimeRemaining();
66 
noteEvent(int code, String name, int uid)67     void noteEvent(int code, String name, int uid);
68 
noteSyncStart(String name, int uid)69     void noteSyncStart(String name, int uid);
noteSyncFinish(String name, int uid)70     void noteSyncFinish(String name, int uid);
noteJobStart(String name, int uid)71     void noteJobStart(String name, int uid);
noteJobFinish(String name, int uid, int stopReason)72     void noteJobFinish(String name, int uid, int stopReason);
73 
noteStartWakelock(int uid, int pid, String name, String historyName, int type, boolean unimportantForLogging)74     void noteStartWakelock(int uid, int pid, String name, String historyName,
75             int type, boolean unimportantForLogging);
noteStopWakelock(int uid, int pid, String name, String historyName, int type)76     void noteStopWakelock(int uid, int pid, String name, String historyName, int type);
77 
noteStartWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, int type, boolean unimportantForLogging)78     void noteStartWakelockFromSource(in WorkSource ws, int pid, String name, String historyName,
79             int type, boolean unimportantForLogging);
noteChangeWakelockFromSource(in WorkSource ws, int pid, String name, String histyoryName, int type, in WorkSource newWs, int newPid, String newName, String newHistoryName, int newType, boolean newUnimportantForLogging)80     void noteChangeWakelockFromSource(in WorkSource ws, int pid, String name, String histyoryName,
81             int type, in WorkSource newWs, int newPid, String newName,
82             String newHistoryName, int newType, boolean newUnimportantForLogging);
noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, int type)83     void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName,
84             int type);
noteLongPartialWakelockStart(String name, String historyName, int uid)85     void noteLongPartialWakelockStart(String name, String historyName, int uid);
noteLongPartialWakelockStartFromSource(String name, String historyName, in WorkSource workSource)86     void noteLongPartialWakelockStartFromSource(String name, String historyName,
87             in WorkSource workSource);
noteLongPartialWakelockFinish(String name, String historyName, int uid)88     void noteLongPartialWakelockFinish(String name, String historyName, int uid);
noteLongPartialWakelockFinishFromSource(String name, String historyName, in WorkSource workSource)89     void noteLongPartialWakelockFinishFromSource(String name, String historyName,
90             in WorkSource workSource);
91 
noteVibratorOn(int uid, long durationMillis)92     void noteVibratorOn(int uid, long durationMillis);
noteVibratorOff(int uid)93     void noteVibratorOff(int uid);
noteGpsChanged(in WorkSource oldSource, in WorkSource newSource)94     void noteGpsChanged(in WorkSource oldSource, in WorkSource newSource);
noteGpsSignalQuality(int signalLevel)95     void noteGpsSignalQuality(int signalLevel);
noteScreenState(int state)96     void noteScreenState(int state);
noteScreenBrightness(int brightness)97     void noteScreenBrightness(int brightness);
noteUserActivity(int uid, int event)98     void noteUserActivity(int uid, int event);
noteWakeUp(String reason, int reasonUid)99     void noteWakeUp(String reason, int reasonUid);
noteInteractive(boolean interactive)100     void noteInteractive(boolean interactive);
noteConnectivityChanged(int type, String extra)101     void noteConnectivityChanged(int type, String extra);
noteMobileRadioPowerState(int powerState, long timestampNs, int uid)102     void noteMobileRadioPowerState(int powerState, long timestampNs, int uid);
notePhoneOn()103     void notePhoneOn();
notePhoneOff()104     void notePhoneOff();
notePhoneSignalStrength(in SignalStrength signalStrength)105     void notePhoneSignalStrength(in SignalStrength signalStrength);
notePhoneDataConnectionState(int dataType, boolean hasData)106     void notePhoneDataConnectionState(int dataType, boolean hasData);
notePhoneState(int phoneState)107     void notePhoneState(int phoneState);
noteWifiOn()108     void noteWifiOn();
noteWifiOff()109     void noteWifiOff();
noteWifiRunning(in WorkSource ws)110     void noteWifiRunning(in WorkSource ws);
noteWifiRunningChanged(in WorkSource oldWs, in WorkSource newWs)111     void noteWifiRunningChanged(in WorkSource oldWs, in WorkSource newWs);
noteWifiStopped(in WorkSource ws)112     void noteWifiStopped(in WorkSource ws);
noteWifiState(int wifiState, String accessPoint)113     void noteWifiState(int wifiState, String accessPoint);
noteWifiSupplicantStateChanged(int supplState, boolean failedAuth)114     void noteWifiSupplicantStateChanged(int supplState, boolean failedAuth);
noteWifiRssiChanged(int newRssi)115     void noteWifiRssiChanged(int newRssi);
noteFullWifiLockAcquired(int uid)116     void noteFullWifiLockAcquired(int uid);
noteFullWifiLockReleased(int uid)117     void noteFullWifiLockReleased(int uid);
noteWifiScanStarted(int uid)118     void noteWifiScanStarted(int uid);
noteWifiScanStopped(int uid)119     void noteWifiScanStopped(int uid);
noteWifiMulticastEnabled(int uid)120     void noteWifiMulticastEnabled(int uid);
noteWifiMulticastDisabled(int uid)121     void noteWifiMulticastDisabled(int uid);
noteFullWifiLockAcquiredFromSource(in WorkSource ws)122     void noteFullWifiLockAcquiredFromSource(in WorkSource ws);
noteFullWifiLockReleasedFromSource(in WorkSource ws)123     void noteFullWifiLockReleasedFromSource(in WorkSource ws);
noteWifiScanStartedFromSource(in WorkSource ws)124     void noteWifiScanStartedFromSource(in WorkSource ws);
noteWifiScanStoppedFromSource(in WorkSource ws)125     void noteWifiScanStoppedFromSource(in WorkSource ws);
noteWifiBatchedScanStartedFromSource(in WorkSource ws, int csph)126     void noteWifiBatchedScanStartedFromSource(in WorkSource ws, int csph);
noteWifiBatchedScanStoppedFromSource(in WorkSource ws)127     void noteWifiBatchedScanStoppedFromSource(in WorkSource ws);
noteWifiRadioPowerState(int powerState, long timestampNs, int uid)128     void noteWifiRadioPowerState(int powerState, long timestampNs, int uid);
noteNetworkInterfaceType(String iface, int type)129     void noteNetworkInterfaceType(String iface, int type);
noteNetworkStatsEnabled()130     void noteNetworkStatsEnabled();
noteDeviceIdleMode(int mode, String activeReason, int activeUid)131     void noteDeviceIdleMode(int mode, String activeReason, int activeUid);
setBatteryState(int status, int health, int plugType, int level, int temp, int volt, int chargeUAh, int chargeFullUAh)132     void setBatteryState(int status, int health, int plugType, int level, int temp, int volt,
133             int chargeUAh, int chargeFullUAh);
getAwakeTimeBattery()134     long getAwakeTimeBattery();
getAwakeTimePlugged()135     long getAwakeTimePlugged();
136 
noteBleScanStarted(in WorkSource ws, boolean isUnoptimized)137     void noteBleScanStarted(in WorkSource ws, boolean isUnoptimized);
noteBleScanStopped(in WorkSource ws, boolean isUnoptimized)138     void noteBleScanStopped(in WorkSource ws, boolean isUnoptimized);
noteResetBleScan()139     void noteResetBleScan();
noteBleScanResults(in WorkSource ws, int numNewResults)140     void noteBleScanResults(in WorkSource ws, int numNewResults);
141 
142     /** {@hide} */
getCellularBatteryStats()143     CellularBatteryStats getCellularBatteryStats();
144 
145     /** {@hide} */
getWifiBatteryStats()146     WifiBatteryStats getWifiBatteryStats();
147 
148     /** {@hide} */
getGpsBatteryStats()149     GpsBatteryStats getGpsBatteryStats();
150 
takeUidSnapshot(int uid)151     HealthStatsParceler takeUidSnapshot(int uid);
takeUidSnapshots(in int[] uid)152     HealthStatsParceler[] takeUidSnapshots(in int[] uid);
153 
noteBluetoothControllerActivity(in BluetoothActivityEnergyInfo info)154     oneway void noteBluetoothControllerActivity(in BluetoothActivityEnergyInfo info);
noteModemControllerActivity(in ModemActivityInfo info)155     oneway void noteModemControllerActivity(in ModemActivityInfo info);
noteWifiControllerActivity(in WifiActivityEnergyInfo info)156     oneway void noteWifiControllerActivity(in WifiActivityEnergyInfo info);
157 }
158