From 947854e44f5d06399123ed31857fa1ccfd58d423 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 14 Dec 2017 21:27:11 -0800 Subject: binding: wifi: set initial Wi-Fi HMI state Wait for homescreen service to become active and set initial Wi-Fi state Bug-AGL: SPEC-1197 Change-Id: I46c9eeb14b392b4cc6e580d6dd86695849c59484 Signed-off-by: Matt Ranostay --- binding-wifi/wifi-api.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/binding-wifi/wifi-api.c b/binding-wifi/wifi-api.c index 7dcc603..45341e3 100644 --- a/binding-wifi/wifi-api.c +++ b/binding-wifi/wifi-api.c @@ -667,12 +667,40 @@ static const struct afb_verb_v2 binding_verbs[] = { { } /* marker for end of the array */ }; + +gboolean initial_homescreen(gpointer ptr) +{ + struct wifiStatus *status = g_try_malloc0(sizeof(struct wifiStatus)); + GError *error = NULL; + int ret = 0; + + ret = wifi_state(status); + + if (ret < 0) { + g_object_unref(status); + return TRUE; + } + + error = setHMIStatus(status->connected == 1 ? BAR_FULL : BAR_NO); + g_error_free(error); + + return ret != NULL; +} + +static void *thread_func() +{ + g_timeout_add_seconds(5, initial_homescreen, NULL); + g_main_loop_run(g_main_loop_new(NULL, FALSE)); +} + static int init() { + pthread_t thread_id; + event_add("passkey"); event_add("networkList"); - return 0; + return pthread_create(&thread_id, NULL, thread_func, NULL); } /* -- cgit 1.2.3-korg