summaryrefslogtreecommitdiff
path: root/android/health.c
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2014-06-24 15:12:01 +0300
committerSzymon Janc <szymon.janc@tieto.com>2014-06-25 17:29:55 +0200
commitc701a30bbedfa333c26758739f95270fae046988 (patch)
tree5115c39fabd8601cb6e36a34897296ccdfdd8f5b /android/health.c
parentf756b74ba48d9c04b20b85b3a98fe569b207e9f6 (diff)
downloadbluez-c701a30bbedfa333c26758739f95270fae046988.tar.gz
android/health: Refactor create_device
create_device() should not search for apps again since we have searched already, and we do not have always app_id.
Diffstat (limited to 'android/health.c')
-rw-r--r--android/health.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/android/health.c b/android/health.c
index 2613ca6b0..df9784886 100644
--- a/android/health.c
+++ b/android/health.c
@@ -1352,12 +1352,11 @@ static int connect_mcl(struct health_channel *channel)
search_cb, channel, NULL, 0);
}
-static struct health_device *create_device(uint16_t app_id, const uint8_t *addr)
+static struct health_device *create_device(struct health_app *app,
+ const uint8_t *addr)
{
- struct health_app *app;
struct health_device *dev;
- app = queue_find(apps, app_by_app_id, INT_TO_PTR(app_id));
if (!app)
return NULL;
@@ -1367,7 +1366,6 @@ static struct health_device *create_device(uint16_t app_id, const uint8_t *addr)
return NULL;
android2bdaddr(addr, &dev->dst);
- dev->app_id = app_id;
dev->channels = queue_new();
if (!dev->channels) {
free_health_device(dev);
@@ -1397,7 +1395,11 @@ static struct health_device *get_device(uint16_t app_id, const uint8_t *addr)
if (dev)
return dev;
- return create_device(app_id, addr);
+ dev = create_device(app, addr);
+ if (dev)
+ dev->app_id = app_id;
+
+ return dev;
}
static struct health_channel *create_channel(uint16_t app_id,