History log of /frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
614636e9263c0d87c8c738dccf298bd16c5fec75 31-May-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Change the thread for handling shutdown of PowerManagerService." into oc-dev
e63965cef516777dae682103e0813b7f024dab62 27-May-2017 Andrii Kulian <akulian@google.com> Merge "Refresh screen off timeout when screen lock is released in VR" into oc-dev
9407a6b52cd9b98e714ceb7b699e5c453a252386 24-May-2017 Andrii Kulian <akulian@google.com> Refresh screen off timeout when screen lock is released in VR

When evaluating conditions for user activity with no lights change,
treat POLICY_VR the same way as for POLICY_BRIGHT, so new activity
timeout will be set.

Bug: 37968591
Test: Set screen timeout to 15s, launch Daydream, wait, launch Welcome flow.
Change-Id: I3185cc97364ae5631ef53906958b16d41f326c3b
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
690c6bd9a371bd9f1f6562728368ab3e2c2e8cb3 11-May-2017 Dmitri Plotnikov <dplotnikov@google.com> Triggering quiescent reboot during OTA

Bug: 34201965
Test: follow instructions in https://docs.google.com/document/d/1RjvUGRi_Ys5-BRoJz6_SnixuipFiF-GAs6CNc7w-Qj0/edit and use fake-ota
Change-Id: I540f86cf11746faefc25bc74319512eba6d0d783
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
64c820d3d4510b4953a8e888eb792a367b52eaa0 21-Mar-2017 Michael Wright <michaelwr@google.com> Change the thread for handling shutdown of PowerManagerService.

Symptom:
Watchdog due to blocked handler PowerManagerService during shutdown
sequence.

Root cause:
While creating the dialogue for shutdown,
HashMap object is accessed by createView() at LayoutInflater.
This object is not excluded at multi threads.
When this issue is occurred, multiple threads accesses this object.
As the result, invalid state is generated inside HashMap object.
And circulating reference is occurred at getEntry method.
So system cannot get out of "for" loop.
It blockes the processing of PowerManagerService thread
and causes watchdog.
That thing is happening.

Solution:
Change the thread for handling shutdown
from "PowerManagerService" to "android.ui" thread.
As the result, exclusive control is not needed.

Bug: 35791029
Test: Manual
Change-Id: Icbc12fb2706fb3c7e859f53bbb4c65f488850ce6
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
9199d0c1ffed3ff3e10c3e20fd7efad10798dc9a 10-May-2017 Michael Wright <michaelwr@google.com> Avoid NPE when getting last shutdown reason.

This can be null if there is a file but it's totally empty, and the
switch statement will throw an NPE when switching on a null string
(thanks Java!)

Bug: 38195795
Test: none
Change-Id: I86901e001b088a4a9b14f15c82b763e12d11875f
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
251894b134a3d1d2bcba5ff9db7e3a4014cd369a 03-May-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fix lock contention: Call into power manager service from handler" into oc-dev
86c39f9edee88baa912c694061010483c7da9daf 02-May-2017 Jorim Jaggi <jjaggi@google.com> Fix lock contention: Call into power manager service from handler

Make sure to not hold the wm lock when calling into power manager
service, because PWM will acquire a lock that might be contended.

Test: Make sure user activity timeout is still respected on
Keyguard
Test: Have activity with screenBrightness=1.0, make sure screen
is fully bright when opened

Bug: 37888898
Bug: 36631902
Change-Id: I4b5433dbaf8aa151465ae32232d3b3b8597715df
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
a6f7b25c3d160be02cb7384f154a1f77a8faaffa 10-Apr-2017 Salvador Martinez <dehboxturtle@google.com> Added dialog to notify user of thermal shutdown

tldr; Have the phone check when it reboots if it last shut
down due to heat. If so, we should show the user an
notification and dialog giving them more details.

