diff options
author | Sharvil Nanavati <sharvil@google.com> | 2014-05-30 16:43:38 -0700 |
---|---|---|
committer | Prerepa Viswanadham <dham@google.com> | 2014-06-12 14:01:25 -0700 |
commit | 3bd8cba78754d63f6379f073649a89baae82b837 (patch) | |
tree | 57f0fb9106ba40c51f5154e80c104b4061761e93 | |
parent | 0f0b6d5ccb65f69c775accd2c2eada79c369c456 (diff) | |
download | hardware_libhardware-3bd8cba78754d63f6379f073649a89baae82b837.zip hardware_libhardware-3bd8cba78754d63f6379f073649a89baae82b837.tar.gz hardware_libhardware-3bd8cba78754d63f6379f073649a89baae82b837.tar.bz2 |
Add callouts for bluedroid to acquire wake locks and set wake alarms.
Since bluedroid is running outside of system_server, it does not have
the necessary Linux capabilities or filesystem permissions to access
/sys/power/wake_* and /dev/alarm (or any other wake alarm). This change
provides a mechanism by which bluedroid can call back up into Java code
and use the standard Android APIs to get wake locks / wake alarms.
Change-Id: I714fd394224d38da5ff0f82de5559599d522010b
Conflicts:
include/hardware/bluetooth.h
-rw-r--r-- | include/hardware/bluetooth.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/hardware/bluetooth.h b/include/hardware/bluetooth.h index 41a1167..56b7367 100644 --- a/include/hardware/bluetooth.h +++ b/include/hardware/bluetooth.h @@ -17,6 +17,7 @@ #ifndef ANDROID_INCLUDE_BLUETOOTH_H #define ANDROID_INCLUDE_BLUETOOTH_H +#include <stdbool.h> #include <stdint.h> #include <sys/cdefs.h> #include <sys/types.h> @@ -360,6 +361,24 @@ typedef struct { le_test_mode_callback le_test_mode_cb; } bt_callbacks_t; +typedef void (*alarm_cb)(void *data); +typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data); +typedef int (*acquire_wake_lock_callout)(const char *lock_name); +typedef int (*release_wake_lock_callout)(const char *lock_name); + +/** The set of functions required by bluedroid to set wake alarms and + * grab wake locks. This struct is passed into the stack through the + * |set_os_callouts| function on |bt_interface_t|. + */ +typedef struct { + /* set to sizeof(bt_os_callouts_t) */ + size_t size; + + set_wake_alarm_callout set_wake_alarm; + acquire_wake_lock_callout acquire_wake_lock; + release_wake_lock_callout release_wake_lock; +} bt_os_callouts_t; + /** NOTE: By default, no profiles are initialized at the time of init/enable. * Whenever the application invokes the 'init' API of a profile, then one of * the following shall occur: @@ -471,6 +490,11 @@ typedef struct { /* enable or disable bluetooth HCI snoop log */ int (*config_hci_snoop_log)(uint8_t enable); + + /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks. + * This should be called immediately after a successful |init|. + */ + int (*set_os_callouts)(bt_os_callouts_t *callouts); } bt_interface_t; /** TODO: Need to add APIs for Service Discovery, Service authorization and |