History log of /frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
2078d3499bca6cd6223ff76a5607eed7357aff22 25-May-2016 Roshan Pius <rpius@google.com> BatteryStats: Allow for sample errors in wlan stats

Add some leeway in the reported time because some inaccuracy
is expected in these stats between samples.

BUG: 28932100
Change-Id: Ia643fa666ca16c0c707d189ec2bc703fe1ef08a4
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
684591116fa6a8a2bf7a72dea19b496272f80af3 16-May-2016 Roshan Pius <rpius@google.com> Adjust wifi idle times to fit in system time period

The battery stats time period calculation is done using a
different clock source compared to the wifi chip's on time calculation. So,
account for skews between the two by adjusting the idle time reported by
wifi chip to fit into the system time calculation.

BUG: 28628799
Change-Id: I3110c53317f3246e26fdc3731f7be0a3d9c8e229
TEST: Compiles & manual verification
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
2512ec9e376b0fce213f6d635dfb991c79041031 14-May-2016 Ruchi Kandoi <kandoiruchi@google.com> Merge "network: Adds the functionality to parse uid in netlink messages." into nyc-dev
fa97fcf7b9b9999102bc0c6b298114375b27a1c3 14-May-2016 Ruchi Kandoi <kandoiruchi@google.com> network: Adds the functionality to parse uid in netlink messages.

Netlink notifications about the state of the modem contains uid too.
This patch adds the functionality to add that. It also fixes the bug to
parse the timestamp in the message even in cases where the length is
greater than expected.

Bug: 28527904
Change-Id: I4643bff3eb5b1ffa2dc0b78f1c6947d60487e0d8
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
3723194dc831f4734d465602b2e21449d9357c2e 12-May-2016 Adam Lesinski <adamlesinski@google.com> Merge "BluetoothManager: Make requestControllerActivityInfo one call" into nyc-dev
991357fe25b3addabf85b871df3f4098fc4b833b 10-May-2016 Adam Lesinski <adamlesinski@google.com> BluetoothManager: Make requestControllerActivityInfo one call

Instead of making multiple calls into the Bluetooth service,
make one call that can timeout. This helps prevent cases
when the Bluetooth process hangs and the system_server is calling into
it and causes a WATCHDOG restart.

Bug:28658141
Change-Id: I37778b7b6e508be420a21bdf23593ae89b38f5b8
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
1476d32b87d85885838fb066bcca48f1df9750b6 05-May-2016 Joe Onorato <joeo@google.com> Add the individual wakeup alarm counts to the batterystats checkin.

Bug: 28601365
Change-Id: I94ad69eeb575f75d62bd45076184f521bd11052d
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
a8018ac47a0c0725882a041a1c42e67f52129f02 03-May-2016 Adam Lesinski <adamlesinski@google.com> BatteryStats: Fix units on battery charge counter

The unit for the battery charge counter is in micro-Ampere-hours, not coulombs.
We store the value as uAh but display it in dumpsys as mAh.

Bug:27174034
Change-Id: Ib5cc1ee1c5c191336a3e1f18dbb12c38e833f8d0
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
926969b411ca52eeefd6b01c0c7970d8a65ee526 29-Apr-2016 Adam Lesinski <adamlesinski@google.com> BatteryStats: Keep track of coulomb counter

Bug:27174034
Change-Id: Ica66817faa20b9788536f28f0e593483f033904b
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
68cdf1997f7b007e4c81089bc402a0356292f4c2 04-Apr-2016 Badhri Jagan Sridharan <Badhri@google.com> Add low power stats to batteryhistory

Exports SOC specific low power state info to batterystats service.
BatteryStats service queries the powerHAL module whenever and
updates the HistoryStepDetails whenever setBatteryState is called by the
BatteryService. The stats get appended to the battery history whenever
there is a change in the battery level.

Bug: 26564574
Change-Id: I02b4db00aec0c69d1558492224f3a4dc1c386fa6
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
20b84dfa59190bfef04aac6dc8fb90c9bac5f21b 20-Apr-2016 Adam Lesinski <adamlesinski@google.com> Move batterystats stats collection to its own thread

Too many other tasks run on common handlers, and the batterystats collection
may block waiting for a timeout of up to 2 seconds.

Bug:27857665
Change-Id: I5be1ddc374d69620f4f7d821eb29e8524294c9a4
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
010bf374d8145528f8733dfa6ef101b15de23a8d 11-Apr-2016 Adam Lesinski <adamlesinski@google.com> BatteryStats: Introduce Async external stats requests

Instead of calling out to external processes with a blocking IPC,
pass along a Binder on which the external process can pass back
the response. The calling process can then wait for the reply with
a timeout.

This eliminates watchdog restarts of the system_server when an external
process like telephony or bluetooth hangs.

Bug:26842468
Change-Id: I1b242e4ed22a63f1a4a0be8c78de8ac4d7bf56c5
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
89d9480be2dbb33e97a6efdf45bc6790eff1e5d0 29-Mar-2016 Roshan Pius <rpius@google.com> Merge changes from topic 'wifi_tx_power_levels' into nyc-dev

* changes:
Add new wifi tx power levels in Wifi activity energy
Add new wifi tx power levels in link layer stats
9cfba3502079f5919ec065da2f8d86fe35c475da 25-Mar-2016 Dianne Hackborn <hackbod@google.com> Fix issue #25817435: Batterystats missing UIDs for secondary users

Change-Id: I9ad907571f04b5825d234758347659544a4de6ab
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
42e606250a13edc22cb9f14937a4d73c14cc41aa 16-Mar-2016 Roshan Pius <rpius@google.com> Add new wifi tx power levels in Wifi activity energy

BUG: 27227497
Change-Id: I66db7f61a5e3a8223a008f7182bb56921145c831
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
713fec85b8612256211f09c62b8958a99fe5b9db 04-Mar-2016 Joe Onorato <joeo@google.com> Add an API for apps to get their System Health / Battery Stats data.

Change-Id: Ib27e1be469b826f6d83d73ce6024102bbdb1d47a
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
9f55cc71b9b0a27604d448b5c54e3c377b7a067f 28-Jan-2016 Adam Lesinski <adamlesinski@google.com> Track BLE scans in BatteryStats

