OSDN Git Service

Implement GKI timers based on wake alarms and wake locks.
authorSharvil Nanavati <sharvil@google.com>
Thu, 29 May 2014 00:09:46 +0000 (17:09 -0700)
committerSharvil Nanavati <sharvil@google.com>
Sat, 7 Jun 2014 07:12:41 +0000 (07:12 +0000)
commit9bce2266bae83dfeb57319076dee569324a6d0a8
tree84907e0bfaf9553441192ee4a85d6aca8a2521ba
parent611f3abf1c12a9f568114e46a21e70c74eaf6a60
Implement GKI timers based on wake alarms and wake locks.

Before this change, bluedroid was unable to acquire wake locks
because the Bluetooth process didn't have permissions to write to
/sys/power/wake_*. We are now making wake locks accessible to
bluedroid through a HAL callout back into Java code.

The previous design did not use wake alarms. Bluedroid would attempt
to hold a wake lock until all pending timers expired, which is awful
if a timer is scheduled seconds or minutes from now. There is a
15min timer in bluedroid now so holding a wake lock for the entire
duration of pending alarms is unacceptable (power cost). The new
implementation uses a hybrid approach: if the next deadline is < 3s
away, we take a wake lock. If it is further than 3s away, we set a
wake alarm and release the wake lock.

As a result of this change, we have also eliminated a thread whose
sole purpose was to wake up every 10ms and update timers.

Change-Id: I46cd4edfcad2f5dce23c4003a14a617e7bf00541
btif/src/bluetooth.c
gki/common/gki_time.c
gki/ulinux/gki_ulinux.c
include/gki_target.h