Fix : logic error in MDM visibility policy 23/162523/1
authorSeungyoun Ju <sy39.ju@samsung.com>
Wed, 29 Nov 2017 08:47:15 +0000 (17:47 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 4 Dec 2017 05:31:14 +0000 (14:31 +0900)
[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: I8e3d9a6a56769c21faa2ef1361623ff0cfd22a8b
Signed-off-by: Seungyoun Ju <sy39.ju@samsung.com>
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-service/bt-service-event-receiver.c

index 9b468bf..7a434cb 100644 (file)
@@ -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;