Diff between e8907bccd47b56da0dcdecb51fc6f8e9a8faff07 and b5a5d2d81affbd38826c41dcefc9209b057e9a2e

Changed Files

File Additions Deletions Status
android/client/if-bt.c +42 -0 modified

Full Patch

diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 22f3f4c..327fa86 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -359,6 +359,44 @@ static bt_callbacks_t bt_callbacks = {
 #endif
 };
 
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static alarm_cb alarm_cb_p = NULL;
+static void *alarm_cb_p_data = NULL;
+
+static bool set_wake_alarm(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data)
+{
+	haltest_info("%s: delay %lu  should_wake %u cb %p data %p\n",
+				__func__, delay_millis, should_wake, cb, data);
+
+	/* TODO call alarm callback after specified delay */
+	alarm_cb_p = cb;
+	alarm_cb_p_data = data;
+
+	return true;
+}
+
+static int acquire_wake_lock(const char *lock_name)
+{
+	haltest_info("%s: %s\n", __func__, lock_name);
+
+	return BT_STATUS_SUCCESS;
+}
+
+static int release_wake_lock(const char *lock_name)
+{
+	haltest_info("%s: %s\n", __func__, lock_name);
+
+	return BT_STATUS_SUCCESS;
+}
+
+static bt_os_callouts_t bt_os_callouts = {
+	.size = sizeof(bt_os_callouts),
+	.set_wake_alarm = set_wake_alarm,
+	.acquire_wake_lock = acquire_wake_lock,
+	.release_wake_lock = release_wake_lock,
+};
+#endif
+
 static void init_p(int argc, const char **argv)
 {
 	int err;
@@ -385,6 +423,10 @@ static void init_p(int argc, const char **argv)
 	}
 
 	EXEC(if_bluetooth->init, &bt_callbacks);
+
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+	EXEC(if_bluetooth->set_os_callouts, &bt_os_callouts);
+#endif
 }
 
 static void cleanup_p(int argc, const char **argv)