From a6fcb3fd337bf63aba9237f54e4ecb8c737e984c Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 27 Jan 2015 21:56:48 +0100 Subject: idevicedebug: Use more efficient instproxy_lookup instead of browsing all apps --- tools/idevicedebug.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'tools/idevicedebug.c') diff --git a/tools/idevicedebug.c b/tools/idevicedebug.c index c9648d0..996fa46 100644 --- a/tools/idevicedebug.c +++ b/tools/idevicedebug.c @@ -2,7 +2,7 @@ * idevicedebug.c * Interact with the debugserver service of a device. * - * Copyright (c) 2014 Martin Szulecki All Rights Reserved. + * Copyright (c) 2014-2015 Martin Szulecki All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -65,31 +65,19 @@ static instproxy_error_t instproxy_client_get_object_by_key_from_info_directiona // only return attributes we need instproxy_client_options_set_return_attributes(client_opts, "CFBundleIdentifier", "CFBundleExecutable", key, NULL); + // only query for specific appid + const char* appids[] = {appid, NULL}; + // query device for list of apps - instproxy_error_t ierr = instproxy_browse(client, client_opts, &apps); + instproxy_error_t ierr = instproxy_lookup(client, appids, client_opts, &apps); + instproxy_client_options_free(client_opts); + if (ierr != INSTPROXY_E_SUCCESS) { return ierr; } - plist_t app_found = NULL; - uint32_t i; - for (i = 0; i < plist_array_get_size(apps); i++) { - char *appid_str = NULL; - plist_t app_info = plist_array_get_item(apps, i); - plist_t idp = plist_dict_get_item(app_info, "CFBundleIdentifier"); - if (idp) { - plist_get_string_val(idp, &appid_str); - } - if (appid_str && strcmp(appid, appid_str) == 0) { - app_found = app_info; - } - free(appid_str); - if (app_found) { - break; - } - } - + plist_t app_found = plist_access_path(apps, 1, appid); if (!app_found) { if (apps) plist_free(apps); -- cgit v1.1-32-gdbae