Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5bb6cac6 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Add support for native kernel and callout wakelocks

 * Moved wakelock-related code to osi/src/wakelock.c
   The API is in osi/include/wakelock.h

 * Use wakelock_set_os_callouts() to specify native kernel
   or callout-based wakelock.
   On Android, wakelock_set_os_callouts() is called to
   set the bt_os_callouts_t callbacks into the Java layer.

 * Renamed alarm_set_wake_lock_paths() to wakelock_set_paths()

Also, added Bluetooth Wakelock Statistics to the bugreport.
Sample output:

$ adb shell dumpsys bluetooth_manager
...
Bluetooth Wakelock Statistics:
  Wakelock is acquired                    : false
  Wakelock acquired/released count        : 5 / 5
  Wakelock acquired/released errors       : 0 / 0
  Wakelock last acquired time (ms)        : 1524
  Wakelock acquired time min/max/avg (ms) : 1511 / 8104 / 3167
  Wakelock total acquired time (ms)       : 15836
  Bluetooth total run time (ms)           : 44123

Bug: 26645431
Change-Id: I42bfb7db5b016719faea39e47ebc77c3ad02467b
parent fc832f59
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "osi/include/log.h"
#include "osi/include/mutex.h"
#include "osi/include/osi.h"
#include "osi/include/wakelock.h"

future_t *osi_init(void) {
  mutex_init();
@@ -33,6 +34,7 @@ future_t *osi_init(void) {

future_t *osi_clean_up(void) {
  alarm_cleanup();
  wakelock_cleanup();
  mutex_cleanup();
  return future_new_immediate(FUTURE_SUCCESS);
}
+2 −4
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@
#include "osi/include/allocation_tracker.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/wakelock.h"
#include "stack_manager.h"
#include "btif_config.h"

@@ -68,9 +69,6 @@

bt_callbacks_t *bt_hal_cbacks = NULL;

/** Operating System specific callouts for resource management */
bt_os_callouts_t *bt_os_callouts = NULL;

/************************************************************************************
**  Externs
************************************************************************************/
@@ -423,7 +421,7 @@ int config_hci_snoop_log(uint8_t enable)
}

static int set_os_callouts(bt_os_callouts_t *callouts) {
    bt_os_callouts = callouts;
    wakelock_set_os_callouts(callouts);
    return BT_STATUS_SUCCESS;
}

+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "btif/include/btif_debug_btsnoop.h"
#include "btif/include/btif_debug_conn.h"
#include "include/bt_target.h"
#include "osi/include/wakelock.h"

void btif_debug_init(void) {
#if defined(BTSNOOP_MEM) && (BTSNOOP_MEM == TRUE)
@@ -32,6 +33,7 @@ void btif_debug_init(void) {

void btif_debug_dump(int fd) {
  btif_debug_conn_dump(fd);
  wakelock_debug_dump(fd);
#if defined(BTSNOOP_MEM) && (BTSNOOP_MEM == TRUE)
  btif_debug_btsnoop_dump(fd);
#endif
+2 −1
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ btosiCommonSrc := \
    ./src/socket_utils/socket_local_client.c \
    ./src/socket_utils/socket_local_server.c \
    ./src/thread.c \
    ./src/time.c
    ./src/time.c \
    ./src/wakelock.c

btosiCommonTestSrc := \
    ./test/AlarmTestHarness.cpp \
+3 −8
Original line number Diff line number Diff line
@@ -57,12 +57,7 @@ void alarm_cancel(alarm_t *alarm);
// TODO: Remove this function once PM timers can be re-factored
period_ms_t alarm_get_remaining_ms(const alarm_t *alarm);

// Alarm-related state cleanup
// Cleanup the alarm internal state.
// This function should be called by the OSI module cleanup during
// graceful shutdown.
void alarm_cleanup(void);

// This function should not need to be called normally.
// /sys/power/wake_{|un}lock are used by default.
// This is not guaranteed to have any effect after an alarm has been
// set with alarm_set.
// If |lock_path| or |unlock_path| are NULL, that path is not changed.
void alarm_set_wake_lock_paths(const char *lock_path, const char *unlock_path);
Loading