• Home
  • History
  • Annotate
  • only in /frameworks/base/services/core/java/com/android/server/power/
History log of /frameworks/base/services/core/java/com/android/server/power/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
9c36c02f0ea5f54bcb7cdf2a6175f4b8f92205a2 20-Apr-2016 Ruchi Kandoi <kandoiruchi@google.com> Revert "PowerManager: Adds the Sustained performance API."

This reverts commit 0abc001275d6cf0af4990f521ccff7346a7cd2bf.

Bug: 28150358
Change-Id: I99c71b3d6641310a33e898d6fd475d37c79ba9d0
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
owerManagerService.java
f44f5a460e9610e027a3b6257b1cf904dc3afbc7 03-Mar-2016 dcashman <dcashman@google.com> Add setting and detection of ro.sys.safemode property.

Bug: 28008032
Change-Id: I6b19b32df615becd88a56a337c999b57011c6200
hutdownThread.java
c7be3beced4ade05466a4a77c003ea81c2429f74 02-Apr-2016 Ruben Brunk <rubenbrunk@google.com> Add VrManager AIDL interface for use by system apps.

Bug: 27884853
Change-Id: I6de0d291deafe5003070d60866c60d6599312e79
owerManagerService.java
b5e89c6debca90be92bf5bc2e0e79d109de6d08f 02-Apr-2016 Jeff Sharkey <jsharkey@android.com> Support direct-boot tests.

Add shell commands to check on current FBE status and system ready
status. Mark variables without first-class locking as volatile.

Fix bug where UI automation would crash while device was locked by
marking it as forced direct-boot aware.

Bug: 26498834
Change-Id: Ib4dfb9350925e5413f93a09baacf84c62f2ba0ea
owerManagerService.java
fb811aaf4dd062c1ef3581522acb523680f081f3 21-Mar-2016 Ruchi Kandoi <kandoiruchi@google.com> Merge "PowerManagerService: Adds a VrStateListener to track Vr Mode state changes." into nyc-dev
b8009fddd85aa5ecd6b2321f92a1ae0568089a54 14-Mar-2016 Tony Mantler <nicoya@google.com> Add safe-mode reboot to PowerManager

b/12787723

Change-Id: If7e6ff63532b49b9e758db290a877f7dbfa8a8b7
owerManagerService.java
03a0428ed3857d1881def7c2767a15acfacfa999 15-Mar-2016 Ruchi Kandoi <kandoiruchi@google.com> PowerManagerService: Adds a VrStateListener to track Vr Mode state changes.

PowerManagerService sends VR_MODE hints to the powerHAL for device-specific
power tunings.

Bug: 27659731
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Change-Id: I152d9b6adfbae5d3df8d131fdd16e33fb14b64d3
owerManagerService.java
82ab9801ebebe8e4783ad327ad02686b44ab87f1 02-Mar-2016 Daichi Hirono <hirono@google.com> Add a new key to Settings.Global to obtain the number of boot.

BUG=26212981

Change-Id: I5ca51ca624a30dc2d96e547a85a712e273af1931
owerManagerService.java
3dee8d6787617a7d3da4faef2ad88c08151ea3eb 02-Mar-2016 Jeff Sharkey <jsharkey@android.com> Delay power broadcasts until system is booted.

When the system isn't booted yet, enqueue any early broadcasts to be
sent after the system is ready.

Bug: 27449137
Change-Id: I5a93be3a2cf4d038149b54e0510b040fd69d3579
owerManagerService.java
a6e9e24be53d2516138f487e340e46b8d0212d86 05-Feb-2016 Sami Tolvanen <samitolvanen@google.com> Support persist.sys.audit_safemode

Don't leave safe more if persist.sys.audit_safemode is set, unless the
current build date is newer than the specified value.

This allows us to keep the device in safe mode across reboots until an
OTA has been applied or user data is wiped.

Bug: 26902605
Change-Id: I781c3059ea8d4fb2f0c923e4488b1932d69678d3
(cherry picked from commit ee2b49283261f7b4518ec7c98f568f883f817c9d)
hutdownThread.java
e8a403d57c8ea540f8287cdaee8b90f0cf9626a3 31-Dec-2015 Tao Bao <tbao@google.com> Add support for update-on-boot feature.

Add a separate system service RecoverySystemService to handle recovery
related requests (calling uncrypt to de-encrypt the OTA package on the
/data partition, setting up bootloader control block (aka BCB) and etc).

We used to trigger uncrypt in ShutdownThread before rebooting into
recovery. Now we expose new SystemApi (RecoverySystem.processPackage())
to allow the caller (e.g. GmsCore) to call that upfront before
initiating a reboot. This will reduce the reboot time and get rid of the
progress bar ("processing update package"). However, we need to reserve
the functionality in ShutdownThread to optionally call uncrypt if
finding that's still needed.

