core/service: Return required version in btd_service_get_version
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 7 Feb 2014 13:42:51 +0000 (15:42 +0200)
committerMikko Ylinen <mikko.ylinen@intel.com>
Tue, 23 Sep 2014 18:29:21 +0000 (21:29 +0300)
This makes btd_service_get_version check both local and remote version
and return the required version that the service should operate.

src/service.c

index 529217a..48b0592 100644 (file)
@@ -291,6 +291,9 @@ uint16_t btd_service_get_version(const struct btd_service *service)
        sdp_profile_desc_t *desc;
        uint16_t version;
 
+       if (!service->profile->version)
+               return 0;
+
        rec = btd_device_get_record(service->device,
                                        service->profile->remote_uuid);
        if (rec == NULL)
@@ -303,7 +306,7 @@ uint16_t btd_service_get_version(const struct btd_service *service)
        version = desc->version;
        sdp_list_free(list, free);
 
-       return version;
+       return MIN(version, service->profile->version);
 }
 
 unsigned int btd_service_add_state_cb(btd_service_state_cb cb, void *user_data)