- Added hidden api to allow apps to query system_server
for the reason the phone last rebooted
- Added notification that is shown when the phone is
booted if the last shutdown was due to excessive
heat.
- Added dialog to provide more details about the
shutdown if the notification is tapped.
- Added tests to verify that file is read and
as expected.
- Updated code for high temperature warning that
is shown while the phone is running to avoid
mixups in the future.

Test: FrameworksServiceTests
Bug: 30994946
Change-Id: Ic25f42539911c89ba7f1834e206f7931d65c2865
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
694f24581ac4f14cc961c6b96368330ed6740772 20-Apr-2017 Tony Mak <tonymak@google.com> Send ACTION_POWER_SAVE_MODE_CHANGED to all user

Fix: 36174715

Test: Install an app that listens to ACTION_POWER_SAVE_MODE_CHANGED in
work profile. Make sure it receives the broadcast.

Change-Id: I26df6710bc996792212d52189cd04bd2d30ac6d1
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
5ab5e1d9514bde75beaf87f46d45b6ffcaac9891 15-Apr-2017 Makoto Onuki <omakoto@google.com> Log screen-on latency with tron

Bug: 36776886
Test: manual test with "adb logcat -b all" and systrace.
Change-Id: I9e7188475a79899569046892e6f08c9005b84303
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
f2c38c130f113600a5363d124723302da9fccade 31-Mar-2017 Jocelyn Dang <jocelyndang@google.com> Add set-mode command to turn battery saver mode on and off.

Affected test will be modified in ag/2101279

Test: adb shell cmd battery unplug && adb shell cmd power set-mode 0
Bug: 31944272
Change-Id: Ia88e7e164aa9b8b4d0ab51f607a64b35e2159273
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
a52fc49845d1103dea2380f34b96e2a22ea1801e 04-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Themes: Apply themes to system_server safely" into oc-dev
fe9a53bc45fd0124a876dc0a49680aaf86641d3e 31-Mar-2017 Jeff Sharkey <jsharkey@android.com> Consistent dump() permission checking.

This change introduces new methods on DumpUtils that can check if the
caller has DUMP and/or PACKAGE_USAGE_STATS access. It then moves all
existing dump() methods to use these checks so that we emit
consistent error messages.

Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases -t android.security.cts.ServicePermissionsTest
Bug: 32806790
Change-Id: Iaff6b9506818ee082b1e169c89ebe1001b3bfeca
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
a82b62678a0e1eaba50ec5adce93862683dac065 22-Mar-2017 Adam Lesinski <adamlesinski@google.com> Themes: Apply themes to system_server safely

Creates a new UI Context for UI based operations.
This UI Context is wired up the same way a normal app
Context would be, and is subject to change when overlays
are enabled/disabled.

For this reason, only UI should be using this new Context.
All other operations should be using the original system Context
so that changing themes don't impact the regular operations of
system_server.

Also added some sanity checks at key places where we show UI
(ShutdownThread, BaseErrorDialog).

Bug: 36059431
Test: $ adb shell am crash com.android.settings
Test: Observe crash and power off dialogs are blue with PixelTheme
Change-Id: I87227ee2e0be1e72dcde8f482b37725cb687260b
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
5f3e93451e87d72c513e75c5d5459a4bd2cc41b2 13-Mar-2017 Jeff Sharkey <jsharkey@android.com> Lower-overhead version of LockGuard.

Instead of building up a giant set of all locks inside the system
server, there are only a handful that we're interested in watching:
specifically those below the ActivityManagerService lock.

This change adds a index-based variant of lock registering and
checking, which has much lower overhead that doesn't bring a device
to its knees. It's disabled by default, but can be enabled on local
development builds.

Currently uses the boostPriorityForLockedSection() hook in AMS to
check for lock inversions when enabled.

Test: builds, boots, no AMS lock inversions detected
Bug: 35410906
Change-Id: I473d634d23c08538029412a1254bf4f92b96fb84
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
5602189a6dec401bfa2e22247a23fb25dd3393f8 27-Feb-2017 Adrian Roos <roosa@google.com> AOD: Show charging status on AOD1

- Change PowerManager to not turn on display when on AOD
- Add charging icon to AOD1
- Add transient charging indication when plugged in

Bug: 30876804
Bug: 35850304
Test: runtest systemui; enable AOD, plug in phone, verify charging indicator shows, verify charging text shows and goes away after a few seconds
Change-Id: Icb80843a12c56c7e2abeca78115a366b4d508d4f
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
92681e8cfbbae58b00a80bb1e60f5444cf53fbdd 28-Feb-2017 jackqdyulei <jackqdyulei@google.com> Hook up screen brightness knob to DisplayPowerController.

This knob is designed to effectively tune the battery saver.

Bug: 34693888
Test: FrameworksServicesTests
Change-Id: I9fd7896f59fabd9baf649cdb12f01b1baaf4c34b
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
455e90add22835d0744fc0f5c2feb5fcaf03b28f 10-Feb-2017 jackqdyulei <jackqdyulei@google.com> Add BatterySaverPolicy for power save mode

The BatterySaverPolicy is designed to consolidate all battery saver
knobs into a central location. Usually it is consistent to
mLowPowerModeEnabled unless it gets different data for specific
service. By adding these knobs, we can effectively tune the battery
saver.

This cl sets up the framework for BatterySaverPolicy and updates
following service to get battery saver data from BatterySaverPolicy

1. GnssLocationProvider
2. VibratorService
3. WindowManagerService
4. BackupManagerService
5. SoundTriggerService
6. NetworkPolicyManagerService

Screen brightness will come in a following cl.

Bug: 34693888
Test: FrameworksServicesTests

Change-Id: I6b040e93391614b44d136a485faa4a332c396e51
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
958d0a503699840f8f4b85cafa62f3793c89ac73 07-Feb-2017 Netta P <nettap@google.com> Protobufferize PowerManager dumpsys

Bug: 34230125
Test: cts-tradefed run cts-dev -m CtsIncidentHostTestCase -t com.android.server.cts.PowerIncidentTest
Change-Id: Ib71563cfc9ca95c297111430d8bbe2ce88d7a41d
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
6e544617c63ca1d60ed0a1a01630557958de093b 20-Feb-2017 Jeff Sharkey <jsharkey@android.com> Guard against possible AMS/PMS deadlock.

PMS can't call into AMS while holding its local lock.

Test: builds, boots
Bug: 35410906
Change-Id: Ib80bbee5c0c3e5fb39ffef324e8176027da83f2f
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
8deb67cb64b0cd93be545caf7887a12ed3611841 08-Feb-2017 Craig Donner <cdonner@google.com> Use the Context name to publish and use vrmanager

Bug: 34736524
Test: build
Change-Id: I8aabb4d242fb2378b24dd30a972c382a7f8f4934
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
5483cea67a60d3c5012fa7120f62e6eacc6ad3ba 02-Feb-2017 Justin Klaassen <justinklaassen@google.com> Remove experimental twilight-based automatic brightness

Bug: 31602449
Test: verified adaptive brightness no longer varies with twilight with
"brightness_use_twilight" set to "1".

Change-Id: I6b5f7310020b2128c2b292414a205b6052270a0a
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
0ef403e53e2762d077750dd0a50b73c2125cadb0 25-Jan-2017 Dianne Hackborn <hackbod@google.com> Add some new experiment constants for activity and power manager.

Activity manager now has constants, starting with two: bg check
and process limit.

Power manager now has constants, starting with one: controlling
disabling of wake locks from cached processes.

Test: manual

Change-Id: I05db42e2104e9d31584f85251412df2d5efb34b6
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
fe6f85cac9e823fd33a134f7129fdf7310703293 20-Jan-2017 Jeff Sharkey <jsharkey@android.com> Introduce RescueParty.

When a device gets stuck in a crash loop, it's pretty much unusable
and impossible for users to recover from.

To help rescue devices from this state, this change introduces a new
feature that watches for runtime restart loops and persistent app
crash loops, and escalates through a series of increasingly
aggressive rescue operations. Currently these rescue levels walk
through clearing any experiments in SettingsProvider before finally
rebooting and prompting the user to wipe data.

Crash loops are detected based on a number of events in a specific
window of time. App stats can be stored in memory, but boot stats
need to be stored in system properties to be more robust.

Start up RecoveryService much earlier during the boot so we can
reboot into recovery when needed.

Add properties tha push system_server or SystemUI into a crash loops
for testing purposes.

Test: builds, boots, forced crashing walks through modes
Bug: 24872457, 30951331
Change-Id: I6cdd37682973fe18de0f08521e88f70ee7d7728b
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
3107d29c8f6f40b98533978a7e19e5c328f73d24 21-Sep-2016 Santos Cordon <santoscordon@google.com> Add Brightness setting for VR Mode.

This change saves and loads a different brightness setting when the user
goes in and out of VR Mode.

Test: runtests frameworks-core
Test: Turn vr mode on and change brightness (should remain separate from
normal brightness)

Bug: 30984614
Change-Id: If3c3e81b592e0c6fd037e5783559683e5cb58379
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
7e96654f1b2e7c97f52cdc68d343139a5186d54d 27-Dec-2016 Ian Pedowitz <ijpedowitz@google.com> Revert "Add Brightness setting for VR Mode."

This reverts commit c7e853f51110b9b6893d526f1f7340b2966f928a.

Bug: 33895226
Bug: 30984614
Change-Id: Icca320e02651b7dd7b8db84ab414f41edee32760
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
c7e853f51110b9b6893d526f1f7340b2966f928a 21-Sep-2016 Santos Cordon <santoscordon@google.com> Add Brightness setting for VR Mode.

This change saves and loads a different brightness setting when the user
goes in and out of VR Mode.

Bug: 30984614
Change-Id: Ie5578bbd6ea346f0eb34fe4abbfd604a5d7c0c93
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
a8d2c6457fe339acaae256510afbe63e39147d62 08-Dec-2016 Dmitri Plotnikov <dplotnikov@google.com> Adding "quiescent" reboot mechanism to support STB operators

Bug: 31681185
Change-Id: Iada4dd4624f0221e5b59440da2718da980742720
Test: with SampleLeanbackDeviceAdmin. CTS test forthcoming
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
5614bf5a1ae4522dfc1a041f003cebc9b25c8b93 08-Nov-2016 Dianne Hackborn <hackbod@google.com> Move code for handling uid obs "cutoff" to activity manager

To do this, I had to fix the PROCESS_STATE_NONEXISTENT constant
to be the last value (instead of the special magical -1 value)
so it semantically matches the public importance constants. I
think this is better anyway.

Also this fixes a big problem in the implementation, where we
weren't keeping track of the last proc state per uid...! Duh.

Test: manually ran testUidImportanceListener
Change-Id: Ie3008f824446089840f896885e6033472abb065e
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
951ea6907c6cc01ce3f9ec4859d65a184c7ce785 02-Nov-2016 Dianne Hackborn <hackbod@google.com> Power manager always needs to allow wake locks for services, receivers

The change to not allow wake locks for idle apps was a little too
aggressive, since we allow apps that are currently executing services
or receivers to be idle. (Idle means that it hasn't been in the
foreground for X amount of time, but services and receivers don't count
as being in the foreground.)

So this takes in to account the actual procstate of the uid to determine
if it should actually respect the current idle state.

Test: manual

Change-Id: I32949124b37875b13233478719abccb8369e47f6
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
d33c7cd87a8ca6ede8622392601f8ce9df7694ad 26-Oct-2016 Dianne Hackborn <hackbod@google.com> Power manager now prevents wake locks from idle uids.

The activity manager now pushes the idle/active state
down in to the power manager. The power manager now
tracks a structure of data about each uid: how many
wake locks it holds, whether it is active, and (as before)
its current process state.

Now when apps are inactive, we always disable wake locks
they hold, regardless of the system's device idle or
other state.

Test: none

Change-Id: I2cd4077e4d8a8572525406ae9747f0a2435764da
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
0d43404a07c1372fef71181ab9daa8fa960fdd4c 03-Oct-2016 Ruchi Kandoi <kandoiruchi@google.com> power: PowerHAL support for HIDL interfaces.

Bug: 31177288
Change-Id: I3ce5a71958f47d26855513cf7523922e80dd25d2
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
a2f01d04877b4521b9e991d77f945c1b83957265 26-Sep-2016 Michael Wright <michaelwr@google.com> Disable battery saver when booting with sufficient battery am: 2763c2ba6c am: 994c5722d6
am: 804a1d266a

Change-Id: Ife535ae4d6854109a27b680f902b5fc0ace21db1
804a1d266a25c07bb1b60e4e355ea14fefb22c2f 26-Sep-2016 Michael Wright <michaelwr@google.com> Disable battery saver when booting with sufficient battery am: 2763c2ba6c
am: 994c5722d6

Change-Id: I0f150a292f3e5415fe18dc54143dcd5bb0ee74b1
994c5722d66f3b9cd3b814dc89dcace4ab9a76d8 26-Sep-2016 Michael Wright <michaelwr@google.com> Disable battery saver when booting with sufficient battery
am: 2763c2ba6c

Change-Id: I7b94bc0ce1c370d456cc9275aa1067929d4d95d0
03d0a367cf8b229c12e51dc5f452deb710093b20 20-Sep-2016 Wei Liu <luciferleo@google.com> resolve merge conflicts of 82d5fc1 to master

Test: device boots

Change-Id: I78e5667577e413763b6be3b06a2feda99ef0d739
82d5fc17b5f19b1fcd4533beb489b35b7ff58606 20-Sep-2016 Wei Liu <luciferleo@google.com> Make VrManager service optional.
am: ef89d21a1b

Change-Id: Ia0a194d34b19ca89e5acdb110a87479187fa4d85
ef89d21a1bf9a8b11befd9b55130816ccf9fb4fb 20-Sep-2016 Wei Liu <luciferleo@google.com> Make VrManager service optional.

b/31244699

Change-Id: I7d276e6945f19b575f880df16f140b84b03052a9
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
1cedf00b09515c8027d99b1dc287a4b069183647 09-Sep-2016 Felipe Leme <felipeal@google.com> Move EventLogTags.writeDeviceIdle calls outside synchronized block. am: ea01439ef2 am: c2df6afdec
am: e892b57e02

Change-Id: I26248764113b52deb10a14a7989cb4538016ae95
e892b57e025cf5becf630e7b588df785753a745e 09-Sep-2016 Felipe Leme <felipeal@google.com> Move EventLogTags.writeDeviceIdle calls outside synchronized block. am: ea01439ef2
am: c2df6afdec

Change-Id: I70335305b9accb01eb09f002668bbb7dbc1eba9d
ea01439ef2c6eb278b1b92fcdedc9e3d78a323b2 06-Sep-2016 Felipe Leme <felipeal@google.com> Move EventLogTags.writeDeviceIdle calls outside synchronized block.

BUG: 31281543

Change-Id: I1cf5f80dda7ef0801a9fa9d0b5a5b207fc684cd5
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
2763c2ba6c41c348920679dac20b7b4cce718408 11-Aug-2016 Michael Wright <michaelwr@google.com> Disable battery saver when booting with sufficient battery

Bug: 29994369
Change-Id: I01d437c884e62e73dba3c1881544cfc36f953137
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
3678d54a3f066e22c0a773e25e30c9f06039832f 01-Aug-2016 Michael Wright <michaelwr@google.com> Prevent brightness changes before boot complete. am: 9f818ea463 am: 16890dd980
am: 3905506938

Change-Id: Ie6f3b6d55acb0e4eae40518962c1afbd70a947c2
39055069386dddaac929383eabc04214d1f72105 01-Aug-2016 Michael Wright <michaelwr@google.com> Prevent brightness changes before boot complete. am: 9f818ea463
am: 16890dd980

Change-Id: I8241a67326b055c8cabc261d5671553ff056e198
9f818ea463af7083fed619a7159c93905169503e 29-Jul-2016 Michael Wright <michaelwr@google.com> Prevent brightness changes before boot complete.

Bug: 29837667
Change-Id: I6385236786f6a73c64a61e1a5181c3787b68ed36
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
e0b1f592a0bf9334a5acfc408b6f2ac1a31c9150 20-Jul-2016 Dianne Hackborn <hackbod@google.com> Merge \\"Add reporting of long wake locks.\\" into nyc-mr1-dev am: ca37695ebc
am: af52a9d1bf

Change-Id: I29451b3dc161e29804f42f40aa9e15836979cd4a
af52a9d1bf5d5501d1260bfaa2807b926b1b4ed9 20-Jul-2016 Dianne Hackborn <hackbod@google.com> Merge \"Add reporting of long wake locks.\" into nyc-mr1-dev
am: ca37695ebc

Change-Id: I98b06d561945fddef5be4b749b5b2128b8622add
d0db6f00435b83c88f041ccf0cfcb9986ae8e6ef 18-Jul-2016 Dianne Hackborn <hackbod@google.com> Add reporting of long wake locks.

These appear as a new event in the battery stats history,
"longwake" in the long version and "Elw" in the checkin.

The power manager keeps track of which wake locks are held
for a long time and reports them to battery stats. Long
is currently considered 1 minute or more. Once it is long,
the start event will appear, and once if is released the
event will end.

In the case of a wake lock changing (typically its work
source changing), for purposes of this accounting this is
considering a pure release of the old state and start of
the new state... so the timer will reset back to one
minute until the wake lock is considered long. This is done
to prevent things that make lots of changes to wake lock
work sources from spamming the log.

Bug: 28753137

Change-Id: I33b6168c57a7ea6ea558273dec731704123124a5
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
084c4d73e7099b3d0c5d9ba73d6d68f85da23ed8 07-Jul-2016 Shibin George <shibing@codeaurora.org> Merge \\\\"Resolve deadlock between ActivityManagerService and PowerManagerService\\\\" am: 06561db207 am: 2c565826ba am: 26a0b16da8
am: 43e8af64c2

Change-Id: I9c261e2c4223069f8cfa8d16a5e96babc4522af0
2c565826bac683a59cdcf4694077d75e5adf0670 07-Jul-2016 Shibin George <shibing@codeaurora.org> Merge \"Resolve deadlock between ActivityManagerService and PowerManagerService\"
am: 06561db207

Change-Id: I7f78cf1ef0c490aceb527dbc82228d00fae2f7e4
43f5de0125a22e9bcc4cf675034116f754f3bfc2 05-Jul-2016 Shibin George <shibing@codeaurora.org> Resolve deadlock between ActivityManagerService and PowerManagerService

ActivityManagerService lock and PowerManagerService.mLock can
be acquired in different threads in different orders.
registerReceiver() here tries to acquire ActivityManagerService
internally while holding mLock. A particular call from
WindowManagerService acquires these locks in reverse order.
This deadlock can be resolved by moving registerReceiver()
to another thread.

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

Change-Id: I12cd610e61f212a3fb5e441f2c7a557c90afbda4
Signed-off-by: Shibin George <shibing@codeaurora.org>
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
a2b96b1c8c6b11e21bc16d8ea2c29e0e214b3f39 21-Apr-2016 Ruchi Kandoi <kandoiruchi@google.com> Merge "Revert "PowerManager: Adds the Sustained performance API."" into nyc-dev am: 0fea8ad am: 4c24df5
am: d84169a92f

* commit 'd84169a92ffe2137a7e53c2debcde42cf2eb1878':
Revert "PowerManager: Adds the Sustained performance API."

Change-Id: Iadb804137b77b1fd9f20da6b03c2b8e30617ed0c
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>
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
4a49791ef97226b08d9ce4977b5212074f8e160d 06-Apr-2016 Ruben Brunk <rubenbrunk@google.com> Merge "Add VrManager AIDL interface for use by system apps." into nyc-dev am: 50e229f
am: bc783e0

* commit 'bc783e038c17524c5182ad6b5e17ba95d0e1a319':
Add VrManager AIDL interface for use by system apps.

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

Bug: 27884853
Change-Id: I6de0d291deafe5003070d60866c60d6599312e79
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
a823c4e27151d99ebbc855c22604312745759e87 03-Apr-2016 Jeff Sharkey <jsharkey@android.com> Merge "Support direct-boot tests." into nyc-dev am: 7d718bb
am: 7fc8b9c

* commit '7fc8b9ce48a74011befdaf3be15a2cc952398433':
Support direct-boot tests.

Change-Id: I946f2a960ab0cfb0f56477a3d5e6da07d17aa5bd
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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
defdd7bd34be0d6c2ca49205e05d08f2268f871a 21-Mar-2016 Ruchi Kandoi <kandoiruchi@google.com> Merge "PowerManagerService: Adds a VrStateListener to track Vr Mode state changes." into nyc-dev am: fb811aa
am: 98c1972

* commit '98c1972a7277fc551219c2cbf7a1d9e78e32e2ce':
PowerManagerService: Adds a VrStateListener to track Vr Mode state changes.
fb811aaf4dd062c1ef3581522acb523680f081f3 21-Mar-2016 Ruchi Kandoi <kandoiruchi@google.com> Merge "PowerManagerService: Adds a VrStateListener to track Vr Mode state changes." into nyc-dev
2f69f042e0ace7687d2b56e23e24b4711c0b4cfd 18-Mar-2016 Tony Mantler <nicoya@google.com> Merge "Add safe-mode reboot to PowerManager" into nyc-dev am: e6e08b4
am: 6f61fd5

* commit '6f61fd538ece71095c686d73991d91138bb5e011':
Add safe-mode reboot to PowerManager
b8009fddd85aa5ecd6b2321f92a1ae0568089a54 14-Mar-2016 Tony Mantler <nicoya@google.com> Add safe-mode reboot to PowerManager

b/12787723

Change-Id: If7e6ff63532b49b9e758db290a877f7dbfa8a8b7
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
3a103655835702a227fffa8fcc41525e145b00f9 08-Mar-2016 Daichi Hirono <hirono@google.com> Merge "Add a new key to Settings.Global to obtain the number of boot." into nyc-dev am: d517e6aeed
am: e07d5b62ed

* commit 'e07d5b62ed6d58f8f81383e6ecde03b1181e08f3':
Add a new key to Settings.Global to obtain the number of boot.
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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
e50adc8e464f80802d80f32b9f3476e860b9f297 02-Mar-2016 Jeff Sharkey <jsharkey@android.com> Merge "Delay power broadcasts until system is booted." into nyc-dev am: c9a91cc050
am: 99723c720d

* commit '99723c720dfd009c05ef4717cb6597ae245a98d8':
Delay power broadcasts until system is booted.
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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
69d01e2376da87a358c15d79222ef4f8f67a0a65 22-Feb-2016 Tao Bao <tbao@google.com> Merge "Add support for update-on-boot feature." into nyc-dev am: 9de7952aa9
am: 3dd23af6a0

