@@ -9183,6 +9183,7 @@ static void controller_resume_callback(uint16_t index, uint16_t length,
info("Controller resume with wake event 0x%x", ev->wake_reason);
controller_resume_notify(adapter);
+ btd_adv_monitor_resume(adapter->adv_monitor_manager);
}
static void device_blocked_callback(uint16_t index, uint16_t length,
@@ -2248,6 +2248,7 @@ static void clear_device_lost_timer(void *data, void *user_data)
if (dev->lost_timer) {
timeout_remove(dev->lost_timer);
dev->lost_timer = 0;
+ dev->found = false;
monitor = dev->monitor;
@@ -2289,3 +2290,21 @@ void btd_adv_monitor_power_down(struct btd_adv_monitor_manager *manager)
/* Clear any running DeviceLost timers in case of power down */
queue_foreach(manager->apps, clear_lost_timers_from_app, NULL);
}
+
+/* Handles wake from system suspend scenario */
+void btd_adv_monitor_resume(struct btd_adv_monitor_manager *manager)
+{
+ if (!manager) {
+ error("Unexpected NULL btd_adv_monitor_manager object upon "
+ "system resume");
+ return;
+ }
+
+ /* Clear any tracked devices on system resume. Matched devices will be
+ * found again if they are in range after resume. (No need to do this if
+ * the controller based monitoring is supported as the kernel clears all
+ * monitored devices on resume.
+ */
+ if (!btd_adv_monitor_offload_enabled(manager))
+ queue_foreach(manager->apps, clear_lost_timers_from_app, NULL);
+}
@@ -42,4 +42,6 @@ void btd_adv_monitor_device_remove(struct btd_adv_monitor_manager *manager,
void btd_adv_monitor_power_down(struct btd_adv_monitor_manager *manager);
+void btd_adv_monitor_resume(struct btd_adv_monitor_manager *manager);
+
#endif /* __ADV_MONITOR_H */
Clear any tracked devices on system resume. Matched devices will be found again if they are in range after resume. Reviewed-by: Miao-chen Chou <mcchou@chromium.org> --- Changes in v2: - Fix compiler error by replacing btd_adv_monitor_offload_supported() with btd_adv_monitor_offload_enabled(). src/adapter.c | 1 + src/adv_monitor.c | 19 +++++++++++++++++++ src/adv_monitor.h | 2 ++ 3 files changed, 22 insertions(+)