From e41ab8397a13802b833ae36463ead14198112637 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 21 Sep 2023 00:03:50 -0700 Subject: [PATCH] chore: tweak device --- .../Commands/FBSessionCommands.m | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/WebDriverAgentLib/Commands/FBSessionCommands.m b/WebDriverAgentLib/Commands/FBSessionCommands.m index 565939080..dae547a8f 100644 --- a/WebDriverAgentLib/Commands/FBSessionCommands.m +++ b/WebDriverAgentLib/Commands/FBSessionCommands.m @@ -257,7 +257,8 @@ + (NSArray *)routes #endif @"ip" : [XCUIDevice sharedDevice].fb_wifiIPAddress ?: [NSNull null] }, - @"build" : buildInfo.copy + @"build" : buildInfo.copy, + @"device": [self.class deviceName:[UIDevice currentDevice].userInterfaceIdiom] } ); } @@ -418,12 +419,26 @@ + (NSDictionary *)sessionInformation }; } ++ (NSString *)deviceName:(UIUserInterfaceIdiom) currentDevice +{ + if (currentDevice == UIUserInterfaceIdiomPad) { + return @"iPad"; + } else if (currentDevice == UIUserInterfaceIdiomTV) { + return @"Apple TV"; + } else if (currentDevice == UIUserInterfaceIdiomPhone) { + return @"iPhone"; + } + // CarPlay, Mac, Vision UI or unknown are possible + return @"Unknown"; + +} + + (NSDictionary *)currentCapabilities { FBApplication *application = [FBSession activeSession].activeApplication; return @{ - @"device": ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? @"ipad" : @"iphone", + @"device": [self.class deviceName:[UIDevice currentDevice].userInterfaceIdiom], @"sdkVersion": [[UIDevice currentDevice] systemVersion], @"browserName": application.label ?: [NSNull null], @"CFBundleIdentifier": application.bundleID ?: [NSNull null],