OSDN Git Service

Fix 5797764: don't hold PowerManager lock when changing native brightness
authorJim Miller <jaggies@google.com>
Wed, 22 Feb 2012 02:57:12 +0000 (18:57 -0800)
committerJim Miller <jaggies@google.com>
Tue, 28 Feb 2012 02:31:03 +0000 (18:31 -0800)
commit92e66dd6835cd5fefad463c79d0589166e8fd3a7
tree894b51a7b8b1fb103661684d62b621f34420cdc1
parent79952ee29a8fc67b6d76a8db747bb72dd7d6ecd1
Fix 5797764: don't hold PowerManager lock when changing native brightness

This fixes a bug where the device could see a priority inversion when
updating display brightness.  The problem occurs because the code that
manages screen brightness holds the master lock while waiting for the
native method to complete.  On some devices, each call can amount to
tens to hundreds of ms, which meant clients using PowerManager APIs
could block for the duration of the call.  In some cases, the animation
could block for many seconds because the unfairness of Java locks.

The solution is to handle all brightness updates in a separate thread that
does not hold the master lock while calling native methods.

This also makes the animation more consistent by animating by actual
wall clock time rather than depending on the round-trip from the driver.

Change-Id: Ifad76fb2fb77e7b2a72dd9150440d87e22581b40
services/java/com/android/server/PowerManagerService.java