The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Adam Lesinski | 010bf37 | 2016-04-11 12:18:18 -0700 | [diff] [blame] | 21 | import android.bluetooth.BluetoothActivityEnergyInfo; |
| 22 | import android.net.wifi.WifiActivityEnergyInfo; |
Dianne Hackborn | 0068d3dc | 2014-08-06 19:20:25 -0700 | [diff] [blame] | 23 | import android.os.ParcelFileDescriptor; |
Dianne Hackborn | 7e9f4eb | 2010-09-10 18:43:00 -0700 | [diff] [blame] | 24 | import android.os.WorkSource; |
Siddharth Ray | a1fd057 | 2017-11-13 14:20:47 -0800 | [diff] [blame] | 25 | import android.os.connectivity.CellularBatteryStats; |
Siddharth Ray | b50a684 | 2017-12-14 15:15:28 -0800 | [diff] [blame] | 26 | import android.os.connectivity.WifiBatteryStats; |
Siddharth Ray | 78ccaf5 | 2017-12-23 16:16:21 -0800 | [diff] [blame] | 27 | import android.os.connectivity.GpsBatteryStats; |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 28 | import android.os.health.HealthStatsParceler; |
Dianne Hackborn | 2ffa11e | 2014-04-21 15:56:18 -0700 | [diff] [blame] | 29 | import android.telephony.DataConnectionRealTimeInfo; |
Adam Lesinski | 010bf37 | 2016-04-11 12:18:18 -0700 | [diff] [blame] | 30 | import android.telephony.ModemActivityInfo; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 31 | import android.telephony.SignalStrength; |
| 32 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | interface IBatteryStats { |
Mike Lockwood | 488bb0e | 2013-09-25 09:27:18 -0700 | [diff] [blame] | 34 | // These first methods are also called by native code, so must |
Peter Visontay | cee7632 | 2017-09-05 11:43:36 +0100 | [diff] [blame] | 35 | // be kept in sync with frameworks/native/libs/binder/include/binder/IBatteryStats.h |
Mike Lockwood | 488bb0e | 2013-09-25 09:27:18 -0700 | [diff] [blame] | 36 | void noteStartSensor(int uid, int sensor); |
| 37 | void noteStopSensor(int uid, int sensor); |
Chong Zhang | f3d00e4 | 2014-07-22 09:12:36 -0700 | [diff] [blame] | 38 | void noteStartVideo(int uid); |
| 39 | void noteStopVideo(int uid); |
| 40 | void noteStartAudio(int uid); |
| 41 | void noteStopAudio(int uid); |
Dianne Hackborn | 10eaa85 | 2014-07-22 22:54:55 -0700 | [diff] [blame] | 42 | void noteResetVideo(); |
| 43 | void noteResetAudio(); |
Ruben Brunk | 6d2c363 | 2015-05-26 17:32:16 -0700 | [diff] [blame] | 44 | void noteFlashlightOn(int uid); |
| 45 | void noteFlashlightOff(int uid); |
| 46 | void noteStartCamera(int uid); |
| 47 | void noteStopCamera(int uid); |
| 48 | void noteResetCamera(); |
| 49 | void noteResetFlashlight(); |
Mike Lockwood | 488bb0e | 2013-09-25 09:27:18 -0700 | [diff] [blame] | 50 | |
| 51 | // Remaining methods are only used in Java. |
Andrei Onea | fa152f9 | 2019-02-27 15:58:05 +0000 | [diff] [blame] | 52 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | byte[] getStatistics(); |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 54 | |
Dianne Hackborn | 0068d3dc | 2014-08-06 19:20:25 -0700 | [diff] [blame] | 55 | ParcelFileDescriptor getStatisticsStream(); |
| 56 | |
Dianne Hackborn | 4870e9d | 2015-04-08 16:55:47 -0700 | [diff] [blame] | 57 | // Return true if we see the battery as currently charging. |
Andrei Onea | fa152f9 | 2019-02-27 15:58:05 +0000 | [diff] [blame] | 58 | @UnsupportedAppUsage |
Dianne Hackborn | 4870e9d | 2015-04-08 16:55:47 -0700 | [diff] [blame] | 59 | boolean isCharging(); |
| 60 | |
Dianne Hackborn | ab5c0ea | 2014-04-29 14:53:32 -0700 | [diff] [blame] | 61 | // Return the computed amount of time remaining on battery, in milliseconds. |
| 62 | // Returns -1 if nothing could be computed. |
| 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. |
Andrei Onea | fa152f9 | 2019-02-27 15:58:05 +0000 | [diff] [blame] | 67 | @UnsupportedAppUsage |
Dianne Hackborn | ab5c0ea | 2014-04-29 14:53:32 -0700 | [diff] [blame] | 68 | long computeChargeTimeRemaining(); |
| 69 | |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 70 | void noteEvent(int code, String name, int uid); |
| 71 | |
Dianne Hackborn | fdb1956 | 2014-07-11 16:03:36 -0700 | [diff] [blame] | 72 | void noteSyncStart(String name, int uid); |
| 73 | void noteSyncFinish(String name, int uid); |
Ben Murdoch | 741e335 | 2019-05-09 11:27:28 +0100 | [diff] [blame] | 74 | void noteJobStart(String name, int uid, int standbyBucket, int jobid); |
| 75 | void noteJobFinish(String name, int uid, int stopReason, int standbyBucket, int jobid); |
Dianne Hackborn | 61659e5 | 2014-07-09 16:13:01 -0700 | [diff] [blame] | 76 | |
Dianne Hackborn | a1f1a3c | 2014-02-24 18:12:28 -0800 | [diff] [blame] | 77 | void noteStartWakelock(int uid, int pid, String name, String historyName, |
| 78 | int type, boolean unimportantForLogging); |
Dianne Hackborn | cbefd8d | 2014-05-14 11:42:00 -0700 | [diff] [blame] | 79 | void noteStopWakelock(int uid, int pid, String name, String historyName, int type); |
Mathias Agopian | 32123fde | 2010-07-22 22:19:43 -0700 | [diff] [blame] | 80 | |
Dianne Hackborn | a1f1a3c | 2014-02-24 18:12:28 -0800 | [diff] [blame] | 81 | void noteStartWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, |
| 82 | int type, boolean unimportantForLogging); |
Dianne Hackborn | cbefd8d | 2014-05-14 11:42:00 -0700 | [diff] [blame] | 83 | void noteChangeWakelockFromSource(in WorkSource ws, int pid, String name, String histyoryName, |
| 84 | int type, in WorkSource newWs, int newPid, String newName, |
Dianne Hackborn | e5167ca | 2014-03-08 14:39:10 -0800 | [diff] [blame] | 85 | String newHistoryName, int newType, boolean newUnimportantForLogging); |
Dianne Hackborn | cbefd8d | 2014-05-14 11:42:00 -0700 | [diff] [blame] | 86 | void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName, |
| 87 | int type); |
Dianne Hackborn | d0db6f0 | 2016-07-18 14:14:20 -0700 | [diff] [blame] | 88 | void noteLongPartialWakelockStart(String name, String historyName, int uid); |
Narayan Kamath | 96a9256 | 2018-01-02 18:57:17 +0000 | [diff] [blame] | 89 | void noteLongPartialWakelockStartFromSource(String name, String historyName, |
| 90 | in WorkSource workSource); |
Dianne Hackborn | d0db6f0 | 2016-07-18 14:14:20 -0700 | [diff] [blame] | 91 | void noteLongPartialWakelockFinish(String name, String historyName, int uid); |
Narayan Kamath | 96a9256 | 2018-01-02 18:57:17 +0000 | [diff] [blame] | 92 | void noteLongPartialWakelockFinishFromSource(String name, String historyName, |
| 93 | in WorkSource workSource); |
Dianne Hackborn | 7e9f4eb | 2010-09-10 18:43:00 -0700 | [diff] [blame] | 94 | |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 95 | void noteVibratorOn(int uid, long durationMillis); |
| 96 | void noteVibratorOff(int uid); |
Narayan Kamath | 32684dd | 2018-01-08 17:32:51 +0000 | [diff] [blame] | 97 | void noteGpsChanged(in WorkSource oldSource, in WorkSource newSource); |
Siddharth Ray | 78ccaf5 | 2017-12-23 16:16:21 -0800 | [diff] [blame] | 98 | void noteGpsSignalQuality(int signalLevel); |
Jeff Brown | e95c3cd | 2014-05-02 16:59:26 -0700 | [diff] [blame] | 99 | void noteScreenState(int state); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 100 | void noteScreenBrightness(int brightness); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 101 | void noteUserActivity(int uid, int event); |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 102 | void noteWakeUp(String reason, int reasonUid); |
Jeff Brown | e95c3cd | 2014-05-02 16:59:26 -0700 | [diff] [blame] | 103 | void noteInteractive(boolean interactive); |
Dianne Hackborn | 1e01d16 | 2014-12-04 17:46:42 -0800 | [diff] [blame] | 104 | void noteConnectivityChanged(int type, String extra); |
Ruchi Kandoi | fa97fcf | 2016-05-13 15:10:39 -0700 | [diff] [blame] | 105 | void noteMobileRadioPowerState(int powerState, long timestampNs, int uid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | void notePhoneOn(); |
| 107 | void notePhoneOff(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 108 | void notePhoneSignalStrength(in SignalStrength signalStrength); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 109 | void notePhoneDataConnectionState(int dataType, boolean hasData); |
Amith Yamasani | f37447b | 2009-10-08 18:28:01 -0700 | [diff] [blame] | 110 | void notePhoneState(int phoneState); |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 111 | void noteWifiOn(); |
| 112 | void noteWifiOff(); |
| 113 | void noteWifiRunning(in WorkSource ws); |
| 114 | void noteWifiRunningChanged(in WorkSource oldWs, in WorkSource newWs); |
| 115 | void noteWifiStopped(in WorkSource ws); |
Dianne Hackborn | ca1bf21 | 2014-02-14 14:18:36 -0800 | [diff] [blame] | 116 | void noteWifiState(int wifiState, String accessPoint); |
Dianne Hackborn | 3251b90 | 2014-06-20 14:40:53 -0700 | [diff] [blame] | 117 | void noteWifiSupplicantStateChanged(int supplState, boolean failedAuth); |
| 118 | void noteWifiRssiChanged(int newRssi); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 119 | void noteFullWifiLockAcquired(int uid); |
| 120 | void noteFullWifiLockReleased(int uid); |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 121 | void noteWifiScanStarted(int uid); |
| 122 | void noteWifiScanStopped(int uid); |
Robert Greenwalt | 5347bd4 | 2009-05-13 15:10:16 -0700 | [diff] [blame] | 123 | void noteWifiMulticastEnabled(int uid); |
| 124 | void noteWifiMulticastDisabled(int uid); |
Dianne Hackborn | 7e9f4eb | 2010-09-10 18:43:00 -0700 | [diff] [blame] | 125 | void noteFullWifiLockAcquiredFromSource(in WorkSource ws); |
| 126 | void noteFullWifiLockReleasedFromSource(in WorkSource ws); |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 127 | void noteWifiScanStartedFromSource(in WorkSource ws); |
| 128 | void noteWifiScanStoppedFromSource(in WorkSource ws); |
Robert Greenwalt | a029ea1 | 2013-09-25 16:38:12 -0700 | [diff] [blame] | 129 | void noteWifiBatchedScanStartedFromSource(in WorkSource ws, int csph); |
| 130 | void noteWifiBatchedScanStoppedFromSource(in WorkSource ws); |
Adam Lesinski | 5f056f6 | 2016-07-14 16:56:08 -0700 | [diff] [blame] | 131 | void noteWifiRadioPowerState(int powerState, long timestampNs, int uid); |
Jeff Sharkey | 1059c3c | 2011-10-04 16:54:49 -0700 | [diff] [blame] | 132 | void noteNetworkInterfaceType(String iface, int type); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 133 | void noteNetworkStatsEnabled(); |
Dianne Hackborn | 08c47a5 | 2015-10-15 12:38:14 -0700 | [diff] [blame] | 134 | void noteDeviceIdleMode(int mode, String activeReason, int activeUid); |
Adam Lesinski | 926969b | 2016-04-28 17:31:12 -0700 | [diff] [blame] | 135 | void setBatteryState(int status, int health, int plugType, int level, int temp, int volt, |
Adam Lesinski | 041d917 | 2016-12-12 12:03:56 -0800 | [diff] [blame] | 136 | int chargeUAh, int chargeFullUAh); |
Andrei Onea | fa152f9 | 2019-02-27 15:58:05 +0000 | [diff] [blame] | 137 | @UnsupportedAppUsage |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 138 | long getAwakeTimeBattery(); |
| 139 | long getAwakeTimePlugged(); |
Adam Lesinski | 6771d62 | 2016-01-15 18:14:47 -0800 | [diff] [blame] | 140 | |
Bookatz | b1f04f3 | 2017-05-19 13:57:32 -0700 | [diff] [blame] | 141 | void noteBleScanStarted(in WorkSource ws, boolean isUnoptimized); |
Bookatz | 94c5a31 | 2017-07-11 16:49:17 -0700 | [diff] [blame] | 142 | void noteBleScanStopped(in WorkSource ws, boolean isUnoptimized); |
Adam Lesinski | 9f55cc7 | 2016-01-27 20:42:14 -0800 | [diff] [blame] | 143 | void noteResetBleScan(); |
Bookatz | 4ebc064 | 2017-05-11 12:21:19 -0700 | [diff] [blame] | 144 | void noteBleScanResults(in WorkSource ws, int numNewResults); |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 145 | |
Siddharth Ray | a1fd057 | 2017-11-13 14:20:47 -0800 | [diff] [blame] | 146 | /** {@hide} */ |
| 147 | CellularBatteryStats getCellularBatteryStats(); |
| 148 | |
Siddharth Ray | 78ccaf5 | 2017-12-23 16:16:21 -0800 | [diff] [blame] | 149 | /** {@hide} */ |
Siddharth Ray | b50a684 | 2017-12-14 15:15:28 -0800 | [diff] [blame] | 150 | WifiBatteryStats getWifiBatteryStats(); |
| 151 | |
| 152 | /** {@hide} */ |
Siddharth Ray | 78ccaf5 | 2017-12-23 16:16:21 -0800 | [diff] [blame] | 153 | GpsBatteryStats getGpsBatteryStats(); |
| 154 | |
Joe Onorato | 713fec8 | 2016-03-04 10:34:02 -0800 | [diff] [blame] | 155 | HealthStatsParceler takeUidSnapshot(int uid); |
| 156 | HealthStatsParceler[] takeUidSnapshots(in int[] uid); |
Adam Lesinski | 010bf37 | 2016-04-11 12:18:18 -0700 | [diff] [blame] | 157 | |
| 158 | oneway void noteBluetoothControllerActivity(in BluetoothActivityEnergyInfo info); |
| 159 | oneway void noteModemControllerActivity(in ModemActivityInfo info); |
| 160 | oneway void noteWifiControllerActivity(in WifiActivityEnergyInfo info); |
Ng Zhi An | 0941120 | 2019-01-23 11:46:50 -0800 | [diff] [blame] | 161 | |
| 162 | /** {@hide} */ |
| 163 | boolean setChargingStateUpdateDelayMillis(int delay); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | } |