summaryrefslogtreecommitdiff
path: root/services/java/com/android/server/power/PowerManagerService.java
AgeCommit message (Collapse)Author
2013-12-19Move some system services to separate directoriesAmith Yamasani
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
2013-12-12Introduce a Lifecycle for system servicesAdam Lesinski
Provide an abstract class for system services to extend from, similar to the android.app.Service. This will allow services to receive events in a uniform way, and will allow services to be created and started in the correct order regardless of whether or not a particular service exists. Similar to android.app.Service, services are meant to implement Binder interfaces as inner classes. This prevents services from having incestuous access to each other and makes them use the public API. Change-Id: Iaacfee8d5f080a28d7cc606761f4624673ed390f
2013-10-25Add a method to set a list of uids for a wake lockMarco Nelissen
Cherrypicked from master. b/9464621 Change-Id: Ia6a9d36d55129ae87d3ec070fbf10dc02f4b6cb4
2013-10-03Merge "Add PowerManager method to assign blame to a single uid" into klp-devMarco Nelissen
2013-10-03Add PowerManager method to assign blame to a single uidMarco Nelissen
Currently used by audioflinger to account for recording wakelocks. b/10985160 Change-Id: I18fc8487f2a197bf02b5269a4bcae9e75b6c2207
2013-10-01Track wireless charger detector timeout explicitly.Jeff Brown
Previously we relied on having a continue stream of sensor events from which to detect whether the device is moving or at rest. However, if the sensor HAL is broken in some way then we might not receive enough sensor events to actually finish the detection process. When this happens, we'll just sit there holding a wakelock indefinitely. Instead of relying on the sensor event stream, post a delayed message to explicitly finish detection. Bug: 10769163 Change-Id: Ia2ed66fe5e7c41a8832df76da9104c13554e1398
2013-09-12Allow phone to enter suspend with positive proximity.Jeff Brown
As part of the power manager rewrite in JB MR1, we removed the ability for the phone to suspend with positive proximity because it was not clear that the proximity sensor was always correctly registered as a wake-up source. The sensor service itself does not contain any code to manage wake-ups. Therefore proximity sensor based wake-up relies on the sensor driver acquiring a timed wake lock when the sensor reports a negative result. This behavior is not very well defined in the sensor HAL so there is a chance that it will not work reliably on all devices. This change adds a new config.xml resource to specify whether the device should be allowed to suspend when the screen is off due to positive proximity. Devices that support this feature should set the "config_suspendWhenScreenOffDueToProximity" resource to "true" in their resource overlays. The feature is disabled by default. Bug: 9760828 Change-Id: Ic65ab7df0357271b133e2e44f5e35e7756e1e9e0
2013-09-10Ignore ON_AFTER_RELEASE for partial wake locks.Jeff Brown
This is a regression in the new power manager. Apparently some apps try to use ON_AFTER_RELEASE with partial wake locks which doesn't make sense. Ignore the flag just like we used to prior to JB MR1. Bug: 10336375 Change-Id: Ib307eb60201612ba9bb03dc4da3365aba0b4848d
2013-07-16Fix missing lock in power manager.Jeff Brown
The display wake lock and other internal state could become out of sync if we happened to execute the power manager's update function concurrently due to the missing lock. This bug can be trigged due to display state changes or proximity sensor updated. Although it would be extremely rare, we have some evidence of this happening on at least a few devices resulting in rapid power drain with the screen off or a crash. Bug: 9880044 Change-Id: I3c674ce429621a50cbb36c3a01883d5f388205b2
2013-05-20Add app ops for wake locks.Dianne Hackborn
Currently only supports auditing, not disabling. Change-Id: Ie85f02c29b490d96e073f54d59e165d48c7c00c9
2013-05-13Improve watchdog error reporting.Dianne Hackborn
We now keep track of all the threads that are stopped, and print stacks for all of them. Also more threads are now adding themselves to the watchdog. Unfortunately the stack we get from threads is far less useful than the stacks from the ANR report, because these don't include any information about the lock the thread is blocked on and what thread is holding that lock. For example, here is a test of the log output from causing a hang in the system process: W/Watchdog( 5205): *** WATCHDOG KILLING SYSTEM PROCESS: com.android.server.am.ActivityManagerService, main thread W/Watchdog( 5205): foreground thread stack trace: W/Watchdog( 5205): at com.android.server.am.ActivityManagerService.monitor(ActivityManagerService.java:14333) W/Watchdog( 5205): at com.android.server.Watchdog$HandlerChecker.run(Watchdog.java:142) W/Watchdog( 5205): at android.os.Handler.handleCallback(Handler.java:730) W/Watchdog( 5205): at android.os.Handler.dispatchMessage(Handler.java:92) W/Watchdog( 5205): at android.os.Looper.loop(Looper.java:137) W/Watchdog( 5205): at android.os.HandlerThread.run(HandlerThread.java:61) W/Watchdog( 5205): main thread stack trace: W/Watchdog( 5205): at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:12252) W/Watchdog( 5205): at android.app.ContextImpl.sendBroadcastAsUser(ContextImpl.java:1158) W/Watchdog( 5205): at com.android.server.DropBoxManagerService$3.handleMessage(DropBoxManagerService.java:161) W/Watchdog( 5205): at android.os.Handler.dispatchMessage(Handler.java:99) W/Watchdog( 5205): at android.os.Looper.loop(Looper.java:137) W/Watchdog( 5205): at com.android.server.ServerThread.initAndLoop(SystemServer.java:1050) W/Watchdog( 5205): at com.android.server.SystemServer.init2(SystemServer.java:1125) W/Watchdog( 5205): at com.android.server.SystemServer.init1(Native Method) W/Watchdog( 5205): at com.android.server.SystemServer.main(SystemServer.java:1116) W/Watchdog( 5205): at java.lang.reflect.Method.invokeNative(Native Method) W/Watchdog( 5205): at java.lang.reflect.Method.invoke(Method.java:525) W/Watchdog( 5205): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774) W/Watchdog( 5205): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590) W/Watchdog( 5205): at dalvik.system.NativeStart.main(Native Method) I/Process ( 5205): Sending signal. PID: 5205 SIG: 9 Change-Id: I8ff9892d8d072d8dc599a73de4bdb75e3b1a6e97
2013-05-08PowerManagerService: Don't reboot directly.Nick Kralevich
Instead of calling the reboot system call ourselves, send a message to init asking it to reboot the system. Init is in a better position to make sure the system is cleanly shutdown. Get rid of CAP_SYS_BOOT from system_server. Bug: 8646621 Change-Id: I200722412844ad8d99e35a442021c6263c3ebc05
2013-04-11Sensor values changes.Jaikumar Ganesh
1. Remove Sensor Event Pool. 2. Allocate fixed array values for each Sensor added. - Needed for backward compatibility. 3. Use SDK checks for backward compatibility for rotation vector. b/8165631 Change-Id: I2d2cf10d3460478ed7af8e6188343f4bb033503c
2013-01-11am 1ec3c2cc: am 28608bbb: am d692ea6d: am b5e4835e: Merge "Improve ↵Sascha Prueter
heuristics for detecting wireless chargers." into jb-mr1.1-dev * commit '1ec3c2ccedde5cd8ff6e94c9b1566a913d5e8db0': Improve heuristics for detecting wireless chargers.
2013-01-10Improve heuristics for detecting wireless chargers.Jeff Brown
On some devices, we need to apply heuristics to determine whether the device is docked on a wireless charger because the charging circuits do not provide sufficient information to know whether the device is on the charger unless it is actually receiving power. The previous heuristics only considered the battery level to suppress spurious dock signals. The new heuristics also take into account whether the device appears to have moved from its previous position on the dock. Bug: 7744185 Change-Id: I5ba885dac25b37840b6db46b8a0f30968a06776c
2012-12-12Merge "Track app and display wakelocks separately."Jeff Brown
2012-12-12Track app and display wakelocks separately.Jeff Brown
Change the power manager to use two different kernel wakelocks to distinguish between an application or the display keeping the CPU alive. This may help make the output of "dumpsys batteryinfo" easier to interpret. Bug: 7726759 Change-Id: Iaff96ad74030d00200617b459679ea16390a8da5
2012-12-11Play a tone when wireless charging begins.Jeff Brown
Only plays a tone if the battery level is below 95% which is the same heuristic used when determining whether to turn the screen on. Use new low battery and wireless charging sounds on Mako. Bug: 7371658 Change-Id: Ia4527ec398d024ee418a4287e1fcbf0ec83bcc24
2012-12-04Pin electron beam surface to natural orientation.Jeff Brown
If a rotation occurred while the electron beam surface was showing, the surface may have appeared in the wrong orientation. We fix this problem by adjusting the transformation matrix of the electron beam surface according to the display orientation whenever a display transaction occurs. The rotation itself is allowed to proceed but it is not visible to the user. We must let this happen so that the lock screen is correctly oriented when the screen is turned back on. Note that the electron beam surface serves two purposes. First, it is used to play the screen off animation. When the animation is finished, the surface remains visible but is solid black. Then we turn the screen off. Second, when we turn the screen back on we leave the electron beam surface showing until the window manager is ready to show the new content. This prevents the user from seeing a flash of the old content while the screen is being turned on. When everything is ready, we dismiss the electron beam. It's important for the electron beam to remain visible for the entire duration from just before the screen is turned off until after the screen is turned on and is ready to be seen. This is why we cannot fix the bug by deferring rotation or otherwise getting in the way of the window manager doing what it needs to do to get the screen ready when the screen is turned on again. Bug: 7479740 Change-Id: I2fcf35114ad9b2e00fdfc67793be6df62c8dc4c3
2012-11-21Ignore invalid combination of PowerManager flags.Craig Mautner
ACQUIRE_CAUSES_WAKEUP is supposed to be ignored if combined with PARTIAL_WAKE_LOCK. Instead it was being carried out for any values of the WakeLock level. This change reverts behavior to closely match previous releases of the framework by only honoring ACQUIRE_CAUSES_WAKEUP for screen wake lock levels. The only difference being that in previous releases ACQUIRE_ could have been combined with PROXIMITY_SCREEN_OFF_WAKE_LOCK (it never was) and now such a combination will ignore the ACQUIRE_ flag. Bug 7532258 fixed. Change-Id: I46e848d8fd1b57e54c63141bf3d4f353986b5bdf
2012-10-19Reduce screen on/off latency.Jeff Brown
Reduce latency of screen on/off and improve how it is synchronized with backlight changes. Screen state changes are no longer posted to vsync which should save time. What's more, the state change occurs on a separate thread so we no longer run the risk of blocking the Looper for a long time while waiting for the screen to turn on or off. Bug: 7382919 Bug: 7139924 Change-Id: I375950d1b07e22fcb94efb82892fd817e2f780dc
2012-10-19Frameworks base: Promote dream setting defaults to config.John Spurlock
So that: - the values can be shared (to fix assoc bug) - the values can be customized in product overlays Bug:7373284 Change-Id: I37f037082523a3d975f6014f36afa28c60117372
2012-10-17Dream when user activity times out while docked if appropriate.Jeff Brown
If the user has requested that dreams start when docked and a user activity timeout occurs, then start dreaming assuming all of the other usual conditions are appropriate for dreaming (the device is powered, etc.). Previously dreams only started when the device was initial docked but not if the device fell asleep while remaining docked. Bug: 7281240 Change-Id: I72c3f854fd1ae8e6615f4fa6e4c4ecd8de37c84b
2012-10-15Stop dreaming if the battery not charging effectively.Jeff Brown
If the user activity timeout expired and the battery appears to be draining faster than it is charging then stop dreaming and go to sleep. Bug: 7312455 Change-Id: I1b9d89e5b2647c72c455d2792e3778a2fe6a4e34
2012-10-15Cleanup some internal documentation.Jeff Brown
Bug: 7312455 Change-Id: Idefd71f2e9d1abe1b2671dac9702edf7f5fbc118
2012-10-09Don't consider the boot completed until the animation is over.Jeff Brown
This fixes a problem where the screen times out shortly after boot before the user has had a chance to interact with the device. Now we wait until the boot animation has completed then set boot completed, poke user activity and start the countdown. Bug: 7316397 Change-Id: Ie5a0b1012d265e655d33cc8fba49ca349f48f1de
2012-10-09Prevent full wake lock from keeping device awake while dreaming.Jeff Brown
A dream may itself hold a wake lock in order to keep the screen bright as it runs. However this wake lock also causes the device to stay awake even when it is not plugged in which is undesirable. This change makes full wake locks behave differently when napping or dreaming. The wake lock still keeps the screen bright but it does not prevent the device from falling asleep. This is similar to our policy of ignoring full wake locks completely when the device is manually put to sleep by the user. Bug: 7295909 Change-Id: Id99e82d2143ae1a81629281d6407d7527efb8137
2012-10-08Blank or unblank all displays as need.Jeff Brown
Ensures that both the internal display and HDMI are blanked or unblanked in tandem. Bug: 7309812 Change-Id: Ie8b96d393e8bb20d23c92f3320142d9f7cf42aff
2012-10-05Ensure that dreams show while docked.Jeff Brown
Fixed a race between the UiModeManagerService and PowerManagerService both of which are trying to wake the device when docked / powered. Bug: 7281240 Change-Id: Ia41fef48f17f2a2eb56549437d295f9a86c95af2
2012-10-05Coordinate screen on with the window manager.Jeff Brown
Bug: 7267457 Change-Id: Ic2c322253639e1f0b2e4e72a7b145025d0240f93
2012-10-04Ensure we send at least one wakeup/gotosleep transition.Jeff Brown
This fixes an issue where the device would not lock immediately when the user quickly pressed power off / power on even if configured to do so. We were suppressing the screen off and wake up broadcast in this case. Now we make sure to always send at least one broadcast to indicate the transition. We still collapse back-to-back full cycle transitions though so as not to end up enqueuing useless broadcasts. Bug: 7061116 Change-Id: I7211c5fd963c271c2b0aceb4d2f746063c629079
2012-10-04Allow phone to go to sleep while in call.Jeff Brown
Bug: 7279383 Change-Id: Ia05490218f40a1843507b95ff48fa07910e582d4
2012-10-03Fix issue #7267494, issue #7212347Dianne Hackborn
7267494 Calendar is not syncing Check for whether a content provider is dead before returning it. This is kind-of a band-aid, but probably the right thing to do; I'm just not sure exactly the full details of why this problem is happening. Hopefully this "fixes" it, though I don't have a way to repro to tell. 7212347 System power off dialog is only visible to user 0 Make it visible. Also turn on some battery debugging stuff and clean it up so we can just keep it. Change-Id: I5add25bf2a763c8dfe1df23bc5c753a9ea5d157a
2012-10-03Ensure dreams can be started when not powered.Jeff Brown
Previously dreams could not be started unless plugged in. Now we allow them to start but they will eventually stop if a user activity timeout occurs and no screen wakelocks are held. Bug: 7253639 Change-Id: I84703e144ca6d4aba1ef9437f04a201c3dde8a49
2012-10-02Improve the screen dim duration calculation.Jeff Brown
Take into account whether the screen off timeout is very short. If so, we use a shorter dim timeout. Don't allow the dim time to be more than 20% of the total screen on time so that the screen remains bright at least 80% of the time even when the timeout is short. Bug: 7273646 Change-Id: Iccea764b90f0d8b1df7009d26160c6bcf6eabe5b
2012-10-02Implement screen on hack for wireless chargers.Jeff Brown
We can't accurately detect whether the device is resting on a wireless charger unless it is actually charging. So we need to tweak the screen on when plugged / unplugged policy accordingly to avoid spurious wakeups. Bug: 7234284 Change-Id: I624b559e2e92b8813b12090bc20eca5f5158997e
2012-10-02Fix some synchronization issues in BatteryService.Jeff Brown
Some of the BatteryService state was being locked sometimes and it wasn't at all consistent. Bug: 7158734 Change-Id: I46e75f66fde92c5a577a80a6bd99c9573066f3c1
2012-10-01Fix CTS test failures.Jeff Brown
Bug: 7001730 Change-Id: I5649b601c310458de5d64b549a407e251d745b7c
2012-10-01New internal API to eliminate poke locks.Jeff Brown
Added a new WindowManager.LayoutParams inputFeatures flag to disable automatic user activity behavior when an input event is sent to a window. Added a new WindowManager.LayoutParams field userActivityTimeout. Bug: 7165399 Change-Id: I204eafa37ef26aacc2c52a1ba1ecce1eebb0e0d9
2012-09-30Remove clearUserActivityTimeout().Jeff Brown
This function is not implemented and not needed. Bug: 7165399 Change-Id: Ib1c50fabad6292ccf670404ba70aeb1242c4614d
2012-09-28Merge "Get rid of preventScreenOn()." into jb-mr1-devJeff Brown
2012-09-28Get rid of preventScreenOn().Jeff Brown
Bug: 7165399 Change-Id: I1968265ecd74fff4d85efd2ca03b1983425ea518
2012-09-28Fix issue #7255954: API Review: rename Dream to DreamServiceDianne Hackborn
Change-Id: I89ecf2c3ec4fef09c0495aa68de11576f9cfd872
2012-09-26Make DreamManagerService more robust.Jeff Brown
Clearly isolated the DreamManagerService and DreamController responsibilities. DreamManagerService contains just enough logic to manage the global synchronous behaviors. All of the asynchronous behaviors are in DreamController. Added a new PowerManager function called nap() to request the device to start napping. If it is a good time to nap, then the PowerManagerService will call startDream() on the DreamManagerService to start dreaming. Fixed a possible multi-user issue by explicitly tracking for which user a dream service is being started and stopping dreams when the current user changes. The user id is also passed to bindService() to ensure that the dream has the right environment. Fix interactions with docks and the UI mode manager. It is important that we always send the ACTION_DOCK_EVENT broadcast to the system so that it can configure audio routing and the like. When docked, the UI mode manager starts a dock app if there is one, otherwise it starts a dream. This change resolves issues with dreams started for reasons other than a user activity timeout. Bug: 7204211 Change-Id: I3193cc8190982c0836319176fa2e9c4dcad9c01f
2012-09-25Handle user switched for settings changes.Jeff Brown
Move OVERLAY_DISPLAY_DEVICES to Global. Bug: 7127417 Change-Id: I632648ac5b01408512f59424f3bb55162431bea4
2012-09-19Fire "dreaming started" and "dreaming stopped" broadcasts.John Spurlock
Dream manager now fires broadcast intents when entering + exiting dreamland (except when testing). Power manager can now listen for dreams ending, using polling only as a backstop. Also: - Bullet-proof dream-manager/dream against known failure modes - Add new read/write dream permissions - Refactor dream-manager to delegate work + state management into a new DreamController class, via a handler Bug:6999949 Bug:7152024 Change-Id: I986bb7812209d8c95ae1d660a5eee5998a7b08b1
2012-09-07Refer to STAY_ON_WHILE_PLUGGED_IN in the global namespaceChristopher Tate
This is the one relevant setting that moved from System to Global, a move that we do not automatically redirect on writes. Change-Id: I7b26d0c364695c4a10a7cd477db3dfcfe89d7ef5
2012-08-28Check proximity detector before powering off.Craig Mautner
Do not automatically power off if the proximity detector wakelock is active. Fixes bug 7047455. Change-Id: I44e30bf388292e5c476dfb5d0de9226d21853e4d
2012-08-25Merge "Initialize screen state earlier in the boot process." into jb-mr1-devJeff Brown
2012-08-25Initialize screen state earlier in the boot process.Jeff Brown
The system depends on receiving reliable vsync signals from surface flinger during the boot process. If it doesn't get them because the screen is off then a hang may occur. This isn't a problem when surface flinger manages the screen blanking itself but it is a problem for devices that still rely on early-suspend. When early-suspend is involved, the screen may be off without surface flinger knowing. This is a problem because surface flinger will only synthesize fake vsyncs when it knows the screen is off, otherwise relying on the hardware to generate vsync signals itself. Unfortunately, the hardware won't generate vsync signals if the screen was turned off by early-suspend, so we have a problem. Bug: 6975688 Change-Id: Iaf4527f716bf4ea72cc3e6fdaf060855697b02f2