From 606ee44985cb05861c85298df1acf1f256a98be8 Mon Sep 17 00:00:00 2001 From: Seungyoun Ju Date: Wed, 29 Nov 2017 17:47:15 +0900 Subject: [PATCH] Fix : logic error in MDM visibility policy [Problem] There are some logic error regarding Discoverable property changed event. 1. When limited discoverable mode is not allowed and general discoverable is set, general discoverable is requested again. 2. When limited discoverable mode and discoverable mode are both not allowed, it tries to set general discoverable mode. 3. DiscoverableTimeout property is not updated. [Cause & Measure] 1. Check current discoverable mode and only if it is in limited discoverable mode and limited discoverable mode is not allowed, set to general discoverable mode. 2. After handling discoverable mode policy, don't check limited discoverable mode policy. 3. Use proper type to set DiscoverableTimeout property. [Checking Method] Code review Change-Id: I3246ab7019c5415e799e448ce4115103211f4e6c --- bt-service/bt-service-event-receiver.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bt-service/bt-service-event-receiver.c b/bt-service/bt-service-event-receiver.c index 9b468bf..7a434cb 100644 --- a/bt-service/bt-service-event-receiver.c +++ b/bt-service/bt-service-event-receiver.c @@ -709,21 +709,22 @@ static void __bt_adapter_property_changed_event(GVariant *msg, const char *path) if (discoverable == FALSE) { if (_bt_get_discoverable_timeout_property() > 0) { - int time = 0; + unsigned int time = 0; + adapter_proxy = _bt_get_adapter_properties_proxy(); if (adapter_proxy == NULL) continue; + ret = g_dbus_proxy_call_sync(adapter_proxy, "Set", g_variant_new("(ssv)", BT_ADAPTER_INTERFACE, "DiscoverableTimeout", - g_variant_new("i", time)), + g_variant_new("u", time)), G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, &err); - if (err != NULL) { - BT_ERR("StopLEDiscovery Failed: %s", err->message); - g_error_free(err); + BT_ERR("Set DiscoverableTimeout Failed: %s", err->message); + g_clear_error(&err); } if (ret) g_variant_unref(ret); @@ -732,7 +733,7 @@ static void __bt_adapter_property_changed_event(GVariant *msg, const char *path) mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE; /* Send event to application */ - BT_INFO("[Connectable]"); + BT_INFO("[Non Discoverable]"); param = g_variant_new("(in)", result, mode); _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED, @@ -761,11 +762,11 @@ static void __bt_adapter_property_changed_event(GVariant *msg, const char *path) /* Send event to application */ BT_INFO("[Limited Discoverable (Timeout %u secs)]", - _bt_get_discoverable_timeout_property()); + _bt_get_discoverable_timeout_property()); param = g_variant_new("(in)", result, mode); _bt_send_event(BT_ADAPTER_EVENT, - BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED, - param); + BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED, + param); } else if (strcasecmp(property, "Powered") == 0) { /* TODO: Need to check this operation!! */ gboolean powered = FALSE; -- 2.7.4