Disable screen-off RPM timing in BatteryStats

RPM = resource power manager.
Fetching the rpm stats (specifically, the subsystem low power stats) is
slow... too slow to reasonably do each time the screen state changes.
Therefore, it is disabled until fetching this information can be done
more quickly. Consequently, the screen-off RPM values will be incorrect
until it is re-enabled; they are therefore not printed.

Bug: 65164435
Bug: 62549421
Test: manual
Change-Id: I54d54f244c69ee372f22ecd99f32570db4aeb222
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 49afeeb..66b6b47 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -53,6 +53,8 @@
     private static final String TAG = "BatteryStats";
 
     private static final boolean LOCAL_LOGV = false;
+    /** Fetching RPM stats is too slow to do each time screen changes, so disable it. */
+    protected static final boolean SCREEN_OFF_RPM_STATS_ENABLED = false;
 
     /** @hide */
     public static final String SERVICE_NAME = "batterystats";
@@ -214,7 +216,7 @@
      * New in version 25:
      *   - Package wakeup alarms are now on screen-off timebase
      * New in version 26:
-     *   - Resource power manager (rpm) states
+     *   - Resource power manager (rpm) states [but screenOffRpm is disabled from working properly]
      */
     static final String CHECKIN_VERSION = "26";
 
@@ -3338,8 +3340,14 @@
                         ? (screenOffTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000 : 0;
                 int screenOffCount = screenOffTimer != null
                         ? screenOffTimer.getCountLocked(which) : 0;
-                dumpLine(pw, 0 /* uid */, category, RESOURCE_POWER_MANAGER_DATA,
-                        "\"" + ent.getKey() + "\"", timeMs, count, screenOffTimeMs, screenOffCount);
+                if (SCREEN_OFF_RPM_STATS_ENABLED) {
+                    dumpLine(pw, 0 /* uid */, category, RESOURCE_POWER_MANAGER_DATA,
+                            "\"" + ent.getKey() + "\"", timeMs, count, screenOffTimeMs,
+                            screenOffCount);
+                } else {
+                    dumpLine(pw, 0 /* uid */, category, RESOURCE_POWER_MANAGER_DATA,
+                            "\"" + ent.getKey() + "\"", timeMs, count);
+                }
             }
         }
 
@@ -4629,18 +4637,20 @@
             }
             pw.println();
         }
-        final Map<String, ? extends Timer> screenOffRpmStats = getScreenOffRpmStats();
-        if (screenOffRpmStats.size() > 0) {
-            pw.print(prefix);
-            pw.println("  Resource Power Manager Stats for when screen was off");
+        if (SCREEN_OFF_RPM_STATS_ENABLED) {
+            final Map<String, ? extends Timer> screenOffRpmStats = getScreenOffRpmStats();
             if (screenOffRpmStats.size() > 0) {
-                for (Map.Entry<String, ? extends Timer> ent : screenOffRpmStats.entrySet()) {
-                    final String timerName = ent.getKey();
-                    final Timer timer = ent.getValue();
-                    printTimer(pw, sb, timer, rawRealtime, which, prefix, timerName);
+                pw.print(prefix);
+                pw.println("  Resource Power Manager Stats for when screen was off");
+                if (screenOffRpmStats.size() > 0) {
+                    for (Map.Entry<String, ? extends Timer> ent : screenOffRpmStats.entrySet()) {
+                        final String timerName = ent.getKey();
+                        final Timer timer = ent.getValue();
+                        printTimer(pw, sb, timer, rawRealtime, which, prefix, timerName);
+                    }
                 }
+                pw.println();
             }
-            pw.println();
         }
 
         final long[] cpuFreqs = getCpuFreqs();