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 void noteLongPartialWakelockStart(String name, String historyName, int uid); 83 void noteLongPartialWakelockFinish(String name, String historyName, int uid); 84 85 void noteVibratorOn(int uid, long durationMillis); 86 void noteVibratorOff(int uid); 87 void noteStartGps(int uid); 88 void noteStopGps(int uid); 89 void noteScreenState(int state); 90 void noteScreenBrightness(int brightness); 91 void noteUserActivity(int uid, int event); 92 void noteWakeUp(String reason, int reasonUid); 93 void noteInteractive(boolean interactive); 94 void noteConnectivityChanged(int type, String extra); 95 void noteMobileRadioPowerState(int powerState, long timestampNs, int uid); 96 void notePhoneOn(); 97 void notePhoneOff(); 98 void notePhoneSignalStrength(in SignalStrength signalStrength); 99 void notePhoneDataConnectionState(int dataType, boolean hasData); 100 void notePhoneState(int phoneState); 101 void noteWifiOn(); 102 void noteWifiOff(); 103 void noteWifiRunning(in WorkSource ws); 104 void noteWifiRunningChanged(in WorkSource oldWs, in WorkSource newWs); 105 void noteWifiStopped(in WorkSource ws); 106 void noteWifiState(int wifiState, String accessPoint); 107 void noteWifiSupplicantStateChanged(int supplState, boolean failedAuth); 108 void noteWifiRssiChanged(int newRssi); 109 void noteFullWifiLockAcquired(int uid); 110 void noteFullWifiLockReleased(int uid); 111 void noteWifiScanStarted(int uid); 112 void noteWifiScanStopped(int uid); 113 void noteWifiMulticastEnabled(int uid); 114 void noteWifiMulticastDisabled(int uid); 115 void noteFullWifiLockAcquiredFromSource(in WorkSource ws); 116 void noteFullWifiLockReleasedFromSource(in WorkSource ws); 117 void noteWifiScanStartedFromSource(in WorkSource ws); 118 void noteWifiScanStoppedFromSource(in WorkSource ws); 119 void noteWifiBatchedScanStartedFromSource(in WorkSource ws, int csph); 120 void noteWifiBatchedScanStoppedFromSource(in WorkSource ws); 121 void noteWifiMulticastEnabledFromSource(in WorkSource ws); 122 void noteWifiMulticastDisabledFromSource(in WorkSource ws); 123 void noteWifiRadioPowerState(int powerState, long timestampNs, int uid); 124 void noteNetworkInterfaceType(String iface, int type); 125 void noteNetworkStatsEnabled(); 126 void noteDeviceIdleMode(int mode, String activeReason, int activeUid); 127 void setBatteryState(int status, int health, int plugType, int level, int temp, int volt, 128 int chargeUAh, int chargeFullUAh); 129 long getAwakeTimeBattery(); 130 long getAwakeTimePlugged(); 131 132 void noteBleScanStarted(in WorkSource ws, boolean isUnoptimized); 133 void noteBleScanStopped(in WorkSource ws); 134 void noteResetBleScan(); 135 void noteBleScanResults(in WorkSource ws, int numNewResults); 136 137 HealthStatsParceler takeUidSnapshot(int uid); 138 HealthStatsParceler[] takeUidSnapshots(in int[] uid); 139 140 oneway void noteBluetoothControllerActivity(in BluetoothActivityEnergyInfo info); 141 oneway void noteModemControllerActivity(in ModemActivityInfo info); 142 oneway void noteWifiControllerActivity(in WifiActivityEnergyInfo info); 143} 144