Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | package android.os; |
| 18 | |
| 19 | import java.io.PrintWriter; |
Dianne Hackborn | e4a5951 | 2010-12-07 11:08:07 -0800 | [diff] [blame] | 20 | import java.util.ArrayList; |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 21 | import java.util.Collections; |
| 22 | import java.util.Comparator; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | import java.util.Formatter; |
Dianne Hackborn | e4a5951 | 2010-12-07 11:08:07 -0800 | [diff] [blame] | 24 | import java.util.List; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import java.util.Map; |
| 26 | |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 27 | import android.content.Context; |
Dianne Hackborn | e4a5951 | 2010-12-07 11:08:07 -0800 | [diff] [blame] | 28 | import android.content.pm.ApplicationInfo; |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 29 | import android.telephony.SignalStrength; |
Dianne Hackborn | 5f4a5f9 | 2014-01-24 16:59:34 -0800 | [diff] [blame] | 30 | import android.text.format.DateFormat; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.util.Printer; |
| 32 | import android.util.SparseArray; |
Dianne Hackborn | 1ebccf5 | 2010-08-15 13:04:34 -0700 | [diff] [blame] | 33 | import android.util.TimeUtils; |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 34 | import com.android.internal.os.BatterySipper; |
| 35 | import com.android.internal.os.BatteryStatsHelper; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * A class providing access to battery usage statistics, including information on |
| 39 | * wakelocks, processes, packages, and services. All times are represented in microseconds |
| 40 | * except where indicated otherwise. |
| 41 | * @hide |
| 42 | */ |
| 43 | public abstract class BatteryStats implements Parcelable { |
| 44 | |
| 45 | private static final boolean LOCAL_LOGV = false; |
Dianne Hackborn | 91268cf | 2013-06-13 19:06:50 -0700 | [diff] [blame] | 46 | |
| 47 | /** @hide */ |
| 48 | public static final String SERVICE_NAME = "batterystats"; |
| 49 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | /** |
| 51 | * A constant indicating a partial wake lock timer. |
| 52 | */ |
| 53 | public static final int WAKE_TYPE_PARTIAL = 0; |
| 54 | |
| 55 | /** |
| 56 | * A constant indicating a full wake lock timer. |
| 57 | */ |
| 58 | public static final int WAKE_TYPE_FULL = 1; |
| 59 | |
| 60 | /** |
| 61 | * A constant indicating a window wake lock timer. |
| 62 | */ |
| 63 | public static final int WAKE_TYPE_WINDOW = 2; |
| 64 | |
| 65 | /** |
| 66 | * A constant indicating a sensor timer. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | */ |
| 68 | public static final int SENSOR = 3; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 71 | * A constant indicating a a wifi running timer |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 72 | */ |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 73 | public static final int WIFI_RUNNING = 4; |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 76 | * A constant indicating a full wifi lock timer |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 77 | */ |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 78 | public static final int FULL_WIFI_LOCK = 5; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 79 | |
| 80 | /** |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 81 | * A constant indicating a wifi scan |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 82 | */ |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 83 | public static final int WIFI_SCAN = 6; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | |
Robert Greenwalt | 5347bd4 | 2009-05-13 15:10:16 -0700 | [diff] [blame] | 85 | /** |
| 86 | * A constant indicating a wifi multicast timer |
Robert Greenwalt | 5347bd4 | 2009-05-13 15:10:16 -0700 | [diff] [blame] | 87 | */ |
| 88 | public static final int WIFI_MULTICAST_ENABLED = 7; |
| 89 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | /** |
Amith Yamasani | 244fa5c | 2009-05-22 14:36:07 -0700 | [diff] [blame] | 91 | * A constant indicating an audio turn on timer |
Amith Yamasani | 244fa5c | 2009-05-22 14:36:07 -0700 | [diff] [blame] | 92 | */ |
| 93 | public static final int AUDIO_TURNED_ON = 7; |
| 94 | |
| 95 | /** |
| 96 | * A constant indicating a video turn on timer |
Amith Yamasani | 244fa5c | 2009-05-22 14:36:07 -0700 | [diff] [blame] | 97 | */ |
| 98 | public static final int VIDEO_TURNED_ON = 8; |
| 99 | |
| 100 | /** |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 101 | * A constant indicating a vibrator on timer |
| 102 | */ |
| 103 | public static final int VIBRATOR_ON = 9; |
| 104 | |
| 105 | /** |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 106 | * A constant indicating a foreground activity timer |
| 107 | */ |
| 108 | public static final int FOREGROUND_ACTIVITY = 10; |
| 109 | |
| 110 | /** |
Robert Greenwalt | a029ea1 | 2013-09-25 16:38:12 -0700 | [diff] [blame] | 111 | * A constant indicating a wifi batched scan is active |
| 112 | */ |
| 113 | public static final int WIFI_BATCHED_SCAN = 11; |
| 114 | |
| 115 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 116 | * Include all of the data in the stats, including previously saved data. |
| 117 | */ |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 118 | public static final int STATS_SINCE_CHARGED = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | |
| 120 | /** |
| 121 | * Include only the last run in the stats. |
| 122 | */ |
| 123 | public static final int STATS_LAST = 1; |
| 124 | |
| 125 | /** |
| 126 | * Include only the current run in the stats. |
| 127 | */ |
| 128 | public static final int STATS_CURRENT = 2; |
| 129 | |
| 130 | /** |
| 131 | * Include only the run since the last time the device was unplugged in the stats. |
| 132 | */ |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 133 | public static final int STATS_SINCE_UNPLUGGED = 3; |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 134 | |
| 135 | // NOTE: Update this list if you add/change any stats above. |
| 136 | // These characters are supposed to represent "total", "last", "current", |
Dianne Hackborn | 3bee5af8 | 2010-07-23 00:22:04 -0700 | [diff] [blame] | 137 | // and "unplugged". They were shortened for efficiency sake. |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 138 | private static final String[] STAT_NAMES = { "t", "l", "c", "u" }; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | |
| 140 | /** |
| 141 | * Bump the version on this if the checkin format changes. |
| 142 | */ |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 143 | private static final int BATTERY_STATS_CHECKIN_VERSION = 7; |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 144 | |
| 145 | private static final long BYTES_PER_KB = 1024; |
| 146 | private static final long BYTES_PER_MB = 1048576; // 1024^2 |
| 147 | private static final long BYTES_PER_GB = 1073741824; //1024^3 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 148 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 149 | |
Dianne Hackborn | e4a5951 | 2010-12-07 11:08:07 -0800 | [diff] [blame] | 150 | private static final String UID_DATA = "uid"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 151 | private static final String APK_DATA = "apk"; |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 152 | private static final String PROCESS_DATA = "pr"; |
| 153 | private static final String SENSOR_DATA = "sr"; |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 154 | private static final String VIBRATOR_DATA = "vib"; |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 155 | private static final String FOREGROUND_DATA = "fg"; |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 156 | private static final String WAKELOCK_DATA = "wl"; |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 157 | private static final String KERNEL_WAKELOCK_DATA = "kwl"; |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 158 | private static final String NETWORK_DATA = "nt"; |
| 159 | private static final String USER_ACTIVITY_DATA = "ua"; |
| 160 | private static final String BATTERY_DATA = "bt"; |
Dianne Hackborn | c1b40e3 | 2011-01-05 18:27:40 -0800 | [diff] [blame] | 161 | private static final String BATTERY_DISCHARGE_DATA = "dc"; |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 162 | private static final String BATTERY_LEVEL_DATA = "lv"; |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 163 | private static final String WIFI_DATA = "wfl"; |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 164 | private static final String MISC_DATA = "m"; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 165 | private static final String GLOBAL_NETWORK_DATA = "gn"; |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 166 | private static final String HISTORY_STRING_POOL = "hsp"; |
Dianne Hackborn | 8a0de58 | 2013-08-07 15:22:07 -0700 | [diff] [blame] | 167 | private static final String HISTORY_DATA = "h"; |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 168 | private static final String SCREEN_BRIGHTNESS_DATA = "br"; |
| 169 | private static final String SIGNAL_STRENGTH_TIME_DATA = "sgt"; |
Amith Yamasani | f37447b | 2009-10-08 18:28:01 -0700 | [diff] [blame] | 170 | private static final String SIGNAL_SCANNING_TIME_DATA = "sst"; |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 171 | private static final String SIGNAL_STRENGTH_COUNT_DATA = "sgc"; |
| 172 | private static final String DATA_CONNECTION_TIME_DATA = "dct"; |
| 173 | private static final String DATA_CONNECTION_COUNT_DATA = "dcc"; |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 174 | private static final String POWER_USE_SUMMARY_DATA = "pws"; |
| 175 | private static final String POWER_USE_ITEM_DATA = "pwi"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 177 | private final StringBuilder mFormatBuilder = new StringBuilder(32); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 178 | private final Formatter mFormatter = new Formatter(mFormatBuilder); |
| 179 | |
| 180 | /** |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 181 | * State for keeping track of counting information. |
| 182 | */ |
| 183 | public static abstract class Counter { |
| 184 | |
| 185 | /** |
| 186 | * Returns the count associated with this Counter for the |
| 187 | * selected type of statistics. |
| 188 | * |
| 189 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT |
| 190 | */ |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 191 | public abstract int getCountLocked(int which); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 192 | |
| 193 | /** |
| 194 | * Temporary for debugging. |
| 195 | */ |
| 196 | public abstract void logState(Printer pw, String prefix); |
| 197 | } |
| 198 | |
| 199 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 200 | * State for keeping track of timing information. |
| 201 | */ |
| 202 | public static abstract class Timer { |
| 203 | |
| 204 | /** |
| 205 | * Returns the count associated with this Timer for the |
| 206 | * selected type of statistics. |
| 207 | * |
| 208 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT |
| 209 | */ |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 210 | public abstract int getCountLocked(int which); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * Returns the total time in microseconds associated with this Timer for the |
| 214 | * selected type of statistics. |
| 215 | * |
| 216 | * @param batteryRealtime system realtime on battery in microseconds |
| 217 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT |
| 218 | * @return a time in microseconds |
| 219 | */ |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 220 | public abstract long getTotalTimeLocked(long batteryRealtime, int which); |
Amith Yamasani | 244fa5c | 2009-05-22 14:36:07 -0700 | [diff] [blame] | 221 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 222 | /** |
| 223 | * Temporary for debugging. |
| 224 | */ |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 225 | public abstract void logState(Printer pw, String prefix); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | /** |
| 229 | * The statistics associated with a particular uid. |
| 230 | */ |
| 231 | public static abstract class Uid { |
| 232 | |
| 233 | /** |
| 234 | * Returns a mapping containing wakelock statistics. |
| 235 | * |
| 236 | * @return a Map from Strings to Uid.Wakelock objects. |
| 237 | */ |
| 238 | public abstract Map<String, ? extends Wakelock> getWakelockStats(); |
| 239 | |
| 240 | /** |
| 241 | * The statistics associated with a particular wake lock. |
| 242 | */ |
| 243 | public static abstract class Wakelock { |
| 244 | public abstract Timer getWakeTime(int type); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * Returns a mapping containing sensor statistics. |
| 249 | * |
| 250 | * @return a Map from Integer sensor ids to Uid.Sensor objects. |
| 251 | */ |
| 252 | public abstract Map<Integer, ? extends Sensor> getSensorStats(); |
| 253 | |
| 254 | /** |
Dianne Hackborn | b5e3165 | 2010-09-07 12:13:55 -0700 | [diff] [blame] | 255 | * Returns a mapping containing active process data. |
| 256 | */ |
| 257 | public abstract SparseArray<? extends Pid> getPidStats(); |
| 258 | |
| 259 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 260 | * Returns a mapping containing process statistics. |
| 261 | * |
| 262 | * @return a Map from Strings to Uid.Proc objects. |
| 263 | */ |
| 264 | public abstract Map<String, ? extends Proc> getProcessStats(); |
| 265 | |
| 266 | /** |
| 267 | * Returns a mapping containing package statistics. |
| 268 | * |
| 269 | * @return a Map from Strings to Uid.Pkg objects. |
| 270 | */ |
| 271 | public abstract Map<String, ? extends Pkg> getPackageStats(); |
| 272 | |
| 273 | /** |
| 274 | * {@hide} |
| 275 | */ |
| 276 | public abstract int getUid(); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 277 | |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 278 | public abstract void noteWifiRunningLocked(); |
| 279 | public abstract void noteWifiStoppedLocked(); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 280 | public abstract void noteFullWifiLockAcquiredLocked(); |
| 281 | public abstract void noteFullWifiLockReleasedLocked(); |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 282 | public abstract void noteWifiScanStartedLocked(); |
| 283 | public abstract void noteWifiScanStoppedLocked(); |
Robert Greenwalt | a029ea1 | 2013-09-25 16:38:12 -0700 | [diff] [blame] | 284 | public abstract void noteWifiBatchedScanStartedLocked(int csph); |
| 285 | public abstract void noteWifiBatchedScanStoppedLocked(); |
Robert Greenwalt | 5347bd4 | 2009-05-13 15:10:16 -0700 | [diff] [blame] | 286 | public abstract void noteWifiMulticastEnabledLocked(); |
| 287 | public abstract void noteWifiMulticastDisabledLocked(); |
Amith Yamasani | 244fa5c | 2009-05-22 14:36:07 -0700 | [diff] [blame] | 288 | public abstract void noteAudioTurnedOnLocked(); |
| 289 | public abstract void noteAudioTurnedOffLocked(); |
| 290 | public abstract void noteVideoTurnedOnLocked(); |
| 291 | public abstract void noteVideoTurnedOffLocked(); |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 292 | public abstract void noteActivityResumedLocked(); |
| 293 | public abstract void noteActivityPausedLocked(); |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 294 | public abstract long getWifiRunningTime(long batteryRealtime, int which); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 295 | public abstract long getFullWifiLockTime(long batteryRealtime, int which); |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 296 | public abstract long getWifiScanTime(long batteryRealtime, int which); |
Robert Greenwalt | a029ea1 | 2013-09-25 16:38:12 -0700 | [diff] [blame] | 297 | public abstract long getWifiBatchedScanTime(int csphBin, long batteryRealtime, int which); |
Robert Greenwalt | 5347bd4 | 2009-05-13 15:10:16 -0700 | [diff] [blame] | 298 | public abstract long getWifiMulticastTime(long batteryRealtime, |
| 299 | int which); |
Amith Yamasani | 244fa5c | 2009-05-22 14:36:07 -0700 | [diff] [blame] | 300 | public abstract long getAudioTurnedOnTime(long batteryRealtime, int which); |
| 301 | public abstract long getVideoTurnedOnTime(long batteryRealtime, int which); |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 302 | public abstract Timer getForegroundActivityTimer(); |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 303 | public abstract Timer getVibratorOnTimer(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 304 | |
Robert Greenwalt | a029ea1 | 2013-09-25 16:38:12 -0700 | [diff] [blame] | 305 | public static final int NUM_WIFI_BATCHED_SCAN_BINS = 5; |
| 306 | |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 307 | /** |
Jeff Brown | df693de | 2012-07-27 12:03:38 -0700 | [diff] [blame] | 308 | * Note that these must match the constants in android.os.PowerManager. |
| 309 | * Also, if the user activity types change, the BatteryStatsImpl.VERSION must |
| 310 | * also be bumped. |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 311 | */ |
| 312 | static final String[] USER_ACTIVITY_TYPES = { |
Jeff Brown | df693de | 2012-07-27 12:03:38 -0700 | [diff] [blame] | 313 | "other", "button", "touch" |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 314 | }; |
| 315 | |
Jeff Brown | df693de | 2012-07-27 12:03:38 -0700 | [diff] [blame] | 316 | public static final int NUM_USER_ACTIVITY_TYPES = 3; |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 317 | |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 318 | public abstract void noteUserActivityLocked(int type); |
| 319 | public abstract boolean hasUserActivity(); |
| 320 | public abstract int getUserActivityCount(int type, int which); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 321 | |
| 322 | public abstract boolean hasNetworkActivity(); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 323 | public abstract long getNetworkActivityBytes(int type, int which); |
| 324 | public abstract long getNetworkActivityPackets(int type, int which); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 325 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 326 | public static abstract class Sensor { |
Mathias Agopian | 7f84c06 | 2013-02-04 19:22:47 -0800 | [diff] [blame] | 327 | /* |
| 328 | * FIXME: it's not correct to use this magic value because it |
| 329 | * could clash with a sensor handle (which are defined by |
| 330 | * the sensor HAL, and therefore out of our control |
| 331 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 332 | // Magic sensor number for the GPS. |
| 333 | public static final int GPS = -10000; |
| 334 | |
| 335 | public abstract int getHandle(); |
| 336 | |
| 337 | public abstract Timer getSensorTime(); |
| 338 | } |
| 339 | |
Dianne Hackborn | b5e3165 | 2010-09-07 12:13:55 -0700 | [diff] [blame] | 340 | public class Pid { |
| 341 | public long mWakeSum; |
| 342 | public long mWakeStart; |
| 343 | } |
| 344 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 345 | /** |
| 346 | * The statistics associated with a particular process. |
| 347 | */ |
| 348 | public static abstract class Proc { |
| 349 | |
Dianne Hackborn | 287952c | 2010-09-22 22:34:31 -0700 | [diff] [blame] | 350 | public static class ExcessivePower { |
| 351 | public static final int TYPE_WAKE = 1; |
| 352 | public static final int TYPE_CPU = 2; |
| 353 | |
| 354 | public int type; |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 355 | public long overTime; |
| 356 | public long usedTime; |
| 357 | } |
| 358 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 359 | /** |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 360 | * Returns true if this process is still active in the battery stats. |
| 361 | */ |
| 362 | public abstract boolean isActive(); |
| 363 | |
| 364 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 365 | * Returns the total time (in 1/100 sec) spent executing in user code. |
| 366 | * |
| 367 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 368 | */ |
| 369 | public abstract long getUserTime(int which); |
| 370 | |
| 371 | /** |
| 372 | * Returns the total time (in 1/100 sec) spent executing in system code. |
| 373 | * |
| 374 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 375 | */ |
| 376 | public abstract long getSystemTime(int which); |
| 377 | |
| 378 | /** |
| 379 | * Returns the number of times the process has been started. |
| 380 | * |
| 381 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 382 | */ |
| 383 | public abstract int getStarts(int which); |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 384 | |
| 385 | /** |
| 386 | * Returns the cpu time spent in microseconds while the process was in the foreground. |
| 387 | * @param which one of STATS_TOTAL, STATS_LAST, STATS_CURRENT or STATS_UNPLUGGED |
| 388 | * @return foreground cpu time in microseconds |
| 389 | */ |
| 390 | public abstract long getForegroundTime(int which); |
Amith Yamasani | e43530a | 2009-08-21 13:11:37 -0700 | [diff] [blame] | 391 | |
| 392 | /** |
| 393 | * Returns the approximate cpu time spent in microseconds, at a certain CPU speed. |
| 394 | * @param speedStep the index of the CPU speed. This is not the actual speed of the |
| 395 | * CPU. |
| 396 | * @param which one of STATS_TOTAL, STATS_LAST, STATS_CURRENT or STATS_UNPLUGGED |
| 397 | * @see BatteryStats#getCpuSpeedSteps() |
| 398 | */ |
| 399 | public abstract long getTimeAtCpuSpeedStep(int speedStep, int which); |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 400 | |
Dianne Hackborn | 287952c | 2010-09-22 22:34:31 -0700 | [diff] [blame] | 401 | public abstract int countExcessivePowers(); |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 402 | |
Dianne Hackborn | 287952c | 2010-09-22 22:34:31 -0700 | [diff] [blame] | 403 | public abstract ExcessivePower getExcessivePower(int i); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | /** |
| 407 | * The statistics associated with a particular package. |
| 408 | */ |
| 409 | public static abstract class Pkg { |
| 410 | |
| 411 | /** |
| 412 | * Returns the number of times this package has done something that could wake up the |
| 413 | * device from sleep. |
| 414 | * |
| 415 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 416 | */ |
| 417 | public abstract int getWakeups(int which); |
| 418 | |
| 419 | /** |
| 420 | * Returns a mapping containing service statistics. |
| 421 | */ |
| 422 | public abstract Map<String, ? extends Serv> getServiceStats(); |
| 423 | |
| 424 | /** |
| 425 | * The statistics associated with a particular service. |
| 426 | */ |
| 427 | public abstract class Serv { |
| 428 | |
| 429 | /** |
| 430 | * Returns the amount of time spent started. |
| 431 | * |
| 432 | * @param batteryUptime elapsed uptime on battery in microseconds. |
| 433 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 434 | * @return |
| 435 | */ |
| 436 | public abstract long getStartTime(long batteryUptime, int which); |
| 437 | |
| 438 | /** |
| 439 | * Returns the total number of times startService() has been called. |
| 440 | * |
| 441 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 442 | */ |
| 443 | public abstract int getStarts(int which); |
| 444 | |
| 445 | /** |
| 446 | * Returns the total number times the service has been launched. |
| 447 | * |
| 448 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 449 | */ |
| 450 | public abstract int getLaunches(int which); |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 455 | public final static class HistoryTag { |
| 456 | public String string; |
| 457 | public int uid; |
| 458 | |
| 459 | public int poolIdx; |
| 460 | |
| 461 | public void setTo(HistoryTag o) { |
| 462 | string = o.string; |
| 463 | uid = o.uid; |
| 464 | poolIdx = o.poolIdx; |
| 465 | } |
| 466 | |
| 467 | public void setTo(String _string, int _uid) { |
| 468 | string = _string; |
| 469 | uid = _uid; |
| 470 | poolIdx = -1; |
| 471 | } |
| 472 | |
| 473 | public void writeToParcel(Parcel dest, int flags) { |
| 474 | dest.writeString(string); |
| 475 | dest.writeInt(uid); |
| 476 | } |
| 477 | |
| 478 | public void readFromParcel(Parcel src) { |
| 479 | string = src.readString(); |
| 480 | uid = src.readInt(); |
| 481 | poolIdx = -1; |
| 482 | } |
| 483 | |
| 484 | @Override |
| 485 | public boolean equals(Object o) { |
| 486 | if (this == o) return true; |
| 487 | if (o == null || getClass() != o.getClass()) return false; |
| 488 | |
| 489 | HistoryTag that = (HistoryTag) o; |
| 490 | |
| 491 | if (uid != that.uid) return false; |
| 492 | if (!string.equals(that.string)) return false; |
| 493 | |
| 494 | return true; |
| 495 | } |
| 496 | |
| 497 | @Override |
| 498 | public int hashCode() { |
| 499 | int result = string.hashCode(); |
| 500 | result = 31 * result + uid; |
| 501 | return result; |
| 502 | } |
| 503 | } |
| 504 | |
Dianne Hackborn | ce2ef76 | 2010-09-20 11:39:14 -0700 | [diff] [blame] | 505 | public final static class HistoryItem implements Parcelable { |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 506 | public HistoryItem next; |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 507 | |
| 508 | public long time; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 509 | |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 510 | public static final byte CMD_UPDATE = 0; // These can be written as deltas |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 511 | public static final byte CMD_NULL = -1; |
| 512 | public static final byte CMD_START = 4; |
| 513 | public static final byte CMD_OVERFLOW = 5; |
| 514 | |
Dianne Hackborn | 1fadab5 | 2011-04-14 17:57:33 -0700 | [diff] [blame] | 515 | public byte cmd = CMD_NULL; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 516 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 517 | /** |
| 518 | * Return whether the command code is a delta data update. |
| 519 | */ |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 520 | public boolean isDeltaData() { |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 521 | return cmd == CMD_UPDATE; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 522 | } |
| 523 | |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 524 | public byte batteryLevel; |
| 525 | public byte batteryStatus; |
| 526 | public byte batteryHealth; |
| 527 | public byte batteryPlugType; |
| 528 | |
Sungmin Choi | c7e9e8b | 2013-01-16 12:57:36 +0900 | [diff] [blame] | 529 | public short batteryTemperature; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 530 | public char batteryVoltage; |
| 531 | |
Dianne Hackborn | 3bee5af8 | 2010-07-23 00:22:04 -0700 | [diff] [blame] | 532 | // Constants from SCREEN_BRIGHTNESS_* |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 533 | public static final int STATE_BRIGHTNESS_SHIFT = 0; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 534 | public static final int STATE_BRIGHTNESS_MASK = 0x7; |
Dianne Hackborn | 3bee5af8 | 2010-07-23 00:22:04 -0700 | [diff] [blame] | 535 | // Constants from SIGNAL_STRENGTH_* |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 536 | public static final int STATE_SIGNAL_STRENGTH_SHIFT = 3; |
| 537 | public static final int STATE_SIGNAL_STRENGTH_MASK = 0x7 << STATE_SIGNAL_STRENGTH_SHIFT; |
Dianne Hackborn | 3bee5af8 | 2010-07-23 00:22:04 -0700 | [diff] [blame] | 538 | // Constants from ServiceState.STATE_* |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 539 | public static final int STATE_PHONE_STATE_SHIFT = 6; |
| 540 | public static final int STATE_PHONE_STATE_MASK = 0x7 << STATE_PHONE_STATE_SHIFT; |
Dianne Hackborn | 3bee5af8 | 2010-07-23 00:22:04 -0700 | [diff] [blame] | 541 | // Constants from DATA_CONNECTION_* |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 542 | public static final int STATE_DATA_CONNECTION_SHIFT = 9; |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 543 | public static final int STATE_DATA_CONNECTION_MASK = 0x1f << STATE_DATA_CONNECTION_SHIFT; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 544 | |
Dianne Hackborn | 1fadab5 | 2011-04-14 17:57:33 -0700 | [diff] [blame] | 545 | // These states always appear directly in the first int token |
| 546 | // of a delta change; they should be ones that change relatively |
| 547 | // frequently. |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 548 | public static final int STATE_WAKE_LOCK_FLAG = 1<<31; |
| 549 | public static final int STATE_SENSOR_ON_FLAG = 1<<30; |
| 550 | public static final int STATE_GPS_ON_FLAG = 1<<29; |
| 551 | public static final int STATE_WIFI_FULL_LOCK_FLAG = 1<<28; |
| 552 | public static final int STATE_WIFI_SCAN_FLAG = 1<<29; |
| 553 | public static final int STATE_WIFI_MULTICAST_ON_FLAG = 1<<26; |
Dianne Hackborn | 1fadab5 | 2011-04-14 17:57:33 -0700 | [diff] [blame] | 554 | // These are on the lower bits used for the command; if they change |
| 555 | // we need to write another int of data. |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 556 | public static final int STATE_WIFI_RUNNING_FLAG = 1<<24; |
| 557 | public static final int STATE_PHONE_SCANNING_FLAG = 1<<23; |
Dianne Hackborn | 1fadab5 | 2011-04-14 17:57:33 -0700 | [diff] [blame] | 558 | public static final int STATE_AUDIO_ON_FLAG = 1<<22; |
| 559 | public static final int STATE_VIDEO_ON_FLAG = 1<<21; |
| 560 | public static final int STATE_SCREEN_ON_FLAG = 1<<20; |
| 561 | public static final int STATE_BATTERY_PLUGGED_FLAG = 1<<19; |
| 562 | public static final int STATE_PHONE_IN_CALL_FLAG = 1<<18; |
| 563 | public static final int STATE_WIFI_ON_FLAG = 1<<17; |
| 564 | public static final int STATE_BLUETOOTH_ON_FLAG = 1<<16; |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 565 | |
Dianne Hackborn | f47d8f2 | 2010-10-08 10:46:55 -0700 | [diff] [blame] | 566 | public static final int MOST_INTERESTING_STATES = |
| 567 | STATE_BATTERY_PLUGGED_FLAG | STATE_SCREEN_ON_FLAG |
| 568 | | STATE_GPS_ON_FLAG | STATE_PHONE_IN_CALL_FLAG; |
| 569 | |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 570 | public int states; |
| 571 | |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 572 | // The wake lock that was acquired at this point. |
| 573 | public HistoryTag wakelockTag; |
| 574 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 575 | public static final int EVENT_NONE = 0; |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 576 | public static final int EVENT_PROC_STARTED = 1; |
| 577 | public static final int EVENT_PROC_FINISHED = 2; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 578 | |
| 579 | // For CMD_EVENT. |
| 580 | public int eventCode; |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 581 | public HistoryTag eventTag; |
| 582 | |
| 583 | // Meta-data when reading. |
| 584 | public int numReadInts; |
| 585 | |
| 586 | // Pre-allocated objects. |
| 587 | public final HistoryTag localWakelockTag = new HistoryTag(); |
| 588 | public final HistoryTag localEventTag = new HistoryTag(); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 589 | |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 590 | public HistoryItem() { |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 591 | } |
| 592 | |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 593 | public HistoryItem(long time, Parcel src) { |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 594 | this.time = time; |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 595 | numReadInts = 2; |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 596 | readFromParcel(src); |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | public int describeContents() { |
| 600 | return 0; |
| 601 | } |
| 602 | |
| 603 | public void writeToParcel(Parcel dest, int flags) { |
| 604 | dest.writeLong(time); |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 605 | int bat = (((int)cmd)&0xff) |
| 606 | | ((((int)batteryLevel)<<8)&0xff00) |
| 607 | | ((((int)batteryStatus)<<16)&0xf0000) |
| 608 | | ((((int)batteryHealth)<<20)&0xf00000) |
| 609 | | ((((int)batteryPlugType)<<24)&0xf000000); |
| 610 | dest.writeInt(bat); |
| 611 | bat = (((int)batteryTemperature)&0xffff) |
| 612 | | ((((int)batteryVoltage)<<16)&0xffff0000); |
| 613 | dest.writeInt(bat); |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 614 | dest.writeInt(states); |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 615 | if (wakelockTag != null) { |
| 616 | dest.writeInt(1); |
| 617 | wakelockTag.writeToParcel(dest, flags); |
| 618 | } else { |
| 619 | dest.writeInt(0); |
| 620 | } |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 621 | dest.writeInt(eventCode); |
| 622 | if (eventCode != EVENT_NONE) { |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 623 | dest.writeInt(eventCode); |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 624 | eventTag.writeToParcel(dest, flags); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 625 | } |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 626 | } |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 627 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 628 | public void readFromParcel(Parcel src) { |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 629 | int start = src.dataPosition(); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 630 | int bat = src.readInt(); |
| 631 | cmd = (byte)(bat&0xff); |
| 632 | batteryLevel = (byte)((bat>>8)&0xff); |
| 633 | batteryStatus = (byte)((bat>>16)&0xf); |
| 634 | batteryHealth = (byte)((bat>>20)&0xf); |
| 635 | batteryPlugType = (byte)((bat>>24)&0xf); |
| 636 | bat = src.readInt(); |
Sungmin Choi | c7e9e8b | 2013-01-16 12:57:36 +0900 | [diff] [blame] | 637 | batteryTemperature = (short)(bat&0xffff); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 638 | batteryVoltage = (char)((bat>>16)&0xffff); |
| 639 | states = src.readInt(); |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 640 | if (src.readInt() != 0) { |
| 641 | wakelockTag = localWakelockTag; |
| 642 | wakelockTag.readFromParcel(src); |
| 643 | } else { |
| 644 | wakelockTag = null; |
| 645 | } |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 646 | eventCode = src.readInt(); |
| 647 | if (eventCode != EVENT_NONE) { |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 648 | eventTag = localEventTag; |
| 649 | eventTag.readFromParcel(src); |
Dianne Hackborn | 1fadab5 | 2011-04-14 17:57:33 -0700 | [diff] [blame] | 650 | } |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 651 | numReadInts += (src.dataPosition()-start)/4; |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 652 | } |
| 653 | |
Dianne Hackborn | 1fadab5 | 2011-04-14 17:57:33 -0700 | [diff] [blame] | 654 | public void clear() { |
| 655 | time = 0; |
| 656 | cmd = CMD_NULL; |
| 657 | batteryLevel = 0; |
| 658 | batteryStatus = 0; |
| 659 | batteryHealth = 0; |
| 660 | batteryPlugType = 0; |
| 661 | batteryTemperature = 0; |
| 662 | batteryVoltage = 0; |
| 663 | states = 0; |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 664 | wakelockTag = null; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 665 | eventCode = EVENT_NONE; |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 666 | eventTag = null; |
Dianne Hackborn | 1fadab5 | 2011-04-14 17:57:33 -0700 | [diff] [blame] | 667 | } |
| 668 | |
Dianne Hackborn | ce2ef76 | 2010-09-20 11:39:14 -0700 | [diff] [blame] | 669 | public void setTo(HistoryItem o) { |
| 670 | time = o.time; |
| 671 | cmd = o.cmd; |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 672 | setToCommon(o); |
| 673 | } |
| 674 | |
| 675 | public void setTo(long time, byte cmd, HistoryItem o) { |
| 676 | this.time = time; |
| 677 | this.cmd = cmd; |
| 678 | setToCommon(o); |
| 679 | } |
| 680 | |
| 681 | private void setToCommon(HistoryItem o) { |
Dianne Hackborn | ce2ef76 | 2010-09-20 11:39:14 -0700 | [diff] [blame] | 682 | batteryLevel = o.batteryLevel; |
| 683 | batteryStatus = o.batteryStatus; |
| 684 | batteryHealth = o.batteryHealth; |
| 685 | batteryPlugType = o.batteryPlugType; |
| 686 | batteryTemperature = o.batteryTemperature; |
| 687 | batteryVoltage = o.batteryVoltage; |
| 688 | states = o.states; |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 689 | if (o.wakelockTag != null) { |
| 690 | wakelockTag = localWakelockTag; |
| 691 | wakelockTag.setTo(o.wakelockTag); |
| 692 | } else { |
| 693 | wakelockTag = null; |
| 694 | } |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 695 | eventCode = o.eventCode; |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 696 | if (o.eventTag != null) { |
| 697 | eventTag = localEventTag; |
| 698 | eventTag.setTo(o.eventTag); |
| 699 | } else { |
| 700 | eventTag = null; |
| 701 | } |
Dianne Hackborn | ce2ef76 | 2010-09-20 11:39:14 -0700 | [diff] [blame] | 702 | } |
| 703 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 704 | public boolean sameNonEvent(HistoryItem o) { |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 705 | return batteryLevel == o.batteryLevel |
| 706 | && batteryStatus == o.batteryStatus |
| 707 | && batteryHealth == o.batteryHealth |
| 708 | && batteryPlugType == o.batteryPlugType |
| 709 | && batteryTemperature == o.batteryTemperature |
| 710 | && batteryVoltage == o.batteryVoltage |
| 711 | && states == o.states; |
| 712 | } |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 713 | |
| 714 | public boolean same(HistoryItem o) { |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 715 | if (!sameNonEvent(o) || eventCode != o.eventCode) { |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 716 | return false; |
| 717 | } |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 718 | if (wakelockTag != o.wakelockTag) { |
| 719 | if (wakelockTag == null || o.wakelockTag == null) { |
| 720 | return false; |
| 721 | } |
| 722 | if (!wakelockTag.equals(o.wakelockTag)) { |
| 723 | return false; |
| 724 | } |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 725 | } |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 726 | if (eventTag != o.eventTag) { |
| 727 | if (eventTag == null || o.eventTag == null) { |
| 728 | return false; |
| 729 | } |
| 730 | if (!eventTag.equals(o.eventTag)) { |
| 731 | return false; |
| 732 | } |
| 733 | } |
| 734 | return true; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 735 | } |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | public static final class BitDescription { |
| 739 | public final int mask; |
| 740 | public final int shift; |
| 741 | public final String name; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 742 | public final String shortName; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 743 | public final String[] values; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 744 | public final String[] shortValues; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 745 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 746 | public BitDescription(int mask, String name, String shortName) { |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 747 | this.mask = mask; |
| 748 | this.shift = -1; |
| 749 | this.name = name; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 750 | this.shortName = shortName; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 751 | this.values = null; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 752 | this.shortValues = null; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 753 | } |
| 754 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 755 | public BitDescription(int mask, int shift, String name, String shortName, |
| 756 | String[] values, String[] shortValues) { |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 757 | this.mask = mask; |
| 758 | this.shift = shift; |
| 759 | this.name = name; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 760 | this.shortName = shortName; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 761 | this.values = values; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 762 | this.shortValues = shortValues; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 763 | } |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 764 | } |
| 765 | |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 766 | public abstract int getHistoryTotalSize(); |
| 767 | |
| 768 | public abstract int getHistoryUsedSize(); |
| 769 | |
Dianne Hackborn | ce2ef76 | 2010-09-20 11:39:14 -0700 | [diff] [blame] | 770 | public abstract boolean startIteratingHistoryLocked(); |
| 771 | |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 772 | public abstract int getHistoryStringPoolSize(); |
| 773 | |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 774 | public abstract int getHistoryStringPoolBytes(); |
| 775 | |
| 776 | public abstract String getHistoryTagPoolString(int index); |
| 777 | |
| 778 | public abstract int getHistoryTagPoolUid(int index); |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 779 | |
Dianne Hackborn | ce2ef76 | 2010-09-20 11:39:14 -0700 | [diff] [blame] | 780 | public abstract boolean getNextHistoryLocked(HistoryItem out); |
| 781 | |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 782 | public abstract void finishIteratingHistoryLocked(); |
| 783 | |
| 784 | public abstract boolean startIteratingOldHistoryLocked(); |
| 785 | |
| 786 | public abstract boolean getNextOldHistoryLocked(HistoryItem out); |
| 787 | |
| 788 | public abstract void finishIteratingOldHistoryLocked(); |
| 789 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 790 | /** |
Dianne Hackborn | b5e3165 | 2010-09-07 12:13:55 -0700 | [diff] [blame] | 791 | * Return the base time offset for the battery history. |
| 792 | */ |
| 793 | public abstract long getHistoryBaseTime(); |
| 794 | |
| 795 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 796 | * Returns the number of times the device has been started. |
| 797 | */ |
| 798 | public abstract int getStartCount(); |
| 799 | |
| 800 | /** |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 801 | * Returns the time in microseconds that the screen has been on while the device was |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 802 | * running on battery. |
| 803 | * |
| 804 | * {@hide} |
| 805 | */ |
| 806 | public abstract long getScreenOnTime(long batteryRealtime, int which); |
| 807 | |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 808 | public static final int SCREEN_BRIGHTNESS_DARK = 0; |
| 809 | public static final int SCREEN_BRIGHTNESS_DIM = 1; |
| 810 | public static final int SCREEN_BRIGHTNESS_MEDIUM = 2; |
| 811 | public static final int SCREEN_BRIGHTNESS_LIGHT = 3; |
| 812 | public static final int SCREEN_BRIGHTNESS_BRIGHT = 4; |
| 813 | |
| 814 | static final String[] SCREEN_BRIGHTNESS_NAMES = { |
| 815 | "dark", "dim", "medium", "light", "bright" |
| 816 | }; |
| 817 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 818 | static final String[] SCREEN_BRIGHTNESS_SHORT_NAMES = { |
| 819 | "0", "1", "2", "3", "4" |
| 820 | }; |
| 821 | |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 822 | public static final int NUM_SCREEN_BRIGHTNESS_BINS = 5; |
| 823 | |
| 824 | /** |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 825 | * Returns the time in microseconds that the screen has been on with |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 826 | * the given brightness |
| 827 | * |
| 828 | * {@hide} |
| 829 | */ |
| 830 | public abstract long getScreenBrightnessTime(int brightnessBin, |
| 831 | long batteryRealtime, int which); |
| 832 | |
| 833 | public abstract int getInputEventCount(int which); |
| 834 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 835 | /** |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 836 | * Returns the time in microseconds that the phone has been on while the device was |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 837 | * running on battery. |
| 838 | * |
| 839 | * {@hide} |
| 840 | */ |
| 841 | public abstract long getPhoneOnTime(long batteryRealtime, int which); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 842 | |
| 843 | /** |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 844 | * Returns the time in microseconds that the phone has been running with |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 845 | * the given signal strength. |
| 846 | * |
| 847 | * {@hide} |
| 848 | */ |
| 849 | public abstract long getPhoneSignalStrengthTime(int strengthBin, |
| 850 | long batteryRealtime, int which); |
| 851 | |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 852 | /** |
Amith Yamasani | f37447b | 2009-10-08 18:28:01 -0700 | [diff] [blame] | 853 | * Returns the time in microseconds that the phone has been trying to |
| 854 | * acquire a signal. |
| 855 | * |
| 856 | * {@hide} |
| 857 | */ |
| 858 | public abstract long getPhoneSignalScanningTime( |
| 859 | long batteryRealtime, int which); |
| 860 | |
| 861 | /** |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 862 | * Returns the number of times the phone has entered the given signal strength. |
| 863 | * |
| 864 | * {@hide} |
| 865 | */ |
| 866 | public abstract int getPhoneSignalStrengthCount(int strengthBin, int which); |
| 867 | |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 868 | public static final int DATA_CONNECTION_NONE = 0; |
| 869 | public static final int DATA_CONNECTION_GPRS = 1; |
| 870 | public static final int DATA_CONNECTION_EDGE = 2; |
| 871 | public static final int DATA_CONNECTION_UMTS = 3; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 872 | public static final int DATA_CONNECTION_CDMA = 4; |
| 873 | public static final int DATA_CONNECTION_EVDO_0 = 5; |
| 874 | public static final int DATA_CONNECTION_EVDO_A = 6; |
| 875 | public static final int DATA_CONNECTION_1xRTT = 7; |
| 876 | public static final int DATA_CONNECTION_HSDPA = 8; |
| 877 | public static final int DATA_CONNECTION_HSUPA = 9; |
| 878 | public static final int DATA_CONNECTION_HSPA = 10; |
| 879 | public static final int DATA_CONNECTION_IDEN = 11; |
| 880 | public static final int DATA_CONNECTION_EVDO_B = 12; |
Robert Greenwalt | 962a990 | 2010-11-02 11:10:25 -0700 | [diff] [blame] | 881 | public static final int DATA_CONNECTION_LTE = 13; |
| 882 | public static final int DATA_CONNECTION_EHRPD = 14; |
Patrick Tjin | b71703c | 2013-11-06 09:27:03 -0800 | [diff] [blame] | 883 | public static final int DATA_CONNECTION_HSPAP = 15; |
| 884 | public static final int DATA_CONNECTION_OTHER = 16; |
Robert Greenwalt | 962a990 | 2010-11-02 11:10:25 -0700 | [diff] [blame] | 885 | |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 886 | static final String[] DATA_CONNECTION_NAMES = { |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 887 | "none", "gprs", "edge", "umts", "cdma", "evdo_0", "evdo_A", |
Robert Greenwalt | 962a990 | 2010-11-02 11:10:25 -0700 | [diff] [blame] | 888 | "1xrtt", "hsdpa", "hsupa", "hspa", "iden", "evdo_b", "lte", |
Patrick Tjin | b71703c | 2013-11-06 09:27:03 -0800 | [diff] [blame] | 889 | "ehrpd", "hspap", "other" |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 890 | }; |
| 891 | |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 892 | public static final int NUM_DATA_CONNECTION_TYPES = DATA_CONNECTION_OTHER+1; |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 893 | |
| 894 | /** |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 895 | * Returns the time in microseconds that the phone has been running with |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 896 | * the given data connection. |
| 897 | * |
| 898 | * {@hide} |
| 899 | */ |
| 900 | public abstract long getPhoneDataConnectionTime(int dataType, |
| 901 | long batteryRealtime, int which); |
| 902 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 903 | /** |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 904 | * Returns the number of times the phone has entered the given data |
| 905 | * connection type. |
| 906 | * |
| 907 | * {@hide} |
| 908 | */ |
| 909 | public abstract int getPhoneDataConnectionCount(int dataType, int which); |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 910 | |
| 911 | public static final BitDescription[] HISTORY_STATE_DESCRIPTIONS |
| 912 | = new BitDescription[] { |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 913 | new BitDescription(HistoryItem.STATE_WAKE_LOCK_FLAG, "wake_lock", "w"), |
| 914 | new BitDescription(HistoryItem.STATE_SENSOR_ON_FLAG, "sensor", "s"), |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 915 | new BitDescription(HistoryItem.STATE_GPS_ON_FLAG, "gps", "g"), |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 916 | new BitDescription(HistoryItem.STATE_WIFI_FULL_LOCK_FLAG, "wifi_full_lock", "Wl"), |
| 917 | new BitDescription(HistoryItem.STATE_WIFI_SCAN_FLAG, "wifi_scan", "Ws"), |
| 918 | new BitDescription(HistoryItem.STATE_WIFI_MULTICAST_ON_FLAG, "wifi_multicast", "Wm"), |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 919 | new BitDescription(HistoryItem.STATE_WIFI_RUNNING_FLAG, "wifi_running", "Wr"), |
| 920 | new BitDescription(HistoryItem.STATE_PHONE_SCANNING_FLAG, "phone_scanning", "Psc"), |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 921 | new BitDescription(HistoryItem.STATE_AUDIO_ON_FLAG, "audio", "a"), |
| 922 | new BitDescription(HistoryItem.STATE_VIDEO_ON_FLAG, "video", "v"), |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 923 | new BitDescription(HistoryItem.STATE_SCREEN_ON_FLAG, "screen", "S"), |
| 924 | new BitDescription(HistoryItem.STATE_BATTERY_PLUGGED_FLAG, "plugged", "BP"), |
| 925 | new BitDescription(HistoryItem.STATE_PHONE_IN_CALL_FLAG, "phone_in_call", "Pcl"), |
| 926 | new BitDescription(HistoryItem.STATE_WIFI_ON_FLAG, "wifi", "W"), |
| 927 | new BitDescription(HistoryItem.STATE_BLUETOOTH_ON_FLAG, "bluetooth", "b"), |
| 928 | new BitDescription(HistoryItem.STATE_DATA_CONNECTION_MASK, |
| 929 | HistoryItem.STATE_DATA_CONNECTION_SHIFT, "data_conn", "Pcn", |
| 930 | DATA_CONNECTION_NAMES, DATA_CONNECTION_NAMES), |
| 931 | new BitDescription(HistoryItem.STATE_PHONE_STATE_MASK, |
| 932 | HistoryItem.STATE_PHONE_STATE_SHIFT, "phone_state", "Pst", |
| 933 | new String[] {"in", "out", "emergency", "off"}, |
| 934 | new String[] {"in", "out", "em", "off"}), |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 935 | new BitDescription(HistoryItem.STATE_SIGNAL_STRENGTH_MASK, |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 936 | HistoryItem.STATE_SIGNAL_STRENGTH_SHIFT, "signal_strength", "Pss", |
| 937 | SignalStrength.SIGNAL_STRENGTH_NAMES, new String[] { |
| 938 | "0", "1", "2", "3", "4" |
| 939 | }), |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 940 | new BitDescription(HistoryItem.STATE_BRIGHTNESS_MASK, |
| 941 | HistoryItem.STATE_BRIGHTNESS_SHIFT, "brightness", "Sb", |
| 942 | SCREEN_BRIGHTNESS_NAMES, SCREEN_BRIGHTNESS_SHORT_NAMES), |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 943 | }; |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 944 | |
| 945 | /** |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 946 | * Returns the time in microseconds that wifi has been on while the device was |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 947 | * running on battery. |
| 948 | * |
| 949 | * {@hide} |
| 950 | */ |
| 951 | public abstract long getWifiOnTime(long batteryRealtime, int which); |
Eric Shienbrood | d4c5f89 | 2009-03-24 18:13:20 -0700 | [diff] [blame] | 952 | |
| 953 | /** |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 954 | * Returns the time in microseconds that wifi has been on and the driver has |
Eric Shienbrood | d4c5f89 | 2009-03-24 18:13:20 -0700 | [diff] [blame] | 955 | * been in the running state while the device was running on battery. |
| 956 | * |
| 957 | * {@hide} |
| 958 | */ |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 959 | public abstract long getGlobalWifiRunningTime(long batteryRealtime, int which); |
Eric Shienbrood | d4c5f89 | 2009-03-24 18:13:20 -0700 | [diff] [blame] | 960 | |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 961 | /** |
Amith Yamasani | eaeb663 | 2009-06-03 15:16:10 -0700 | [diff] [blame] | 962 | * Returns the time in microseconds that bluetooth has been on while the device was |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 963 | * running on battery. |
| 964 | * |
| 965 | * {@hide} |
| 966 | */ |
| 967 | public abstract long getBluetoothOnTime(long batteryRealtime, int which); |
| 968 | |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 969 | public abstract int getBluetoothPingCount(); |
| 970 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 971 | public static final int NETWORK_MOBILE_RX_DATA = 0; |
| 972 | public static final int NETWORK_MOBILE_TX_DATA = 1; |
| 973 | public static final int NETWORK_WIFI_RX_DATA = 2; |
| 974 | public static final int NETWORK_WIFI_TX_DATA = 3; |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 975 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 976 | public static final int NUM_NETWORK_ACTIVITY_TYPES = NETWORK_WIFI_TX_DATA + 1; |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 977 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 978 | public abstract long getNetworkActivityBytes(int type, int which); |
| 979 | public abstract long getNetworkActivityPackets(int type, int which); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 980 | |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 981 | /** |
Dianne Hackborn | 5f4a5f9 | 2014-01-24 16:59:34 -0800 | [diff] [blame] | 982 | * Return the wall clock time when battery stats data collection started. |
| 983 | */ |
| 984 | public abstract long getStartClockTime(); |
| 985 | |
| 986 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 987 | * Return whether we are currently running on battery. |
| 988 | */ |
| 989 | public abstract boolean getIsOnBattery(); |
| 990 | |
| 991 | /** |
| 992 | * Returns a SparseArray containing the statistics for each uid. |
| 993 | */ |
| 994 | public abstract SparseArray<? extends Uid> getUidStats(); |
| 995 | |
| 996 | /** |
| 997 | * Returns the current battery uptime in microseconds. |
| 998 | * |
| 999 | * @param curTime the amount of elapsed realtime in microseconds. |
| 1000 | */ |
| 1001 | public abstract long getBatteryUptime(long curTime); |
| 1002 | |
| 1003 | /** |
Amith Yamasani | 3f7e35c | 2009-07-13 16:02:45 -0700 | [diff] [blame] | 1004 | * @deprecated use getRadioDataUptime |
| 1005 | */ |
| 1006 | public long getRadioDataUptimeMs() { |
| 1007 | return getRadioDataUptime() / 1000; |
| 1008 | } |
| 1009 | |
| 1010 | /** |
| 1011 | * Returns the time that the radio was on for data transfers. |
| 1012 | * @return the uptime in microseconds while unplugged |
| 1013 | */ |
| 1014 | public abstract long getRadioDataUptime(); |
| 1015 | |
| 1016 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1017 | * Returns the current battery realtime in microseconds. |
| 1018 | * |
| 1019 | * @param curTime the amount of elapsed realtime in microseconds. |
| 1020 | */ |
| 1021 | public abstract long getBatteryRealtime(long curTime); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1022 | |
| 1023 | /** |
Evan Millar | 633a174 | 2009-04-02 16:36:33 -0700 | [diff] [blame] | 1024 | * Returns the battery percentage level at the last time the device was unplugged from power, or |
| 1025 | * the last time it booted on battery power. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1026 | */ |
Evan Millar | 633a174 | 2009-04-02 16:36:33 -0700 | [diff] [blame] | 1027 | public abstract int getDischargeStartLevel(); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1028 | |
| 1029 | /** |
Evan Millar | 633a174 | 2009-04-02 16:36:33 -0700 | [diff] [blame] | 1030 | * Returns the current battery percentage level if we are in a discharge cycle, otherwise |
| 1031 | * returns the level at the last plug event. |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1032 | */ |
Evan Millar | 633a174 | 2009-04-02 16:36:33 -0700 | [diff] [blame] | 1033 | public abstract int getDischargeCurrentLevel(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1034 | |
| 1035 | /** |
Dianne Hackborn | 3bee5af8 | 2010-07-23 00:22:04 -0700 | [diff] [blame] | 1036 | * Get the amount the battery has discharged since the stats were |
| 1037 | * last reset after charging, as a lower-end approximation. |
| 1038 | */ |
| 1039 | public abstract int getLowDischargeAmountSinceCharge(); |
| 1040 | |
| 1041 | /** |
| 1042 | * Get the amount the battery has discharged since the stats were |
| 1043 | * last reset after charging, as an upper-end approximation. |
| 1044 | */ |
| 1045 | public abstract int getHighDischargeAmountSinceCharge(); |
| 1046 | |
| 1047 | /** |
Dianne Hackborn | c1b40e3 | 2011-01-05 18:27:40 -0800 | [diff] [blame] | 1048 | * Get the amount the battery has discharged while the screen was on, |
| 1049 | * since the last time power was unplugged. |
| 1050 | */ |
| 1051 | public abstract int getDischargeAmountScreenOn(); |
| 1052 | |
| 1053 | /** |
| 1054 | * Get the amount the battery has discharged while the screen was on, |
| 1055 | * since the last time the device was charged. |
| 1056 | */ |
| 1057 | public abstract int getDischargeAmountScreenOnSinceCharge(); |
| 1058 | |
| 1059 | /** |
| 1060 | * Get the amount the battery has discharged while the screen was off, |
| 1061 | * since the last time power was unplugged. |
| 1062 | */ |
| 1063 | public abstract int getDischargeAmountScreenOff(); |
| 1064 | |
| 1065 | /** |
| 1066 | * Get the amount the battery has discharged while the screen was off, |
| 1067 | * since the last time the device was charged. |
| 1068 | */ |
| 1069 | public abstract int getDischargeAmountScreenOffSinceCharge(); |
| 1070 | |
| 1071 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1072 | * Returns the total, last, or current battery uptime in microseconds. |
| 1073 | * |
| 1074 | * @param curTime the elapsed realtime in microseconds. |
| 1075 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 1076 | */ |
| 1077 | public abstract long computeBatteryUptime(long curTime, int which); |
| 1078 | |
| 1079 | /** |
| 1080 | * Returns the total, last, or current battery realtime in microseconds. |
| 1081 | * |
| 1082 | * @param curTime the current elapsed realtime in microseconds. |
| 1083 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 1084 | */ |
| 1085 | public abstract long computeBatteryRealtime(long curTime, int which); |
| 1086 | |
| 1087 | /** |
| 1088 | * Returns the total, last, or current uptime in microseconds. |
| 1089 | * |
| 1090 | * @param curTime the current elapsed realtime in microseconds. |
| 1091 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 1092 | */ |
| 1093 | public abstract long computeUptime(long curTime, int which); |
| 1094 | |
| 1095 | /** |
| 1096 | * Returns the total, last, or current realtime in microseconds. |
| 1097 | * * |
| 1098 | * @param curTime the current elapsed realtime in microseconds. |
| 1099 | * @param which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 1100 | */ |
| 1101 | public abstract long computeRealtime(long curTime, int which); |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1102 | |
| 1103 | public abstract Map<String, ? extends Timer> getKernelWakelockStats(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1104 | |
Amith Yamasani | e43530a | 2009-08-21 13:11:37 -0700 | [diff] [blame] | 1105 | /** Returns the number of different speeds that the CPU can run at */ |
| 1106 | public abstract int getCpuSpeedSteps(); |
| 1107 | |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1108 | public abstract void writeToParcelWithoutUids(Parcel out, int flags); |
| 1109 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1110 | private final static void formatTimeRaw(StringBuilder out, long seconds) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1111 | long days = seconds / (60 * 60 * 24); |
| 1112 | if (days != 0) { |
| 1113 | out.append(days); |
| 1114 | out.append("d "); |
| 1115 | } |
| 1116 | long used = days * 60 * 60 * 24; |
| 1117 | |
| 1118 | long hours = (seconds - used) / (60 * 60); |
| 1119 | if (hours != 0 || used != 0) { |
| 1120 | out.append(hours); |
| 1121 | out.append("h "); |
| 1122 | } |
| 1123 | used += hours * 60 * 60; |
| 1124 | |
| 1125 | long mins = (seconds-used) / 60; |
| 1126 | if (mins != 0 || used != 0) { |
| 1127 | out.append(mins); |
| 1128 | out.append("m "); |
| 1129 | } |
| 1130 | used += mins * 60; |
| 1131 | |
| 1132 | if (seconds != 0 || used != 0) { |
| 1133 | out.append(seconds-used); |
| 1134 | out.append("s "); |
| 1135 | } |
| 1136 | } |
| 1137 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1138 | private final static void formatTime(StringBuilder sb, long time) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1139 | long sec = time / 100; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1140 | formatTimeRaw(sb, sec); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1141 | sb.append((time - (sec * 100)) * 10); |
| 1142 | sb.append("ms "); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1143 | } |
| 1144 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1145 | private final static void formatTimeMs(StringBuilder sb, long time) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1146 | long sec = time / 1000; |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1147 | formatTimeRaw(sb, sec); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1148 | sb.append(time - (sec * 1000)); |
| 1149 | sb.append("ms "); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1150 | } |
| 1151 | |
| 1152 | private final String formatRatioLocked(long num, long den) { |
| 1153 | if (den == 0L) { |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1154 | return "--%"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1155 | } |
| 1156 | float perc = ((float)num) / ((float)den) * 100; |
| 1157 | mFormatBuilder.setLength(0); |
| 1158 | mFormatter.format("%.1f%%", perc); |
| 1159 | return mFormatBuilder.toString(); |
| 1160 | } |
| 1161 | |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1162 | private final String formatBytesLocked(long bytes) { |
| 1163 | mFormatBuilder.setLength(0); |
| 1164 | |
| 1165 | if (bytes < BYTES_PER_KB) { |
| 1166 | return bytes + "B"; |
| 1167 | } else if (bytes < BYTES_PER_MB) { |
| 1168 | mFormatter.format("%.2fKB", bytes / (double) BYTES_PER_KB); |
| 1169 | return mFormatBuilder.toString(); |
| 1170 | } else if (bytes < BYTES_PER_GB){ |
| 1171 | mFormatter.format("%.2fMB", bytes / (double) BYTES_PER_MB); |
| 1172 | return mFormatBuilder.toString(); |
| 1173 | } else { |
| 1174 | mFormatter.format("%.2fGB", bytes / (double) BYTES_PER_GB); |
| 1175 | return mFormatBuilder.toString(); |
| 1176 | } |
| 1177 | } |
| 1178 | |
Dianne Hackborn | c24ab86 | 2011-10-18 15:55:03 -0700 | [diff] [blame] | 1179 | private static long computeWakeLock(Timer timer, long batteryRealtime, int which) { |
| 1180 | if (timer != null) { |
| 1181 | // Convert from microseconds to milliseconds with rounding |
| 1182 | long totalTimeMicros = timer.getTotalTimeLocked(batteryRealtime, which); |
| 1183 | long totalTimeMillis = (totalTimeMicros + 500) / 1000; |
| 1184 | return totalTimeMillis; |
| 1185 | } |
| 1186 | return 0; |
| 1187 | } |
| 1188 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1189 | /** |
| 1190 | * |
| 1191 | * @param sb a StringBuilder object. |
| 1192 | * @param timer a Timer object contining the wakelock times. |
| 1193 | * @param batteryRealtime the current on-battery time in microseconds. |
| 1194 | * @param name the name of the wakelock. |
| 1195 | * @param which which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 1196 | * @param linePrefix a String to be prepended to each line of output. |
| 1197 | * @return the line prefix |
| 1198 | */ |
| 1199 | private static final String printWakeLock(StringBuilder sb, Timer timer, |
| 1200 | long batteryRealtime, String name, int which, String linePrefix) { |
| 1201 | |
| 1202 | if (timer != null) { |
Dianne Hackborn | c24ab86 | 2011-10-18 15:55:03 -0700 | [diff] [blame] | 1203 | long totalTimeMillis = computeWakeLock(timer, batteryRealtime, which); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1204 | |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1205 | int count = timer.getCountLocked(which); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1206 | if (totalTimeMillis != 0) { |
| 1207 | sb.append(linePrefix); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1208 | formatTimeMs(sb, totalTimeMillis); |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1209 | if (name != null) { |
| 1210 | sb.append(name); |
| 1211 | sb.append(' '); |
| 1212 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1213 | sb.append('('); |
| 1214 | sb.append(count); |
| 1215 | sb.append(" times)"); |
| 1216 | return ", "; |
| 1217 | } |
| 1218 | } |
| 1219 | return linePrefix; |
| 1220 | } |
| 1221 | |
| 1222 | /** |
| 1223 | * Checkin version of wakelock printer. Prints simple comma-separated list. |
| 1224 | * |
| 1225 | * @param sb a StringBuilder object. |
| 1226 | * @param timer a Timer object contining the wakelock times. |
| 1227 | * @param now the current time in microseconds. |
| 1228 | * @param name the name of the wakelock. |
| 1229 | * @param which which one of STATS_TOTAL, STATS_LAST, or STATS_CURRENT. |
| 1230 | * @param linePrefix a String to be prepended to each line of output. |
| 1231 | * @return the line prefix |
| 1232 | */ |
| 1233 | private static final String printWakeLockCheckin(StringBuilder sb, Timer timer, long now, |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1234 | String name, int which, String linePrefix) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1235 | long totalTimeMicros = 0; |
| 1236 | int count = 0; |
| 1237 | if (timer != null) { |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1238 | totalTimeMicros = timer.getTotalTimeLocked(now, which); |
| 1239 | count = timer.getCountLocked(which); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1240 | } |
| 1241 | sb.append(linePrefix); |
| 1242 | sb.append((totalTimeMicros + 500) / 1000); // microseconds to milliseconds with rounding |
| 1243 | sb.append(','); |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1244 | sb.append(name != null ? name + "," : ""); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1245 | sb.append(count); |
| 1246 | return ","; |
| 1247 | } |
| 1248 | |
| 1249 | /** |
| 1250 | * Dump a comma-separated line of values for terse checkin mode. |
| 1251 | * |
| 1252 | * @param pw the PageWriter to dump log to |
| 1253 | * @param category category of data (e.g. "total", "last", "unplugged", "current" ) |
| 1254 | * @param type type of data (e.g. "wakelock", "sensor", "process", "apk" , "process", "network") |
| 1255 | * @param args type-dependent data arguments |
| 1256 | */ |
| 1257 | private static final void dumpLine(PrintWriter pw, int uid, String category, String type, |
| 1258 | Object... args ) { |
| 1259 | pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); |
| 1260 | pw.print(uid); pw.print(','); |
| 1261 | pw.print(category); pw.print(','); |
Dianne Hackborn | 13ac041 | 2013-06-25 19:34:49 -0700 | [diff] [blame] | 1262 | pw.print(type); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1263 | |
| 1264 | for (Object arg : args) { |
Dianne Hackborn | 13ac041 | 2013-06-25 19:34:49 -0700 | [diff] [blame] | 1265 | pw.print(','); |
| 1266 | pw.print(arg); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1267 | } |
Dianne Hackborn | 13ac041 | 2013-06-25 19:34:49 -0700 | [diff] [blame] | 1268 | pw.println(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1269 | } |
| 1270 | |
| 1271 | /** |
| 1272 | * Checkin server version of dump to produce more compact, computer-readable log. |
| 1273 | * |
| 1274 | * NOTE: all times are expressed in 'ms'. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1275 | */ |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1276 | public final void dumpCheckinLocked(Context context, PrintWriter pw, int which, int reqUid) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1277 | final long rawUptime = SystemClock.uptimeMillis() * 1000; |
| 1278 | final long rawRealtime = SystemClock.elapsedRealtime() * 1000; |
| 1279 | final long batteryUptime = getBatteryUptime(rawUptime); |
| 1280 | final long batteryRealtime = getBatteryRealtime(rawRealtime); |
| 1281 | final long whichBatteryUptime = computeBatteryUptime(rawUptime, which); |
| 1282 | final long whichBatteryRealtime = computeBatteryRealtime(rawRealtime, which); |
| 1283 | final long totalRealtime = computeRealtime(rawRealtime, which); |
| 1284 | final long totalUptime = computeUptime(rawUptime, which); |
| 1285 | final long screenOnTime = getScreenOnTime(batteryRealtime, which); |
| 1286 | final long phoneOnTime = getPhoneOnTime(batteryRealtime, which); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1287 | final long wifiOnTime = getWifiOnTime(batteryRealtime, which); |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 1288 | final long wifiRunningTime = getGlobalWifiRunningTime(batteryRealtime, which); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1289 | final long bluetoothOnTime = getBluetoothOnTime(batteryRealtime, which); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1290 | |
| 1291 | StringBuilder sb = new StringBuilder(128); |
| 1292 | |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1293 | SparseArray<? extends Uid> uidStats = getUidStats(); |
| 1294 | final int NU = uidStats.size(); |
| 1295 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1296 | String category = STAT_NAMES[which]; |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 1297 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1298 | // Dump "battery" stat |
| 1299 | dumpLine(pw, 0 /* uid */, category, BATTERY_DATA, |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 1300 | which == STATS_SINCE_CHARGED ? getStartCount() : "N/A", |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1301 | whichBatteryRealtime / 1000, whichBatteryUptime / 1000, |
Dianne Hackborn | 5f4a5f9 | 2014-01-24 16:59:34 -0800 | [diff] [blame] | 1302 | totalRealtime / 1000, totalUptime / 1000, |
| 1303 | getStartClockTime()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1304 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1305 | // Calculate wakelock times across all uids. |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1306 | long fullWakeLockTimeTotal = 0; |
| 1307 | long partialWakeLockTimeTotal = 0; |
| 1308 | |
| 1309 | for (int iu = 0; iu < NU; iu++) { |
| 1310 | Uid u = uidStats.valueAt(iu); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 1311 | |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1312 | Map<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats(); |
| 1313 | if (wakelocks.size() > 0) { |
| 1314 | for (Map.Entry<String, ? extends BatteryStats.Uid.Wakelock> ent |
| 1315 | : wakelocks.entrySet()) { |
| 1316 | Uid.Wakelock wl = ent.getValue(); |
| 1317 | |
| 1318 | Timer fullWakeTimer = wl.getWakeTime(WAKE_TYPE_FULL); |
| 1319 | if (fullWakeTimer != null) { |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1320 | fullWakeLockTimeTotal += fullWakeTimer.getTotalTimeLocked(batteryRealtime, which); |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1321 | } |
| 1322 | |
| 1323 | Timer partialWakeTimer = wl.getWakeTime(WAKE_TYPE_PARTIAL); |
| 1324 | if (partialWakeTimer != null) { |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1325 | partialWakeLockTimeTotal += partialWakeTimer.getTotalTimeLocked( |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1326 | batteryRealtime, which); |
| 1327 | } |
| 1328 | } |
| 1329 | } |
| 1330 | } |
| 1331 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1332 | long mobileRxTotalBytes = getNetworkActivityBytes(NETWORK_MOBILE_RX_DATA, which); |
| 1333 | long mobileTxTotalBytes = getNetworkActivityBytes(NETWORK_MOBILE_TX_DATA, which); |
| 1334 | long wifiRxTotalBytes = getNetworkActivityBytes(NETWORK_WIFI_RX_DATA, which); |
| 1335 | long wifiTxTotalBytes = getNetworkActivityBytes(NETWORK_WIFI_TX_DATA, which); |
| 1336 | long mobileRxTotalPackets = getNetworkActivityPackets(NETWORK_MOBILE_RX_DATA, which); |
| 1337 | long mobileTxTotalPackets = getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, which); |
| 1338 | long wifiRxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which); |
| 1339 | long wifiTxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which); |
| 1340 | |
| 1341 | // Dump network stats |
| 1342 | dumpLine(pw, 0 /* uid */, category, GLOBAL_NETWORK_DATA, |
| 1343 | mobileRxTotalBytes, mobileTxTotalBytes, wifiRxTotalBytes, wifiTxTotalBytes, |
| 1344 | mobileRxTotalPackets, mobileTxTotalPackets, wifiRxTotalPackets, wifiTxTotalPackets); |
| 1345 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1346 | // Dump misc stats |
| 1347 | dumpLine(pw, 0 /* uid */, category, MISC_DATA, |
Eric Shienbrood | d4c5f89 | 2009-03-24 18:13:20 -0700 | [diff] [blame] | 1348 | screenOnTime / 1000, phoneOnTime / 1000, wifiOnTime / 1000, |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 1349 | wifiRunningTime / 1000, bluetoothOnTime / 1000, |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1350 | mobileRxTotalBytes, mobileTxTotalBytes, wifiRxTotalBytes, wifiTxTotalBytes, |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1351 | fullWakeLockTimeTotal, partialWakeLockTimeTotal, |
| 1352 | getInputEventCount(which)); |
| 1353 | |
| 1354 | // Dump screen brightness stats |
| 1355 | Object[] args = new Object[NUM_SCREEN_BRIGHTNESS_BINS]; |
| 1356 | for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) { |
| 1357 | args[i] = getScreenBrightnessTime(i, batteryRealtime, which) / 1000; |
| 1358 | } |
| 1359 | dumpLine(pw, 0 /* uid */, category, SCREEN_BRIGHTNESS_DATA, args); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1360 | |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1361 | // Dump signal strength stats |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 1362 | args = new Object[SignalStrength.NUM_SIGNAL_STRENGTH_BINS]; |
| 1363 | for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1364 | args[i] = getPhoneSignalStrengthTime(i, batteryRealtime, which) / 1000; |
| 1365 | } |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1366 | dumpLine(pw, 0 /* uid */, category, SIGNAL_STRENGTH_TIME_DATA, args); |
Amith Yamasani | f37447b | 2009-10-08 18:28:01 -0700 | [diff] [blame] | 1367 | dumpLine(pw, 0 /* uid */, category, SIGNAL_SCANNING_TIME_DATA, |
| 1368 | getPhoneSignalScanningTime(batteryRealtime, which) / 1000); |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 1369 | for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1370 | args[i] = getPhoneSignalStrengthCount(i, which); |
| 1371 | } |
| 1372 | dumpLine(pw, 0 /* uid */, category, SIGNAL_STRENGTH_COUNT_DATA, args); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1373 | |
| 1374 | // Dump network type stats |
| 1375 | args = new Object[NUM_DATA_CONNECTION_TYPES]; |
| 1376 | for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) { |
| 1377 | args[i] = getPhoneDataConnectionTime(i, batteryRealtime, which) / 1000; |
| 1378 | } |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1379 | dumpLine(pw, 0 /* uid */, category, DATA_CONNECTION_TIME_DATA, args); |
| 1380 | for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) { |
| 1381 | args[i] = getPhoneDataConnectionCount(i, which); |
| 1382 | } |
| 1383 | dumpLine(pw, 0 /* uid */, category, DATA_CONNECTION_COUNT_DATA, args); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1384 | |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 1385 | if (which == STATS_SINCE_UNPLUGGED) { |
Evan Millar | e84de8d | 2009-04-02 22:16:12 -0700 | [diff] [blame] | 1386 | dumpLine(pw, 0 /* uid */, category, BATTERY_LEVEL_DATA, getDischargeStartLevel(), |
Evan Millar | 633a174 | 2009-04-02 16:36:33 -0700 | [diff] [blame] | 1387 | getDischargeCurrentLevel()); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1388 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1389 | |
Dianne Hackborn | c1b40e3 | 2011-01-05 18:27:40 -0800 | [diff] [blame] | 1390 | if (which == STATS_SINCE_UNPLUGGED) { |
| 1391 | dumpLine(pw, 0 /* uid */, category, BATTERY_DISCHARGE_DATA, |
| 1392 | getDischargeStartLevel()-getDischargeCurrentLevel(), |
| 1393 | getDischargeStartLevel()-getDischargeCurrentLevel(), |
| 1394 | getDischargeAmountScreenOn(), getDischargeAmountScreenOff()); |
| 1395 | } else { |
| 1396 | dumpLine(pw, 0 /* uid */, category, BATTERY_DISCHARGE_DATA, |
| 1397 | getLowDischargeAmountSinceCharge(), getHighDischargeAmountSinceCharge(), |
| 1398 | getDischargeAmountScreenOn(), getDischargeAmountScreenOff()); |
| 1399 | } |
| 1400 | |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1401 | if (reqUid < 0) { |
| 1402 | Map<String, ? extends BatteryStats.Timer> kernelWakelocks = getKernelWakelockStats(); |
| 1403 | if (kernelWakelocks.size() > 0) { |
| 1404 | for (Map.Entry<String, ? extends BatteryStats.Timer> ent : kernelWakelocks.entrySet()) { |
| 1405 | sb.setLength(0); |
| 1406 | printWakeLockCheckin(sb, ent.getValue(), batteryRealtime, null, which, ""); |
| 1407 | |
| 1408 | dumpLine(pw, 0 /* uid */, category, KERNEL_WAKELOCK_DATA, ent.getKey(), |
| 1409 | sb.toString()); |
| 1410 | } |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1411 | } |
| 1412 | } |
| 1413 | |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1414 | BatteryStatsHelper helper = new BatteryStatsHelper(context); |
| 1415 | helper.create(this); |
| 1416 | helper.refreshStats(which, UserHandle.USER_ALL); |
| 1417 | List<BatterySipper> sippers = helper.getUsageList(); |
| 1418 | if (sippers != null && sippers.size() > 0) { |
| 1419 | dumpLine(pw, 0 /* uid */, category, POWER_USE_SUMMARY_DATA, |
| 1420 | BatteryStatsHelper.makemAh(helper.getPowerProfile().getBatteryCapacity()), |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 1421 | BatteryStatsHelper.makemAh(helper.getComputedPower()), |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1422 | BatteryStatsHelper.makemAh(helper.getMinDrainedPower()), |
| 1423 | BatteryStatsHelper.makemAh(helper.getMaxDrainedPower())); |
| 1424 | for (int i=0; i<sippers.size(); i++) { |
| 1425 | BatterySipper bs = sippers.get(i); |
| 1426 | int uid = 0; |
| 1427 | String label; |
| 1428 | switch (bs.drainType) { |
| 1429 | case IDLE: |
| 1430 | label="idle"; |
| 1431 | break; |
| 1432 | case CELL: |
| 1433 | label="cell"; |
| 1434 | break; |
| 1435 | case PHONE: |
| 1436 | label="phone"; |
| 1437 | break; |
| 1438 | case WIFI: |
| 1439 | label="wifi"; |
| 1440 | break; |
| 1441 | case BLUETOOTH: |
| 1442 | label="blue"; |
| 1443 | break; |
| 1444 | case SCREEN: |
| 1445 | label="scrn"; |
| 1446 | break; |
| 1447 | case APP: |
| 1448 | uid = bs.uidObj.getUid(); |
| 1449 | label = "uid"; |
| 1450 | break; |
| 1451 | case USER: |
| 1452 | uid = UserHandle.getUid(bs.userId, 0); |
| 1453 | label = "user"; |
| 1454 | break; |
| 1455 | case UNACCOUNTED: |
| 1456 | label = "unacc"; |
| 1457 | break; |
| 1458 | case OVERCOUNTED: |
| 1459 | label = "over"; |
| 1460 | break; |
| 1461 | default: |
| 1462 | label = "???"; |
| 1463 | } |
| 1464 | dumpLine(pw, uid, category, POWER_USE_ITEM_DATA, label, |
| 1465 | BatteryStatsHelper.makemAh(bs.value)); |
| 1466 | } |
| 1467 | } |
| 1468 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1469 | for (int iu = 0; iu < NU; iu++) { |
| 1470 | final int uid = uidStats.keyAt(iu); |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1471 | if (reqUid >= 0 && uid != reqUid) { |
| 1472 | continue; |
| 1473 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1474 | Uid u = uidStats.valueAt(iu); |
| 1475 | // Dump Network stats per uid, if any |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1476 | long mobileBytesRx = u.getNetworkActivityBytes(NETWORK_MOBILE_RX_DATA, which); |
| 1477 | long mobileBytesTx = u.getNetworkActivityBytes(NETWORK_MOBILE_TX_DATA, which); |
| 1478 | long wifiBytesRx = u.getNetworkActivityBytes(NETWORK_WIFI_RX_DATA, which); |
| 1479 | long wifiBytesTx = u.getNetworkActivityBytes(NETWORK_WIFI_TX_DATA, which); |
| 1480 | long mobilePacketsRx = u.getNetworkActivityPackets(NETWORK_MOBILE_RX_DATA, which); |
| 1481 | long mobilePacketsTx = u.getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, which); |
| 1482 | long wifiPacketsRx = u.getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which); |
| 1483 | long wifiPacketsTx = u.getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1484 | long fullWifiLockOnTime = u.getFullWifiLockTime(batteryRealtime, which); |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 1485 | long wifiScanTime = u.getWifiScanTime(batteryRealtime, which); |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 1486 | long uidWifiRunningTime = u.getWifiRunningTime(batteryRealtime, which); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 1487 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1488 | if (mobileBytesRx > 0 || mobileBytesTx > 0 || wifiBytesRx > 0 || wifiBytesTx > 0 |
| 1489 | || mobilePacketsRx > 0 || mobilePacketsTx > 0 || wifiPacketsRx > 0 |
| 1490 | || wifiPacketsTx > 0) { |
| 1491 | dumpLine(pw, uid, category, NETWORK_DATA, mobileBytesRx, mobileBytesTx, |
| 1492 | wifiBytesRx, wifiBytesTx, |
| 1493 | mobilePacketsRx, mobilePacketsTx, |
| 1494 | wifiPacketsRx, wifiPacketsTx); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 1495 | } |
| 1496 | |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 1497 | if (fullWifiLockOnTime != 0 || wifiScanTime != 0 |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 1498 | || uidWifiRunningTime != 0) { |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 1499 | dumpLine(pw, uid, category, WIFI_DATA, |
| 1500 | fullWifiLockOnTime, wifiScanTime, uidWifiRunningTime); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1501 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1502 | |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1503 | if (u.hasUserActivity()) { |
| 1504 | args = new Object[Uid.NUM_USER_ACTIVITY_TYPES]; |
| 1505 | boolean hasData = false; |
| 1506 | for (int i=0; i<Uid.NUM_USER_ACTIVITY_TYPES; i++) { |
| 1507 | int val = u.getUserActivityCount(i, which); |
| 1508 | args[i] = val; |
| 1509 | if (val != 0) hasData = true; |
| 1510 | } |
| 1511 | if (hasData) { |
| 1512 | dumpLine(pw, 0 /* uid */, category, USER_ACTIVITY_DATA, args); |
| 1513 | } |
| 1514 | } |
| 1515 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1516 | Map<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats(); |
| 1517 | if (wakelocks.size() > 0) { |
| 1518 | for (Map.Entry<String, ? extends BatteryStats.Uid.Wakelock> ent |
| 1519 | : wakelocks.entrySet()) { |
| 1520 | Uid.Wakelock wl = ent.getValue(); |
| 1521 | String linePrefix = ""; |
| 1522 | sb.setLength(0); |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1523 | linePrefix = printWakeLockCheckin(sb, wl.getWakeTime(WAKE_TYPE_FULL), |
| 1524 | batteryRealtime, "f", which, linePrefix); |
| 1525 | linePrefix = printWakeLockCheckin(sb, wl.getWakeTime(WAKE_TYPE_PARTIAL), |
| 1526 | batteryRealtime, "p", which, linePrefix); |
| 1527 | linePrefix = printWakeLockCheckin(sb, wl.getWakeTime(WAKE_TYPE_WINDOW), |
| 1528 | batteryRealtime, "w", which, linePrefix); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1529 | |
| 1530 | // Only log if we had at lease one wakelock... |
| 1531 | if (sb.length() > 0) { |
Dianne Hackborn | 13ac041 | 2013-06-25 19:34:49 -0700 | [diff] [blame] | 1532 | String name = ent.getKey(); |
| 1533 | if (name.indexOf(',') >= 0) { |
| 1534 | name = name.replace(',', '_'); |
| 1535 | } |
| 1536 | dumpLine(pw, uid, category, WAKELOCK_DATA, name, sb.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1537 | } |
| 1538 | } |
| 1539 | } |
| 1540 | |
| 1541 | Map<Integer, ? extends BatteryStats.Uid.Sensor> sensors = u.getSensorStats(); |
| 1542 | if (sensors.size() > 0) { |
| 1543 | for (Map.Entry<Integer, ? extends BatteryStats.Uid.Sensor> ent |
| 1544 | : sensors.entrySet()) { |
| 1545 | Uid.Sensor se = ent.getValue(); |
| 1546 | int sensorNumber = ent.getKey(); |
| 1547 | Timer timer = se.getSensorTime(); |
| 1548 | if (timer != null) { |
| 1549 | // Convert from microseconds to milliseconds with rounding |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1550 | long totalTime = (timer.getTotalTimeLocked(batteryRealtime, which) + 500) / 1000; |
| 1551 | int count = timer.getCountLocked(which); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1552 | if (totalTime != 0) { |
| 1553 | dumpLine(pw, uid, category, SENSOR_DATA, sensorNumber, totalTime, count); |
| 1554 | } |
| 1555 | } |
| 1556 | } |
| 1557 | } |
| 1558 | |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 1559 | Timer vibTimer = u.getVibratorOnTimer(); |
| 1560 | if (vibTimer != null) { |
| 1561 | // Convert from microseconds to milliseconds with rounding |
| 1562 | long totalTime = (vibTimer.getTotalTimeLocked(batteryRealtime, which) + 500) / 1000; |
| 1563 | int count = vibTimer.getCountLocked(which); |
| 1564 | if (totalTime != 0) { |
| 1565 | dumpLine(pw, uid, category, VIBRATOR_DATA, totalTime, count); |
| 1566 | } |
| 1567 | } |
| 1568 | |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 1569 | Timer fgTimer = u.getForegroundActivityTimer(); |
| 1570 | if (fgTimer != null) { |
| 1571 | // Convert from microseconds to milliseconds with rounding |
| 1572 | long totalTime = (fgTimer.getTotalTimeLocked(batteryRealtime, which) + 500) / 1000; |
| 1573 | int count = fgTimer.getCountLocked(which); |
| 1574 | if (totalTime != 0) { |
| 1575 | dumpLine(pw, uid, category, FOREGROUND_DATA, totalTime, count); |
| 1576 | } |
| 1577 | } |
| 1578 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1579 | Map<String, ? extends BatteryStats.Uid.Proc> processStats = u.getProcessStats(); |
| 1580 | if (processStats.size() > 0) { |
| 1581 | for (Map.Entry<String, ? extends BatteryStats.Uid.Proc> ent |
| 1582 | : processStats.entrySet()) { |
| 1583 | Uid.Proc ps = ent.getValue(); |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 1584 | |
| 1585 | final long userMillis = ps.getUserTime(which) * 10; |
| 1586 | final long systemMillis = ps.getSystemTime(which) * 10; |
| 1587 | final long foregroundMillis = ps.getForegroundTime(which) * 10; |
| 1588 | final long starts = ps.getStarts(which); |
| 1589 | |
| 1590 | if (userMillis != 0 || systemMillis != 0 || foregroundMillis != 0 |
| 1591 | || starts != 0) { |
| 1592 | dumpLine(pw, uid, category, PROCESS_DATA, ent.getKey(), userMillis, |
| 1593 | systemMillis, foregroundMillis, starts); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1594 | } |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | Map<String, ? extends BatteryStats.Uid.Pkg> packageStats = u.getPackageStats(); |
| 1599 | if (packageStats.size() > 0) { |
| 1600 | for (Map.Entry<String, ? extends BatteryStats.Uid.Pkg> ent |
| 1601 | : packageStats.entrySet()) { |
| 1602 | |
| 1603 | Uid.Pkg ps = ent.getValue(); |
| 1604 | int wakeups = ps.getWakeups(which); |
| 1605 | Map<String, ? extends Uid.Pkg.Serv> serviceStats = ps.getServiceStats(); |
| 1606 | for (Map.Entry<String, ? extends BatteryStats.Uid.Pkg.Serv> sent |
| 1607 | : serviceStats.entrySet()) { |
| 1608 | BatteryStats.Uid.Pkg.Serv ss = sent.getValue(); |
| 1609 | long startTime = ss.getStartTime(batteryUptime, which); |
| 1610 | int starts = ss.getStarts(which); |
| 1611 | int launches = ss.getLaunches(which); |
| 1612 | if (startTime != 0 || starts != 0 || launches != 0) { |
| 1613 | dumpLine(pw, uid, category, APK_DATA, |
| 1614 | wakeups, // wakeup alarms |
| 1615 | ent.getKey(), // Apk |
| 1616 | sent.getKey(), // service |
| 1617 | startTime / 1000, // time spent started, in ms |
| 1618 | starts, |
| 1619 | launches); |
| 1620 | } |
| 1621 | } |
| 1622 | } |
| 1623 | } |
| 1624 | } |
| 1625 | } |
| 1626 | |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1627 | static final class TimerEntry { |
| 1628 | final String mName; |
| 1629 | final int mId; |
| 1630 | final BatteryStats.Timer mTimer; |
| 1631 | final long mTime; |
| 1632 | TimerEntry(String name, int id, BatteryStats.Timer timer, long time) { |
| 1633 | mName = name; |
| 1634 | mId = id; |
| 1635 | mTimer = timer; |
| 1636 | mTime = time; |
| 1637 | } |
| 1638 | } |
| 1639 | |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1640 | private void printmAh(PrintWriter printer, double power) { |
| 1641 | printer.print(BatteryStatsHelper.makemAh(power)); |
| 1642 | } |
| 1643 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1644 | @SuppressWarnings("unused") |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1645 | public final void dumpLocked(Context context, PrintWriter pw, String prefix, final int which, |
| 1646 | int reqUid) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1647 | final long rawUptime = SystemClock.uptimeMillis() * 1000; |
| 1648 | final long rawRealtime = SystemClock.elapsedRealtime() * 1000; |
| 1649 | final long batteryUptime = getBatteryUptime(rawUptime); |
Eric Shienbrood | d4c5f89 | 2009-03-24 18:13:20 -0700 | [diff] [blame] | 1650 | final long batteryRealtime = getBatteryRealtime(rawRealtime); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1651 | |
| 1652 | final long whichBatteryUptime = computeBatteryUptime(rawUptime, which); |
| 1653 | final long whichBatteryRealtime = computeBatteryRealtime(rawRealtime, which); |
| 1654 | final long totalRealtime = computeRealtime(rawRealtime, which); |
| 1655 | final long totalUptime = computeUptime(rawUptime, which); |
| 1656 | |
| 1657 | StringBuilder sb = new StringBuilder(128); |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1658 | |
| 1659 | SparseArray<? extends Uid> uidStats = getUidStats(); |
| 1660 | final int NU = uidStats.size(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1661 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1662 | sb.setLength(0); |
| 1663 | sb.append(prefix); |
| 1664 | sb.append(" Time on battery: "); |
| 1665 | formatTimeMs(sb, whichBatteryRealtime / 1000); sb.append("("); |
| 1666 | sb.append(formatRatioLocked(whichBatteryRealtime, totalRealtime)); |
| 1667 | sb.append(") realtime, "); |
| 1668 | formatTimeMs(sb, whichBatteryUptime / 1000); |
| 1669 | sb.append("("); sb.append(formatRatioLocked(whichBatteryUptime, totalRealtime)); |
| 1670 | sb.append(") uptime"); |
| 1671 | pw.println(sb.toString()); |
| 1672 | sb.setLength(0); |
| 1673 | sb.append(prefix); |
| 1674 | sb.append(" Total run time: "); |
| 1675 | formatTimeMs(sb, totalRealtime / 1000); |
| 1676 | sb.append("realtime, "); |
| 1677 | formatTimeMs(sb, totalUptime / 1000); |
| 1678 | sb.append("uptime, "); |
| 1679 | pw.println(sb.toString()); |
Dianne Hackborn | 5f4a5f9 | 2014-01-24 16:59:34 -0800 | [diff] [blame] | 1680 | pw.print(" Start clock time: "); |
| 1681 | pw.println(DateFormat.format("yyyy-MM-dd-HH-mm-ss", getStartClockTime()).toString()); |
| 1682 | |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1683 | final long screenOnTime = getScreenOnTime(batteryRealtime, which); |
| 1684 | final long phoneOnTime = getPhoneOnTime(batteryRealtime, which); |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 1685 | final long wifiRunningTime = getGlobalWifiRunningTime(batteryRealtime, which); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1686 | final long wifiOnTime = getWifiOnTime(batteryRealtime, which); |
| 1687 | final long bluetoothOnTime = getBluetoothOnTime(batteryRealtime, which); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1688 | sb.setLength(0); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1689 | sb.append(prefix); |
| 1690 | sb.append(" Screen on: "); formatTimeMs(sb, screenOnTime / 1000); |
| 1691 | sb.append("("); sb.append(formatRatioLocked(screenOnTime, whichBatteryRealtime)); |
| 1692 | sb.append("), Input events: "); sb.append(getInputEventCount(which)); |
| 1693 | sb.append(", Active phone call: "); formatTimeMs(sb, phoneOnTime / 1000); |
| 1694 | sb.append("("); sb.append(formatRatioLocked(phoneOnTime, whichBatteryRealtime)); |
| 1695 | sb.append(")"); |
| 1696 | pw.println(sb.toString()); |
| 1697 | sb.setLength(0); |
| 1698 | sb.append(prefix); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1699 | sb.append(" Screen brightnesses: "); |
| 1700 | boolean didOne = false; |
| 1701 | for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) { |
| 1702 | final long time = getScreenBrightnessTime(i, batteryRealtime, which); |
| 1703 | if (time == 0) { |
| 1704 | continue; |
| 1705 | } |
| 1706 | if (didOne) sb.append(", "); |
| 1707 | didOne = true; |
| 1708 | sb.append(SCREEN_BRIGHTNESS_NAMES[i]); |
| 1709 | sb.append(" "); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1710 | formatTimeMs(sb, time/1000); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1711 | sb.append("("); |
| 1712 | sb.append(formatRatioLocked(time, screenOnTime)); |
| 1713 | sb.append(")"); |
| 1714 | } |
| 1715 | if (!didOne) sb.append("No activity"); |
| 1716 | pw.println(sb.toString()); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1717 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1718 | // Calculate wakelock times across all uids. |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1719 | long fullWakeLockTimeTotalMicros = 0; |
| 1720 | long partialWakeLockTimeTotalMicros = 0; |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1721 | |
| 1722 | final Comparator<TimerEntry> timerComparator = new Comparator<TimerEntry>() { |
| 1723 | @Override |
| 1724 | public int compare(TimerEntry lhs, TimerEntry rhs) { |
| 1725 | long lhsTime = lhs.mTime; |
| 1726 | long rhsTime = rhs.mTime; |
| 1727 | if (lhsTime < rhsTime) { |
| 1728 | return 1; |
| 1729 | } |
| 1730 | if (lhsTime > rhsTime) { |
| 1731 | return -1; |
| 1732 | } |
| 1733 | return 0; |
| 1734 | } |
| 1735 | }; |
| 1736 | |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1737 | if (reqUid < 0) { |
| 1738 | Map<String, ? extends BatteryStats.Timer> kernelWakelocks = getKernelWakelockStats(); |
| 1739 | if (kernelWakelocks.size() > 0) { |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1740 | final ArrayList<TimerEntry> timers = new ArrayList<TimerEntry>(); |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1741 | for (Map.Entry<String, ? extends BatteryStats.Timer> ent : kernelWakelocks.entrySet()) { |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1742 | BatteryStats.Timer timer = ent.getValue(); |
| 1743 | long totalTimeMillis = computeWakeLock(timer, batteryRealtime, which); |
| 1744 | if (totalTimeMillis > 0) { |
| 1745 | timers.add(new TimerEntry(ent.getKey(), 0, timer, totalTimeMillis)); |
| 1746 | } |
| 1747 | } |
| 1748 | Collections.sort(timers, timerComparator); |
| 1749 | for (int i=0; i<timers.size(); i++) { |
| 1750 | TimerEntry timer = timers.get(i); |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1751 | String linePrefix = ": "; |
| 1752 | sb.setLength(0); |
| 1753 | sb.append(prefix); |
| 1754 | sb.append(" Kernel Wake lock "); |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1755 | sb.append(timer.mName); |
| 1756 | linePrefix = printWakeLock(sb, timer.mTimer, batteryRealtime, null, |
| 1757 | which, linePrefix); |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1758 | if (!linePrefix.equals(": ")) { |
| 1759 | sb.append(" realtime"); |
Jason Parks | 94b916d | 2010-07-20 12:39:07 -0500 | [diff] [blame] | 1760 | // Only print out wake locks that were held |
| 1761 | pw.println(sb.toString()); |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 1762 | } |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1763 | } |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1764 | } |
| 1765 | } |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1766 | |
| 1767 | final ArrayList<TimerEntry> timers = new ArrayList<TimerEntry>(); |
| 1768 | |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1769 | for (int iu = 0; iu < NU; iu++) { |
| 1770 | Uid u = uidStats.valueAt(iu); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 1771 | |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1772 | Map<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats(); |
| 1773 | if (wakelocks.size() > 0) { |
| 1774 | for (Map.Entry<String, ? extends BatteryStats.Uid.Wakelock> ent |
| 1775 | : wakelocks.entrySet()) { |
| 1776 | Uid.Wakelock wl = ent.getValue(); |
| 1777 | |
| 1778 | Timer fullWakeTimer = wl.getWakeTime(WAKE_TYPE_FULL); |
| 1779 | if (fullWakeTimer != null) { |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 1780 | fullWakeLockTimeTotalMicros += fullWakeTimer.getTotalTimeLocked( |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1781 | batteryRealtime, which); |
| 1782 | } |
| 1783 | |
| 1784 | Timer partialWakeTimer = wl.getWakeTime(WAKE_TYPE_PARTIAL); |
| 1785 | if (partialWakeTimer != null) { |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1786 | long totalTimeMicros = partialWakeTimer.getTotalTimeLocked( |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1787 | batteryRealtime, which); |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1788 | if (totalTimeMicros > 0) { |
| 1789 | if (reqUid < 0) { |
| 1790 | // Only show the ordered list of all wake |
| 1791 | // locks if the caller is not asking for data |
| 1792 | // about a specific uid. |
| 1793 | timers.add(new TimerEntry(ent.getKey(), u.getUid(), |
| 1794 | partialWakeTimer, totalTimeMicros)); |
| 1795 | } |
| 1796 | partialWakeLockTimeTotalMicros += totalTimeMicros; |
| 1797 | } |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1798 | } |
| 1799 | } |
| 1800 | } |
| 1801 | } |
| 1802 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1803 | long mobileRxTotalBytes = getNetworkActivityBytes(NETWORK_MOBILE_RX_DATA, which); |
| 1804 | long mobileTxTotalBytes = getNetworkActivityBytes(NETWORK_MOBILE_TX_DATA, which); |
| 1805 | long wifiRxTotalBytes = getNetworkActivityBytes(NETWORK_WIFI_RX_DATA, which); |
| 1806 | long wifiTxTotalBytes = getNetworkActivityBytes(NETWORK_WIFI_TX_DATA, which); |
| 1807 | long mobileRxTotalPackets = getNetworkActivityPackets(NETWORK_MOBILE_RX_DATA, which); |
| 1808 | long mobileTxTotalPackets = getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, which); |
| 1809 | long wifiRxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which); |
| 1810 | long wifiTxTotalPackets = getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which); |
| 1811 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1812 | pw.print(prefix); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1813 | pw.print(" Mobile total received: "); pw.print(formatBytesLocked(mobileRxTotalBytes)); |
| 1814 | pw.print(", sent: "); pw.print(formatBytesLocked(mobileTxTotalBytes)); |
| 1815 | pw.print(" (packets received "); pw.print(mobileRxTotalPackets); |
| 1816 | pw.print(", sent "); pw.print(mobileTxTotalPackets); pw.println(")"); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 1817 | pw.print(prefix); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 1818 | pw.print(" Wi-Fi total received: "); pw.print(formatBytesLocked(wifiRxTotalBytes)); |
| 1819 | pw.print(", sent: "); pw.print(formatBytesLocked(wifiTxTotalBytes)); |
| 1820 | pw.print(" (packets received "); pw.print(wifiRxTotalPackets); |
| 1821 | pw.print(", sent "); pw.print(wifiTxTotalPackets); pw.println(")"); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1822 | sb.setLength(0); |
| 1823 | sb.append(prefix); |
| 1824 | sb.append(" Total full wakelock time: "); formatTimeMs(sb, |
| 1825 | (fullWakeLockTimeTotalMicros + 500) / 1000); |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1826 | sb.append(", Total partial wakelock time: "); formatTimeMs(sb, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1827 | (partialWakeLockTimeTotalMicros + 500) / 1000); |
| 1828 | pw.println(sb.toString()); |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 1829 | |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1830 | sb.setLength(0); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1831 | sb.append(prefix); |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 1832 | sb.append(" Signal levels:"); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1833 | didOne = false; |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 1834 | for (int i=0; i<SignalStrength.NUM_SIGNAL_STRENGTH_BINS; i++) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1835 | final long time = getPhoneSignalStrengthTime(i, batteryRealtime, which); |
| 1836 | if (time == 0) { |
| 1837 | continue; |
| 1838 | } |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 1839 | sb.append("\n "); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1840 | didOne = true; |
Wink Saville | 5284090 | 2011-02-18 12:40:47 -0800 | [diff] [blame] | 1841 | sb.append(SignalStrength.SIGNAL_STRENGTH_NAMES[i]); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1842 | sb.append(" "); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1843 | formatTimeMs(sb, time/1000); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1844 | sb.append("("); |
| 1845 | sb.append(formatRatioLocked(time, whichBatteryRealtime)); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1846 | sb.append(") "); |
| 1847 | sb.append(getPhoneSignalStrengthCount(i, which)); |
| 1848 | sb.append("x"); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1849 | } |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 1850 | if (!didOne) sb.append(" (no activity)"); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1851 | pw.println(sb.toString()); |
Amith Yamasani | f37447b | 2009-10-08 18:28:01 -0700 | [diff] [blame] | 1852 | |
| 1853 | sb.setLength(0); |
| 1854 | sb.append(prefix); |
| 1855 | sb.append(" Signal scanning time: "); |
| 1856 | formatTimeMs(sb, getPhoneSignalScanningTime(batteryRealtime, which) / 1000); |
| 1857 | pw.println(sb.toString()); |
| 1858 | |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1859 | sb.setLength(0); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1860 | sb.append(prefix); |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 1861 | sb.append(" Radio types:"); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1862 | didOne = false; |
| 1863 | for (int i=0; i<NUM_DATA_CONNECTION_TYPES; i++) { |
| 1864 | final long time = getPhoneDataConnectionTime(i, batteryRealtime, which); |
| 1865 | if (time == 0) { |
| 1866 | continue; |
| 1867 | } |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 1868 | sb.append("\n "); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1869 | didOne = true; |
| 1870 | sb.append(DATA_CONNECTION_NAMES[i]); |
| 1871 | sb.append(" "); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1872 | formatTimeMs(sb, time/1000); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1873 | sb.append("("); |
| 1874 | sb.append(formatRatioLocked(time, whichBatteryRealtime)); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1875 | sb.append(") "); |
| 1876 | sb.append(getPhoneDataConnectionCount(i, which)); |
| 1877 | sb.append("x"); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1878 | } |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 1879 | if (!didOne) sb.append(" (no activity)"); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1880 | pw.println(sb.toString()); |
Amith Yamasani | 3f7e35c | 2009-07-13 16:02:45 -0700 | [diff] [blame] | 1881 | |
| 1882 | sb.setLength(0); |
| 1883 | sb.append(prefix); |
| 1884 | sb.append(" Radio data uptime when unplugged: "); |
| 1885 | sb.append(getRadioDataUptime() / 1000); |
| 1886 | sb.append(" ms"); |
| 1887 | pw.println(sb.toString()); |
| 1888 | |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1889 | sb.setLength(0); |
| 1890 | sb.append(prefix); |
| 1891 | sb.append(" Wifi on: "); formatTimeMs(sb, wifiOnTime / 1000); |
| 1892 | sb.append("("); sb.append(formatRatioLocked(wifiOnTime, whichBatteryRealtime)); |
| 1893 | sb.append("), Wifi running: "); formatTimeMs(sb, wifiRunningTime / 1000); |
| 1894 | sb.append("("); sb.append(formatRatioLocked(wifiRunningTime, whichBatteryRealtime)); |
| 1895 | sb.append("), Bluetooth on: "); formatTimeMs(sb, bluetoothOnTime / 1000); |
| 1896 | sb.append("("); sb.append(formatRatioLocked(bluetoothOnTime, whichBatteryRealtime)); |
| 1897 | sb.append(")"); |
| 1898 | pw.println(sb.toString()); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1899 | |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1900 | pw.println(" "); |
| 1901 | |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 1902 | if (which == STATS_SINCE_UNPLUGGED) { |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1903 | if (getIsOnBattery()) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1904 | pw.print(prefix); pw.println(" Device is currently unplugged"); |
| 1905 | pw.print(prefix); pw.print(" Discharge cycle start level: "); |
| 1906 | pw.println(getDischargeStartLevel()); |
| 1907 | pw.print(prefix); pw.print(" Discharge cycle current level: "); |
| 1908 | pw.println(getDischargeCurrentLevel()); |
Dianne Hackborn | 99d0452 | 2010-08-20 13:43:00 -0700 | [diff] [blame] | 1909 | } else { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 1910 | pw.print(prefix); pw.println(" Device is currently plugged into power"); |
| 1911 | pw.print(prefix); pw.print(" Last discharge cycle start level: "); |
| 1912 | pw.println(getDischargeStartLevel()); |
| 1913 | pw.print(prefix); pw.print(" Last discharge cycle end level: "); |
| 1914 | pw.println(getDischargeCurrentLevel()); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1915 | } |
Dianne Hackborn | c1b40e3 | 2011-01-05 18:27:40 -0800 | [diff] [blame] | 1916 | pw.print(prefix); pw.print(" Amount discharged while screen on: "); |
| 1917 | pw.println(getDischargeAmountScreenOn()); |
| 1918 | pw.print(prefix); pw.print(" Amount discharged while screen off: "); |
| 1919 | pw.println(getDischargeAmountScreenOff()); |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 1920 | pw.println(" "); |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 1921 | } else { |
| 1922 | pw.print(prefix); pw.println(" Device battery use since last full charge"); |
| 1923 | pw.print(prefix); pw.print(" Amount discharged (lower bound): "); |
| 1924 | pw.println(getLowDischargeAmountSinceCharge()); |
| 1925 | pw.print(prefix); pw.print(" Amount discharged (upper bound): "); |
| 1926 | pw.println(getHighDischargeAmountSinceCharge()); |
Dianne Hackborn | c1b40e3 | 2011-01-05 18:27:40 -0800 | [diff] [blame] | 1927 | pw.print(prefix); pw.print(" Amount discharged while screen on: "); |
| 1928 | pw.println(getDischargeAmountScreenOnSinceCharge()); |
| 1929 | pw.print(prefix); pw.print(" Amount discharged while screen off: "); |
| 1930 | pw.println(getDischargeAmountScreenOffSinceCharge()); |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1931 | pw.println(); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 1932 | } |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1933 | |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1934 | BatteryStatsHelper helper = new BatteryStatsHelper(context); |
| 1935 | helper.create(this); |
| 1936 | helper.refreshStats(which, UserHandle.USER_ALL); |
| 1937 | List<BatterySipper> sippers = helper.getUsageList(); |
| 1938 | if (sippers != null && sippers.size() > 0) { |
| 1939 | pw.print(prefix); pw.println(" Estimated power use (mAh):"); |
| 1940 | pw.print(prefix); pw.print(" Capacity: "); |
| 1941 | printmAh(pw, helper.getPowerProfile().getBatteryCapacity()); |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 1942 | pw.print(", Computed drain: "); printmAh(pw, helper.getComputedPower()); |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1943 | pw.print(", Min drain: "); printmAh(pw, helper.getMinDrainedPower()); |
| 1944 | pw.print(", Max drain: "); printmAh(pw, helper.getMaxDrainedPower()); |
| 1945 | pw.println(); |
| 1946 | for (int i=0; i<sippers.size(); i++) { |
| 1947 | BatterySipper bs = sippers.get(i); |
| 1948 | switch (bs.drainType) { |
| 1949 | case IDLE: |
| 1950 | pw.print(prefix); pw.print(" Idle: "); printmAh(pw, bs.value); |
| 1951 | pw.println(); |
| 1952 | break; |
| 1953 | case CELL: |
| 1954 | pw.print(prefix); pw.print(" Cell standby: "); printmAh(pw, bs.value); |
| 1955 | pw.println(); |
| 1956 | break; |
| 1957 | case PHONE: |
| 1958 | pw.print(prefix); pw.print(" Phone calls: "); printmAh(pw, bs.value); |
| 1959 | pw.println(); |
| 1960 | break; |
| 1961 | case WIFI: |
| 1962 | pw.print(prefix); pw.print(" Wifi: "); printmAh(pw, bs.value); |
| 1963 | pw.println(); |
| 1964 | break; |
| 1965 | case BLUETOOTH: |
| 1966 | pw.print(prefix); pw.print(" Bluetooth: "); printmAh(pw, bs.value); |
| 1967 | pw.println(); |
| 1968 | break; |
| 1969 | case SCREEN: |
| 1970 | pw.print(prefix); pw.print(" Screen: "); printmAh(pw, bs.value); |
| 1971 | pw.println(); |
| 1972 | break; |
| 1973 | case APP: |
| 1974 | pw.print(prefix); pw.print(" Uid "); pw.print(bs.uidObj.getUid()); |
| 1975 | pw.print(": "); printmAh(pw, bs.value); pw.println(); |
| 1976 | break; |
| 1977 | case USER: |
| 1978 | pw.print(prefix); pw.print(" User "); pw.print(bs.userId); |
| 1979 | pw.print(": "); printmAh(pw, bs.value); pw.println(); |
| 1980 | break; |
| 1981 | case UNACCOUNTED: |
| 1982 | pw.print(prefix); pw.print(" Unaccounted: "); printmAh(pw, bs.value); |
| 1983 | pw.println(); |
| 1984 | break; |
| 1985 | case OVERCOUNTED: |
| 1986 | pw.print(prefix); pw.print(" Over-counted: "); printmAh(pw, bs.value); |
| 1987 | pw.println(); |
| 1988 | break; |
| 1989 | } |
| 1990 | } |
Dianne Hackborn | c46809e | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1991 | pw.println(); |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 1992 | } |
| 1993 | |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 1994 | if (timers.size() > 0) { |
| 1995 | Collections.sort(timers, timerComparator); |
| 1996 | pw.print(prefix); pw.println(" All partial wake locks:"); |
| 1997 | for (int i=0; i<timers.size(); i++) { |
| 1998 | TimerEntry timer = timers.get(i); |
| 1999 | sb.setLength(0); |
Dianne Hackborn | a4cc205 | 2013-07-08 17:31:25 -0700 | [diff] [blame] | 2000 | sb.append(" Wake lock "); |
| 2001 | UserHandle.formatUid(sb, timer.mId); |
Dianne Hackborn | 8103890 | 2012-11-26 17:04:09 -0800 | [diff] [blame] | 2002 | sb.append(" "); |
| 2003 | sb.append(timer.mName); |
| 2004 | printWakeLock(sb, timer.mTimer, batteryRealtime, null, which, ": "); |
| 2005 | sb.append(" realtime"); |
| 2006 | pw.println(sb.toString()); |
| 2007 | } |
| 2008 | timers.clear(); |
| 2009 | pw.println(); |
| 2010 | } |
Evan Millar | 22ac043 | 2009-03-31 11:33:18 -0700 | [diff] [blame] | 2011 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2012 | for (int iu=0; iu<NU; iu++) { |
| 2013 | final int uid = uidStats.keyAt(iu); |
Dianne Hackborn | e4a5951 | 2010-12-07 11:08:07 -0800 | [diff] [blame] | 2014 | if (reqUid >= 0 && uid != reqUid && uid != Process.SYSTEM_UID) { |
Dianne Hackborn | 21f1bd1 | 2010-02-19 17:02:21 -0800 | [diff] [blame] | 2015 | continue; |
| 2016 | } |
| 2017 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2018 | Uid u = uidStats.valueAt(iu); |
Dianne Hackborn | a4cc205 | 2013-07-08 17:31:25 -0700 | [diff] [blame] | 2019 | |
| 2020 | pw.print(prefix); |
| 2021 | pw.print(" "); |
| 2022 | UserHandle.formatUid(pw, uid); |
| 2023 | pw.println(":"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2024 | boolean uidActivity = false; |
| 2025 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2026 | long mobileRxBytes = u.getNetworkActivityBytes(NETWORK_MOBILE_RX_DATA, which); |
| 2027 | long mobileTxBytes = u.getNetworkActivityBytes(NETWORK_MOBILE_TX_DATA, which); |
| 2028 | long wifiRxBytes = u.getNetworkActivityBytes(NETWORK_WIFI_RX_DATA, which); |
| 2029 | long wifiTxBytes = u.getNetworkActivityBytes(NETWORK_WIFI_TX_DATA, which); |
| 2030 | long mobileRxPackets = u.getNetworkActivityPackets(NETWORK_MOBILE_RX_DATA, which); |
| 2031 | long mobileTxPackets = u.getNetworkActivityPackets(NETWORK_MOBILE_TX_DATA, which); |
| 2032 | long wifiRxPackets = u.getNetworkActivityPackets(NETWORK_WIFI_RX_DATA, which); |
| 2033 | long wifiTxPackets = u.getNetworkActivityPackets(NETWORK_WIFI_TX_DATA, which); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2034 | long fullWifiLockOnTime = u.getFullWifiLockTime(batteryRealtime, which); |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 2035 | long wifiScanTime = u.getWifiScanTime(batteryRealtime, which); |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 2036 | long uidWifiRunningTime = u.getWifiRunningTime(batteryRealtime, which); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 2037 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2038 | if (mobileRxBytes > 0 || mobileTxBytes > 0 |
| 2039 | || mobileRxPackets > 0 || mobileTxPackets > 0) { |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 2040 | pw.print(prefix); pw.print(" Mobile network: "); |
| 2041 | pw.print(formatBytesLocked(mobileRxBytes)); pw.print(" received, "); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2042 | pw.print(formatBytesLocked(mobileTxBytes)); |
| 2043 | pw.print(" sent (packets "); pw.print(mobileRxPackets); |
| 2044 | pw.print(" received, "); pw.print(mobileTxPackets); pw.println(" sent)"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2045 | } |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2046 | if (wifiRxBytes > 0 || wifiTxBytes > 0 || wifiRxPackets > 0 || wifiTxPackets > 0) { |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 2047 | pw.print(prefix); pw.print(" Wi-Fi network: "); |
| 2048 | pw.print(formatBytesLocked(wifiRxBytes)); pw.print(" received, "); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2049 | pw.print(formatBytesLocked(wifiTxBytes)); |
| 2050 | pw.print(" sent (packets "); pw.print(wifiRxPackets); |
| 2051 | pw.print(" received, "); pw.print(wifiTxPackets); pw.println(" sent)"); |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 2052 | } |
| 2053 | |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 2054 | if (u.hasUserActivity()) { |
| 2055 | boolean hasData = false; |
Raph Levien | 4c7a4a7 | 2012-08-03 14:32:39 -0700 | [diff] [blame] | 2056 | for (int i=0; i<Uid.NUM_USER_ACTIVITY_TYPES; i++) { |
Dianne Hackborn | 617f877 | 2009-03-31 15:04:46 -0700 | [diff] [blame] | 2057 | int val = u.getUserActivityCount(i, which); |
| 2058 | if (val != 0) { |
| 2059 | if (!hasData) { |
| 2060 | sb.setLength(0); |
| 2061 | sb.append(" User activity: "); |
| 2062 | hasData = true; |
| 2063 | } else { |
| 2064 | sb.append(", "); |
| 2065 | } |
| 2066 | sb.append(val); |
| 2067 | sb.append(" "); |
| 2068 | sb.append(Uid.USER_ACTIVITY_TYPES[i]); |
| 2069 | } |
| 2070 | } |
| 2071 | if (hasData) { |
| 2072 | pw.println(sb.toString()); |
| 2073 | } |
| 2074 | } |
| 2075 | |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 2076 | if (fullWifiLockOnTime != 0 || wifiScanTime != 0 |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 2077 | || uidWifiRunningTime != 0) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2078 | sb.setLength(0); |
Dianne Hackborn | 58e0eef | 2010-09-16 01:22:10 -0700 | [diff] [blame] | 2079 | sb.append(prefix); sb.append(" Wifi Running: "); |
| 2080 | formatTimeMs(sb, uidWifiRunningTime / 1000); |
| 2081 | sb.append("("); sb.append(formatRatioLocked(uidWifiRunningTime, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2082 | whichBatteryRealtime)); sb.append(")\n"); |
| 2083 | sb.append(prefix); sb.append(" Full Wifi Lock: "); |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 2084 | formatTimeMs(sb, fullWifiLockOnTime / 1000); |
| 2085 | sb.append("("); sb.append(formatRatioLocked(fullWifiLockOnTime, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2086 | whichBatteryRealtime)); sb.append(")\n"); |
Nick Pelly | 6ccaa54 | 2012-06-15 15:22:47 -0700 | [diff] [blame] | 2087 | sb.append(prefix); sb.append(" Wifi Scan: "); |
| 2088 | formatTimeMs(sb, wifiScanTime / 1000); |
| 2089 | sb.append("("); sb.append(formatRatioLocked(wifiScanTime, |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2090 | whichBatteryRealtime)); sb.append(")"); |
| 2091 | pw.println(sb.toString()); |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 2092 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2093 | |
| 2094 | Map<String, ? extends BatteryStats.Uid.Wakelock> wakelocks = u.getWakelockStats(); |
| 2095 | if (wakelocks.size() > 0) { |
Dianne Hackborn | c24ab86 | 2011-10-18 15:55:03 -0700 | [diff] [blame] | 2096 | long totalFull = 0, totalPartial = 0, totalWindow = 0; |
| 2097 | int count = 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2098 | for (Map.Entry<String, ? extends BatteryStats.Uid.Wakelock> ent |
| 2099 | : wakelocks.entrySet()) { |
| 2100 | Uid.Wakelock wl = ent.getValue(); |
| 2101 | String linePrefix = ": "; |
| 2102 | sb.setLength(0); |
| 2103 | sb.append(prefix); |
| 2104 | sb.append(" Wake lock "); |
| 2105 | sb.append(ent.getKey()); |
| 2106 | linePrefix = printWakeLock(sb, wl.getWakeTime(WAKE_TYPE_FULL), batteryRealtime, |
| 2107 | "full", which, linePrefix); |
| 2108 | linePrefix = printWakeLock(sb, wl.getWakeTime(WAKE_TYPE_PARTIAL), batteryRealtime, |
| 2109 | "partial", which, linePrefix); |
| 2110 | linePrefix = printWakeLock(sb, wl.getWakeTime(WAKE_TYPE_WINDOW), batteryRealtime, |
| 2111 | "window", which, linePrefix); |
| 2112 | if (!linePrefix.equals(": ")) { |
| 2113 | sb.append(" realtime"); |
Jason Parks | 94b916d | 2010-07-20 12:39:07 -0500 | [diff] [blame] | 2114 | // Only print out wake locks that were held |
| 2115 | pw.println(sb.toString()); |
| 2116 | uidActivity = true; |
Dianne Hackborn | c24ab86 | 2011-10-18 15:55:03 -0700 | [diff] [blame] | 2117 | count++; |
| 2118 | } |
| 2119 | totalFull += computeWakeLock(wl.getWakeTime(WAKE_TYPE_FULL), |
| 2120 | batteryRealtime, which); |
| 2121 | totalPartial += computeWakeLock(wl.getWakeTime(WAKE_TYPE_PARTIAL), |
| 2122 | batteryRealtime, which); |
| 2123 | totalWindow += computeWakeLock(wl.getWakeTime(WAKE_TYPE_WINDOW), |
| 2124 | batteryRealtime, which); |
| 2125 | } |
| 2126 | if (count > 1) { |
| 2127 | if (totalFull != 0 || totalPartial != 0 || totalWindow != 0) { |
| 2128 | sb.setLength(0); |
| 2129 | sb.append(prefix); |
| 2130 | sb.append(" TOTAL wake: "); |
| 2131 | boolean needComma = false; |
| 2132 | if (totalFull != 0) { |
| 2133 | needComma = true; |
| 2134 | formatTimeMs(sb, totalFull); |
| 2135 | sb.append("full"); |
| 2136 | } |
| 2137 | if (totalPartial != 0) { |
| 2138 | if (needComma) { |
| 2139 | sb.append(", "); |
| 2140 | } |
| 2141 | needComma = true; |
| 2142 | formatTimeMs(sb, totalPartial); |
| 2143 | sb.append("partial"); |
| 2144 | } |
| 2145 | if (totalWindow != 0) { |
| 2146 | if (needComma) { |
| 2147 | sb.append(", "); |
| 2148 | } |
| 2149 | needComma = true; |
| 2150 | formatTimeMs(sb, totalWindow); |
| 2151 | sb.append("window"); |
| 2152 | } |
| 2153 | sb.append(" realtime"); |
| 2154 | pw.println(sb.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2155 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2156 | } |
| 2157 | } |
| 2158 | |
| 2159 | Map<Integer, ? extends BatteryStats.Uid.Sensor> sensors = u.getSensorStats(); |
| 2160 | if (sensors.size() > 0) { |
| 2161 | for (Map.Entry<Integer, ? extends BatteryStats.Uid.Sensor> ent |
| 2162 | : sensors.entrySet()) { |
| 2163 | Uid.Sensor se = ent.getValue(); |
| 2164 | int sensorNumber = ent.getKey(); |
| 2165 | sb.setLength(0); |
| 2166 | sb.append(prefix); |
| 2167 | sb.append(" Sensor "); |
| 2168 | int handle = se.getHandle(); |
| 2169 | if (handle == Uid.Sensor.GPS) { |
| 2170 | sb.append("GPS"); |
| 2171 | } else { |
| 2172 | sb.append(handle); |
| 2173 | } |
| 2174 | sb.append(": "); |
| 2175 | |
| 2176 | Timer timer = se.getSensorTime(); |
| 2177 | if (timer != null) { |
| 2178 | // Convert from microseconds to milliseconds with rounding |
Evan Millar | c64edde | 2009-04-18 12:26:32 -0700 | [diff] [blame] | 2179 | long totalTime = (timer.getTotalTimeLocked( |
| 2180 | batteryRealtime, which) + 500) / 1000; |
| 2181 | int count = timer.getCountLocked(which); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2182 | //timer.logState(); |
| 2183 | if (totalTime != 0) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2184 | formatTimeMs(sb, totalTime); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2185 | sb.append("realtime ("); |
| 2186 | sb.append(count); |
| 2187 | sb.append(" times)"); |
| 2188 | } else { |
| 2189 | sb.append("(not used)"); |
| 2190 | } |
| 2191 | } else { |
| 2192 | sb.append("(not used)"); |
| 2193 | } |
| 2194 | |
| 2195 | pw.println(sb.toString()); |
| 2196 | uidActivity = true; |
| 2197 | } |
| 2198 | } |
| 2199 | |
Dianne Hackborn | a06de0f | 2012-12-11 16:34:47 -0800 | [diff] [blame] | 2200 | Timer vibTimer = u.getVibratorOnTimer(); |
| 2201 | if (vibTimer != null) { |
| 2202 | // Convert from microseconds to milliseconds with rounding |
| 2203 | long totalTime = (vibTimer.getTotalTimeLocked( |
| 2204 | batteryRealtime, which) + 500) / 1000; |
| 2205 | int count = vibTimer.getCountLocked(which); |
| 2206 | //timer.logState(); |
| 2207 | if (totalTime != 0) { |
| 2208 | sb.setLength(0); |
| 2209 | sb.append(prefix); |
| 2210 | sb.append(" Vibrator: "); |
| 2211 | formatTimeMs(sb, totalTime); |
| 2212 | sb.append("realtime ("); |
| 2213 | sb.append(count); |
| 2214 | sb.append(" times)"); |
| 2215 | pw.println(sb.toString()); |
| 2216 | uidActivity = true; |
| 2217 | } |
| 2218 | } |
| 2219 | |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 2220 | Timer fgTimer = u.getForegroundActivityTimer(); |
| 2221 | if (fgTimer != null) { |
| 2222 | // Convert from microseconds to milliseconds with rounding |
| 2223 | long totalTime = (fgTimer.getTotalTimeLocked(batteryRealtime, which) + 500) / 1000; |
| 2224 | int count = fgTimer.getCountLocked(which); |
| 2225 | if (totalTime != 0) { |
| 2226 | sb.setLength(0); |
| 2227 | sb.append(prefix); |
| 2228 | sb.append(" Foreground activities: "); |
| 2229 | formatTimeMs(sb, totalTime); |
| 2230 | sb.append("realtime ("); |
| 2231 | sb.append(count); |
| 2232 | sb.append(" times)"); |
| 2233 | pw.println(sb.toString()); |
| 2234 | uidActivity = true; |
| 2235 | } |
| 2236 | } |
| 2237 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2238 | Map<String, ? extends BatteryStats.Uid.Proc> processStats = u.getProcessStats(); |
| 2239 | if (processStats.size() > 0) { |
| 2240 | for (Map.Entry<String, ? extends BatteryStats.Uid.Proc> ent |
| 2241 | : processStats.entrySet()) { |
| 2242 | Uid.Proc ps = ent.getValue(); |
| 2243 | long userTime; |
| 2244 | long systemTime; |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 2245 | long foregroundTime; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2246 | int starts; |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 2247 | int numExcessive; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2248 | |
| 2249 | userTime = ps.getUserTime(which); |
| 2250 | systemTime = ps.getSystemTime(which); |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 2251 | foregroundTime = ps.getForegroundTime(which); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2252 | starts = ps.getStarts(which); |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 2253 | numExcessive = which == STATS_SINCE_CHARGED |
Dianne Hackborn | 287952c | 2010-09-22 22:34:31 -0700 | [diff] [blame] | 2254 | ? ps.countExcessivePowers() : 0; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2255 | |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 2256 | if (userTime != 0 || systemTime != 0 || foregroundTime != 0 || starts != 0 |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 2257 | || numExcessive != 0) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2258 | sb.setLength(0); |
| 2259 | sb.append(prefix); sb.append(" Proc "); |
| 2260 | sb.append(ent.getKey()); sb.append(":\n"); |
| 2261 | sb.append(prefix); sb.append(" CPU: "); |
| 2262 | formatTime(sb, userTime); sb.append("usr + "); |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 2263 | formatTime(sb, systemTime); sb.append("krn ; "); |
| 2264 | formatTime(sb, foregroundTime); sb.append("fg"); |
Dianne Hackborn | 0d903a8 | 2010-09-07 23:51:03 -0700 | [diff] [blame] | 2265 | if (starts != 0) { |
Dianne Hackborn | b8071d79 | 2010-09-09 16:45:15 -0700 | [diff] [blame] | 2266 | sb.append("\n"); sb.append(prefix); sb.append(" "); |
| 2267 | sb.append(starts); sb.append(" proc starts"); |
Dianne Hackborn | 0d903a8 | 2010-09-07 23:51:03 -0700 | [diff] [blame] | 2268 | } |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2269 | pw.println(sb.toString()); |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 2270 | for (int e=0; e<numExcessive; e++) { |
Dianne Hackborn | 287952c | 2010-09-22 22:34:31 -0700 | [diff] [blame] | 2271 | Uid.Proc.ExcessivePower ew = ps.getExcessivePower(e); |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 2272 | if (ew != null) { |
Dianne Hackborn | 287952c | 2010-09-22 22:34:31 -0700 | [diff] [blame] | 2273 | pw.print(prefix); pw.print(" * Killed for "); |
| 2274 | if (ew.type == Uid.Proc.ExcessivePower.TYPE_WAKE) { |
| 2275 | pw.print("wake lock"); |
| 2276 | } else if (ew.type == Uid.Proc.ExcessivePower.TYPE_CPU) { |
| 2277 | pw.print("cpu"); |
| 2278 | } else { |
| 2279 | pw.print("unknown"); |
| 2280 | } |
| 2281 | pw.print(" use: "); |
Dianne Hackborn | 1ebccf5 | 2010-08-15 13:04:34 -0700 | [diff] [blame] | 2282 | TimeUtils.formatDuration(ew.usedTime, pw); |
| 2283 | pw.print(" over "); |
| 2284 | TimeUtils.formatDuration(ew.overTime, pw); |
Robert Greenwalt | a029ea1 | 2013-09-25 16:38:12 -0700 | [diff] [blame] | 2285 | if (ew.overTime != 0) { |
| 2286 | pw.print(" ("); |
| 2287 | pw.print((ew.usedTime*100)/ew.overTime); |
| 2288 | pw.println("%)"); |
| 2289 | } |
Dianne Hackborn | 9adb9c3 | 2010-08-13 14:09:56 -0700 | [diff] [blame] | 2290 | } |
| 2291 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2292 | uidActivity = true; |
| 2293 | } |
| 2294 | } |
| 2295 | } |
| 2296 | |
| 2297 | Map<String, ? extends BatteryStats.Uid.Pkg> packageStats = u.getPackageStats(); |
| 2298 | if (packageStats.size() > 0) { |
| 2299 | for (Map.Entry<String, ? extends BatteryStats.Uid.Pkg> ent |
| 2300 | : packageStats.entrySet()) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2301 | pw.print(prefix); pw.print(" Apk "); pw.print(ent.getKey()); pw.println(":"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2302 | boolean apkActivity = false; |
| 2303 | Uid.Pkg ps = ent.getValue(); |
| 2304 | int wakeups = ps.getWakeups(which); |
| 2305 | if (wakeups != 0) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2306 | pw.print(prefix); pw.print(" "); |
| 2307 | pw.print(wakeups); pw.println(" wakeup alarms"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2308 | apkActivity = true; |
| 2309 | } |
| 2310 | Map<String, ? extends Uid.Pkg.Serv> serviceStats = ps.getServiceStats(); |
| 2311 | if (serviceStats.size() > 0) { |
| 2312 | for (Map.Entry<String, ? extends BatteryStats.Uid.Pkg.Serv> sent |
| 2313 | : serviceStats.entrySet()) { |
| 2314 | BatteryStats.Uid.Pkg.Serv ss = sent.getValue(); |
| 2315 | long startTime = ss.getStartTime(batteryUptime, which); |
| 2316 | int starts = ss.getStarts(which); |
| 2317 | int launches = ss.getLaunches(which); |
| 2318 | if (startTime != 0 || starts != 0 || launches != 0) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2319 | sb.setLength(0); |
| 2320 | sb.append(prefix); sb.append(" Service "); |
| 2321 | sb.append(sent.getKey()); sb.append(":\n"); |
| 2322 | sb.append(prefix); sb.append(" Created for: "); |
| 2323 | formatTimeMs(sb, startTime / 1000); |
Jeff Sharkey | 3e013e8 | 2013-04-25 14:48:19 -0700 | [diff] [blame] | 2324 | sb.append("uptime\n"); |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2325 | sb.append(prefix); sb.append(" Starts: "); |
| 2326 | sb.append(starts); |
| 2327 | sb.append(", launches: "); sb.append(launches); |
| 2328 | pw.println(sb.toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2329 | apkActivity = true; |
| 2330 | } |
| 2331 | } |
| 2332 | } |
| 2333 | if (!apkActivity) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2334 | pw.print(prefix); pw.println(" (nothing executed)"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2335 | } |
| 2336 | uidActivity = true; |
| 2337 | } |
| 2338 | } |
| 2339 | if (!uidActivity) { |
Dianne Hackborn | 1d442e0 | 2009-04-20 18:14:05 -0700 | [diff] [blame] | 2340 | pw.print(prefix); pw.println(" (nothing executed)"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2341 | } |
| 2342 | } |
| 2343 | } |
| 2344 | |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2345 | static void printBitDescriptions(PrintWriter pw, int oldval, int newval, HistoryTag wakelockTag, |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2346 | BitDescription[] descriptions, boolean longNames) { |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 2347 | int diff = oldval ^ newval; |
| 2348 | if (diff == 0) return; |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2349 | boolean didWake = false; |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 2350 | for (int i=0; i<descriptions.length; i++) { |
| 2351 | BitDescription bd = descriptions[i]; |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2352 | if ((diff&bd.mask) != 0) { |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2353 | pw.print(longNames ? " " : ","); |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 2354 | if (bd.shift < 0) { |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2355 | pw.print((newval&bd.mask) != 0 ? "+" : "-"); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2356 | pw.print(longNames ? bd.name : bd.shortName); |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2357 | if (bd.mask == HistoryItem.STATE_WAKE_LOCK_FLAG && wakelockTag != null) { |
| 2358 | didWake = true; |
| 2359 | pw.print("="); |
| 2360 | if (longNames) { |
| 2361 | UserHandle.formatUid(pw, wakelockTag.uid); |
| 2362 | pw.print(":\""); |
| 2363 | pw.print(wakelockTag.string); |
| 2364 | pw.print("\""); |
| 2365 | } else { |
| 2366 | pw.print(wakelockTag.poolIdx); |
| 2367 | } |
| 2368 | } |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 2369 | } else { |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2370 | pw.print(longNames ? bd.name : bd.shortName); |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 2371 | pw.print("="); |
| 2372 | int val = (newval&bd.mask)>>bd.shift; |
| 2373 | if (bd.values != null && val >= 0 && val < bd.values.length) { |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2374 | pw.print(longNames? bd.values[val] : bd.shortValues[val]); |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 2375 | } else { |
| 2376 | pw.print(val); |
| 2377 | } |
| 2378 | } |
| 2379 | } |
| 2380 | } |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2381 | if (!didWake && wakelockTag != null) { |
| 2382 | pw.print(longNames ? "wake_lock=" : "w="); |
| 2383 | if (longNames) { |
| 2384 | UserHandle.formatUid(pw, wakelockTag.uid); |
| 2385 | pw.print(":\""); |
| 2386 | pw.print(wakelockTag.string); |
| 2387 | pw.print("\""); |
| 2388 | } else { |
| 2389 | pw.print(wakelockTag.poolIdx); |
| 2390 | } |
| 2391 | } |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 2392 | } |
| 2393 | |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2394 | public void prepareForDumpLocked() { |
| 2395 | } |
| 2396 | |
| 2397 | public static class HistoryPrinter { |
| 2398 | int oldState = 0; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2399 | int oldLevel = -1; |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2400 | int oldStatus = -1; |
| 2401 | int oldHealth = -1; |
| 2402 | int oldPlug = -1; |
| 2403 | int oldTemp = -1; |
| 2404 | int oldVolt = -1; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2405 | long lastTime = -1; |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2406 | |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2407 | public void printNextItem(PrintWriter pw, HistoryItem rec, long now, boolean checkin) { |
| 2408 | if (!checkin) { |
| 2409 | pw.print(" "); |
| 2410 | TimeUtils.formatDuration(rec.time-now, pw, TimeUtils.HUNDRED_DAY_FIELD_LEN); |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2411 | pw.print(" ("); |
| 2412 | pw.print(rec.numReadInts); |
| 2413 | pw.print(") "); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2414 | } else { |
| 2415 | if (lastTime < 0) { |
| 2416 | pw.print("@"); |
| 2417 | pw.print(rec.time-now); |
| 2418 | } else { |
| 2419 | pw.print(rec.time-lastTime); |
| 2420 | } |
| 2421 | lastTime = rec.time; |
| 2422 | } |
| 2423 | if (rec.cmd == HistoryItem.CMD_START) { |
| 2424 | if (checkin) { |
| 2425 | pw.print(":"); |
| 2426 | } |
| 2427 | pw.println("START"); |
| 2428 | } else if (rec.cmd == HistoryItem.CMD_OVERFLOW) { |
| 2429 | if (checkin) { |
| 2430 | pw.print(":"); |
| 2431 | } |
| 2432 | pw.println("*OVERFLOW*"); |
| 2433 | } else { |
| 2434 | if (!checkin) { |
| 2435 | if (rec.batteryLevel < 10) pw.print("00"); |
| 2436 | else if (rec.batteryLevel < 100) pw.print("0"); |
| 2437 | pw.print(rec.batteryLevel); |
| 2438 | pw.print(" "); |
Dianne Hackborn | 3d658bf | 2014-02-05 13:38:56 -0800 | [diff] [blame^] | 2439 | if (rec.states < 0) ; |
| 2440 | else if (rec.states < 0x10) pw.print("0000000"); |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2441 | else if (rec.states < 0x100) pw.print("000000"); |
| 2442 | else if (rec.states < 0x1000) pw.print("00000"); |
| 2443 | else if (rec.states < 0x10000) pw.print("0000"); |
| 2444 | else if (rec.states < 0x100000) pw.print("000"); |
| 2445 | else if (rec.states < 0x1000000) pw.print("00"); |
| 2446 | else if (rec.states < 0x10000000) pw.print("0"); |
| 2447 | pw.print(Integer.toHexString(rec.states)); |
| 2448 | } else { |
| 2449 | if (oldLevel != rec.batteryLevel) { |
| 2450 | oldLevel = rec.batteryLevel; |
| 2451 | pw.print(",Bl="); pw.print(rec.batteryLevel); |
| 2452 | } |
| 2453 | } |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2454 | if (oldStatus != rec.batteryStatus) { |
| 2455 | oldStatus = rec.batteryStatus; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2456 | pw.print(checkin ? ",Bs=" : " status="); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2457 | switch (oldStatus) { |
| 2458 | case BatteryManager.BATTERY_STATUS_UNKNOWN: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2459 | pw.print(checkin ? "?" : "unknown"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2460 | break; |
| 2461 | case BatteryManager.BATTERY_STATUS_CHARGING: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2462 | pw.print(checkin ? "c" : "charging"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2463 | break; |
| 2464 | case BatteryManager.BATTERY_STATUS_DISCHARGING: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2465 | pw.print(checkin ? "d" : "discharging"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2466 | break; |
| 2467 | case BatteryManager.BATTERY_STATUS_NOT_CHARGING: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2468 | pw.print(checkin ? "n" : "not-charging"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2469 | break; |
| 2470 | case BatteryManager.BATTERY_STATUS_FULL: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2471 | pw.print(checkin ? "f" : "full"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2472 | break; |
| 2473 | default: |
| 2474 | pw.print(oldStatus); |
| 2475 | break; |
| 2476 | } |
| 2477 | } |
| 2478 | if (oldHealth != rec.batteryHealth) { |
| 2479 | oldHealth = rec.batteryHealth; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2480 | pw.print(checkin ? ",Bh=" : " health="); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2481 | switch (oldHealth) { |
| 2482 | case BatteryManager.BATTERY_HEALTH_UNKNOWN: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2483 | pw.print(checkin ? "?" : "unknown"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2484 | break; |
| 2485 | case BatteryManager.BATTERY_HEALTH_GOOD: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2486 | pw.print(checkin ? "g" : "good"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2487 | break; |
| 2488 | case BatteryManager.BATTERY_HEALTH_OVERHEAT: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2489 | pw.print(checkin ? "h" : "overheat"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2490 | break; |
| 2491 | case BatteryManager.BATTERY_HEALTH_DEAD: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2492 | pw.print(checkin ? "d" : "dead"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2493 | break; |
| 2494 | case BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2495 | pw.print(checkin ? "v" : "over-voltage"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2496 | break; |
| 2497 | case BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2498 | pw.print(checkin ? "f" : "failure"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2499 | break; |
| 2500 | default: |
| 2501 | pw.print(oldHealth); |
| 2502 | break; |
| 2503 | } |
| 2504 | } |
| 2505 | if (oldPlug != rec.batteryPlugType) { |
| 2506 | oldPlug = rec.batteryPlugType; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2507 | pw.print(checkin ? ",Bp=" : " plug="); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2508 | switch (oldPlug) { |
| 2509 | case 0: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2510 | pw.print(checkin ? "n" : "none"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2511 | break; |
| 2512 | case BatteryManager.BATTERY_PLUGGED_AC: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2513 | pw.print(checkin ? "a" : "ac"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2514 | break; |
| 2515 | case BatteryManager.BATTERY_PLUGGED_USB: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2516 | pw.print(checkin ? "u" : "usb"); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2517 | break; |
Brian Muramatsu | 37a37f4 | 2012-08-14 15:21:02 -0700 | [diff] [blame] | 2518 | case BatteryManager.BATTERY_PLUGGED_WIRELESS: |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2519 | pw.print(checkin ? "w" : "wireless"); |
Brian Muramatsu | 37a37f4 | 2012-08-14 15:21:02 -0700 | [diff] [blame] | 2520 | break; |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2521 | default: |
| 2522 | pw.print(oldPlug); |
| 2523 | break; |
| 2524 | } |
| 2525 | } |
| 2526 | if (oldTemp != rec.batteryTemperature) { |
| 2527 | oldTemp = rec.batteryTemperature; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2528 | pw.print(checkin ? ",Bt=" : " temp="); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2529 | pw.print(oldTemp); |
| 2530 | } |
| 2531 | if (oldVolt != rec.batteryVoltage) { |
| 2532 | oldVolt = rec.batteryVoltage; |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2533 | pw.print(checkin ? ",Bv=" : " volt="); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2534 | pw.print(oldVolt); |
| 2535 | } |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2536 | printBitDescriptions(pw, oldState, rec.states, rec.wakelockTag, |
Dianne Hackborn | 57ed6a6 | 2013-12-09 18:15:56 -0800 | [diff] [blame] | 2537 | HISTORY_STATE_DESCRIPTIONS, !checkin); |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 2538 | if (rec.eventCode != HistoryItem.EVENT_NONE) { |
| 2539 | switch (rec.eventCode) { |
| 2540 | case HistoryItem.EVENT_PROC_STARTED: |
| 2541 | pw.print(checkin ? ",PrSt=" : " procstart="); |
| 2542 | break; |
| 2543 | case HistoryItem.EVENT_PROC_FINISHED: |
| 2544 | pw.print(checkin ? ",PrFn=" : " procfin="); |
| 2545 | break; |
| 2546 | default: |
| 2547 | if (checkin) { |
| 2548 | pw.print(",?cmd_"); |
| 2549 | pw.print(rec.eventCode); |
| 2550 | pw.print("="); |
| 2551 | } else { |
| 2552 | pw.print(" cmd_"); |
| 2553 | pw.print(rec.eventCode); |
| 2554 | pw.print("="); |
| 2555 | } |
| 2556 | break; |
| 2557 | } |
| 2558 | if (checkin) { |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2559 | pw.print(rec.eventTag.poolIdx); |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 2560 | } else { |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2561 | UserHandle.formatUid(pw, rec.eventTag.uid); |
| 2562 | pw.print(":\""); |
| 2563 | pw.print(rec.eventTag.string); |
| 2564 | pw.print("\""); |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 2565 | } |
| 2566 | } |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2567 | pw.println(); |
| 2568 | } |
| 2569 | oldState = rec.states; |
| 2570 | } |
| 2571 | } |
| 2572 | |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2573 | private void printSizeValue(PrintWriter pw, long size) { |
| 2574 | float result = size; |
| 2575 | String suffix = ""; |
| 2576 | if (result >= 10*1024) { |
| 2577 | suffix = "KB"; |
| 2578 | result = result / 1024; |
| 2579 | } |
| 2580 | if (result >= 10*1024) { |
| 2581 | suffix = "MB"; |
| 2582 | result = result / 1024; |
| 2583 | } |
| 2584 | if (result >= 10*1024) { |
| 2585 | suffix = "GB"; |
| 2586 | result = result / 1024; |
| 2587 | } |
| 2588 | if (result >= 10*1024) { |
| 2589 | suffix = "TB"; |
| 2590 | result = result / 1024; |
| 2591 | } |
| 2592 | if (result >= 10*1024) { |
| 2593 | suffix = "PB"; |
| 2594 | result = result / 1024; |
| 2595 | } |
| 2596 | pw.print((int)result); |
| 2597 | pw.print(suffix); |
| 2598 | } |
| 2599 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2600 | /** |
| 2601 | * Dumps a human-readable summary of the battery statistics to the given PrintWriter. |
| 2602 | * |
| 2603 | * @param pw a Printer to receive the dump output. |
| 2604 | */ |
| 2605 | @SuppressWarnings("unused") |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 2606 | public void dumpLocked(Context context, PrintWriter pw, boolean isUnpluggedOnly, int reqUid, |
| 2607 | boolean historyOnly) { |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2608 | prepareForDumpLocked(); |
| 2609 | |
| 2610 | long now = getHistoryBaseTime() + SystemClock.elapsedRealtime(); |
| 2611 | |
Dianne Hackborn | ce2ef76 | 2010-09-20 11:39:14 -0700 | [diff] [blame] | 2612 | final HistoryItem rec = new HistoryItem(); |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2613 | final long historyTotalSize = getHistoryTotalSize(); |
| 2614 | final long historyUsedSize = getHistoryUsedSize(); |
Dianne Hackborn | ce2ef76 | 2010-09-20 11:39:14 -0700 | [diff] [blame] | 2615 | if (startIteratingHistoryLocked()) { |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2616 | try { |
| 2617 | pw.print("Battery History ("); |
| 2618 | pw.print((100*historyUsedSize)/historyTotalSize); |
| 2619 | pw.print("% used, "); |
| 2620 | printSizeValue(pw, historyUsedSize); |
| 2621 | pw.print(" used of "); |
| 2622 | printSizeValue(pw, historyTotalSize); |
| 2623 | pw.print(", "); |
| 2624 | pw.print(getHistoryStringPoolSize()); |
| 2625 | pw.print(" strings using "); |
| 2626 | printSizeValue(pw, getHistoryStringPoolBytes()); |
| 2627 | pw.println("):"); |
| 2628 | HistoryPrinter hprinter = new HistoryPrinter(); |
| 2629 | while (getNextHistoryLocked(rec)) { |
| 2630 | hprinter.printNextItem(pw, rec, now, false); |
| 2631 | } |
| 2632 | pw.println(); |
| 2633 | } finally { |
| 2634 | finishIteratingHistoryLocked(); |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 2635 | } |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2636 | } |
| 2637 | |
| 2638 | if (startIteratingOldHistoryLocked()) { |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2639 | try { |
| 2640 | pw.println("Old battery History:"); |
| 2641 | HistoryPrinter hprinter = new HistoryPrinter(); |
| 2642 | while (getNextOldHistoryLocked(rec)) { |
| 2643 | hprinter.printNextItem(pw, rec, now, false); |
| 2644 | } |
| 2645 | pw.println(); |
| 2646 | } finally { |
| 2647 | finishIteratingOldHistoryLocked(); |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2648 | } |
Dianne Hackborn | b5e3165 | 2010-09-07 12:13:55 -0700 | [diff] [blame] | 2649 | } |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 2650 | |
| 2651 | if (historyOnly) { |
| 2652 | return; |
| 2653 | } |
| 2654 | |
Dianne Hackborn | b5e3165 | 2010-09-07 12:13:55 -0700 | [diff] [blame] | 2655 | SparseArray<? extends Uid> uidStats = getUidStats(); |
| 2656 | final int NU = uidStats.size(); |
| 2657 | boolean didPid = false; |
| 2658 | long nowRealtime = SystemClock.elapsedRealtime(); |
Dianne Hackborn | b5e3165 | 2010-09-07 12:13:55 -0700 | [diff] [blame] | 2659 | for (int i=0; i<NU; i++) { |
| 2660 | Uid uid = uidStats.valueAt(i); |
| 2661 | SparseArray<? extends Uid.Pid> pids = uid.getPidStats(); |
| 2662 | if (pids != null) { |
| 2663 | for (int j=0; j<pids.size(); j++) { |
| 2664 | Uid.Pid pid = pids.valueAt(j); |
| 2665 | if (!didPid) { |
| 2666 | pw.println("Per-PID Stats:"); |
| 2667 | didPid = true; |
| 2668 | } |
| 2669 | long time = pid.mWakeSum + (pid.mWakeStart != 0 |
| 2670 | ? (nowRealtime - pid.mWakeStart) : 0); |
| 2671 | pw.print(" PID "); pw.print(pids.keyAt(j)); |
| 2672 | pw.print(" wake time: "); |
| 2673 | TimeUtils.formatDuration(time, pw); |
| 2674 | pw.println(""); |
| 2675 | } |
| 2676 | } |
| 2677 | } |
| 2678 | if (didPid) { |
| 2679 | pw.println(""); |
Dianne Hackborn | 32907cf | 2010-06-10 17:50:20 -0700 | [diff] [blame] | 2680 | } |
Jeff Sharkey | ec43a6b | 2013-04-30 13:33:18 -0700 | [diff] [blame] | 2681 | |
| 2682 | if (!isUnpluggedOnly) { |
| 2683 | pw.println("Statistics since last charge:"); |
| 2684 | pw.println(" System starts: " + getStartCount() |
| 2685 | + ", currently on battery: " + getIsOnBattery()); |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 2686 | dumpLocked(context, pw, "", STATS_SINCE_CHARGED, reqUid); |
Jeff Sharkey | ec43a6b | 2013-04-30 13:33:18 -0700 | [diff] [blame] | 2687 | pw.println(""); |
| 2688 | } |
Dianne Hackborn | 6b7b484 | 2010-06-14 17:17:44 -0700 | [diff] [blame] | 2689 | pw.println("Statistics since last unplugged:"); |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 2690 | dumpLocked(context, pw, "", STATS_SINCE_UNPLUGGED, reqUid); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2691 | } |
| 2692 | |
| 2693 | @SuppressWarnings("unused") |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 2694 | public void dumpCheckinLocked(Context context, |
Dianne Hackborn | 49021f5 | 2013-09-04 18:03:40 -0700 | [diff] [blame] | 2695 | PrintWriter pw, List<ApplicationInfo> apps, boolean isUnpluggedOnly, |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 2696 | boolean includeHistory, boolean historyOnly) { |
Dianne Hackborn | 0ffc988 | 2011-04-13 18:15:56 -0700 | [diff] [blame] | 2697 | prepareForDumpLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2698 | |
Dianne Hackborn | 13ac041 | 2013-06-25 19:34:49 -0700 | [diff] [blame] | 2699 | long now = getHistoryBaseTime() + SystemClock.elapsedRealtime(); |
| 2700 | |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 2701 | if (includeHistory || historyOnly) { |
Dianne Hackborn | 49021f5 | 2013-09-04 18:03:40 -0700 | [diff] [blame] | 2702 | final HistoryItem rec = new HistoryItem(); |
| 2703 | if (startIteratingHistoryLocked()) { |
Dianne Hackborn | 71fc13e | 2014-02-03 10:50:53 -0800 | [diff] [blame] | 2704 | try { |
| 2705 | for (int i=0; i<getHistoryStringPoolSize(); i++) { |
| 2706 | pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); |
| 2707 | pw.print(HISTORY_STRING_POOL); pw.print(','); |
| 2708 | pw.print(i); |
| 2709 | pw.print(','); |
| 2710 | pw.print(getHistoryTagPoolString(i)); |
| 2711 | pw.print(','); |
| 2712 | pw.print(getHistoryTagPoolUid(i)); |
| 2713 | pw.println(); |
| 2714 | } |
| 2715 | HistoryPrinter hprinter = new HistoryPrinter(); |
| 2716 | while (getNextHistoryLocked(rec)) { |
| 2717 | pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); |
| 2718 | pw.print(HISTORY_DATA); pw.print(','); |
| 2719 | hprinter.printNextItem(pw, rec, now, true); |
| 2720 | } |
| 2721 | } finally { |
| 2722 | finishIteratingHistoryLocked(); |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 2723 | } |
Dianne Hackborn | 13ac041 | 2013-06-25 19:34:49 -0700 | [diff] [blame] | 2724 | } |
Dianne Hackborn | 13ac041 | 2013-06-25 19:34:49 -0700 | [diff] [blame] | 2725 | } |
| 2726 | |
Dianne Hackborn | 099bc62 | 2014-01-22 13:39:16 -0800 | [diff] [blame] | 2727 | if (historyOnly) { |
| 2728 | return; |
| 2729 | } |
| 2730 | |
Dianne Hackborn | e4a5951 | 2010-12-07 11:08:07 -0800 | [diff] [blame] | 2731 | if (apps != null) { |
| 2732 | SparseArray<ArrayList<String>> uids = new SparseArray<ArrayList<String>>(); |
| 2733 | for (int i=0; i<apps.size(); i++) { |
| 2734 | ApplicationInfo ai = apps.get(i); |
| 2735 | ArrayList<String> pkgs = uids.get(ai.uid); |
| 2736 | if (pkgs == null) { |
| 2737 | pkgs = new ArrayList<String>(); |
| 2738 | uids.put(ai.uid, pkgs); |
| 2739 | } |
| 2740 | pkgs.add(ai.packageName); |
| 2741 | } |
| 2742 | SparseArray<? extends Uid> uidStats = getUidStats(); |
| 2743 | final int NU = uidStats.size(); |
| 2744 | String[] lineArgs = new String[2]; |
| 2745 | for (int i=0; i<NU; i++) { |
| 2746 | int uid = uidStats.keyAt(i); |
| 2747 | ArrayList<String> pkgs = uids.get(uid); |
| 2748 | if (pkgs != null) { |
| 2749 | for (int j=0; j<pkgs.size(); j++) { |
| 2750 | lineArgs[0] = Integer.toString(uid); |
| 2751 | lineArgs[1] = pkgs.get(j); |
| 2752 | dumpLine(pw, 0 /* uid */, "i" /* category */, UID_DATA, |
| 2753 | (Object[])lineArgs); |
| 2754 | } |
| 2755 | } |
| 2756 | } |
| 2757 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2758 | if (isUnpluggedOnly) { |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 2759 | dumpCheckinLocked(context, pw, STATS_SINCE_UNPLUGGED, -1); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2760 | } |
| 2761 | else { |
Dianne Hackborn | a7c837f | 2014-01-15 16:20:44 -0800 | [diff] [blame] | 2762 | dumpCheckinLocked(context, pw, STATS_SINCE_CHARGED, -1); |
| 2763 | dumpCheckinLocked(context, pw, STATS_SINCE_UNPLUGGED, -1); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2764 | } |
| 2765 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2766 | } |