In order to support the update-on-boot feature, we also add new
SystemApis scheduleUpdateOnBoot() and cancelScheduledUpdate() into
android.os.RecoverySystem. They allow the caller (e.g. GmsCore) to
schedule / cancel an update by setting up the BCB, which will be read by
the bootloader and the recovery image. With the new SystemApis, an
update package can be processed (uncrypt'd) in the background and
scheduled to be installed at the next boot.

Bug: 26830925
Change-Id: Ic606fcf5b31c54ce54f0ab12c1768fef0fa64560
owerManagerService.java
hutdownThread.java
5dbd4aad809e6fec51df62280bcc1bfe05cc7df5 07-Feb-2016 Jason Monk <jmonk@google.com> SysUI Tuner: Night mode v3

TwilightService:
- Add support for locking on/off twilight globally
- Change twilight state to have float amount rather than
having clients calculate it using the sunrise/set values
- State controlled through secure setting
- Override mode which locks to a state for a couple hours then
resets
- Add broadcast for SysUI to listen to

Brightness/Power:
- Updates to handle TwilightService changes
- Added secure setting to control whether or not to use
twilight when calculating brightness.

Tuner:
- UI Overhall
- NightModeController will set the values of the custom color matrix
taking into account the current twilight service state and any
custom calibration set by the user.
- Probably other stuff.

Change-Id: I213f1f76a143e711c507b2ba7d784f581bfc32b4
owerManagerService.java
0abc001275d6cf0af4990f521ccff7346a7cd2bf 12-Jan-2016 Ruchi Kandoi <kandoiruchi@google.com> PowerManager: Adds the Sustained performance API.

Adds a new type of wakelock - SUSTAINED_PERFORMANCE_WAKELOCK. This
wakelock can only be acquired when the application is in the foreground.
And it is not effective when the application is no longer in the
foreground.

Acquiring this wakelock enables the Sustained performance mode which
guarantees a certain level of performance.

Bug: 22864186

Change-Id: Id0ececc756fe014779db6efde7aede23ea181dc5
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
owerManagerService.java
afae4bd437563c3997740ff6a537108409f7884c 15-Dec-2015 Jason Monk <jmonk@google.com> Add internal power mode changed broadcast

This broadcast allows settings to be (rarely) be started by a power
change event.

Settings will have a conditional item informing the user of battery
saving mode, when they dismiss it, the item will not show up again
until after power saving mode has been exited and re-entered.
Settings will catch the exit of power saving mode by enabling a
receiver for this broadcast only when in this state.

Change-Id: I62385413e4b8b004d4e1e0e5ba250730848ba013
owerManagerService.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
owerManagerService.java
dd62fb4392664c3c7dc43c7556351b36cf17dcf2 05-Oct-2015 Nick Armstrong-Crews <strongarm@google.com> am f107709f: am 13a71fbc: Merge "Fix the logging of wake time saved by Ungaze." into cw-e-dev

* commit 'f107709fb3f884f904deb1f3c09a88dd411ea30d':
Fix the logging of wake time saved by Ungaze.
024872ea70bf82a8526e7b91a28a936cb432b095 01-Oct-2015 Nick Armstrong-Crews <strongarm@google.com> Fix the logging of wake time saved by Ungaze.

The logging of saved time was erroneously being called more than once
per wake period. Moved the logging logic to be called from
finishWakefulnessChange(), which is only called once per wake period.

Change-Id: I268ef44edce5807644fcc8fb0dcaa1a96cae6c9e
owerManagerService.java
08dcdb1a5beac29643dca2a03c2e308760de636d 23-Sep-2015 Mojtaba Seyedhosseini <mseyed@google.com> am d70a7737: am 6e7cbb7c: Merge "Add logs for the ungaze gesture." into cw-e-dev

* commit 'd70a773793bf9fce06ba8888908601b94090236d':
Add logs for the ungaze gesture.
2d80edc232cad7d5fe17c2eb14d4263cbe2c757c 19-Sep-2015 Mojtaba <mseyed@google.com> Add logs for the ungaze gesture.

-We add logs to track how much screen time we save with the ungaze feature.

Change-Id: I02bce959ce7ed5bc6c848e51256063c946ff3e87
owerManagerService.java
0816319a29709ed746682b17400b34b6f540ca56 17-Sep-2015 Tim Murray <timmurray@google.com> am 4816ea0e: am a02f9823: am 952d5b33: Merge "Send power hint on fling gestures." into mnc-dr-dev

* commit '4816ea0e120fd4e2892d372f33c8ca21e4b2efb6':
Send power hint on fling gestures.
a02f98239ea683b802ede31382f51eb88eda05d3 17-Sep-2015 Tim Murray <timmurray@google.com> am 952d5b33: Merge "Send power hint on fling gestures." into mnc-dr-dev

* commit '952d5b334ccdf9cab0f56673861906e59d4e9933':
Send power hint on fling gestures.
a4d22d718affbc7145d1012157feb819557b5c06 17-Sep-2015 Michael Wright <michaelwr@google.com> Send power hint on fling gestures.

Use the existing PointerEventListener infrastructure to listen for
gestures that look like flings and hint to the power system when they
happen. Since we don't actually have a bound for the fling like a
regular application would, limit them to five seconds and refresh
every time a new fling is seen until the five second time period is
up.

bug 24059298

Change-Id: I5757a1e88f2ab2ef08cccefa8221d809ae71bb6f
owerManagerService.java
13d2fa50b0815c63d2d289c27d8edacf1ace01eb 08-Sep-2015 Nick Armstrong-Crews <strongarm@google.com> am 740cf71c: am 56ecfcce: Handle KEYCODE_SOFT_SLEEP from Ungaze.

* commit '740cf71c9978e5dcb0a68b6558531a52dc26d44f':
Handle KEYCODE_SOFT_SLEEP from Ungaze.
56ecfcce6c88fc80cf509effcebb124bbe0c79f8 08-Sep-2015 Nick Armstrong-Crews <strongarm@google.com> Handle KEYCODE_SOFT_SLEEP from Ungaze.

Needed for Ungaze to trigger "soft sleep" (respecting wake locks); operates by
sending new KEYCODE_SOFT_SLEEP to PhoneWindowManager, which calls
PowerManagerService's new method setUserInactiveOverride (thereby
causing immediate sleep, modulo wakelocks, upon next iteration of
PowerManagerService's main loop).

BUG: b/23589870
Change-Id: Iddafdde923605d119075e890eeda5d3fd3fd2bc7
owerManagerService.java
d70377b537450d03d5cdc2efb15977d48e5cfebd 08-Sep-2015 Nick Armstrong-Crews <strongarm@google.com> am 36afc2b7: am 9b8f82a3: Merge "Revert "Handle KEYCODE_SOFT_SLEEP from Ungaze."" into cw-e-dev

* commit '36afc2b76743b2b2803da20dc6a8b2142d1f9b17':
Revert "Handle KEYCODE_SOFT_SLEEP from Ungaze."
b331bf951499396111cb47b477ac35e82c805322 08-Sep-2015 Nick Armstrong-Crews <strongarm@google.com> Revert "Handle KEYCODE_SOFT_SLEEP from Ungaze."

This reverts commit 677adf1e66ba83b8fb2c849c181303b35bd489bc.

Hiding new keycode to prevent change to public API before resubmitting.

Change-Id: Ic43273dd0c7ade1d51a36b77f363543f1df466e8
owerManagerService.java
7f37402d8c5667f72c1ef02a20112d49d7a149b8 04-Sep-2015 Nick Armstrong-Crews <strongarm@google.com> am 43c4459d: am 6f0ba402: Merge "Handle KEYCODE_SOFT_SLEEP from Ungaze." into cw-e-dev

* commit '43c4459d995ce7a723d92945a7e4ccb81d48e224':
Handle KEYCODE_SOFT_SLEEP from Ungaze.
677adf1e66ba83b8fb2c849c181303b35bd489bc 27-Aug-2015 Nick Armstrong-Crews <strongarm@google.com> Handle KEYCODE_SOFT_SLEEP from Ungaze.

Needed for Ungaze to trigger "soft sleep" (respecting wake locks); operates by
sending new KEYCODE_SOFT_SLEEP to PhoneWindowManager, which calls
PowerManagerService's new method setUserInactiveOverride (thereby
causing immediate sleep, modulo wakelocks, upon next iteration of
PowerManagerService's main loop).

BUG: b/23589870
Change-Id: I24a96bd6db8ff28674c907f2898e49c4f6140209
owerManagerService.java
82e780743046e620b724c28023b580e0e624bb15 03-Aug-2015 Yusuke Sato <yusukes@google.com> am b98e2353: am 158560ad: Merge "Distinguish user-requested shutdown from power-related ones"

* commit 'b98e235364c2b221521f622c546733b2862e4677':
Distinguish user-requested shutdown from power-related ones
705ffd1efe529bb291e90fa06e92c8090ee98627 22-Jul-2015 Yusuke Sato <yusukes@google.com> Distinguish user-requested shutdown from power-related ones

With this patch, when the user requested shutdown,
PowerManagerService sets sys.powerctl is set to
"shutdown,userrequested", and init runs fsck on shutdown.

When shutdown is triggered due to a low power state etc.,
the service sets the property to "shutdown,", and init
immediately shuts down the system without running the
command.

This is a follow-up CL for http://r.android.com/158525.

Bug: 21853106
Change-Id: Iae72990130fe9aa479c802f77301438190dbbfb3
owerManagerService.java
hutdownThread.java
6ad2d66072795dd9836350b273dcde52910ab4c3 18-Jul-2015 Billy Lau <billylau@google.com> Bug: 21589105 Rescope WRITE_SETTINGS permission (framework services perm check
changes)

AppOpsManager:
Changed the default operating mode for WRITE_SETTINGS to MODE_DEFAULT from
MODE_ALLOWED.

packages/SettingsProvider:
We no longer do static permission checks for WRITE_SETTINGS in early checks and
defer that to app op when MODE_DEFAULT is returned. For some operations,
checking against WRITE_SECURE_SETTINGS is sufficient.

ActivityManagerService & PowerManagerService:
Incorporated app op checks and handled the MODE_DEFAULT case.

provider/Settings:
Added helper function to do checks on whether app ops protected operations
can be performed by a caller. This includes checks for WRITE_SETTINGS and
SYSTEM_ALERT_WINDOW.
Also added a public API (with javadocs) for apps to query if they can modify
system settings.
Changed the javadocs description for ACTION_MANAGE_WRITE_SETTINGS and
ACTION_MANAGE_OVERLAY_PERMISSION.
Added public API (with javadocs) for apps to query whether they can draw overlays or not,
and also javadocs description on how to use that check.

Change-Id: I7b651fe8af836c2074defdbd6acfec3f32acdbe9
owerManagerService.java
fa6e0a80e20a4917b403fd330e01a9edd021aabc 24-Jul-2015 Yohei Yukawa <yukawa@google.com> Don't rely on broadcast intent for waking up input method.

Basically this is a copy of Iabef96921dd554ce3768fb18619cefc
for InputMethodManagerService.

As described in JavaDoc of Intent#ACTION_SCREEN_OFF and
Intent#ACTION_SCREEN_ON, one can use those Intents to be
notified when the device becomes non-interactive and
interactive. IMMS has relied on them to enable and disable
InputConnection between the IME and the application so as not
to allow IMEs to update text when the user does not present.
This is actually our design goal as documented in JavaDoc of
InputMethodManager.

An IME can never interact with an InputConnection while
the screen is off. This is enforced by making all clients
inactive while the screen is off, and prevents bad IMEs from
driving the UI when the user can not be aware of its
behavior.

The goal of this CL is to improve the timeliness of above
mechianism by introducing a direct communication channel from
PowerManagerService to InputMethodManagerService via Notifier.
Actually this is what InputManager has been doing since
Iabef96921dd554ce3768fb18619cefc3230b5fb0.

Reasons behind this change are:

1. There are several bugreports that imply those Intents can
dispatch tens of seconds after it is enqueued. This is
indeed problematic because the user cannot type password
to unlock their devices until queued
Intent#ACTION_SCREEN_ON is dispatched. This CL addresses
such an issue without waiting for figuring out the root
cause of the delay.
2. Intent#ACTION_SCREEN_OFF and Intent#ACTION_SCREEN_ON are
sent as a ordered broadcast, which may not be suitable for
tasks that require a certain level of timeliness, and what
IMMS wants is to enable users to start typing immediately
after the system.

This CL was originally authored by Seigo Nonaka.

Bug: 22423200
Bug: 22555778
Change-Id: I747c37ff6dd8f233faef43f2b5713a4320e848eb
otifier.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
otifier.java
owerManagerService.java
3b16cf4f47142a845bf0ede54ef8ef956506c6c3 02-Jul-2015 Dianne Hackborn <hackbod@google.com> Device idle fixes: issue #22209630 and issue #22225665

Issue #22209630: Only allow whitelisted apps to put apps on the temp whitelist

We now check whether the calling app is a system uid or in the whitelist
and, if not, throw an exception.

Issue #22225665: Alarm still goes off in idle mode (doze)

Fix a bug where we were not clearing the calling identity when coming
through the dump command to the service, and as a result when we would
eventually call out to the alarm manager it wouldn't do what we want.
This was only broken when being controlled by the shell.

Also adjust the network policy manager service's handling of device
idle transitions to only toggle the device idle state, which gets rid
of the long delay we have coming out of idle mode. And add in a bit
of logging around going in/out of idle mode to try to understand where
things may be slow in the future.

Change-Id: I4a41f790e9b0bb31330314b94111557d479f2ba5
owerManagerService.java
63ec93d57094be624f2069d063146ca713574530 26-Jun-2015 Jim Miller <jaggies@google.com> Merge "Have FingerprintService keep the device awake on relevant events." into mnc-dev
c4bd42c1eedefca4f15816e4e00af617dcfc8993 13-Jun-2015 Jeff Brown <jeffbrown@google.com> Fix reporting of wakelocks to battery stats.

Fixed certain wake lock types which were being incorrectly reported to
BatteryStats as WAKE_TYPE_FULL due to incomplete decoding of the wake
lock level.

Bug: 21949905
Change-Id: Ie3abfc9f473ce721ad042d228175592c7b8ede33
otifier.java
owerManagerService.java
dca15d22e8f37d4bc2dfb6db4522ea166149525b 17-Jun-2015 Jim Miller <jaggies@google.com> Have FingerprintService keep the device awake on relevant events.

Fixes bug 20732273

Change-Id: I61b827dd7b1bc706a0288571751032301fd5479f
owerManagerService.java
f2a91ee148a3b753f85abff0d8adeace0c713726 03-Jun-2015 Tao Bao <tbao@google.com> Improve the reboot-to-recovery dialogs

To address the UX comments, this CL modifies the dialogs when the
device is rebooted to install an update or to perform factory data
reset.

Bug: 20949086
(cherry picked from commit 81dce6631396012e8b722bbed6d003f584800ae1)
Change-Id: I6d0cbbbaf184806366c6581c1c2e7dbcc5d89a17
hutdownThread.java
fa861429f7ec0b9f83a2baacc3c6fb680467039b 22-May-2015 Tao Bao <tbao@google.com> Wait for uncrypt to finish before rebooting

/system/bin/uncrypt needs to be triggered to prepare the OTA package
before rebooting into the recovery. For larger packages, uncrypt may be
killed before it finishes the work after the timeout. Change to monitor
the uncrypt status and show the progress to user.

Needs matching changes in bootable/recovery/uncrypt, system/core and
external/sepolicy.

Also pick up the two NPE fixes in commits
9bb765448df43d41e0a3edb7de1d1641c9251c35 and
da3f63ffb87397943546a7c5c893ce98f2489df2.

Bug: 20012567
Bug: 20949086
(cherry picked from commit 90237f7beb55dae79cdcba5271f96be778573737)
Change-Id: Ibf2fc80032967e5f6cda3cd469005dd29665c87c
owerManagerService.java
hutdownThread.java
81dce6631396012e8b722bbed6d003f584800ae1 03-Jun-2015 Tao Bao <tbao@google.com> Improve the reboot-to-recovery dialogs

To address the UX comments, this CL modifies the dialogs when the
device is rebooted to install an update or to perform factory data
reset.

Bug: 20949086
Change-Id: Icc1cdec7e0336ae37c17fffde7dae7ff882e5470
hutdownThread.java
ff3b76d04672d09214cd0ceb29ec548c8abb2330 02-Jun-2015 Amith Yamasani <yamasani@google.com> Merge "Temporarily whitelist an app for network during doze" into mnc-dev
983d449a84b6040e15368da925149419fc6b7010 02-Jun-2015 Tao Bao <tbao@google.com> Fix the NPE when checking mRebootReason

Bug: 21584198
Change-Id: Ie11092dbc771b54bd049d258dc705835a3eda494
hutdownThread.java
af575b9f8e1b59be9c8862b6a65c0dcb88145a23 30-May-2015 Amith Yamasani <yamasani@google.com> Temporarily whitelist an app for network during doze

API to allow an app to be whitelisted for network and wakelock
access for a short period. So even if the device is in idle
mode, such apps can be given a chance to download the payload
related to a high priority cloud-to-device message.

This API is meant for system apps only.

A new permission CHANGE_DEVICE_IDLE_TEMP_WHITELIST is required
to make this call.

Bug: 21525864
Change-Id: Id7a761a664f21af5d7ff55aa56e8df98d15511ca
owerManagerService.java
cb81d183672a3d9858ade10a997990c5d66a1be3 30-May-2015 Jeff Brown <jeffbrown@google.com> Merge "Tell PhoneWindowManager when we start/finish interactive changes." into mnc-dev
416c49c4049f572134273e228d7988904a51b990 27-May-2015 Jeff Brown <jeffbrown@google.com> Tell PhoneWindowManager when we start/finish interactive changes.

Added some new callbacks that can be used to more precisely trigger
certain behaviors that need to happen around the time the device
is put to sleep and locked.

Fixed an issue where the going to sleep signal might be sent too
early on devices that don't support ambient mode due to the extra
wakefulness change between DOZING and ASLEEP. We are now track
the early / late interactive change work separately from the rest.

Bug: 21375811
Change-Id: I95387195e216ae92a6e45485bd1bd362e41aa45a
otifier.java
owerManagerService.java
9bb765448df43d41e0a3edb7de1d1641c9251c35 29-May-2015 Guang Zhu <guangzhu@google.com> fix NPE in shutdown thread

null reboot reason is used when it's a simple reboot.

Change-Id: I9d3110ca733a1b0401721fde907924c101997c4f
hutdownThread.java
165102f350e08bd186b25b90dd8a42aad8975890 28-May-2015 Tao Bao <tbao@google.com> Merge "Wait for uncrypt to finish before rebooting" into mnc-dev
90237f7beb55dae79cdcba5271f96be778573737 22-May-2015 Tao Bao <tbao@google.com> Wait for uncrypt to finish before rebooting

/system/bin/uncrypt needs to be triggered to prepare the OTA package
before rebooting into the recovery. For larger packages, uncrypt may be
killed before it finishes the work after the timeout. Change to monitor
the uncrypt status and show the progress to user.

Needs matching changes in bootable/recovery/uncrypt, system/core and
external/sepolicy.

Bug: 20012567
Bug: 20949086
Change-Id: I2348a98312c4dae81f618b45a2ee3b4cf6246ff5
owerManagerService.java
hutdownThread.java
d23e0d6901935588f9472bd7073fea0009581e9b 16-May-2015 Dianne Hackborn <hackbod@google.com> Update power manager to track uid state like netstats.

To follow the correct semantics for when restricts due to
device idle can be applied, power manager need to know about
uid process states like net policy so that it can allow
wake locks from apps that are in the foreground.

Since this is being added to a second place, I reworked things
so that the activity manager now keeps track of per-uid process
states and allows apps to register to listen to those, rather
than having to track lower-level process states and transform
them into an overall uid state. Both net policy and power
manager use this new facility.

Change-Id: I77359164c40d0f36fe1ef296dd9f9c3062431148
owerManagerService.java
27bbb2d0a1c8a3bb38768511ac840c3388b0fb03 31-Mar-2015 Jason Monk <jmonk@google.com> Add control for double tap to wake setting

Bug: 16875464
Change-Id: Ic1ad910dd38acbc68ef040b2acdf3696ec2c2e4e
owerManagerService.java
9c8600e1af1af6eb2f57a965bbfe941fbd082786 12-May-2015 Dianne Hackborn <hackbod@google.com> Merge "Implement device idle in power manager." into mnc-dev
8d66b3fbf5d8036e25d64a8472bcd2b6b7892a1a 09-May-2015 Dianne Hackborn <hackbod@google.com> Implement device idle in power manager.

When in device idle mode, we now prevent most apps
from being able to hold partial wake locks. The
device idle controller now pushes its white list of
app uids into the power manager, so it can apply this
policy correctly to only apps that are not whitelisted.

The implementation adds a new "disabled" flag to a wake
lock which is set when we want to apply this policy. When
set, we ensure that we tell battery stats that the wake lock
is not being held and ignore that wake lock when computing
the power state summary.

Also add new SDK APIs to schedule alarms that are allowed
to execute while in idle mode.

Finally add new dumpsys commands to the device idle controller
to completely disable and re-enable its operation, to use
for testing.

Change-Id: I1f16672c6ac06d03bb538f9854d5843db9aa6f27
owerManagerService.java
51a871d48a9f4d912b2c12c29bbddcc5ec175825 06-May-2015 John Spurlock <jspurlock@google.com> Add setting to mute wireless charging sound.

Bug: 19538553
Change-Id: I1af971b35ae9eeb38d8ec38c57b22152095e2725
otifier.java
df7f02b6e098dbcda6a6d52252c31ee2e02d8e00 30-Apr-2015 John Spurlock <jspurlock@google.com> am ad61b833: Merge "Fix no vibration during shutdown."

* commit 'ad61b8336aa9627a6ae19580bbdc370dc8bd6810':
Fix no vibration during shutdown.
0b4daca9ba54b7252ea8c159218391380eb00c8a 27-Apr-2015 Dianne Hackborn <hackbod@google.com> Implement user-settable power save whitelist.

The whitelist is now maintained by DeviceIdleController,
which is moving out into its own independent system service.
Network stats now queries it for the whitelist, instead of
collecting that itself.

Also did a few improvements in alarm manager -- made the
code for moving alarms out of the pending list more robust,
and fixed the debug output to always print the contents of
the pending list even if we aren't in a pending state. (That
would have helped me identify the problem much earlier.)