* commit '3dd23af6a0fb58ce7d1f6f078c765890ca839bd3':
Add support for update-on-boot feature.
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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
9e4f241ba454b5778b47c8b91f43d8b76cd41870 19-Feb-2016 Jason Monk <jmonk@google.com> Merge changes Ie427a2d8,I213f1f76 into nyc-dev am: ea168d229d
am: 0aecf08207

* commit '0aecf08207267bcbf36af9c8f4dd8daad0f14283':
SysUI Tuner: UI cleanup and grouping
SysUI Tuner: Night mode v3
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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
05a9f1d89ab473be2959e4a9ad78dfa5ea9c7d7a 12-Feb-2016 Dianne Hackborn <hackbod@google.com> Fix crash during boot.

Broadcast should only be going to registered receivers.

Change-Id: I7b70cd2bd38f0ff0448cb9786d821c7e41a0e269
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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>
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
27bbb2d0a1c8a3bb38768511ac840c3388b0fb03 31-Mar-2015 Jason Monk <jmonk@google.com> Add control for double tap to wake setting

Bug: 16875464
Change-Id: Ic1ad910dd38acbc68ef040b2acdf3696ec2c2e4e
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
84d6c0fbf6e513d68330234503b809751d0e3564 17-Mar-2015 Bryce Lee <brycelee@google.com> Add isScreenBrightnessBoosted and a broadcast when underlying
value changes.

Bug: 18334219
Change-Id: I20051e97633017711574a063b8061f95c3b616c5
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
584a44517950204a04ef01345be70b33d8ba43f9 22-Oct-2014 Bryce Lee <brycelee@google.com> [Theater Mode] framework implementation through global setting

Bug: 17684570
Change-Id: I64a9c9c0620049cdfcca0150648fa201281f7178
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
c12035cd40d01b032013f515cb509e6c8791cf65 14-Aug-2014 Jeff Brown <jeffbrown@google.com> Log who is calling goToSleep().

Change-Id: Ibae61c90ee115735835e878bb3bf79eedaa0ae44
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
ddef7e776b35aba0f7b4eb4978e93361b49c145f 10-Jul-2014 Dianne Hackborn <hackbod@google.com> Get rid of security exception spam during boot.

Change-Id: If7a516e463722280bf597f7dd601e7a0f6e379c8
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
2139276ce8b54aba5faa858ca69ed5f01445c269 14-Jun-2014 Jeff Brown <jeffbrown@google.com> Refactor BatteryService to new pattern.

Apply SystemService pattern to BatteryService.

Change-Id: I4971b2da8d2aed4d14440fb65863a8b916bab03c
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
d862ebb6036a769cb3be371b396e9e33f89ee365 21-May-2014 Narayan Kamath <narayan@google.com> resolved conflicts for merge of fcc4fed3 to master

Change-Id: Icebca982b01debd67a1470c02651ef8936f6e5b0
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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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.
27736f5c0ada99bf2a7e007a1dec0ad51f65fa52 21-May-2014 Jeff Brown <jeffbrown@google.com> Allow display timeouts to be set in config.xml.

Bug: 13671523
Change-Id: I79fc21999bc62743178d2d22071455a0c11070c9
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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>
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
d83a096f299abd9c7fe5e441ef1bb169c314b575 03-May-2014 Dianne Hackborn <hackbod@google.com> Bump up priority of system receiving BOOT_COMPLETED.

Change-Id: I5166f88f11f781914312e867cb653c8ecbefa705
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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>
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
ef640cdfb29caf9d0abf4aba020afbc3eb3e0443 25-Mar-2014 Dianne Hackborn <hackbod@google.com> Don't allow -1 uids for wake locks.

Change-Id: Ia1b412a166f69247be3b047138349e7b4031bd7d
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
10102e4c0e501333a12b38a5cfe709d1558d84dd 21-Feb-2014 Jeff Brown <jeffbrown@google.com> resolved conflicts for merge of baaa080b to master

Change-Id: I3ee12321e298f7a2ea577a99f30c49f3bb497fae
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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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
/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.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/power/PowerManagerService.java