Distribute the power used by apps scanning with BLE.

Bug:22718669
Change-Id: I626d8a459fc28fdd7dac682c9ac7c8434945109d
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
72c3927f864ddd8cc2fb02c868a576e4171606d3 28-Jan-2016 Adam Lesinski <adamlesinski@google.com> Merge "Record ModemActivityInfo and distribute power blame to apps"
21f76aa77075be5e057c36040d7d6e695c669b72 25-Jan-2016 Adam Lesinski <adamlesinski@google.com> Record ModemActivityInfo and distribute power blame to apps

Telephony expsoses a getModemActivity() method, which BatteryStats
will poll when a change in network activity occurs (on the modem).

The time spent in various states (tx, idle, rx) are distributed amongst
the apps that did rx/tx traffic during that window.

Bug:23147562
Change-Id: I480a85df95786f87c382b96816fe2ed4bb2d5a42
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
6771d629b5ad0b9296f0febaa2300fdaf1f90515 16-Jan-2016 Adam Lesinski <adamlesinski@google.com> Add WorkSource to BLE scanning API

This will allow apps that do work on behalf of others to correctly blame
those apps for the power implications of BLE scanning.
Bug:22718669

Change-Id: Ib64af0b6a5d37721a6067ac4e5c39c01f921b56b
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
e06b4d1d9f718b9fe02980fea794a36831a16db2 06-Jan-2016 Jeff Sharkey <jsharkey@android.com> Consistent naming for PackageManager methods.

When hidden PackageManager methods take a userId argument, they
should be named explicitly with the "AsUser" suffix. This fixes
several lagging examples so that we can pave the way to safely
start passing flags to new methods without scary overloading.

Also fix spacing issues in various logging statements.

Change-Id: I1e42f7f66427410275df713bea04f6e0445fba28
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
a8d10945a608ac6f85a6ab85b69b9a118d7853d8 20-Nov-2015 Dianne Hackborn <hackbod@google.com> Fix reporting of uid state in battery stats.

Now that the activity manager keeps track of per-uid process states,
we can push that already rolled-up data into battery stats to directly
track the times in those states.

The problem with the reporting was actually that we weren't dealing
correctly with negative process states, which is now fixed. (It was
interpreting them as FOREGROUND rather than not running.)

Also split out a number of new states -- TOP, FOREGROUND_SERVICE,
TOP_SLEEPING -- from FOREGROUND. This should allow us to get a much
better idea of how much an app has been actively in use: TOP is when
it is directly visible to the user or in use by such, FOREGROUND_SERVICE
is when it is running in the background in a way the user is aware of.
Also when reporting these numbers, they are no longer added together as
reported but kept as separate times.

Change-Id: I6d307503a4b4ad5c0d5d49305ef63f8eb858e2c9
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
08c47a5dece977a55d250d98bda9e2a8df8b6ed0 15-Oct-2015 Dianne Hackborn <hackbod@google.com> Initial implementation of light-weight idle mode.

This mode turns on after the screen has been off for 15 minutes,
and then cycles through 15 minutes of idle and 1 minute of
maintenance, ragardless of whether the device is moving around.

It currently only impacts network access and sync/job scheduling.
It does not remove access to wake locks or alarms for any apps.
It also doesn't report in the public API that the device is in
idle mode (since it isn't modifying the behavior of the power
manager) -- this is probably what we desire, since we don't want
stuff like GCM to be reporting these frequent changes.

We'll probably at least want to have the alarm manager do some
kind of more aggressive batching of alarms in this most (not allowing
more than one wakeup every minute?). That's for the future.

Also updated batterystats to include this new information, which
means the format of some of the data has changed -- device_idle
is no longer a flag, but an enum of (off, light, full), and there
is no information about time spent in light modes.

Also added new data about the maximum duration spent in both light
and full idle modes, to get a better understanding of how those
are behaving.

And did a little cleanup of DeviceIdleController, removing the
sensing alarm which was redundant with the regular alarm.

Change-Id: Ibeea6659577dc02deff58f048f97fcd9b0223307
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
6832f39416cbe2cc9655af4eabefe39c5d272254 06-Sep-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Better big-little CPU accounting

Generalize cpu clusters so we can measure frequency
and power usage across heterogeneous cpu clusters.

This also brings back reading of cpu-times for power calculation.

Bug:22773176
Change-Id: I9c794ae9756c782c0e971c7f5fcebbe70374b269
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
5983ae7b98bbe16b8a0a5ffe9203baa1ed58a8fb 26-Aug-2015 Todd Kennedy <toddke@google.com> Merge "Allow extra slop in battery stats" into mnc-dev
590da11a85d6e5201f3a96be7d30950e4b9178e5 26-Aug-2015 Todd Kennedy <toddke@google.com> Allow extra slop in battery stats

Current slop of 30ms was causing too many WTFs to be thrown. Increase the slop
to 750ms.

Bug: 23391894
Change-Id: Ica5be9b00745bfe58872d43be8c32f8c147075ed
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
865b79b43b75361fceb3aa1c99ad6f6e7c90e6ac 19-Aug-2015 Dianne Hackborn <hackbod@google.com> Fix issue #23326715: Clarify --checkin/-c options in batterystats

Change-Id: I3f026447ba7c6d2c3f9ef065269c31a78cf73512
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
4c9ace51db6ded47665cbafce3edf8a92a67f775 28-Jul-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Compensate for accuracy issues when reporting WiFi energy data issues with Slog.wtf

In practice I've seen the reported time spent in all WiFi energy states ~20 milliseconds larger
than the time between samples, which seems reasonable.

This will reduce false positives in APR.

Bug:22774068
Change-Id: Ibf33c9826586c8a1b70449b9a609cb51bdfc08b8
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
fc28d6fc9dec30e4cd98cc894d596f7df986f5b9 27-Jul-2015 Adam Lesinski <adamlesinski@google.com> Merge "BatteryStats: Prevent BatteryService from blocking" into mnc-dev
d7616ef73c48a1e5d6ba0e36fc6e85b007832d25 27-Jul-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Prevent BatteryService from blocking