Change-Id: I0f7119d4c553c3af4d77b2f71246fa6e2c13c561
eviceIdleController.java
a576b4d3be8687f0a65fc5777424955d551604e4 24-Apr-2015 Jeff Brown <jeffbrown@google.com> Add code to collect data about auto-brightness adjustments.

Write samples of the old and new state to the binary event log whenever
the user modifies the auto-brightness adjustment. We wait a few seconds
before logging to ensure that the user is satisfied with the adjustment.

Bug: 19786916
Change-Id: I41402decd1034d0839aa0f47495bc00907ab9c08
owerManagerService.java
f70faed503c8482266e6acb94dd5281488a9117e 21-Apr-2015 Dianne Hackborn <hackbod@google.com> Work on issue #20401752: device idle and alarms.

Main change is to fix problems in the alarm manager where it
was not doing a good job at scheduling the device idle wakeup
before an alarm. To fix this, we now keep explicit track of
the next "wake from idle" alarm so we can consistently use that
to adjust the time of the device idle alarm if needed.

Also a bunch of debugging stuff to help further diagnose this
problem:

- Alarm summary now includes the last time the alarm went off.
- Improved dumpsys output of alarms.
- New event log tags for changes related to idle state.

Change-Id: Idd2c8d24ae23379f7c75815ddbc6835c2a04656c
eviceIdleController.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
eviceIdleController.java
a223d658306fea5c0a6d30c9850058d5afadb2d1 25-Mar-2015 Bryce Lee <brycelee@google.com> am 3309be5e: am 21b7e6de: am c831b978: Merge "Add isScreenBrightnessBoosted and a broadcast when underlying value changes." into lmp-mr1-modular-dev

* commit '3309be5e7bc782d89adaf4abca5f1f81649c655f':
Add isScreenBrightnessBoosted and a broadcast when underlying value changes.
c831b978238d5ed200ca329c540eff00faba77e3 25-Mar-2015 Bryce Lee <brycelee@google.com> Merge "Add isScreenBrightnessBoosted and a broadcast when underlying value changes." into lmp-mr1-modular-dev
88e98dfa59e68a860d8c3b462ec03bc0b06d6b5c 23-Mar-2015 Dianne Hackborn <hackbod@google.com> More work on device idle mode.

