in idb_companion/SwiftServer/MethodHandlers/DescribeMethodHandler.swift [21:60]
func handle(request: Idb_TargetDescriptionRequest, context: GRPCAsyncServerCallContext) async throws -> Idb_TargetDescriptionResponse {
var response = Idb_TargetDescriptionResponse.with {
$0.targetDescription = .with {
$0.udid = target.udid
$0.name = target.name
$0.state = FBiOSTargetStateStringFromState(target.state).rawValue
$0.targetType = FBiOSTargetTypeStringFromTargetType(target.targetType).lowercased()
$0.osVersion = target.osVersion.name.rawValue
$0.architecture = target.architecture.rawValue
if let screenInfo = target.screenInfo {
$0.screenDimensions = .with {
$0.width = UInt64(screenInfo.widthPixels)
$0.widthPoints = $0.width / UInt64(screenInfo.scale)
$0.height = UInt64(screenInfo.heightPixels)
$0.heightPoints = $0.height / UInt64(screenInfo.scale)
$0.density = Double(screenInfo.scale)
}
}
if let extData = try? JSONSerialization.data(withJSONObject: target.extendedInformation) {
$0.extended = extData;
}
}
$0.companion = Idb_CompanionInfo.with {
$0.udid = target.udid
if let metadata = try? JSONSerialization.data(withJSONObject: reporter.metadata) {
$0.metadata = metadata
}
}
}
guard request.fetchDiagnostics else {
return response
}
let diagnosticInformation = try await FutureBox(commandExecutor.diagnostic_information()).value
let diagnosticInfoData = try JSONSerialization.data(withJSONObject: diagnosticInformation)
response.targetDescription.diagnostics = diagnosticInfoData
return response
}