BatteryService is a low level service, and we shouldn't have it
block in BatteryStatsService while collecting external data from
components like WiFi. Deadlocks can occur this way.

Bug:22559655
Change-Id: I64026453d191695eb583a47163ab6f48f882b085
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
515702c29e5eae0e3f02b5d65ed86218813e8945 24-Jul-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Decode wakeup reasons in Java

Wakeup reasons come from drivers and sometimes are malformed UTF-8.
Decode them in Java so we can easily replace malformed characters
and still have user visible strings.

Bug:22368519
Change-Id: Ifade1a7fcdf6545e7e344d74390200c329430e14
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
280a64e793d081847c5dcea23ed9be38aa5332d2 13-Jul-2015 Dianne Hackborn <hackbod@google.com> Improve tracking of screen on reasons.

- New screen on app op to record the last time each app has
caused the screen to be turned on.
- New battery stats event that tells us the reason the screen
has been asked to turn on.
- Propagate out power manager API to specify the reason a caller
is asking to have the screen turned on.

Note that currently the window flag to turn the screen on bypasses
much of this because it is being handled in the window manager by
just directly telling the power manager to turn the screen on. To
make this better we need a new API where it can specify who it is
calling the API for.

Change-Id: I667e56cb1f80508d054da004db667efbcc22e971
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
56d82dd28a3c7dcca9c9dc37a73a1cf5fc44498e 15-Jul-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Fix deadlock

Bug:22486756
Change-Id: I20e10cc344b128bfa156c5aada93d3fb2b0fcaa3
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
9ae9cba0209a8baf0a5d7463dc1c9a4831c916f6 09-Jul-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Fail gracefully on corrupt battery stats

Bug:22328963
Change-Id: Id0b4c6334706e58483d5fdfd2c1137bfb821c409
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
61db88fc8b4a5729d9ce6bc1b7bfaac5c09c8f90 02-Jul-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Remove isolated UIDs from /proc/uid_cputime when they are not in use anymore

Bug:22225933
Change-Id: I384a3c37ad45af981cca5fc3e92643da948d48d0
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
87fd322ecb5cd7582f449e5b4721a1e4dea062e6 25-Jun-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Record suspend abort reasons

Bug:18179405
Change-Id: I28c77f035400c32375dbe6d3c7057c0a2c093e8f
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
06f46cb32067572f25721ebe62fefd29cc34c7f0 23-Jun-2015 Adam Lesinski <adamlesinski@google.com> Extend the time between WiFi energy samples

With bursty WiFi traffic, we end up sampling the WiFi controller's
energy data quite a lot. Extend the timeout so that we sample
once there has been no activity for 15 seconds.

Note: Once the WiFi radio goes down after being active, it can come back and be
active in less than 15 seconds, which means we may sample twice quickly.

Bug:21478443
Change-Id: I99081b664f8a33fef734bc55eef4d33ac297e83a
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
8b156e37d5238487f1b3742fe9fb8a0632bfd66c 19-Jun-2015 Adam Lesinski <adamlesinski@google.com> Merge "BatteryStats: Update external stats individually." into mnc-dev
d2b9dcac7ff3b2aafb3a58bf9ef78945a215a6b0 19-Jun-2015 Adam Lesinski <adamlesinski@google.com> Merge "BatteryStats: Log when WiFi idle time is too large" into mnc-dev
a7c90c84e46501b3afed221a448079d567ed853c 18-Jun-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Update external stats individually.

When wifi traffic causes a stats collection, we shouldn't care about
cpu or bluetooth updates.

Bug:21478443
Change-Id: I177dc0fc09951813cb4a702ad0e5d951d69f8c22
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
bd6704fc4de980ae149c54775aaab9cbc3205f6b 19-Jun-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Log when WiFi idle time is too large

We have issues with bad data coming from the WiFi system, so
log when we have unreasonably large WiFi idle time.

Bug:21929173
Change-Id: I54b34c5efad14264306155c588f4c3b71cae35df
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
0348ba2e2303d9dce57a6b5d19cc47ecc5089afe 19-Jun-2015 Dianne Hackborn <hackbod@google.com> Merge "Fix issue #20494208: Go out of device idle when headset button is pressed" into mnc-dev
b6683c428698105f715985a96066192aa62e9f53 19-Jun-2015 Dianne Hackborn <hackbod@google.com> Fix issue #20494208: Go out of device idle when headset button is pressed

Rework how we record active transitions in battery stats to be
more general, and add an API that others can call in to
DeviceIdleController to request that we go out of idle mode.
use this for VOICE_SEARCH_HANDS_FREE.

Change-Id: Ie58de60e63036a4142881283835961fbcceec892
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
72478f053f403e29223dba6cc7be9e5bf115f670 18-Jun-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Fix regression in wakelock power distribution

We used to give 50% of the cpu time of each app to any app holding a wakelock
while the screen is off.
Since we switched to the new kernel module for measuring app's cpu time, this distribution
was lost.

Bug:21876567
Change-Id: I42c294547f63d150d9929271ca0e27fedaaa9d77
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
8a351373881e2e11c2636d6f9445f9df9accbace 16-Jun-2015 Adam Lesinski <adamlesinski@google.com> Bluetooth energy: fix overflow in calculation

Use longs instead of ints, because the energy values can get pretty
high.

Change-Id: I43e696ad9e5965c2e616b11920db5bfae5db1671
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
f4013aa4f7f9ba0010840c20fd747b73880f3d74 13-Jun-2015 Adam Lesinski <adamlesinski@google.com> BatteryStats: Wifi energy data is sometimes wrong

Wifi energy data sometimes reports negative values. The bug
is filed, but in the meanwhile, batterystats calculations
are way off due to strange values.

Now we ignore invalid data, and sample again later.
Bug:21613534

Change-Id: I3c5c1385e15d85346e6fd3a2737cb58ca706ab74
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
11df5b66ef621c4d67f5b4980e879784de43fd70 02-Jun-2015 Ruben Brunk <rubenbrunk@google.com> Merge "Track camera and flashlight usage in battery stats." into mnc-dev
6d2c363fd59af805380622ff7a3ce4c34975aab2 27-May-2015 Ruben Brunk <rubenbrunk@google.com> Track camera and flashlight usage in battery stats.

