in idb_companion/Server/FBIDBServiceHandler.mm [668:695]
Status FBIDBServiceHandler::list_apps(ServerContext *context, const idb::ListAppsRequest *request, idb::ListAppsResponse *response)
{@autoreleasepool{
NSError *error = nil;
NSSet<NSString *> *persistedBundleIDs = _commandExecutor.storageManager.application.persistedBundleIDs;
BOOL fetchAppProcessState = request->suppress_process_state() == false;
NSDictionary<FBInstalledApplication *, id> *apps = [[_commandExecutor list_apps:fetchAppProcessState] block:&error];
if (!apps) {
return Status(grpc::StatusCode::INTERNAL, error.localizedDescription.UTF8String);
}
for (FBInstalledApplication *app in apps.allKeys) {
idb::InstalledAppInfo *appInfo = response->add_apps();
appInfo->set_bundle_id(app.bundle.identifier.UTF8String ?: "");
appInfo->set_name(app.bundle.name.UTF8String ?: "");
appInfo->set_install_type(app.installTypeString.UTF8String);
for (NSString *architecture in app.bundle.binary.architectures) {
appInfo->add_architectures(architecture.UTF8String);
}
id processState = apps[app];
if ([processState isKindOfClass:NSNumber.class]) {
appInfo->set_process_state(idb::InstalledAppInfo_AppProcessState_RUNNING);
appInfo->set_process_identifier([processState unsignedIntegerValue]);
} else {
appInfo->set_process_state(idb::InstalledAppInfo_AppProcessState_UNKNOWN);
}
appInfo->set_debuggable(app.installType == FBApplicationInstallTypeUserDevelopment && [persistedBundleIDs containsObject:app.bundle.identifier]);
}
return Status::OK;
}}