blob: 514ff76372a93c5cc3ae1d0c99a6e9061b318f57 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package com.android.internal.app;
18
19import com.android.internal.os.BatteryStatsImpl;
20
Adam Lesinski010bf372016-04-11 12:18:18 -070021import android.bluetooth.BluetoothActivityEnergyInfo;
22import android.net.wifi.WifiActivityEnergyInfo;
Dianne Hackborn0068d3dc2014-08-06 19:20:25 -070023import android.os.ParcelFileDescriptor;
Dianne Hackborn7e9f4eb2010-09-10 18:43:00 -070024import android.os.WorkSource;
Siddharth Raya1fd0572017-11-13 14:20:47 -080025import android.os.connectivity.CellularBatteryStats;
Siddharth Rayb50a6842017-12-14 15:15:28 -080026import android.os.connectivity.WifiBatteryStats;
Siddharth Ray78ccaf52017-12-23 16:16:21 -080027import android.os.connectivity.GpsBatteryStats;
Joe Onorato713fec82016-03-04 10:34:02 -080028import android.os.health.HealthStatsParceler;
Dianne Hackborn2ffa11e2014-04-21 15:56:18 -070029import android.telephony.DataConnectionRealTimeInfo;
Adam Lesinski010bf372016-04-11 12:18:18 -070030import android.telephony.ModemActivityInfo;
Wink Savillee9b06d72009-05-18 21:47:50 -070031import android.telephony.SignalStrength;
32
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033interface IBatteryStats {
Mike Lockwood488bb0e2013-09-25 09:27:18 -070034 // These first methods are also called by native code, so must
Peter Visontaycee76322017-09-05 11:43:36 +010035 // be kept in sync with frameworks/native/libs/binder/include/binder/IBatteryStats.h
Mike Lockwood488bb0e2013-09-25 09:27:18 -070036 void noteStartSensor(int uid, int sensor);
37 void noteStopSensor(int uid, int sensor);
Chong Zhangf3d00e42014-07-22 09:12:36 -070038 void noteStartVideo(int uid);
39 void noteStopVideo(int uid);
40 void noteStartAudio(int uid);
41 void noteStopAudio(int uid);
Dianne Hackborn10eaa852014-07-22 22:54:55 -070042 void noteResetVideo();
43 void noteResetAudio();
Ruben Brunk6d2c3632015-05-26 17:32:16 -070044 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 Lockwood488bb0e2013-09-25 09:27:18 -070050
51 // Remaining methods are only used in Java.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052 byte[] getStatistics();
Dianne Hackborn099bc622014-01-22 13:39:16 -080053
Dianne Hackborn0068d3dc2014-08-06 19:20:25 -070054 ParcelFileDescriptor getStatisticsStream();
55
Dianne Hackborn4870e9d2015-04-08 16:55:47 -070056 // Return true if we see the battery as currently charging.
57 boolean isCharging();
58
Dianne Hackbornab5c0ea2014-04-29 14:53:32 -070059 // Return the computed amount of time remaining on battery, in milliseconds.
60 // Returns -1 if nothing could be computed.
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.
65 long computeChargeTimeRemaining();
66
Dianne Hackborn099bc622014-01-22 13:39:16 -080067 void noteEvent(int code, String name, int uid);
68
Dianne Hackbornfdb19562014-07-11 16:03:36 -070069 void noteSyncStart(String name, int uid);
70 void noteSyncFinish(String name, int uid);
71 void noteJobStart(String name, int uid);
Dianne Hackborn94326cb2017-06-28 16:17:20 -070072 void noteJobFinish(String name, int uid, int stopReason);
Dianne Hackborn61659e52014-07-09 16:13:01 -070073
Dianne Hackborna1f1a3c2014-02-24 18:12:28 -080074 void noteStartWakelock(int uid, int pid, String name, String historyName,
75 int type, boolean unimportantForLogging);
Dianne Hackborncbefd8d2014-05-14 11:42:00 -070076 void noteStopWakelock(int uid, int pid, String name, String historyName, int type);
Mathias Agopian32123fde2010-07-22 22:19:43 -070077
Dianne Hackborna1f1a3c2014-02-24 18:12:28 -080078 void noteStartWakelockFromSource(in WorkSource ws, int pid, String name, String historyName,
79 int type, boolean unimportantForLogging);
Dianne Hackborncbefd8d2014-05-14 11:42:00 -070080 void noteChangeWakelockFromSource(in WorkSource ws, int pid, String name, String histyoryName,
81 int type, in WorkSource newWs, int newPid, String newName,
Dianne Hackborne5167ca2014-03-08 14:39:10 -080082 String newHistoryName, int newType, boolean newUnimportantForLogging);
Dianne Hackborncbefd8d2014-05-14 11:42:00 -070083 void noteStopWakelockFromSource(in WorkSource ws, int pid, String name, String historyName,
84 int type);
Dianne Hackbornd0db6f02016-07-18 14:14:20 -070085 void noteLongPartialWakelockStart(String name, String historyName, int uid);
Narayan Kamath96a92562018-01-02 18:57:17 +000086 void noteLongPartialWakelockStartFromSource(String name, String historyName,
87 in WorkSource workSource);
Dianne Hackbornd0db6f02016-07-18 14:14:20 -070088 void noteLongPartialWakelockFinish(String name, String historyName, int uid);
Narayan Kamath96a92562018-01-02 18:57:17 +000089 void noteLongPartialWakelockFinishFromSource(String name, String historyName,
90 in WorkSource workSource);
Dianne Hackborn7e9f4eb2010-09-10 18:43:00 -070091
Dianne Hackborna06de0f2012-12-11 16:34:47 -080092 void noteVibratorOn(int uid, long durationMillis);
93 void noteVibratorOff(int uid);
Narayan Kamath32684dd2018-01-08 17:32:51 +000094 void noteGpsChanged(in WorkSource oldSource, in WorkSource newSource);
Siddharth Ray78ccaf52017-12-23 16:16:21 -080095 void noteGpsSignalQuality(int signalLevel);
Jeff Browne95c3cd2014-05-02 16:59:26 -070096 void noteScreenState(int state);
Dianne Hackborn617f8772009-03-31 15:04:46 -070097 void noteScreenBrightness(int brightness);
Dianne Hackborn617f8772009-03-31 15:04:46 -070098 void noteUserActivity(int uid, int event);
Dianne Hackborn280a64e2015-07-13 14:48:08 -070099 void noteWakeUp(String reason, int reasonUid);
Jeff Browne95c3cd2014-05-02 16:59:26 -0700100 void noteInteractive(boolean interactive);
Dianne Hackborn1e01d162014-12-04 17:46:42 -0800101 void noteConnectivityChanged(int type, String extra);
Ruchi Kandoifa97fcf2016-05-13 15:10:39 -0700102 void noteMobileRadioPowerState(int powerState, long timestampNs, int uid);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 void notePhoneOn();
104 void notePhoneOff();
Wink Savillee9b06d72009-05-18 21:47:50 -0700105 void notePhoneSignalStrength(in SignalStrength signalStrength);
Dianne Hackborn627bba72009-03-24 22:32:56 -0700106 void notePhoneDataConnectionState(int dataType, boolean hasData);
Amith Yamasanif37447b2009-10-08 18:28:01 -0700107 void notePhoneState(int phoneState);
Dianne Hackborn58e0eef2010-09-16 01:22:10 -0700108 void noteWifiOn();
109 void noteWifiOff();
110 void noteWifiRunning(in WorkSource ws);
111 void noteWifiRunningChanged(in WorkSource oldWs, in WorkSource newWs);
112 void noteWifiStopped(in WorkSource ws);
Dianne Hackbornca1bf212014-02-14 14:18:36 -0800113 void noteWifiState(int wifiState, String accessPoint);
Dianne Hackborn3251b902014-06-20 14:40:53 -0700114 void noteWifiSupplicantStateChanged(int supplState, boolean failedAuth);
115 void noteWifiRssiChanged(int newRssi);
The Android Open Source Project10592532009-03-18 17:39:46 -0700116 void noteFullWifiLockAcquired(int uid);
117 void noteFullWifiLockReleased(int uid);
Nick Pelly6ccaa542012-06-15 15:22:47 -0700118 void noteWifiScanStarted(int uid);
119 void noteWifiScanStopped(int uid);
Robert Greenwalt5347bd42009-05-13 15:10:16 -0700120 void noteWifiMulticastEnabled(int uid);
121 void noteWifiMulticastDisabled(int uid);
Dianne Hackborn7e9f4eb2010-09-10 18:43:00 -0700122 void noteFullWifiLockAcquiredFromSource(in WorkSource ws);
123 void noteFullWifiLockReleasedFromSource(in WorkSource ws);
Nick Pelly6ccaa542012-06-15 15:22:47 -0700124 void noteWifiScanStartedFromSource(in WorkSource ws);
125 void noteWifiScanStoppedFromSource(in WorkSource ws);
Robert Greenwalta029ea12013-09-25 16:38:12 -0700126 void noteWifiBatchedScanStartedFromSource(in WorkSource ws, int csph);
127 void noteWifiBatchedScanStoppedFromSource(in WorkSource ws);
Adam Lesinski5f056f62016-07-14 16:56:08 -0700128 void noteWifiRadioPowerState(int powerState, long timestampNs, int uid);
Jeff Sharkey1059c3c2011-10-04 16:54:49 -0700129 void noteNetworkInterfaceType(String iface, int type);
Jeff Sharkey7a1c3fc2013-06-04 12:29:00 -0700130 void noteNetworkStatsEnabled();
Dianne Hackborn08c47a52015-10-15 12:38:14 -0700131 void noteDeviceIdleMode(int mode, String activeReason, int activeUid);
Adam Lesinski926969b2016-04-28 17:31:12 -0700132 void setBatteryState(int status, int health, int plugType, int level, int temp, int volt,
Adam Lesinski041d9172016-12-12 12:03:56 -0800133 int chargeUAh, int chargeFullUAh);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 long getAwakeTimeBattery();
135 long getAwakeTimePlugged();
Adam Lesinski6771d622016-01-15 18:14:47 -0800136
Bookatzb1f04f32017-05-19 13:57:32 -0700137 void noteBleScanStarted(in WorkSource ws, boolean isUnoptimized);
Bookatz94c5a312017-07-11 16:49:17 -0700138 void noteBleScanStopped(in WorkSource ws, boolean isUnoptimized);
Adam Lesinski9f55cc72016-01-27 20:42:14 -0800139 void noteResetBleScan();
Bookatz4ebc0642017-05-11 12:21:19 -0700140 void noteBleScanResults(in WorkSource ws, int numNewResults);
Joe Onorato713fec82016-03-04 10:34:02 -0800141
Siddharth Raya1fd0572017-11-13 14:20:47 -0800142 /** {@hide} */
143 CellularBatteryStats getCellularBatteryStats();
144
Siddharth Ray78ccaf52017-12-23 16:16:21 -0800145 /** {@hide} */
Siddharth Rayb50a6842017-12-14 15:15:28 -0800146 WifiBatteryStats getWifiBatteryStats();
147
148 /** {@hide} */
Siddharth Ray78ccaf52017-12-23 16:16:21 -0800149 GpsBatteryStats getGpsBatteryStats();
150
Joe Onorato713fec82016-03-04 10:34:02 -0800151 HealthStatsParceler takeUidSnapshot(int uid);
152 HealthStatsParceler[] takeUidSnapshots(in int[] uid);
Adam Lesinski010bf372016-04-11 12:18:18 -0700153
154 oneway void noteBluetoothControllerActivity(in BluetoothActivityEnergyInfo info);
155 oneway void noteModemControllerActivity(in ModemActivityInfo info);
156 oneway void noteWifiControllerActivity(in WifiActivityEnergyInfo info);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800157}