Bug: 15986092

Change-Id: Idf03981271721c44fd43327d5d90cf6f3fecfacb
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
c14c273bf83d58a8049ac95a5a9885d0ba9c2188 22-May-2015 Adam Lesinski <adamlesinski@google.com> BatteryStatsService: Only query bluetooth on demand.

Bluetooth was being queried too often, leading to more power
consumption and wakelock time.

Bug:21063567
Bug:21269307
Change-Id: Idddbab46d13016ef8528e095945b7817c12f7266
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
b83ffee5a40bf00e156152ad85bf8cf6bb96e2f1 12-May-2015 Adam Lesinski <adamlesinski@google.com> Remove UID from kernel cpu accounting when uninstalled

Bug:20182139
Change-Id: I77d41570c6aa0efd927b7beb266ef249ed9abff1
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
06af1fac166a83507450b6bbb1f98a8dde68d92e 06-May-2015 Adam Lesinski <adamlesinski@google.com> Parse uid_cputime proc file

Instead of using the ProcessCpuTracker as the source of truth, we
periodically poll the new uid_cputime kernel module for stats
on all UID cpu time.

TODO: Need to tell the kernel when to stop tracking UIDs (aka on package
uninstall).

Change-Id: Id1d251aae23ab53f7acc0aba3bca5118bc2c194a
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
13a6a9b39ed99fa38e452dd0aacfe1897f32d84a 23-Apr-2015 Dianne Hackborn <hackbod@google.com> Maybe fix needing wifi permission to dump battery stats.

Change-Id: I39f265bbdf1855e6e31d1b43e0e919199708aebd
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
e283d33feda27f54672f90512c25304842cd7eb4 16-Apr-2015 Adam Lesinski <adamlesinski@google.com> Report WiFi and Bluetooth energy collection in checkin stats

Also removed some legacy bluetooth energy collection
that was never invoked.

Also fixed an issue with Wifi scan power estimation.

Bluetooth energy recording is still disabled as strange results
are still reported.

Change-Id: Iafa37eba285fd933ff221116b14af260e904fa4f
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
0c820db22c83808fdb06c7cb06aaf13ef4b559a3 15-Apr-2015 Dianne Hackborn <hackbod@google.com> Some improvements to battery stats data.

History now records when wifi data activity starts and "ends"
based on the triggers we get from the kernel used to determine
when to collect data. (Basically the same as the current cell
data, but of course when it ends is just an arbitrary x seconds
after the last data traffic.)

Re-arranged the state bits to make room for this data in the
right place and move some other things that make more sense to
have in states2.

Try to improve overflow handling, so when it happens we allow
the various bit states to drop to 0 instead of being stuck
active for an indeterminant amount of time.

Added recording of the points where we decide we want to
retrieve new power stats, giving the reason for doing so.
These are only recorded when full logging is turned on.

Change-Id: Ic5d216960a07e0eb658731cdfba7f49ad3acf67e
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
1e38382b542f5cef9957a89692b02c55a3dd351c 10-Apr-2015 Dianne Hackborn <hackbod@google.com> Fixes to idle alarm scheduling, package importance.

- Add new API to ask the activity manager what the current
importance of a particular package name is (along with a few
new useful importance levels).

- Fix my last alarm manager change to actually execute the
alarms we have now decided should run even while we are idle.

Change-Id: I1f14712b4e390770d53b185c96a1b36f6aadd687
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
4870e9d5eba59fb257a87f97f1adf0b734cf48d3 09-Apr-2015 Dianne Hackborn <hackbod@google.com> More work on device idle mode and other power stuff.

Add idle mode support to the alarm manager. Introduce
a new concept of flags associated with alarms to tell
the alarm manager how to treat the alarm -- they allow
everything from the alarm that will bring us out of idle
mode, to alarms that are allowed when idle or should
also bring us out of idle. The standalone boolean is
now also a flag.

(Note there is currently no protection from user space
setting the flags however it wants; I will be working
on that in a follow-up change.)

When in idle mode, the alarm manager pushes all alarms
that shouldn't execute during that time over to a
separate list that is not executed until out of idle.
To help with this, I reworked a bit how Alarm objects
are managed, so that when rebatching or moving between
lists we don't have to allocated new objects but can
just use the same existing instance.

Also tweaked the sync manager to deal with idle mode,
which currently just means doing the same thing as when
low on storage -- turning off sync.

Add new ACTION_CHARGING and ACTION_DISCHARGING broadcasts
that apps can listen for to know when the device is actively
charging and discharging. These are better than the old
POWER_CONNECTED and POWER_DISCONNECTED ones because we only
report charging when we actually see that there is enough
power being provided to charge the battery (and will report
discharging if there is not enough power).

The job controller uses these new actions for scheduling
jobs that want to run while plugged in. Removed the
"stable charging" stuff while doing so, since the new
charging state serves as an even better signal for that.

Introduced two new process states: FOREGROUND_SERVICE and
TOP_SLEEPING. This will allow us to treat foreground services
specially (such as still allowing network access to them for
background music playback) while not mixing them together with
whatever happens to be the top activity while the device is
asleep.

Also some other small cleanup here and there.

Change-Id: I7a9808b578bad6f50deb8e1baf919298512a0d3a
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
e08af19fcc7b13d526f3dfd24d58300947cf1146 26-Mar-2015 Adam Lesinski <adamlesinski@google.com> Adding per UID WiFi power distribution.

Change-Id: I88c539074607d7261f6c5cf1dbae47c3cf53f253
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
e9b9b73ab598a912de04fbd5501bca5924ce8f71 07-Apr-2015 Bart Sears <bsears@google.com> Revert "Adding per UID WiFi power distribution."

This CL is breaking the clockwork settings app in master. Reverting
until Adam has a chance to investigate.

This reverts commit b943fabfc8ddb581dc2fd7288f87428dcb5d27b7.