- There is now an API for people to find out about
its state.
- Moved DeviceIdleController to be closer to the
power manager implementation, since they are
closely related.
- Job scheduler now knows about idle state and doesn't
run jobs while the device is idle.
- Battery stats now keeps track of "idling" vs "idle mode".
Idling is when we consider the device to be idle,
independent of whether we are actually in deep idle mode.
This allows us to keep track of longer-term changes
independently of cycling in and out of idle mode.
- Battery stats also now keeps track of package changes in
its daily stats.
- Small optimization to network policy manager service to
not touch uids that do not have the NETWORK permission.

Change-Id: I0b3304fb3722c78cdfdd0c1eada7369ece7cbcf9
eviceIdleController.java
owerManagerService.java
bff46bac807ae8a9ebdc22c449a8d4f78711b4d2 05-Mar-2015 Benjamin Franz <bfranz@google.com> Add DO policy to disable safe boot mode.

Bug: 19615843
Change-Id: I14dbe911995ec216c57bd285d6b7b04c9684591a
hutdownThread.java
d3b371755df509cabbc5b4451df83309be5439b0 18-Mar-2015 riddle_hsu <riddle_hsu@htc.com> Fix no vibration during shutdown.

In ShutdownThread:rebootOrShutdown, the vibrator is created
by "new SystemVibrator()" which will use default constructor
of Vibrator.

And because system server is not bound application,
ActivityThread.currentPackageName will be null.
Then the member mPackageName of Vibrator is null.

When doing vibration:
VibratorService.startVibrationLocked
-> mAppOpsService.startOperation
-> getOpsLocked (null package will get null op)
-> return MODE_ERRORED
-> no vibration

https://code.google.com/p/android/issues/detail?id=160830

Pass null context in SystemServer.performPendingShutdown
because vibrator service is not ready, and from the call
sequence, there is no available context to use.

Change-Id: I3e0175ba6dc2e1a92787873eda4461fba6e89783
hutdownThread.java
84d6c0fbf6e513d68330234503b809751d0e3564 17-Mar-2015 Bryce Lee <brycelee@google.com> Add isScreenBrightnessBoosted and a broadcast when underlying
value changes.

Bug: 18334219
Change-Id: I20051e97633017711574a063b8061f95c3b616c5
otifier.java
owerManagerService.java
9779e128d611f13cdb44d31b0509ff43c62a35f6 14-Mar-2015 Filip Gruszczynski <gruszczy@google.com> Option for going home when going to sleep for devices without physical button.

Bug: 19623388
Change-Id: Iec16f83c64646ded12ec97d4b540510b7f9dfd47
owerManagerService.java
c2932a1be3e320679034212698aff376d5104dbe 21-Nov-2014 Jeff Brown <jeffbrown@google.com> Hold a wake lock while dozing when display updates are pending.

When the display state is DOZE or DOZE_SUSPEND, assume this means
that the AP may go to sleep at any time so hold a wake lock for
a little while starting when traversals are scheduled to ensure
that the AP remains awake long enough to draw and post the frame
to the display hardware.

This patch is somewhat approximate but should be good enough for
most devices today.

