@@ -1323,6 +1323,33 @@ int app_exists(AMDeviceRef device)
1323
1323
return -1 ;
1324
1324
}
1325
1325
1326
+ void list_bundle_id (AMDeviceRef device )
1327
+ {
1328
+ AMDeviceConnect (device );
1329
+ assert (AMDeviceIsPaired (device ));
1330
+ check_error (AMDeviceValidatePairing (device ));
1331
+ check_error (AMDeviceStartSession (device ));
1332
+
1333
+ NSArray * a = [NSArray arrayWithObjects :@"CFBundleIdentifier" , nil ];
1334
+ NSDictionary * optionsDict = [NSDictionary dictionaryWithObject :a forKey :@"ReturnAttributes" ];
1335
+ CFDictionaryRef options = (CFDictionaryRef )optionsDict ;
1336
+ CFDictionaryRef result = nil ;
1337
+ check_error (AMDeviceLookupApplications (device , options , & result ));
1338
+
1339
+ CFIndex count ;
1340
+ count = CFDictionaryGetCount (result );
1341
+ const void * keys [count ];
1342
+ CFDictionaryGetKeysAndValues (result , keys , NULL );
1343
+ for (int i = 0 ; i < count ; ++ i ) {
1344
+ CFStringRef test = (CFStringRef )keys [i ];
1345
+ const char * key = CFStringGetCStringPtr ((CFStringRef )keys [i ], kCFStringEncodingASCII );
1346
+ printf ("%s\n" , key );
1347
+ }
1348
+
1349
+ check_error (AMDeviceStopSession (device ));
1350
+ check_error (AMDeviceDisconnect (device ));
1351
+ }
1352
+
1326
1353
void copy_file_callback (afc_connection * afc_conn_p , const char * name ,int file )
1327
1354
{
1328
1355
const char * local_name = name ;
@@ -1574,6 +1601,8 @@ void handle_device(AMDeviceRef device) {
1574
1601
exit (app_exists (device ));
1575
1602
} else if (strcmp ("uninstall_only" , command ) == 0 ) {
1576
1603
uninstall_app (device );
1604
+ } else if (strcmp ("list_bundle_id" , command ) == 0 ) {
1605
+ list_bundle_id (device );
1577
1606
}
1578
1607
exit (0 );
1579
1608
}
@@ -1756,7 +1785,8 @@ void usage(const char* app) {
1756
1785
" -D, --mkdir <dir> make directory on device\n"
1757
1786
" -R, --rm <path> remove file or directory on device (directories must be empty)\n"
1758
1787
" -V, --version print the executable version \n"
1759
- " -e, --exists check if the app with given bundle_id is installed or not \n" ,
1788
+ " -e, --exists check if the app with given bundle_id is installed or not \n"
1789
+ " -B, --list_bundle_id list bundle_id \n" ,
1760
1790
app );
1761
1791
}
1762
1792
@@ -1790,11 +1820,12 @@ int main(int argc, char *argv[]) {
1790
1820
{ "mkdir" , required_argument , NULL , 'D' },
1791
1821
{ "rm" , required_argument , NULL , 'R' },
1792
1822
{ "exists" , no_argument , NULL , 'e' },
1823
+ { "list_bundle_id" , no_argument , NULL , 'B' },
1793
1824
{ NULL , 0 , NULL , 0 },
1794
1825
};
1795
1826
char ch ;
1796
1827
1797
- while ((ch = getopt_long (argc , argv , "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::" , longopts , NULL )) != -1 )
1828
+ while ((ch = getopt_long (argc , argv , "VmcdvunrILeD:R:i:b:a:t:g:x:p:1:2:o:l::w::9::B:: " , longopts , NULL )) != -1 )
1798
1829
{
1799
1830
switch (ch ) {
1800
1831
case 'm' :
@@ -1884,6 +1915,10 @@ int main(int argc, char *argv[]) {
1884
1915
command_only = true;
1885
1916
command = "exists" ;
1886
1917
break ;
1918
+ case 'B' :
1919
+ command_only = true;
1920
+ command = "list_bundle_id" ;
1921
+ break ;
1887
1922
default :
1888
1923
usage (argv [0 ]);
1889
1924
return exitcode_error ;
0 commit comments