Change-Id: Ieb11423c11cf9874a6175dce49843d0e1080c590
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
b943fabfc8ddb581dc2fd7288f87428dcb5d27b7 26-Mar-2015 Adam Lesinski <adamlesinski@google.com> Adding per UID WiFi power distribution.

Change-Id: Ia3d97e0a1c3352127185c18626d8ba8221c9ab40
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
4b6bd8d36b093d36d9ae80b43e95049c259d7319 19-Mar-2015 Adam Lesinski <adamlesinski@google.com> Retrieve WiFi info outside of BatteryStatsImpl

In order to not deadlock the system, we need to retrieve
WiFi energy info outside of the BatteryStats lock. We do this,
then pass that data down to BatteryStatsImpl to process.

b/19729960

Change-Id: Ib8beba1d5ac81d89144d502c4b688d0a88c5b102
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
1e725a7ec9eb79bb447d5171839c453d672a895c 25-Mar-2015 Dianne Hackborn <hackbod@google.com> Battery stats: wakeup alarm tracking, general cleanup.

Instead of just tracking the total number of wakeup alarms
per package, track a count for each tag. Note this is only
wakeup alarms, not non-wakeup alarms.

Also tighten up the code a bit by exposing the actual ArrayMap
container through most of the BatteryStats API, so we can more
efficiently iterate over them (which is all we ever want to do
with those containers at that point).

Finally remove all printing of "since unplugged" stats, as
another step towards completely removing that tracking. If
nobody screams, hopefully soon we can go through and just get
rid of all the extra state we are carrying around that is
tracking that data.

Also note that currently the per-tag wakeup alarm data is
being reported in the human-readable stats, but in the checkin
data it is still being rolled up into a single number. To fix
this, I need to completely rework the pkg entry line to have
separate data for services and wakeup alarms (so have three
types -- pkg for the start of a package, wal for a wakeup
alarm, svc for a service).

Change-Id: I8033acca8742935cfe95511cdea730a405b17cab
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
8ad2af7e5b28f71e7bdfc1bb097937c6c1d22b18 18-Mar-2015 Dianne Hackborn <hackbod@google.com> First stab at device idle mode.

Introduce a new device idle controller service that
monitor's the device state and determines when to go
in to idle mode. When in idle mode, all we do right
now is turn off network access the same as we do for
power save mode. Many more things should come in the
future -- stopping the alarm manager from scheduling
(most) alarms, telling GmsCore for it to stop doing
stuff, etc.

Battery stats now has state tracking for devie idle
mode, as well as events for the reasons we can come
out of idle mode (significant motion or the device
becoming active). Also added new events noting when
packages are installed.

Renamed the "low power" event in battery stats to
"power save" because the former was just way too
confusing.

Finally, fix buffer size reading kernel wake locks.
(Stupidly, just increasing the buffer size. Ideally
we should try to be smarter and grow our buffer to
fit the data available, but I'll leave that for
another time.)

Change-Id: I0be2062466c83ee9d890c6cf5a228d9cc4090eca
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
7d088428f32a864570d830e45d07a2fe143f6fbd 04-Mar-2015 Dianne Hackborn <hackbod@google.com> Merge "Add new "daily stats" tracking to battery stats."
d4a8af7b6a4dd663cb9c4d993ee41ca82af3c4cd 03-Mar-2015 Dianne Hackborn <hackbod@google.com> Add new "daily stats" tracking to battery stats.

Currently is only used for tracking the daily charge
and discharge rates. We keep up to 10 days of data.

Change-Id: I54e29e35ff60d9277da9e476cdab22f4a6d540bf
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
08c7116ab9cd04ad6dd3c04aa1017237e7f409ac 28-Feb-2015 John Spurlock <jspurlock@google.com> Remove unused imports in frameworks/base.

Change-Id: I031443de83f93eb57a98863001826671b18f3b17
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
1e01d16982e6b22ec4c0e2d6dc1e261eb6f92c8e 05-Dec-2014 Dianne Hackborn <hackbod@google.com> Fix issue #17323751: Additional items in aggregated battery stats

- Now aggregate number of times each process has crashed and ANRed.
- Now aggregate total number of connectivity changes.
- Now record connectivity changes in the history.

Crash and ANR counts are new entries at the end of "pr" in checkin.

Connectivity change counts is a new entry at the end of "m" in checkin.

Connectivity changes in the history checkin are Ecn and include the
type of connection and its state.

Change-Id: I0c01186446034cf6c3fb97d45f5e3b5c69a0438a
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
ab4a81b3c625e33d04ae8070fcce6b6baee6522c 10-Oct-2014 Dianne Hackborn <hackbod@google.com> Improve some docs, fix some debugging.

- Add docs to Binder, Messenger, ResultReceier to explain their
relation (or lack there-of) to process lifecycle.
- Clarify some aspects of process lifecycle for services.
- Fix help text of am command.
- Fix per-package dumping of battery stats to not include history.
- Fix per-package dumping of proc stats to only include aggregated
and current stats and fix some formatting.
- Fix per-process dumping of meminfo to have an option to interpret
the input as a package, so including all processes that are
running code of that package.
- Fix top-level per-package debug output to correctly include all
of these improvements and give them a little more time (10s) to
complete for timing out.

Change-Id: I2a04c0f862bd47b08329443d722345a13ad9b6e2
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
2f1993ec460166413e7887f151630f6708077c0f 26-Sep-2014 Dianne Hackborn <hackbod@google.com> Fix issue #17671802: "content" command always prints...

..."uid 2000 does not have android.permission.UPDATE_DEVICE_STATS"

Make sure to clear calling identity before getting into the guts
of the activity manager. Also fix the places the activity manager
calls in to battery stats to not require a permission check, anyway.

Change-Id: Ifd90937875b9fe0c36aa3f5cf1ec173746914e6b
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
d953c53d3b04d772bb1b62ede1c2011641ca82b5 17-Aug-2014 Dianne Hackborn <hackbod@google.com> Work on issue #16629489: Google (Play?) Services eating through battery