Note that the implementation uses the window manager to ensure that
the window which wants to draw is actually visible before acquiring
the wake lock. There is a cost to this test (a round-trip) which
should not be significant today since we do not expect apps to draw
more than one frame or two while dozing. However, if we wanted to
support animations in general, we might want to optimize it or
eliminate the check altogether (since we can already account for
the app's use of the wake lock).

Another way to implement this functionality might be for the view
hierarchy to listen for the power manager to report that it has entered
a non-interactive power state before deciding to poke draw locks.
This would be somewhat more accurate than watching the display state.
Also, the draw lock timeout logic could be implemented more directly
instead of using an ordinary timed wake lock.

Bug: 18284212
Change-Id: I84b341c678303e8b7481bd1620e634fe82cc4350
owerManagerService.java
01c06dfb076b71cb72c4bff9175bec9d59d2efde 17-Dec-2014 Michael Runge <mrunge@google.com> Increase timeout when uncrypting OTA

Larger OTAs (750 MB tested) are taking 3-4 minutes
to write, due to the O_SYNC needed to ensure that
the data is actually committed to disk prior to
reboot.

Bug: 18750317
Change-Id: Idfab3ffd0276df4548f69a09c72ad6f4a344b6e6
owerManagerService.java
9ef94019386183cb88ad090965418ef294bbb79a 21-Nov-2014 Jeff Brown <jeffbrown@google.com> resolved conflicts for merge of 694c1d2b to lmp-mr1-dev

Change-Id: I9a9b724e0fd12aa161ff276540431b9d8e218e2b
fbe96706bb9754f9ea3f6345f32e058a45ad10b4 20-Nov-2014 Jeff Brown <jeffbrown@google.com> Support keeping activities resumed while dozing.

If the lock screen is not shown, then let activities keep running
while dozing. This is important to support ambient mode on watches
since it allows the home app to keep running.

To make this possible, we need to inform the activity manager about
the exact wakefulness state, not just the overall boolean
interactive state.

Bug: 18284212
Change-Id: Ia35c99127ce51ffc178f3a2f51fca67d24061c71
otifier.java
owerManagerService.java
cb906677fc65fd1b43f6dc3b8e029711ec8e86dc 13-Nov-2014 Jeff Brown <jeffbrown@google.com> am 24c1d664: Merge "Remove an unnecessary condition from previous change." into lmp-sprout-dev

* commit '24c1d664c4f95a8c997bfc4683844e05b788c3db':
Remove an unnecessary condition from previous change.
72f1e3b9c9992bfc3449c5441bc8e50e7b05f083 13-Nov-2014 Jeff Brown <jeffbrown@google.com> am 1cbff0e3: Merge "Improve screen brightness boost behavior." into lmp-sprout-dev

* commit '1cbff0e310b0fba6b25ca1c1e14eaefeabdee0d9':
Improve screen brightness boost behavior.
a191aa99ab67d05bc72e5e20f854bbdd1ea474c1 13-Nov-2014 Jeff Brown <jeffbrown@google.com> Remove an unnecessary condition from previous change.

Change-Id: Ib966fbb373294ad60caf7f1d9cbb7fafd05ded6b
owerManagerService.java
7b5be5e2a738859d36e1977cdc756cf83361d72f 13-Nov-2014 Jeff Brown <jeffbrown@google.com> Improve screen brightness boost behavior.

Wake-up when entering brightness boost mode, don't boost in ambient
mode since some display device drivers do strange things in that mode and
boost doesn't work. Waking up feels more natural as well.

Don't flutter the power HAL's interactive mode bit simply due to changes
in display ready state since that may result in visible artifacts
such as display flashes.

Don't stop the auto-brightness sensor while temporarily boosted.

Don't prevent the display from entering the ready state while in brightness
boost since that would unnecessarily delay the transition from DOZING to AWAKE
until boost is finished.

Restart the user activity timeout when brightness boost ends and prevent
the display from dimming while boosted.

The pixel fairies basked in the sunlight.

Bug: 18262044
Bug: 18261782
Change-Id: I8c42a1e6091b0fe1253e90265ac248087ebc24e1
owerManagerService.java
5ce1cb240b13db98fbdc21e1ef069b5f9cec8d72 07-Nov-2014 Jeff Brown <jeffbrown@google.com> Move device admin max screen off timeout to internal interface.

The setting was previously exposed in IPowerManager but it
doesn't need to be there.

Bug: 17656076
Change-Id: If3ed0cbe89f67c60aa00376be0c54b1bd9656144
owerManagerService.java
e333e674a758c39885d4d9779a1aad387fb0e6aa 28-Oct-2014 Jeff Brown <jeffbrown@google.com> Add a function to boost screen brightness temporarily.

When PowerManager.boostScreenBrightness() is called, the screen
brightness is set to maximum for 5 seconds. This action is
also considered to be user activity.

Bug: 17934954
Change-Id: I1cb4a03a60705c6c1c5cc9ff84b1c5dbd2932fcd
owerManagerService.java
584a44517950204a04ef01345be70b33d8ba43f9 22-Oct-2014 Bryce Lee <brycelee@google.com> [Theater Mode] framework implementation through global setting

Bug: 17684570
Change-Id: I64a9c9c0620049cdfcca0150648fa201281f7178
owerManagerService.java
c338784bf6bfcce3cd7db40f46b0e6c815e9ed3a 02-Oct-2014 Dianne Hackborn <hackbod@google.com> Merge "More work on issue #17656716: Unhandled exception in Window Manager" into lmp-dev
8d05172112436a81bed6e4a0810f8914509d8a4d 01-Oct-2014 Dianne Hackborn <hackbod@google.com> More work on issue #17656716: Unhandled exception in Window Manager

Fix Slog.wtf to not acquire the activity manager lock in its code
path, so that it can never deadlock. This was the original intention
of it, but part was missed.

Now we can put back in the code to detect when strict mode data is
getting large (a little more targeted now to the actual problem),
and use Slog.wtf to report it. And as a bonus, when this happens
we will now clear all of the collected violations, to avoid getting
in to the bad case where IPCs start failing. So this should be
good enough for L to fix the problem, with wtf reports for us to
see if the underlying issue is still happening.

Finally, switch a butch of stuff in the system process from Log.wtf
to Slog.wtf, since many of those are deadlocks waiting to happen.

Oh and fix a crash in the settings provider I noticed in APR.

Change-Id: I307d51b7a4db238fd1e5fe2f3f9bf1b9c6f1c041
owerManagerService.java
05af6adb8d4fd5ea069c9aead5a877da9085daa8 01-Oct-2014 Jeff Brown <jeffbrown@google.com> Implement auto-sleep functionality.

Added a new SLEEP_TIMEOUT setting which governs how long the device will
remain awake or dreaming without user activity. By default this
value is set to -1 which maintains today's existing behavior.

We basically represent the time we are allowed to be dreaming as a new
kind of user activity summary state called DREAM, similar to BRIGHT
and DIM. When the sleep timeout expires, the state is cleared and
the dream ends.

Bug: 17665809
Change-Id: I59aa7648dcec215f1285464fc1134934a09230e5
owerManagerService.java
3ee549ca2404067bb8b2fcbaa741ec118c76bf3e 23-Sep-2014 Jeff Brown <jeffbrown@google.com> Fix window manager policy state when waking from doze.

Once upon a time when the world was fresh and new, the heavens
had an easy rhythm. Day and night. Night and day. In the day,
the pixel fairies would cavort and play in the bright gardens
with narry a mark of shadow or gloom. In the night, they would
rest peacefully, dreaming no dreams and knowing no fear.

Then one night a fairy dreamed the first dream. At first
the dream was peaceful, full of colors and delight, hopes and
memories. Then all at once, jarringly, it awoke in bright
daylight. The pixel fairy knew fear, for the world had changed
and it was unprepared.

Time passed and the pixel fairies grew accustomed to their
fate, day and night, night and day, sometimes dreaming, until
there came a night when a fairy did not sleep. It roamed
the land in a dreamless doze, lost and afraid amid a grim haze
of grey and darkness. The fairy despaired. It wanted no
part of this place. It pretended for a time to be awake but
the bright daylight would not come. It pretended for a time to
be dreaming but the colors and memories would not come.
That is when the fairy wished for oblivion. Then just as
suddenly, it awoke in the daylight. It fell to the ground,
stunned as if it had forgotten how to walk in the too bright
daylight.

Though the world again grew softer and kinder in time, the pixel
fairies were never the same. For the night is dark and full
of terrors.

---

It used to be easy. Screen on and screen off could explain almost
everything about the state of the device but it's different now with
ambient display. We need to be able to wait for all windows to be
drawn even in the case where the device is still nominally asleep.
In truth, the window manager policy which drives a lot of these
interactions is a thicket of outdated assumptions.

Added a new method to tell the window manager policy when the screen
is being turned off so that it can correctly account for changes
to the interactive state (wakeUp and goingToSleep) and screen state
(screenTurningOn and screenTurnedOff). Now we can independently
poke keyguard during interactive state changes and we can apply
screen on blocking during screen state changes.

Moved the code which manages screen on blocking (which is what
ensures the UI has fully drawn before revealing screen contents)
from the power manager to the display manager since the display
manager is in a better position to accurately track the state of
the screen, particularly when the screen is being turned off.

Fixed a bunch of synchronization issues. Previously some work
had been moved to a handler without considering what might
happen if it became reordered relative to other work happening
elsewhere. Documented the desired behavior in the code to
prevent this from happening again.

There's still a bunch of stuff in here that isn't quite right,
particularly the assumption that there's only one screen, but
it's good enough for now. Hopefully there aren't too many bugs.

Bug: 17605802
Change-Id: Ic7319e09948c8a3cda014d7e169c964a3ad86f14
otifier.java
owerManagerService.java
36c4db8bd3bd7dad4b6cb8abd9cdc1a627fe3bbc 19-Sep-2014 Jeff Brown <jeffbrown@google.com> Decouple turning screen on from waking up in policy.

This allows us to ensure windows are fully drawn before unblocking
screen on while dozing.

Bug: 17516245
Change-Id: Ibe63c212b8db855ce26a34a8169f33764b266ee6
otifier.java
owerManagerService.java
8d4e6cb06005a2ce994360340a6191f0690db8f4 14-Sep-2014 John Spurlock <jspurlock@google.com> Saver: PowerManager call to set low power mode.

- Add an explicit power manager call to set the low power mode state,
instead of trying manage everything around a single setting.
- When low-power mode is triggered by falling below the configured
threshold, it does not update the setting.
- The "is-enabled" api returns setting || below configured trigger.
- Move the snooze management into the new api call.
- Callers (sysui + settings) updated to use the api instead of the
setting.
- Handles the case where the level does an unpowered leap out of the
low battery level. (Possible if powered in-between while the device
is off)

Bug:17460535
Change-Id: Ic030504c9cad9868a7137abbe837b170da37852b
owerManagerService.java
2175e9c366998ed7bd1a4501b94a02f4f49b932c 13-Sep-2014 Jeff Brown <jeffbrown@google.com> Add support for dozing after screen off.

On some devices, we want the screen off transition to complete before
we start dozing. Added a new config.xml attribute config_dozeAfterScreenOff
to configure this behavior.

Defer starting dreams until the display is ready.

Fixed some minor issues in the system UI doze service when setting the
display state.

Bug: 16187655
Change-Id: Ib1bc60de5457166f4b4880732db5df989dda67a4
owerManagerService.java
1208e2718daeae538dc89c37198092ccb32798a2 09-Sep-2014 Michael Wright <michaelwr@google.com> Change constant to PowerManager.RELEAES_FLAG_WAIT_FOR_NO_PROXIMITY

Bug: 17290118
Change-Id: Iae3866bf3f7ac24f756ec4c183e848a79d1f779b
owerManagerService.java
6e2f395a86d557d2de4b52dda419a5f3eee00c84 09-Sep-2014 Craig Mautner <cmautner@google.com> Wait for animation complete before completing boot

Defer the boot process in ActivityManagerService,
WindowManagerService and PowerManagerService until the boot
animation has completed.

Fixes bug 16309312.

Change-Id: Ic5e0d627ca4ded3e211c5d2afece89da40d34642
owerManagerService.java
219857b900e2a15464c6254d8d64b68db7d548c0 28-Aug-2014 Michael Wright <michaelwr@google.com> Change constant to PowerManager#FLAG_WAIT_FOR_DISTANT_PROXIMITY

Also add docs to PowerManager.WakeLock#release(int)

Bug: 17290118
Change-Id: Ibcbc4279efdd0f275808042356e6ff843958e23f
owerManagerService.java
0a571123544058578b4ef1558c276a4050519652 22-Aug-2014 Jeff Brown <jeffbrown@google.com> Poke interactive hint from userActivity and add @SystemApi.

Previously we only poked the interactive hint for input events that
were dispatched through the regular input system. However, when
using a car dock in projection mode input events are directly
delivered to apps by other system components, bypassing user activity.
So now we poke the interactive hint on all user activity.

Added an @SystemApi version of userActivity.

Added a new signature|system permission called USER_ACTIVITY
to allow system apps to poke userActivity. For now it seems
prudent to keep DEVICE_POWER signature only.

Bug: 17043684
Change-Id: Ia84bd03083065b8938a9853c08901fbf71b2e56b
owerManagerService.java
72671fbb2036e13fccb0b8eeb98be606de1819dd 22-Aug-2014 Jeff Brown <jeffbrown@google.com> Require DEVICE_POWER permission for DOZE_WAKE_LOCK.

This wake lock is only intended to be used internally.

Change-Id: I8d109c492605673616cf7f4f31f082a42fb1d912
owerManagerService.java
bd7723637b14d1895c043c2257f1cd9560322d4e 02-Aug-2014 Naveen Kalla <nkalla@codeaurora.org> Invoke shutdownMobileRadios Telephony APIs from ShutdownThread

shutdownMobileRadios API shuts down multiple Radios on MSIM devices and
also gracefully shuts down Radios and SIM cards on single SIM and
MSIM devices. Use this API instead of the old setRadio APIs.

Add RIL_REQUEST_SHUTDOWN to RILConstants. Message is sent to notify
RIL that the device is shutting down.

Bug: 9773278
Change-Id: I6afa9e810cefc7855f7ae42e51f39cc51fa2aa6e
hutdownThread.java
89e4ae2f504b4c55d7823c3f04d4894de0d8e471 18-Aug-2014 Dianne Hackborn <hackbod@google.com> Merge "Work on issue #16629489: Google (Play?) Services eating through battery" into lmp-dev
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
owerManagerService.java
3edf5272fb2185403dfe64b9722b9fc9b9de80f8 15-Aug-2014 Jeff Brown <jeffbrown@google.com> Add trace tag for power management.

Instrumented the basic power manager state transitions,
calling into the Power HAL, setting the display power mode,
and setting the backlight.

Bug: 17004602
Change-Id: I4e362162ddfd7292a7eea8b5d029ce3f6593c4a9
otifier.java
owerManagerService.java
3d69256fdf3f2006d312824386a4b68b4c6f79bd 15-Aug-2014 Ruchi Kandoi <kandoiruchi@google.com> Revert "PowerManager: Adds a call to reduce refresh rate while device is in BatterySaverMode"

This reverts commit d54157e2e92f58e997c4bdb50e026e6a0d0121fd.

Bug: 16654179
Change-Id: Id4f22c0a4e23518881ac58ad969c16c4612306a2
owerManagerService.java
c12035cd40d01b032013f515cb509e6c8791cf65 14-Aug-2014 Jeff Brown <jeffbrown@google.com> Log who is calling goToSleep().

Change-Id: Ibae61c90ee115735835e878bb3bf79eedaa0ae44
owerManagerService.java
6d2a9492e2b19421165f0cd918d9f28595bfb770 08-Aug-2014 Jeff Brown <jeffbrown@google.com> Eliminate power manager latency for boot completed.

The power manager disables the power button until boot completed
occurs. If there are many pending broadcasts in the queue, it
may be possible for BOOT_COMPLETED to be delayed for several
seconds after boot.

To avoid the delay, introduced a new boot phase which is
sent to system services immediately when boot completed happens.

Bug: 13398280
Change-Id: I1833d2ffb20305009dd76363b43e534034f1d0a2
owerManagerService.java
1bb480a3a4ce2ce63c5d09fa7f5cc38ec160ebf4 02-Aug-2014 John Spurlock <jspurlock@google.com> Battery saver: new policy changes + SystemUI tweaks.

- Service policy changes: allow the user to turn off (snooze)
saver mode below the auto-trigger level. Plugging in the
device always exits saver mode.
- Default trigger level is now 0 (never) instead of 15.
- SystemUI now also listens to a new POWER_SAVE_MODE_CHANGING,
since waiting for _CHANGED can take seconds.
- Move shared feature description text into the framework so it
can be shared.
- Tweak dialog title + action strings.
- Remove trigger-level from SystemUI, it no longer needs it.
- Add the ability to turn off saver mode directly from the
notification.
- Migrate saver confirmation dialog to common system UI dialog
helper, and add a few convenience methods.
- Fix bug where the status bar area would be orange over the keyguard
in SHADE_LOCKED mode.

Bug:16214395
Change-Id: I3d1ded1eec9e63e7d97469486f6a320e1bebbccd
owerManagerService.java
6714e86a545a38d8726e75fcd271947b4259c759 24-Jul-2014 Craig Mautner <cmautner@google.com> Refactor screen blocking logic.

Because of the call to turn on the screen introduced in ag/495255
is now made earlier we may not have sent the wakeup broadcast by
the time the windows have all drawn. In such a case onScreenOn()
did not release the wakelock and the screen stayed off.

This change ensures that no matter the timing of onScreenOn()
the wakelock will be released but only for the onScreenOn()
called in response to the most recent screen on transition.

Fixes bug 16404078.

Change-Id: Ic1e3e61e16c1fc34d4ec657e0e53ac49a05ca6a4
otifier.java
970d4132ea28e748c1010be39450a98bbf7466f3 19-Jul-2014 Jeff Brown <jeffbrown@google.com> Allow dreams to control screen state and brightness.

Added setDozeScreenState() and setDozeScreenBrightness() methods to
DreamService. The values specified here only take effect once
startDozing is called and can be changed while dozing.

This required some significant rework of the display power controller
but the result seems quite nice and better represents the policy
we want to apply.

Changed the test dream a little bit to make it flash the screen
every minute using the new functions.

Bug: 15903322
Change-Id: I83bcc34503f1b87727d2b2b3c0ef08507f9f0808
owerManagerService.java
7b41467704f941b11af6aace3e40993afc7f6c6f 18-Jul-2014 John Spurlock <jspurlock@google.com> Zen mode filtering should use new usage constants.

Refactor stream-based calls to usage-based calls.

Bug:15279516
Change-Id: I3f7757d8123c14670e2ad5f8e6aa4e9803efe7ec
hutdownThread.java
f6d466895b74d620d646abbec1c8911f3a0ce0bb 18-Jul-2014 Jeff Brown <jeffbrown@google.com> Allow dreams to wake up gently.

This change adds a new DreamService.wakeUp() method to allow a
dream to wake itself up gently and perform a transition before
finally finishing. The power manager will ask a dream to wake
up gently in most cases but may force it to happen immediately
when necessary.

If the dream takes too long to finish itself then the dream
controller will douse it with water summarily after 5 seconds.

Change-Id: Ib0564c5650cd5a454e1acc5aa91fe46995eecfa7
owerManagerService.java
0d192a9e279133f80a288d34e50c64a5c91c1a5b 16-Jul-2014 Dianne Hackborn <hackbod@google.com> Maybe fix issue #16167054: Wakelock is acquired and released in...

...battery history even though CPU is in suspend

There is a race in the power manager between noting a wake lock
acquire and ensuring the device is staying awake.

Change-Id: I3d76f99d73dca119b09f253f0e31448408c88a3c
owerManagerService.java
0fe32ae50bcbf6d2a281bdc407ce56f3d05632c5 11-Jul-2014 Ruchi Kandoi <kandoiruchi@google.com> PowerManager: Adds a call to reduce refresh rate while device is in
BatterySaverMode.

Adds a binder call to the surface flinger to change the refresh rate
while the device is in BatterySaverMode.

Change-Id: I9b5fdcc279757ceb4b9917cb0445643b50133a04
owerManagerService.java
ddef7e776b35aba0f7b4eb4978e93361b49c145f 10-Jul-2014 Dianne Hackborn <hackbod@google.com> Get rid of security exception spam during boot.

Change-Id: If7a516e463722280bf597f7dd601e7a0f6e379c8
owerManagerService.java
c522d1646ac353aec302252fa53976c1fa46ad3d 02-Jul-2014 Jim Miller <jaggies@google.com> Decouple critical policy power update from SCREEN_ON broadcast

This attempts to fix a bug where ordered broadcasts like
ACTION_SCREEN_ON are substantially delayed by misbehaving
receivers. Instead, we immediately send the state to mPolicy
so that it can wake/sleep the device without delay.

Fixes bug 14313639

Change-Id: I21a191f90e0a19f1ee75c160ecc4e63e8def709e
otifier.java
2139276ce8b54aba5faa858ca69ed5f01445c269 14-Jun-2014 Jeff Brown <jeffbrown@google.com> Refactor BatteryService to new pattern.

Apply SystemService pattern to BatteryService.

Change-Id: I4971b2da8d2aed4d14440fb65863a8b916bab03c
owerManagerService.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
owerManagerService.java
14272302a8b635bd8e9267c1411d0a7ef11bff45 11-Jun-2014 Dianne Hackborn <hackbod@google.com> Implement control of auto power save mode.

Follow the setting for auto power save mode in both
battery service and battery UI. Default level is 15 when
setting is not set; otherwise it is whatever the setting
gives, with 0 meaning auto battery save is off.

Change how we define the "turn off warn" level to be
an adjustment from the warn level, so we can have a good
value for whatever auto setting is set.

Fix power manager to never go in to power save mode when
plugged in, even if the user has manually turned it on.

Add new delete option to settings command, because I needed
it for testing.

Change-Id: I512b691df84399d50b8e751fd50732c6093ebe85
owerManagerService.java
eb94fa7975b1e8742f3b00cec6bd4f9d6b329e3a 04-Jun-2014 Dianne Hackborn <hackbod@google.com> Improvements to low power mode.

Add new public API for monitoring low power mode.

BatteryService now puts device in to low power mode when
battery level is low.

Window manager now watches low power mode to turn off
animations.

Modifying the animator scale now gets propagated to all
processes.

Change-Id: I8fa566994764ddd4e1977631e28381ab9409f8ee
owerManagerService.java
d862ebb6036a769cb3be371b396e9e33f89ee365 21-May-2014 Narayan Kamath <narayan@google.com> resolved conflicts for merge of fcc4fed3 to master

Change-Id: Icebca982b01debd67a1470c02651ef8936f6e5b0
fcc4fed3c16a57ef713a96b7298ed43aaeef2df4 21-May-2014 Jeff Brown <jeffbrown@google.com> am 6fb904bf: Merge "Make power button behavior configurable." into klp-modular-dev

* commit '6fb904bfd1f943547d6e5bc6f199ffec2290da01':
Make power button behavior configurable.
6d8fd27e51d799cf7418b14092b5e806d9792812 21-May-2014 Jeff Brown <jeffbrown@google.com> Make power button behavior configurable.

Allow power button to be used to either go to sleep as usual,
which may doze, or skip that completely and really go to sleep.
May also really go to sleep and go home all at once.

Bug: 14406056
Change-Id: Ia19e2551b9c2a72271bb2eddd5c0d1749761e019
owerManagerService.java
df3bad37d2e3b52a86b18e0d9c84ede4d5098f92 21-May-2014 Jeff Brown <jeffbrown@google.com> am 8f120dd6: am 0702786d: Merge "Allow display timeouts to be set in config.xml." into klp-modular-dev

* commit '8f120dd6d631ac632d3356b81403a53f958021f0':
Allow display timeouts to be set in config.xml.
8f120dd6d631ac632d3356b81403a53f958021f0 21-May-2014 Jeff Brown <jeffbrown@google.com> am 0702786d: Merge "Allow display timeouts to be set in config.xml." into klp-modular-dev

* commit '0702786d81eb9f9bf47c3a0827d3f2824c3f4228':
Allow display timeouts to be set in config.xml.
27736f5c0ada99bf2a7e007a1dec0ad51f65fa52 21-May-2014 Jeff Brown <jeffbrown@google.com> Allow display timeouts to be set in config.xml.

Bug: 13671523
Change-Id: I79fc21999bc62743178d2d22071455a0c11070c9
owerManagerService.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
otifier.java
owerManagerService.java
6dee605c834fe4926cc1ae5c584563bdb2b608a1 14-May-2014 Adrian Roos <roosa@google.com> Fix adaptive auto brightness bugs

Fix update of the light sensor in AutoBrightnessController.
Register observer for Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ.

Change-Id: I5201259c4efc0afa200fea3ad9fe3af2991d8676
owerManagerService.java
15aedf5bfceb7267f0c79e0d29e149f193b15b0a 10-May-2014 Ruchi Kandoi <kandoiruchi@google.com> PowerManager: Minor Coding style issues.

Corrects coding style errors caused by
Ibed319e734340dfd5348dbeb8fe20c01b1adaac5

Change-Id: I81eb0a2bcc4fb45804a1f47aef76d94142f6aba7
owerManagerService.java
f974cc870635227ae13201480fb2f019d153af22 01-May-2014 Ruchi Kandoi <kandoiruchi@google.com> Display: Brightness: Low power mode scales the brightness to 50 percent.

When the device is in low power mode all changes to brightness will be
scaled to half of the brightness that would be normally set when not in
low power mode.

Change-Id: I03be820ef64c1d5631ded35f7dfc2799e807226b
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
owerManagerService.java
6422abef786632e53337c6c298ffa64f7ddf4d90 07-May-2014 Brian Carlstrom <bdc@google.com> resolved conflicts for merge of 3bbef521 to master

Change-Id: I0bbb7c80f6c4f003779da784475d7acbfb898c94
3bbef521d4b07f86010ba0729a36ff8b73bcb0ac 07-May-2014 Brian Carlstrom <bdc@google.com> resolved conflicts for merge of f2db00fd to klp-modular-dev-plus-aosp

Change-Id: I745164033962f6222832f8f19fa316a2e2634fd0
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
otifier.java
01ee6f6cf7de9fb98fc3a88509b43416caa71040 03-May-2014 Jeff Brown <jeffbrown@google.com> Plumb display state and interactive information to BatteryStats. (DO NOT MERGE)

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
otifier.java
d83a096f299abd9c7fe5e441ef1bb169c314b575 03-May-2014 Dianne Hackborn <hackbod@google.com> Bump up priority of system receiving BOOT_COMPLETED.

Change-Id: I5166f88f11f781914312e867cb653c8ecbefa705
owerManagerService.java
fb0448ab4b42c1b390cd75c3660ec0de511b7b3b 02-May-2014 Jeff Brown <jeffbrown@google.com> resolved conflicts for merge of 4f8cd188 to master

Change-Id: I148cd616cd14d834915978aa2dc3f9e27188dbd3
140ffc783c50bbe3b62e817c117a31b93e7f627e 02-May-2014 Jeff Brown <jeffbrown@google.com> Clean up some terminology related to interactive state.

Change-Id: Ife4445685a5314dea64332a3490fa8dd3ffd89a2
otifier.java
62b8a49856cc0822905dcb7a213f082b92fa69e3 18-Apr-2014 Ruchi Kandoi <kandoiruchi@google.com> Adds Content Observer for the Low power mode in developer options.

Change-Id: Ibed319e734340dfd5348dbeb8fe20c01b1adaac5
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
owerManagerService.java
4e5c089ef3e62e7f658e71c0be262d09bd3e399b 11-Apr-2014 Jeff Brown <jeffbrown@google.com> resolved conflicts for merge of 337e764d to master

Change-Id: I8168dbf42b68c2f7b5ccb300e0080dddc627af26
037c33eae74bee2774897d969d48947f9abe254f 09-Apr-2014 Jeff Brown <jeffbrown@google.com> Plumb display power state through display manager.

Declare a new method, Display.getState() to retrieve the actual
power state of a display.

Improved documentation for Intent.ACTION_SCREEN_ON and
Intent.ACTION_SCREEN_OFF to clarify what they really mean in
terms of the interactive state of the device.

Deprecated PowerManager.isScreenOn() and replaced it with
PowerManager.isInteractive() with a more suggestive name and
better documentation.

Redirect display power state changes to go through the display
manager first and only then head over to the power manager for
legacy compatibility.

Eliminated the bright here and woke here policy flags since they
were unused. Simplified the input dispatch policy somewhat.

Ensure that screen wake locks are respected up until the point
when dozing really begins.

Fixed a regression in DreamService where onDreamingStarted
might be called before onWindowAttached.

Bug: 13133142
Bug: 13472578
Bug: 13929355
Bug: 13760290
Change-Id: Iabef96921dd554ce3768fb18619cefc3230b5fb0
otifier.java
owerManagerService.java
a981e3b01ae6af2b67e582f0d1cbb95560d05626 09-Apr-2014 Narayan Kamath <narayan@google.com> resolved conflicts for merge of 7289f3ab to klp-modular-dev-plus-aosp

Change-Id: I788ca17503e2fd225e205a76d3e7062f71d58316
131206b8a9d07400d7c98aea50cc45c38769448f 09-Apr-2014 Jeff Brown <jeffbrown@google.com> Move display power controller to display manager service.

This refactoring is in preparation for enabling the display manager
to have more control over the blanking state of individual displays.
There are no functional changes. Some bits will be cleaned up in
a subsequent patch.

Bug: 13133142
Change-Id: I159a060088344d8e6fcdf9208a1f242960f7ab90
utomaticBrightnessController.java
isplayBlanker.java
isplayPowerController.java
isplayPowerRequest.java
isplayPowerState.java
lectronBeam.java
otifier.java
owerManagerService.java
ampAnimator.java
13014b5fe5967b3c7e232ffaf81581ed178e6df6 08-Apr-2014 Jeff Brown <jeffbrown@google.com> Move certain internal activity manager methods to new class.

This is a little bit of refactoring in preparation for changing how
the power manager notifies system components about changes in power
state.

Deleted the startRunning method since it is no longer useful.

Bug: 13133142
Change-Id: I7f845c61ecc7ee890154ed0cbd90795de609b7ea
otifier.java
ad9ef191f50767d8d5b6f0fbd4b59bb1400dcd25 09-Apr-2014 Jeff Brown <jeffbrown@google.com> Move display power controller to display manager service. (DO NOT MERGE)

This refactoring is in preparation for enabling the display manager
to have more control over the blanking state of individual displays.
There are no functional changes. Some bits will be cleaned up in
a subsequent patch.

Bug: 13133142
Change-Id: Ib811835e8757449c7899ac61807029baaf998161
isplayBlanker.java
isplayPowerController.java
isplayPowerRequest.java
isplayPowerState.java
lectronBeam.java
otifier.java
owerManagerService.java
ampAnimator.java
f20a5eb279035d462e1f5d9895f4eb66cc152215 02-Apr-2014 Ruchi Kandoi <kandoiruchi@google.com> PowerManager: add powerHint method

Add powerHint method to IPowerManager for passing power hints from other
processes.

Change-Id: Ic596ace2ed1796a6da4cddb2163dcc4536115e55
owerManagerService.java
ef640cdfb29caf9d0abf4aba020afbc3eb3e0443 25-Mar-2014 Dianne Hackborn <hackbod@google.com> Don't allow -1 uids for wake locks.

Change-Id: Ia1b412a166f69247be3b047138349e7b4031bd7d
owerManagerService.java
4590e52f3d0558e01322fe4dd55bb612afdfb079 24-Mar-2014 Dianne Hackborn <hackbod@google.com> Battery stats: wake locks, radio active, cleanup.

- Improve wake lock work source updates to also update the current
history tag, in case the new work source gets recorded in the
history.

- Fix bug in recording radio active time that was not distributing
any time to apps.

- No longer hold a wake lock while dispatching data conn active call,
since it comes with its own timestamp.

- Fix issue where the top app was not being cleared while the screen
was off.

- Remove obsolete STATS_LAST stats type.

- Fix bug that was not clearing the total run time when resetting
the stats.

Change-Id: Iabe17a9edf34f762374ae09fcffb8a819cf72e30
owerManagerService.java
f9e1a0b369740e11ea1ed4f141ffb936fc1a6cdb 20-Mar-2014 John Spurlock <jspurlock@google.com> Annotate framework vibrate calls with stream hints.

Migrate existing framework usages of Vibrator.vibrate to use
the new overload with an explicit stream hint. This prevents
them from being blocked by rules targeting the unspecified stream.

For calls that pass the existing appops check in VibrateService,
pass streamHint down to the input device vibrator so we don't lose
the signal, but leave it up to InputManager to decide what to do
with it - currently unused.

Change-Id: I65c944e4010edea29a412bf57d8d7d3b8098b746
hutdownThread.java
e5659baa4f439865658d11d6617773e0849f22a2 19-Mar-2014 Michael Wright <michaelwr@google.com> Use DisplayPowerRequest#wantLightSensorEnabled in ABC.

Change-Id: I2cb869a40ed91331a55972d0ea557269733d5204
utomaticBrightnessController.java
08fc3a7fc24cf16c15f53bab3d061a8c32367655 13-Mar-2014 Dianne Hackborn <hackbod@google.com> Merge "Fix some uid issues in battery stats."
bbb7472b8e378a46a1e77747265c19d22bd6968c 13-Mar-2014 Dianne Hackborn <hackbod@google.com> Fix some uid issues in battery stats.

Change-Id: I9f7773568ff12603d51b26d50d758add09bedbb2
otifier.java
088a997defe5ac88d10c341af277bceb7c46f479 12-Mar-2014 Jeff Brown <jeffbrown@google.com> am 81cc19cf: am 236e174a: am 0575b185: Merge "Add a temporary hack to report screen on while dozing." into klp-modular-dev

* commit '81cc19cf18dff969319c7d1ded4f285394e37aab':
Add a temporary hack to report screen on while dozing.
141d88916647cada1c90448d5739a927fa508724 12-Mar-2014 Jeff Brown <jeffbrown@google.com> am 578e1938: am 3ce589e5: am 2d8a3908: Fix power manager display wake lock bugs.

* commit '578e19381c2329511187083045d3ad5509428730':
Fix power manager display wake lock bugs.
0575b185c618a79ede771389ed9a78436b5636bd 12-Mar-2014 Jeff Brown <jeffbrown@google.com> Merge "Add a temporary hack to report screen on while dozing." into klp-modular-dev
2d8a3908d2b0a74ccdecd97e86e7bfda1caa218e 12-Mar-2014 Jeff Brown <jeffbrown@google.com> Fix power manager display wake lock bugs.

Under certain circumstances, the power manager might continue to
hold the display wakelock long after the display had been turned
off due to the mDisplayReady flag having an incorrect value.

1. An inverted conditional caused DisplayPowerState to incorrectly
signal the screen on ready state.

2. The DisplayPowerController failed to clear the block screen on
flag in the case where the screen was turned off before it became
unblocked from turning on. This could happen when the display was
rapidly turned on-off-on-off.

Bug: 13248135
Change-Id: I8faa3034695c83c8cd35613d81acccf40d22128d
isplayPowerController.java
isplayPowerState.java
owerManagerService.java
e39ef098963df1c50912cfeb53c01868ad91a48b 12-Mar-2014 Jeff Brown <jeffbrown@google.com> Add a temporary hack to report screen on while dozing.

The window manager and view hierarchy currently disable all drawing
when PowerManager.isScreenOn() returns false so no drawing occurs
while dozing. This will be fixed in a future patch to take the
display blanking state into account correctly.

This patch is a workaround to unblock development in the meantime.

Bug: 13133142
Change-Id: I2dc0b422c77285e657d73adca2606aa68264d987
owerManagerService.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
otifier.java
owerManagerService.java
ddb90b65f7a4bc2c7b0d1af01af00bd0358ed361 28-Feb-2014 Jeff Brown <jeffbrown@google.com> am 098bed6f: am bb689496: am 4c7e6900: Make meaning of PowerManager.isScreenOn() more consistent.

* commit '098bed6f27b05c16ecc30f9d39005e5995f14263':
Make meaning of PowerManager.isScreenOn() more consistent.
4c7e6900c8bfd57652fc1ceca724208ca7556196 28-Feb-2014 Jeff Brown <jeffbrown@google.com> Make meaning of PowerManager.isScreenOn() more consistent.

The power manager sends SCREEN_ON and SCREEN_OFF broadcasts
purely based on the current wakefulness state. In particular,
when the system is awake, we consider the screen to be on even
if the screen may actually be off due to the proximity sensor
or some other condition. Likewise when the system is dozing
or asleep, we consider the screen to be off although technically
it may still be on and dozing.

This behavior is maintained for compatibility with applications
that interpret screen on / off as an indicator of user presence.

As it happened, the value of PowerManager.isScreenOn() did not
always match the state indicated by the broadcasts under certain
situations. Instead, it was based on the desired screen state.
These states used to be closely correlated but the addition
of doze mode causes them to diverge in meaning.

One consequence is that wake events from input devices might not
always wake the device from sleep unless the display's power
state was actually DOZING or OFF even if the power manager's
wakefulness was already DOZING or ASLEEP. This is now fixed.

Change-Id: Ie819c6d2c5a9ffaaf3101c5dee93ff72e9bc9f30
owerManagerService.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
otifier.java
owerManagerService.java
eb1d804246f031889619e9c5466e899f95c249d0 25-Feb-2014 Jeff Brown <jeffbrown@google.com> am 01d63a35: am ae8106ef: am 2326acb5: Merge "Fix typo that causes dreaming on battery." into klp-modular-dev

* commit '01d63a35245ad20cf5251b69777db5c81fc76a84':
Fix typo that causes dreaming on battery.
966604f1599886989c954b9246f157bb47f4a4f8 25-Feb-2014 Jeff Brown <jeffbrown@google.com> Fix typo that causes dreaming on battery.

Bug: 13173012
Change-Id: I611970a5b4c4b0072ce52e3fc6a57dd3a0c075b3
owerManagerService.java
d429710f8edf6aeacb79c2f8ae8a6dc404173c42 21-Feb-2014 Michael Wright <michaelwr@google.com> Merge "Unbreak manual brightness setting."
10102e4c0e501333a12b38a5cfe709d1558d84dd 21-Feb-2014 Jeff Brown <jeffbrown@google.com> resolved conflicts for merge of baaa080b to master

Change-Id: I3ee12321e298f7a2ea577a99f30c49f3bb497fae
5c977ea1b78046e54f9975c78290316fcc2d630a 19-Feb-2014 Michael Wright <michaelwr@google.com> Unbreak manual brightness setting.

Change-Id: I0ba5b82f60eacd66db0dcf4166e9a919ee06f2e0
isplayPowerController.java
2687550272ba061448f5d5b914700dc335299ee7 31-Jan-2014 Jeff Brown <jeffbrown@google.com> Add a new "doze mode" based on Dream components.

When a doze component has been specified in a config.xml resource
overlay, the power manager will try to start a preconfigured dream
whenever it would have otherwise gone to sleep and turned the
screen off. The dream should render whatever it intends to show
then call startDozing() to tell the power manager to put the display
into a low power "doze" state and allow the application processor
to be suspended. The dream may wake up periodically using the
alarm manager or other features to update the contents of the display.

Added several new config.xml resources related to dreams and dozing.
In particular for dozing there are two new resources that pertain to
decoupling auto-suspend mode and interactive mode from the display
state. This is a requirement to enable the application processor
and other components to be suspended while dozing. Most devices
do not support these features today.

Consolidated the power manager's NAPPING and DREAMING states into one
to simplify the logic. The NAPPING state was mostly superfluous
and simply indicated that the power manager should attempt to start
a new dream. This state is now tracked in the mSandmanSummoned field.

Added a new DOZING state which is analoguous to DREAMING. The normal
state transition is now: AWAKE -> DREAMING -> DOZING -> ASLEEP.
The PowerManager.goToSleep() method now enters the DOZING state instead
of immediately going to sleep.

While in the doze state, the screen remains on. However, we actually
tell the rest of the system that the screen is off. This is somewhat
unfortunate but much of the system makes inappropriate assumptions
about what it means for the screen to be on or off. In particular,
screen on is usually taken to indicate an interactive state where
the user is present but that's not at all true for dozing (and is
only sometimes true while dreaming). We will probably need to add
some more precise externally visible states at some point.

