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