There is a bug in how we deal with name overflows combined with resetting
the battery stats data. If we do a reset while a wakelock is being
actively held that has been put into the overflow bucket, then we can
end up reducing the number of known wake locks in the list so when after
that it is released we try to release it under its real name rather than
the overflow name.

This means we need to keep track of which wake locks have been placed
in the overflow bucket while they are actively being used, so we can be
sure to properly handle it as part of that bucket until it is eventually
released.

This makes things... somewhat more complicated. So now we have a class
to take care of all these details, and also use it for other places where
we have the same overflow semantics sync and job stats.

Also fix potential deadlock -- BatteryStatsHelper needs to call on to
ConnectivityManager to find out of there is telepohny, however we use
that class when doing a dump while the battery stats lock is held. To
fix this, we check the connectivity state up in the battery stats service
before acquiring the lock and propagate that information through to the
dump code.

Change-Id: Ib452206af5c36f4b0f03cc94d2845d36613d1ba5
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
0068d3dcf1f1a804554a1a09e3b173ac12651786 07-Aug-2014 Dianne Hackborn <hackbod@google.com> Fix issue @16555033: Battery history overflowing too much

- No longer track process starts/stops normally.
- Increase buffer size to 256KB.
- Buffer size increase requires reworking how battery stats
are retrieved, since it is going to be hitting IPC limits.
- Also, store the last full stats after a reset, to be reported
at the next checkin.
- Also, discharge and charge times are tagged with the screen
and battery save state during that time.

Change-Id: Ie108ac9b626846108a9bb858101ac2b93276ac16
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
10eaa8574bb220e7dddf9a78057f83dc64ee5687 23-Jul-2014 Dianne Hackborn <hackbod@google.com> Fix issue #16467284: Make noteStartVideo and noteStartAudio nesting

Also add new methods to clear these states, so we can avoid any
nesting issues from getting the tracking state stuck.

Change-Id: Iba0eaba2a9a186355c24d392f16118982c5331ed
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
fdb1956ff71ff57fcdaafaaeb7f42c19de3d7c2f 12-Jul-2014 Dianne Hackborn <hackbod@google.com> Fix issue #15681802: Missing RESET:TIME in complete battery histories

But wait, there's more!

- Keep track of sync durations in the aggregated stats.
- Add events for users that are running and in the foreground.
- Rework the activity manager's tracking of stuff using
battery in the background to be based on proc stats, which
allows it to be better about determing when it should reset
its tracking of background work.
- Also add tracking of scheduled job execution, like we are
doing for syncs.
- And once I started hooking battery stats in to
JobSchedulerService, I found a few things I couldn't stop myself
from changing: (1) make it very explicit that it doesn't start
scheduling jobs until we have reached the point in system boot
where third party apps are allowed to run, and (2) adjust
the various for loops to not use iterators.

Change-Id: I69d812e27bcfee9e58a614f0f6b1c7545d7530b1
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
61659e5daaea80104d4d0fd567e78b5f757b5df4 10-Jul-2014 Dianne Hackborn <hackbod@google.com> Add tracking of uid process states in battery stats.

We now keep track of how long each uid had processes in
various states: foreground, active, running. This is based
on a collapse of the various activity manager process states
into these three bins.

You'll see these in a checkin like this:

8,10013,l,st,61504,61504,83109

Also fix issue #16021555: App showing up as on "top" even
when the screen is off. This is "fixed" by just saying we
always report the current app at the top of the activity stack,
regardless of the state of the screen.

Change-Id: I1204904225101243eb00b43425d9806bffdd2ab9
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
abc7c499133fe640d6ece2b28d43b52e66cdaa9a 01-Jul-2014 Dianne Hackborn <hackbod@google.com> Issue #15986092: Add power tracking of flashlight.

Not yet hooked up.

Change-Id: Id95e44ecc365e9f38169c0a629b0a48ddb29aa06
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
3251b9075246841a7b1ddecf10859b1abd858f33 20-Jun-2014 Dianne Hackborn <hackbod@google.com> Add some wifi tracking to battery stats.

Now track supplicant state and wifi signal strength.
Output looks like this:

+12m45s235ms (1) 095 +wifi_full_lock +wifi_running wifi_signal_strength=3 wifi_suppl=scanning
+12m46s095ms (1) 095 -wifi_full_lock wifi_suppl=associated
+12m46s469ms (2) 095 wifi_suppl=completed +proc=u0a74:"com.google.android.videos"
+12m52s103ms (1) 095 +wifi_full_lock wifi_suppl=disconn

Also modify history dump so that when we hit a RESET or START
command, we clear our previous history data, so the next event
will include new data. This means if you are scanning through
the output, you must at this point clear any binary stats you
have like "running" or "wake_lock" or else you will continue to
think they are on until whatever point later they get turned on
and then back off.

And a small bug fix in proc stats that would cause the system
process to crash.

Change-Id: Ibec416a1ef786d428bd0d1d86e6e3296c41f7648
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
2c43c339de5aaf4fef58aa9b5ac3af48609263a8 13-Jun-2014 Jeff Brown <jeffbrown@google.com> Resolve boot time dependencies related to the power manager.

This change fixes a bug where native daemons may try to communicate
with the power manager before it was fully initialized due to a race
between publishing the binder service and completing init().

The solution was to simplify the dependencies related to the power
manager. It turns out that most services that were passed in
init are not actually needed until systemReady. What remained
was a dependency on the activity manager to check permissions for
incoming calls. So now we start activity manager first.
However, the activity manager also depends on power manager for
wakelocks. To break the cycle, we now defer initializing the activity
manager's wakelocks until after the power manager has been started.

Cleaned up a bunch of boot-time service dependencies so that we
can have better confidence that they are correctly maintained.

Bug: 13884219
Change-Id: If08e2d7ccd44e7026a72441bb6bd5afd7bb9fffe
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
16b0b56c79ee0bd068ce47ce4460c24b5e62311d 04-Jun-2014 Dianne Hackborn <hackbod@google.com> Force write battery stats after a --history-since.

This should help the stats be more consistent across
system restarts.

Change-Id: If1736608373aada8b55d72ecf80fbbc52bd288bd
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
fc0641340ff927d9c35d5613723d25858f751118 02-Jun-2014 Dianne Hackborn <hackbod@google.com> Some battery stats history fixes.