The DozeHardware interface encapsulates a generic microcontroller
interface to allow a doze dream for off-loading rendering or other
functions while dozing. If the device possesses an MCU HAL for dozing
then it is exposed to the DreamService here.

Removed a number of catch blocks in DreamService that caught Throwable
and attempted to cause the dream to finish itself. We actually just
want to let the process crash. Cleanup will happen automatically if
needed. Catching these exceptions results in mysterious undefined
behavior and broken dreams.

Bug: 12494706
Change-Id: Ie78336b37dde7250d1ce65b3d367879e3bfb2b8b
isplayPowerController.java
isplayPowerRequest.java
owerManagerService.java
88aaef71289177644f723d3d0f20f34a6f9b3d2c 14-Feb-2014 Jeff Brown <jeffbrown@google.com> am ce0552f3: am 8a4c2bb1: am 567f7ca4: Refactor dream manager to new pattern.

* commit 'ce0552f360d8c8f0bc45095293be369800ce9c93':
Refactor dream manager to new pattern.
567f7ca424280ae957b04d4f3df690055f2d41df 31-Jan-2014 Jeff Brown <jeffbrown@google.com> Refactor dream manager to new pattern.

Change-Id: I99ab4bd98d56a290368dc4b24e5bb24e0656b522
owerManagerService.java
639c8becc6d0efe9c205f3abf1e9347464a95020 18-Jan-2014 Michael Wright <michaelwr@google.com> Extract automatic brightness strategy

