diff options
Diffstat (limited to 'core/java/android/os')
-rw-r--r-- | core/java/android/os/BatteryStats.java | 109 | ||||
-rw-r--r-- | core/java/android/os/Hardware.java | 37 | ||||
-rwxr-xr-x | core/java/android/os/IHardwareService.aidl | 12 | ||||
-rw-r--r-- | core/java/android/os/Power.java | 28 | ||||
-rw-r--r-- | core/java/android/os/RemoteCallbackList.java | 2 |
5 files changed, 133 insertions, 55 deletions
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java index 7590bfe..76c74df 100644 --- a/core/java/android/os/BatteryStats.java +++ b/core/java/android/os/BatteryStats.java @@ -4,6 +4,8 @@ import java.io.PrintWriter; import java.util.Formatter; import java.util.Map; +import com.android.internal.os.BatteryStatsImpl.Timer; + import android.util.Log; import android.util.Printer; import android.util.SparseArray; @@ -39,6 +41,20 @@ public abstract class BatteryStats implements Parcelable { * {@hide} */ public static final int SENSOR = 3; + + /** + * A constant indicating a full wifi lock timer + * + * {@hide} + */ + public static final int FULL_WIFI_LOCK = 4; + + /** + * A constant indicating a scan wifi lock timer + * + * {@hide} + */ + public static final int SCAN_WIFI_LOCK = 5; /** * Include all of the data in the stats, including previously saved data. @@ -74,6 +90,7 @@ public abstract class BatteryStats implements Parcelable { private static final String WAKELOCK_DATA = "wakelock"; private static final String NETWORK_DATA = "network"; private static final String BATTERY_DATA = "battery"; + private static final String WIFI_LOCK_DATA = "wifilock"; private static final String MISC_DATA = "misc"; private final StringBuilder mFormatBuilder = new StringBuilder(8); @@ -162,6 +179,13 @@ public abstract class BatteryStats implements Parcelable { * {@hide} */ public abstract long getTcpBytesSent(int which); + + public abstract void noteFullWifiLockAcquiredLocked(); + public abstract void noteFullWifiLockReleasedLocked(); + public abstract void noteScanWifiLockAcquiredLocked(); + public abstract void noteScanWifiLockReleasedLocked(); + public abstract long getFullWifiLockTime(long batteryRealtime, int which); + public abstract long getScanWifiLockTime(long batteryRealtime, int which); public static abstract class Sensor { // Magic sensor number for the GPS. @@ -270,6 +294,22 @@ public abstract class BatteryStats implements Parcelable { public abstract long getPhoneOnTime(long batteryRealtime, int which); /** + * Returns the time in milliseconds that wifi has been on while the device was + * running on battery. + * + * {@hide} + */ + public abstract long getWifiOnTime(long batteryRealtime, int which); + + /** + * Returns the time in milliseconds that bluetooth has been on while the device was + * running on battery. + * + * {@hide} + */ + public abstract long getBluetoothOnTime(long batteryRealtime, int which); + + /** * Return whether we are currently running on battery. */ public abstract boolean getIsOnBattery(); @@ -292,6 +332,17 @@ public abstract class BatteryStats implements Parcelable { * @param curTime the amount of elapsed realtime in microseconds. */ public abstract long getBatteryRealtime(long curTime); + + /** + * Returns the battery percentage level at the last time the device was unplugged from power, + * or the last time it was booted while unplugged. + */ + public abstract int getUnpluggedStartLevel(); + + /** + * Returns the battery percentage level at the last time the device was plugged into power. + */ + public abstract int getPluggedStartLevel(); /** * Returns the total, last, or current battery uptime in microseconds. @@ -483,6 +534,8 @@ public abstract class BatteryStats implements Parcelable { final long totalUptime = computeUptime(rawUptime, which); final long screenOnTime = getScreenOnTime(batteryRealtime, which); final long phoneOnTime = getPhoneOnTime(batteryRealtime, which); + final long wifiOnTime = getWifiOnTime(batteryRealtime, which); + final long bluetoothOnTime = getBluetoothOnTime(batteryRealtime, which); StringBuilder sb = new StringBuilder(128); @@ -496,7 +549,12 @@ public abstract class BatteryStats implements Parcelable { // Dump misc stats dumpLine(pw, 0 /* uid */, category, MISC_DATA, - screenOnTime / 1000, phoneOnTime / 1000); + screenOnTime / 1000, phoneOnTime / 1000, wifiOnTime / 1000, bluetoothOnTime / 1000); + + if (which == STATS_UNPLUGGED) { + dumpLine(pw, 0 /* uid */, category, BATTERY_DATA, getUnpluggedStartLevel(), + getPluggedStartLevel()); + } SparseArray<? extends Uid> uidStats = getUidStats(); final int NU = uidStats.size(); @@ -506,7 +564,15 @@ public abstract class BatteryStats implements Parcelable { // Dump Network stats per uid, if any long rx = u.getTcpBytesReceived(which); long tx = u.getTcpBytesSent(which); + long fullWifiLockOnTime = u.getFullWifiLockTime(batteryRealtime, which); + long scanWifiLockOnTime = u.getScanWifiLockTime(batteryRealtime, which); + if (rx > 0 || tx > 0) dumpLine(pw, uid, category, NETWORK_DATA, rx, tx); + + if (fullWifiLockOnTime != 0 || scanWifiLockOnTime != 0) { + dumpLine(pw, uid, category, WIFI_LOCK_DATA, + fullWifiLockOnTime, scanWifiLockOnTime); + } Map<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats(); if (wakelocks.size() > 0) { @@ -624,13 +690,35 @@ public abstract class BatteryStats implements Parcelable { + formatTimeMs(totalRealtime / 1000) + "realtime"); - long screenOnTime = getScreenOnTime(batteryRealtime, which); - long phoneOnTime = getPhoneOnTime(batteryRealtime, which); + final long screenOnTime = getScreenOnTime(batteryRealtime, which); + final long phoneOnTime = getPhoneOnTime(batteryRealtime, which); + final long wifiOnTime = getWifiOnTime(batteryRealtime, which); + final long bluetoothOnTime = getBluetoothOnTime(batteryRealtime, which); pw.println(prefix + " Time with screen on: " + formatTimeMs(screenOnTime / 1000) + "(" + formatRatioLocked(screenOnTime, whichBatteryRealtime) + "), time with phone on: " + formatTimeMs(phoneOnTime / 1000) - + "(" + formatRatioLocked(phoneOnTime, whichBatteryRealtime) + ")"); + + "(" + formatRatioLocked(phoneOnTime, whichBatteryRealtime) + + "), time with wifi on: " + formatTimeMs(wifiOnTime / 1000) + + "(" + formatRatioLocked(wifiOnTime, whichBatteryRealtime) + + "), time with bluetooth on: " + formatTimeMs(bluetoothOnTime / 1000) + + "(" + formatRatioLocked(bluetoothOnTime, whichBatteryRealtime)+ ")"); + + pw.println(" "); + + if (which == STATS_UNPLUGGED) { + if (getIsOnBattery()) { + pw.println(prefix + " Device is currently unplugged"); + pw.println(prefix + " Discharge cycle start level: " + + getUnpluggedStartLevel()); + } else { + pw.println(prefix + " Device is currently plugged into power"); + pw.println(prefix + " Last discharge cycle start level: " + + getUnpluggedStartLevel()); + pw.println(prefix + " Last discharge cycle end level: " + + getPluggedStartLevel()); + } + } pw.println(" "); @@ -644,10 +732,23 @@ public abstract class BatteryStats implements Parcelable { long tcpReceived = u.getTcpBytesReceived(which); long tcpSent = u.getTcpBytesSent(which); + long fullWifiLockOnTime = u.getFullWifiLockTime(batteryRealtime, which); + long scanWifiLockOnTime = u.getScanWifiLockTime(batteryRealtime, which); + if (tcpReceived != 0 || tcpSent != 0) { pw.println(prefix + " Network: " + tcpReceived + " bytes received, " + tcpSent + " bytes sent"); } + if (fullWifiLockOnTime != 0 || scanWifiLockOnTime != 0) { + pw.println(prefix + " Full Wifi Lock Time: " + + formatTime(fullWifiLockOnTime / 1000) + + "(" + formatRatioLocked(fullWifiLockOnTime, + whichBatteryRealtime)+ ")"); + pw.println(prefix + " Scan Wifi Lock Time: " + + formatTime(scanWifiLockOnTime / 1000) + + "(" + formatRatioLocked(scanWifiLockOnTime, + whichBatteryRealtime)+ ")"); + } Map<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats(); if (wakelocks.size() > 0) { diff --git a/core/java/android/os/Hardware.java b/core/java/android/os/Hardware.java index 3b6c9d7..efc5617 100644 --- a/core/java/android/os/Hardware.java +++ b/core/java/android/os/Hardware.java @@ -21,22 +21,29 @@ package android.os; */ public class Hardware { - /** - * Control the LED. - */ - public static native int setLedState(int colorARGB, int onMS, int offMS); - - /** - * Control the Flashlight - */ + + + /* ******************************************************************************** + * + * + * + * + * + * + * + * + * Don't add anything else to this class. Add it to HardwareService instead. + * + * + * + * + * + * + * + * ********************************************************************************/ + + public static native boolean getFlashlightEnabled(); public static native void setFlashlightEnabled(boolean on); public static native void enableCameraFlash(int milliseconds); - - /** - * Control the backlights - */ - public static native void setScreenBacklight(int brightness); - public static native void setKeyboardBacklight(boolean on); - public static native void setButtonBacklight(boolean on); } diff --git a/core/java/android/os/IHardwareService.aidl b/core/java/android/os/IHardwareService.aidl index 4f6029f..fb121bb 100755 --- a/core/java/android/os/IHardwareService.aidl +++ b/core/java/android/os/IHardwareService.aidl @@ -29,12 +29,10 @@ interface IHardwareService void setFlashlightEnabled(boolean on); void enableCameraFlash(int milliseconds); - // backlight support - void setScreenBacklight(int brightness); - void setKeyboardBacklight(boolean on); - void setButtonBacklight(boolean on); - - // LED support - void setLedState(int colorARGB, int onMS, int offMS); + // sets the brightness of the backlights (screen, keyboard, button) 0-255 + void setBacklights(int brightness); + + // for the phone + void setAttentionLight(boolean on); } diff --git a/core/java/android/os/Power.java b/core/java/android/os/Power.java index b53e227..47497e5 100644 --- a/core/java/android/os/Power.java +++ b/core/java/android/os/Power.java @@ -45,26 +45,6 @@ public class Power public static native void releaseWakeLock(String id); /** - * Flag to turn on and off the keyboard light. - */ - public static final int KEYBOARD_LIGHT = 0x00000001; - - /** - * Flag to turn on and off the screen backlight. - */ - public static final int SCREEN_LIGHT = 0x00000002; - - /** - * Flag to turn on and off the button backlight. - */ - public static final int BUTTON_LIGHT = 0x00000004; - - /** - * Flags to turn on and off all the backlights. - */ - public static final int ALL_LIGHTS = (KEYBOARD_LIGHT|SCREEN_LIGHT|BUTTON_LIGHT); - - /** * Brightness value for fully off */ public static final int BRIGHTNESS_OFF = 0; @@ -91,14 +71,6 @@ public class Power public static final int LOW_BATTERY_THRESHOLD = 10; /** - * Set the brightness for one or more lights - * - * @param mask flags indicating which lights to change brightness - * @param brightness new brightness value (0 = off, 255 = fully bright) - */ - public static native int setLightBrightness(int mask, int brightness); - - /** * Turn the screen on or off * * @param on Whether you want the screen on or off diff --git a/core/java/android/os/RemoteCallbackList.java b/core/java/android/os/RemoteCallbackList.java index 04e7ef0..63f6dff 100644 --- a/core/java/android/os/RemoteCallbackList.java +++ b/core/java/android/os/RemoteCallbackList.java @@ -211,7 +211,7 @@ public class RemoteCallbackList<E extends IInterface> { for (Callback cb : mCallbacks.values()) { active[i++] = cb.mCallback; } - return N; + return i; } } |