Fix deadlock issue in BatteryStatsHelper.

It was assumed that BatteryStatsHelper could safely call into system services.
Because it is used when dumping information from the BatteryStatsService,
this assumption was incorrect.

Now the BatteryStats object carries around the state of the energy reporting
for Bluetooth and WiFi, so BatteryStatsHelper avoids a query into WiFiManager.

b/19729960

Change-Id: I8745cf6aafeea8e862e34fe63b20056f6ba54b40
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 1566985..c7edb1a 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -1947,6 +1947,13 @@
     public static final int NUM_CONTROLLER_ACTIVITY_TYPES = CONTROLLER_POWER_DRAIN + 1;
 
     /**
+     * Returns true if the BatteryStats object has detailed bluetooth power reports.
+     * When true, calling {@link #getBluetoothControllerActivity(int, int)} will yield the
+     * actual power data.
+     */
+    public abstract boolean hasBluetoothActivityReporting();
+
+    /**
      * For {@link #CONTROLLER_IDLE_TIME}, {@link #CONTROLLER_RX_TIME}, and
      * {@link #CONTROLLER_TX_TIME}, returns the time spent (in milliseconds) in the
      * respective state.
@@ -1956,6 +1963,13 @@
     public abstract long getBluetoothControllerActivity(int type, int which);
 
     /**
+     * Returns true if the BatteryStats object has detailed WiFi power reports.
+     * When true, calling {@link #getWifiControllerActivity(int, int)} will yield the
+     * actual power data.
+     */
+    public abstract boolean hasWifiActivityReporting();
+
+    /**
      * For {@link #CONTROLLER_IDLE_TIME}, {@link #CONTROLLER_RX_TIME}, and
      * {@link #CONTROLLER_TX_TIME}, returns the time spent (in milliseconds) in the
      * respective state.