- Now the full wake history uses the history tag if it can.
Hopefully this will still result in a consistent history,
since that isn't really want the tag is for... but the
current implementation in places will probably make this work.

- Possibly fix a bug with inconsistent state between partial
history snapshots: after a snapshot is printed, don't allow
any more batching into the most recent history entry, so the
next snapshot will not miss anything that might get placed
into it soon after.

Also rework command line arguments for enable/disable to make these
commands instead of options.

Change-Id: Ia33445cad1538bf8df549cef284f1e736efbc079
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
9a7554300637902bbb25991ffba41a9b8f682eff 16-May-2014 Dianne Hackborn <hackbod@google.com> Fix recording of wake_lock_in.

There was a bug that would allow the nesting count
to get off. Also better documentation of times in
HistoryItem, and new option to disable resetting of
the stats when unplugging.

Change-Id: If1b39a02475c5b620c67b700a323a6d0462d5c61
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
cbefd8dd2befcb768f911a63becc427ec4c13250 14-May-2014 Dianne Hackborn <hackbod@google.com> Battery stats more wake history, power save mode.

Add new option for battery stats to record the full wake
lock history, and recording the current power save mode.

Also add in some additional error constants when generating
Binder error exceptions.

And fix issue #14974572: Avoid repeating wakeup_reason at
the beginning of history

Change-Id: I7c1a2ab9569de216634f63d8ad69f1294ef1d235
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
e95c3cd89591ba586aa8a0f7a17660c6fb8770bc 03-May-2014 Jeff Brown <jeffbrown@google.com> Plumb display state and interactive information to BatteryStats.

Fixes an issue where dozing was treated the same as the screen
being fully on. Now dozing is treated the same as the screen
being fully off which is slightly better. The decision of how
to represent this state is now internal to the battery stats
so it can be improved later.

Removed noteInputEvent() since it is unused.

Bug: 14480844
Change-Id: Iee8cf8dce1a1f91c62678bb6d3d9fe567ad6db42
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
ab5c0ea43cf457b20ab4267a14b224f39e0511bf 29-Apr-2014 Dianne Hackborn <hackbod@google.com> Add IBatteryStats API to retrieve current charge times.

Also include charge/discharge information in dumpsys.

Change-Id: Ica1b333ad334dc698d4a67da391b378757662f41
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
2ffa11e4b71c545e34533ef827bdc1a07fbe8246 22-Apr-2014 Dianne Hackborn <hackbod@google.com> Start collecting mobile radio activity from the radio.

Hook in to the new radio API to find out when the radio
is active and use that to track its state in batter stats.
We also still have the data being tracked from the kernel's
emulation, and continue to use that if we don't get data from
the radio.

Currently this monitoring is turned off until some issues
in the radio can be fixed that are providing bad data.

Also add a new API to get estimated drain and charge times.

Change-Id: Ifc4900fabb8f848f9cda361dce698664ea75f175
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
a1bd79268be693f04f4adee90673d6ed400cc9fd 21-Mar-2014 Dianne Hackborn <hackbod@google.com> Battery stats: track actually running time

Use the uptime while creating the battery stats history to
generate a new event indicating when the CPU is actually running.
We can do this in combination with the new event reporting when
the CPU comes awake, looking at the difference between the
uptime and elapsed time at that point to determine when it last
when to sleep.

Also use this information to generate a new set of aggregated
states, the uptime caused by each wake reason.

Finally use new radio down timestamp to adjust the times we
compute for radio use. Note that this information is not (yet)
being used to adjust how these are recorded in the history.

Change-Id: I723b3b526c8e7d64de0cac9d1193e04132d5a3e4
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
40c8725804f46c9d53f2815e0ee69e6cfb0152cc 20-Mar-2014 Dianne Hackborn <hackbod@google.com> batstats: fix wake lock tracking, service bug

- Fix bug I introduced in handling wake lock changes where
we weren't iterating over the new work sources correctly.
- Fix bug in ActiveServices that would wtf too much.
- Prepare to start tracking uptime in the battery history.

Change-Id: Ia94316be51bc6eab7b02f214a5c40c08e99cc3b1
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
e5167ca61e2c5607aad9041b44158581bc61b4d8 08-Mar-2014 Dianne Hackborn <hackbod@google.com> Reduce wake lock noise in battery history.

When the work source of a wake lock was changed, this would
cause the old wake lock to be released in battery stats before
the new one was acquired (the power manager would correctly
keep holding the associated wake lock). This resulted in a
pointless entry in the battery history showing the last wake
lock being released and a new one acquired.

This change adds a new path in to battery stats to report
when a wake lock has changed, allowing it to acquire the
new wake locks first before the old ones, so it can't drop
down to zero wake locks. This also provides better timing
information, as the same current time can be used for both
operations.

In addition, added a new kind of history entry for the
current time, so you can tell when in actual world clock
time the battery data is happening.

Change-Id: Ibbf2eed83bb93f31f60267889b7bc5b9e71e355f
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
c51cf03cf2458c8c137f60c7379f2cccf681d16f 03-Mar-2014 Dianne Hackborn <hackbod@google.com> Start recording wakeup reasons in battery history.

Depends on a modification to libsuspend so that we can get
a callback each time the device wakes up, to read the current
wakeup reasons from the kernel. These are then stuffed in
to a new field in the battery history.

Also add new dump options --history-start and --charged
to better control what is dumped.

Finally the alarm manager uses a "*walarm*" tag for history
item wake locks that are coming from a wakeup alarm.

Change-Id: I457571973d5b2b5fdc4e4b63ab16275db20d7edd
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
77b987f1a1bb6028a871de01065b94c4cfff0b5c 27-Feb-2014 Dianne Hackborn <hackbod@google.com> Hold a wake lock while dispatching network activity events.

Also add new API for determining whether the current data network
is active, and thus better scheduling network operations. This
API is designed to not be tied to a mobile network -- regardless
of the network, apps can use it to determine whether they should
initiate activity or wait. On non-mobile networks, it simply always
reports as the network being active.

