Skip to content

Commit

Permalink
chore: tweak device
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Sep 21, 2023
1 parent 3ec9628 commit e41ab83
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions WebDriverAgentLib/Commands/FBSessionCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
);
}
Expand Down Expand Up @@ -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],
Expand Down

0 comments on commit e41ab83

Please sign in to comment.