Pull the strategy for determining the automatic brightness levels
into its own class. This cleans up DisplayPowerController a bit and
lets us experiment with different automatic brightness strategies
more easily.

Change-Id: I8f4249da511e38f63260dbef81f97f5507aac948
utomaticBrightnessController.java
isplayPowerController.java
isplayPowerRequest.java
41a5cdf9862d4fa77153656e677567e707aa1d45 14-Nov-2013 Michael Wright <michaelwr@google.com> New ambient light level filtering for automatic brightness

This new filtering method maintains a ring buffer of all light sensor
measurements within the last ten seconds. Once all of the
measurements are either above the brightening threshold or below the
darkening threshold, adjust the screen brightness to the average of
the recorded measurements.

Change-Id: I012bd99f86149e02f03b05f19722aef9a07aba31
isplayPowerController.java
cab8617b8ccea3a99b1ee15e15915c512a10c738 11-Feb-2014 Jeff Brown <jeffbrown@google.com> am 25df673b: am 1b51c9cb: Merge "Make SystemService constructor take a Context." into klp-modular-dev

* commit '25df673b849de374cf1de40250dfd8a48b7ac28b':
Make SystemService constructor take a Context.
b880d880c6cd989eacc28c365fc9a41d31900da1 11-Feb-2014 Jeff Brown <jeffbrown@google.com> Make SystemService constructor take a Context.