This changed involved reworking how the idle timers are done so
that we only register an idle timer with the current default
network. This way, we can know whether we currently expect to
get callbacks about the network being active, or should just always
report that it is active. (Ultimately we need to be getting this
radio active data from the radio itself.)

Change-Id: Iaf6cc91a960d7542a70b72f87a7db26d12c4ea8e
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
a1f1a3c573acd91024fda0ceb3b921c73b186963 25-Feb-2014 Dianne Hackborn <hackbod@google.com> More battery stats.

- Add events for sync.
- Add more descriptive tags for wake events.
- Fix battery reset.
- Fix tracking of wifi data.

Change-Id: Ic07f2a86a5ed33e7da57eb1108c31c777ecd801f
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
ca1bf21c511dc7d513b631a1af8498b5b08d107a 14-Feb-2014 Dianne Hackborn <hackbod@google.com> Implement wifi part of issue #12973036: Improve power_profile.xml

Add battery stats tracking of wifi state.

Also update when we retrieve the current time to use a more
consistent value across stats tracking.

Change-Id: I6a7c3efd58ff2c8ea86dac141c8f848e7996d63f
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
e13c4c0b664dabdc069ca8f9601d96a337eb02f9 12-Feb-2014 Dianne Hackborn <hackbod@google.com> Start tracking radio up time.

We now always turn on network state tracking for mobile,
and push this information down to battery stats.

In battery stats we use this to both log the changes in
the history and keep track of the total time the mobile
radio was active.

Power computation is switched over to using this information
to help determine power use, which will hopefully make it
more accurate (not counting inaccuracies in knowing when it
actually goes down).

Note yet done is aggregating this data per-uid, to better
emphasize which apps are causing the radio to be up. Right
now we just spread the total time across all uids weighted
by the total number of packets they have sent and received.

Also put in the battery stats infrastructure for bluetooth to
address issue #12973036: Improve power_profile.xml

Change-Id: I39d11b7ff6ae4f336f253d1cba308d8569de7e0d
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
3d658bf20e2d56e36941e7407deebeec1276fbcf 05-Feb-2014 Dianne Hackborn <hackbod@google.com> Improve logging of first wake lock, history size.

We now try to have a better label for the first wake lock
that is acquired in the log. This is done in two ways:

- The alarm manager now sorts the alarms it is going to
execute so that wakeup alarms are first, which are more
important w.r.t. which one should be logged.
- There is a new power manager facility to make a wake lock
as "unimportant for logging," which just means in battery
stats that a wake lock acquired after that can be considered
the actual one to log. This is only used by the alarm manager
to mark its TIME_TICK alarms as unimportant for logging.

Also reworked the battery history code to be cleaner and a bit
smaller. There is no longer a separate EVENT command, instead
the event code and tag are just another thing that can be included
in an UPDATE command.

The bits used in the first history int are also re-arrange, so
that only the ones that really change a fair amount in the state
bits are up at the top and there is no longer space used for
the command code (since now it is always just UPDATE). This
allows us to have more room for the time delta at the bottom,
to better avoid situations where we need to write an int delta.

Change-Id: I1bb860ae5b558a248800b090b03a84fbf7acd68a
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
099bc627c463d9941e23e480f25a78a154429c55 22-Jan-2014 Dianne Hackborn <hackbod@google.com> Battery stats improvements.

- Adjust total power use when there is unaccounted power so that our
percentages don't end up > 100%.
- Fix accounting of isolated uids to be against the owning real app
uids.
- Rework how we put cpu use into the battery stats to no longer need
this uid name cache that can confuse the uid it is associated with.
- Finish implementing events in the history, adding a string pool and
reading/writing/dumping them.
- Add first two events: processes starting and finishing.
- Fix alarm manager reporting of wakeup alarms to be adjusted by the
WorkSource associated with the alarm, so they are blamed on the
correct app.
- New "--history" dump option allows you to perform a checkin of
only the history data.
- Fixed BitDescription bug that would cause incorrect printing of
changes in some states.

Change-Id: Ifbdd0740132ed178033851c58f165adc0d50f716
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
09d30981f8e882ffaa336aa4665bfe348557895a 16-Jan-2014 Jeff Brown <jeffbrown@google.com> resolved conflicts for merge of 6f357d32 to master

Change-Id: I1979e6ed1acddbe656f5010114fd900f10865e75
6f357d3284a833cc50a990e14b39f389b8972254 16-Jan-2014 Jeff Brown <jeffbrown@google.com> Start untangling system server early bootstrapping.

Refactored SystemServer to get rid of a bunch of legacy cruft related
to how the ServerThread used to be started up.

Create system context first when system server starts. This removes
the tangled initialization order dependency that forced us to start
the activity manager service before most anything else.

Moved factory test related constants into the FactoryTest class.

Partially migrated Installer, ActivityManagerService, and
PowerManagerService to the new SystemService pattern. There's more
work to be done here, particularly around the lifecycle of the
power manager.

Bug: 12172368
Change-Id: Ia527dd56e3b3fd90f9eeb41289dbe044921230d4
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
a7c837f043c1ca0bdecd42645ba7da8c5717566d 16-Jan-2014 Dianne Hackborn <hackbod@google.com> Add battery power use reporting to batterystats service.

Move the BatteryStatsHelper class (which computes power use based
on the raw battery stats) out of the settings app and in to the
framework. It is now used by batterystats dump output to print
the computed power information from its current stats.

This involved a lot of refactoring of the BatteryStatsHelper code
to remove all of the UI dependencies. I also did a bunch of cleanup
in it, such as making all power computations be in terms of mAh.

Change-Id: I8ccf2c9789dc9ad34904917ef57050371a59dc28
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
9158825f9c41869689d6b1786d7c7aa8bdd524ce 22-Nov-2013 Amith Yamasani <yamasani@google.com> Move some system services to separate directories

Refactored the directory structure so that services can be optionally
excluded. This is step 1. Will be followed by another change that makes
it possible to remove services from the build.

Change-Id: Ideacedfd34b5e213217ad3ff4ebb21c4a8e73f85
/frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java