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. 52 @UnsupportedAppUsage getStatistics()53 byte[] getStatistics(); 54 getStatisticsStream()55 ParcelFileDescriptor getStatisticsStream(); 56 57 // Return true if we see the battery as currently charging. 58 @UnsupportedAppUsage isCharging()59 boolean isCharging(); 60 61 // Return the computed amount of time remaining on battery, in milliseconds. 62 // Returns -1 if nothing could be computed. computeBatteryTimeRemaining()63 long computeBatteryTimeRemaining(); 64 65 // Return the computed amount of time remaining to fully charge, in milliseconds. 66 // Returns -1 if nothing could be computed. 67 @UnsupportedAppUsage computeChargeTimeRemaining()68 long computeChargeTimeRemaining(); 69 noteEvent(int code, String name, int uid)70 void noteEvent(int code, String name, int uid); 71 noteSyncStart(String name, int uid)72 void noteSyncStart(String name, int uid); noteSyncFinish(String name, int uid)73 void noteSyncFinish(String name, int uid); noteJobStart(String name, int uid, int standbyBucket, int jobid)74 void noteJobStart(String name, int uid, int standbyBucket, int jobid); noteJobFinish(String name, int uid, int stopReason, int standbyBucket, int jobid)75 void noteJobFinish(String name, int uid, int stopReason, int standbyBucket, int jobid); 76 noteStartWakelock(int uid, int pid, String name, String historyName, int type, boolean unimportantForLogging)77 void noteStartWakelock(int uid, int pid, String name, String historyName, 78 int type, boolean unimportantForLogging); noteStopWakelock(int uid, int pid, String name, String historyName, int type)79 void noteStopWakelock(int uid, int pid, String name, String historyName, int type); 80 noteStartWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, int type, boolean unimportantForLogging)81 void noteStartWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, 82 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)83 void noteChangeWakelockFromSource(in WorkSource ws, int pid, String name, String histyoryName, 84 int type, in WorkSource newWs, int newPid, String newName, 85 String newHistoryName, int newType, boolean newUnimportantForLogging); noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, int type)86 void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, 87 int type); noteLongPartialWakelockStart(String name, String historyName, int uid)88 void noteLongPartialWakelockStart(String name, String historyName, int uid); noteLongPartialWakelockStartFromSource(String name, String historyName, in WorkSource workSource)89 void noteLongPartialWakelockStartFromSource(String name, String historyName, 90 in WorkSource workSource); noteLongPartialWakelockFinish(String name, String historyName, int uid)91 void noteLongPartialWakelockFinish(String name, String historyName, int uid); noteLongPartialWakelockFinishFromSource(String name, String historyName, in WorkSource workSource)92 void noteLongPartialWakelockFinishFromSource(String name, String historyName, 93 in WorkSource workSource); 94 noteVibratorOn(int uid, long durationMillis)95 void noteVibratorOn(int uid, long durationMillis); noteVibratorOff(int uid)96 void noteVibratorOff(int uid); noteGpsChanged(in WorkSource oldSource, in WorkSource newSource)97 void noteGpsChanged(in WorkSource oldSource, in WorkSource newSource); noteGpsSignalQuality(int signalLevel)98 void noteGpsSignalQuality(int signalLevel); noteScreenState(int state)99 void noteScreenState(int state); noteScreenBrightness(int brightness)100 void noteScreenBrightness(int brightness); noteUserActivity(int uid, int event)101 void noteUserActivity(int uid, int event); noteWakeUp(String reason, int reasonUid)102 void noteWakeUp(String reason, int reasonUid); noteInteractive(boolean interactive)103 void noteInteractive(boolean interactive); noteConnectivityChanged(int type, String extra)104 void noteConnectivityChanged(int type, String extra); noteMobileRadioPowerState(int powerState, long timestampNs, int uid)105 void noteMobileRadioPowerState(int powerState, long timestampNs, int uid); notePhoneOn()106 void notePhoneOn(); notePhoneOff()107 void notePhoneOff(); notePhoneSignalStrength(in SignalStrength signalStrength)108 void notePhoneSignalStrength(in SignalStrength signalStrength); notePhoneDataConnectionState(int dataType, boolean hasData, int serviceType)109 void notePhoneDataConnectionState(int dataType, boolean hasData, int serviceType); notePhoneState(int phoneState)110 void notePhoneState(int phoneState); noteWifiOn()111 void noteWifiOn(); noteWifiOff()112 void noteWifiOff(); noteWifiRunning(in WorkSource ws)113 void noteWifiRunning(in WorkSource ws); noteWifiRunningChanged(in WorkSource oldWs, in WorkSource newWs)114 void noteWifiRunningChanged(in WorkSource oldWs, in WorkSource newWs); noteWifiStopped(in WorkSource ws)115 void noteWifiStopped(in WorkSource ws); noteWifiState(int wifiState, String accessPoint)116 void noteWifiState(int wifiState, String accessPoint); noteWifiSupplicantStateChanged(int supplState, boolean failedAuth)117 void noteWifiSupplicantStateChanged(int supplState, boolean failedAuth); noteWifiRssiChanged(int newRssi)118 void noteWifiRssiChanged(int newRssi); noteFullWifiLockAcquired(int uid)119 void noteFullWifiLockAcquired(int uid); noteFullWifiLockReleased(int uid)120 void noteFullWifiLockReleased(int uid); noteWifiScanStarted(int uid)121 void noteWifiScanStarted(int uid); noteWifiScanStopped(int uid)122 void noteWifiScanStopped(int uid); noteWifiMulticastEnabled(int uid)123 void noteWifiMulticastEnabled(int uid); noteWifiMulticastDisabled(int uid)124 void noteWifiMulticastDisabled(int uid); noteFullWifiLockAcquiredFromSource(in WorkSource ws)125 void noteFullWifiLockAcquiredFromSource(in WorkSource ws); noteFullWifiLockReleasedFromSource(in WorkSource ws)126 void noteFullWifiLockReleasedFromSource(in WorkSource ws); noteWifiScanStartedFromSource(in WorkSource ws)127 void noteWifiScanStartedFromSource(in WorkSource ws); noteWifiScanStoppedFromSource(in WorkSource ws)128 void noteWifiScanStoppedFromSource(in WorkSource ws); noteWifiBatchedScanStartedFromSource(in WorkSource ws, int csph)129 void noteWifiBatchedScanStartedFromSource(in WorkSource ws, int csph); noteWifiBatchedScanStoppedFromSource(in WorkSource ws)130 void noteWifiBatchedScanStoppedFromSource(in WorkSource ws); noteWifiRadioPowerState(int powerState, long timestampNs, int uid)131 void noteWifiRadioPowerState(int powerState, long timestampNs, int uid); noteNetworkInterfaceType(String iface, int type)132 void noteNetworkInterfaceType(String iface, int type); noteNetworkStatsEnabled()133 void noteNetworkStatsEnabled(); noteDeviceIdleMode(int mode, String activeReason, int activeUid)134 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, long chargeTimeToFullSeconds)135 void setBatteryState(int status, int health, int plugType, int level, int temp, int volt, 136 int chargeUAh, int chargeFullUAh, long chargeTimeToFullSeconds); 137 @UnsupportedAppUsage getAwakeTimeBattery()138 long getAwakeTimeBattery(); getAwakeTimePlugged()139 long getAwakeTimePlugged(); 140 noteBleScanStarted(in WorkSource ws, boolean isUnoptimized)141 void noteBleScanStarted(in WorkSource ws, boolean isUnoptimized); noteBleScanStopped(in WorkSource ws, boolean isUnoptimized)142 void noteBleScanStopped(in WorkSource ws, boolean isUnoptimized); noteResetBleScan()143 void noteResetBleScan(); noteBleScanResults(in WorkSource ws, int numNewResults)144 void noteBleScanResults(in WorkSource ws, int numNewResults); 145 146 /** {@hide} */ getCellularBatteryStats()147 CellularBatteryStats getCellularBatteryStats(); 148 149 /** {@hide} */ getWifiBatteryStats()150 WifiBatteryStats getWifiBatteryStats(); 151 152 /** {@hide} */ getGpsBatteryStats()153 GpsBatteryStats getGpsBatteryStats(); 154 takeUidSnapshot(int uid)155 HealthStatsParceler takeUidSnapshot(int uid); takeUidSnapshots(in int[] uid)156 HealthStatsParceler[] takeUidSnapshots(in int[] uid); 157 noteBluetoothControllerActivity(in BluetoothActivityEnergyInfo info)158 oneway void noteBluetoothControllerActivity(in BluetoothActivityEnergyInfo info); noteModemControllerActivity(in ModemActivityInfo info)159 oneway void noteModemControllerActivity(in ModemActivityInfo info); noteWifiControllerActivity(in WifiActivityEnergyInfo info)160 oneway void noteWifiControllerActivity(in WifiActivityEnergyInfo info); 161 162 /** {@hide} */ setChargingStateUpdateDelayMillis(int delay)163 boolean setChargingStateUpdateDelayMillis(int delay); 164 } 165