This change simplifies the process of initializing a SystemService
by folding the onCreate() step back into the constructor. It removes
some ambuiguity about what work should happen in the constructor and
should make it possible for services to retain most of their final
fields after refactoring into the new pattern.

Change-Id: I25f41af0321bc01898658ab44b369f9c5d16800b
owerManagerService.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
isplayPowerController.java
otifier.java
509cc13b705f8c488774e7097ab17471c3dacd2e 18-Jan-2014 Jeff Brown <jeffbrown@google.com> am e2c9cd58: Merge "Refactor display manager service to new pattern." into klp-modular-dev

* commit 'e2c9cd583f4f706b48270b8cbe84df627c69af24':
Refactor display manager service to new pattern.
4ccb823a9f62e57f9d221f83a97e82967e79a9e5 17-Jan-2014 Jeff Brown <jeffbrown@google.com> Refactor display manager service to new pattern.

Transform DisplayManagerService into a SystemService and start cleaning
up other local services that it uses from window manager and input manager.

Clean up service thread initialization.

Remove unnecessary static variables from ActivityManagerService.

It's starting to become clear that we really need a better way to manage
service dependencies. Boot phases don't quite cut it.

Change-Id: If319dbd7cbfbd4812fe55ece969e818d4b20755b
isplayPowerController.java
lectronBeam.java
owerManagerService.java
3b0218b0ae1fad67f539ff3c10d6d2f3abec1a11 14-Jan-2014 Doug Zongker <dougz@android.com> boot into recovery via the pre-recovery service

Change PowerManagerService to start the pre-recovery service rather
than rebooting directly, when requested to reboot into recovery. Add
a new RECOVERY permission which a caller needs (in addition to REBOOT)
in order to go to recovery.

Bug: 12188746
Change-Id: I39121b701c4724558fe751adfbad79f8567faa43
owerManagerService.java
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
owerManagerService.java
02cc684e42b13454ba1a013340b41696323a4c2a 16-Jan-2014 Jeff Brown <jeffbrown@google.com> Delete unused power manager functionality.

timeSinceScreenWasLastOn() was used by Watchdog previously but is no
longer so we can remove it.

Change-Id: I91c324b6c98c1aeb85f64b0296a41240e6c2ef4f
owerManagerService.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
isplayBlanker.java
isplayPowerController.java
isplayPowerRequest.java
isplayPowerState.java
lectronBeam.java
otifier.java
owerManagerService.java
ampAnimator.java
creenOnBlocker.java
hutdownThread.java
uspendBlocker.java
irelessChargerDetector.java