Skip to content

Commit

Permalink
chore: tweak device in currentCapabilities (#773)
Browse files Browse the repository at this point in the history
* chore: tweak device

* chore: tweak

* keep lower case

* Update FBSessionCommands.m
  • Loading branch information
KazuCocoa authored Sep 22, 2023
1 parent 49c135c commit 8481b02
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 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 deviceNameByUserInterfaceIdiom:[UIDevice currentDevice].userInterfaceIdiom]
}
);
}
Expand Down Expand Up @@ -418,14 +419,31 @@ + (NSDictionary *)sessionInformation
};
}

/*
Return the device kind as lower case
*/
+ (NSString *)deviceNameByUserInterfaceIdiom:(UIUserInterfaceIdiom) userInterfaceIdiom
{
if (userInterfaceIdiom == UIUserInterfaceIdiomPad) {
return @"ipad";
} else if (userInterfaceIdiom == UIUserInterfaceIdiomTV) {
return @"apple tv";
} else if (userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
return @"iphone";
}
// CarPlay, Mac, Vision UI or unknown are possible
return @"Unknown";

}

+ (NSDictionary *)currentCapabilities
{
FBApplication *application = [FBSession activeSession].activeApplication;
// to log the info in the system
[FBLogger logFmt:@"Current active application bundle id is %@", application.bundleID];
return
@{
@"device": ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? @"ipad" : @"iphone",
@"device": [self.class deviceNameByUserInterfaceIdiom:[UIDevice currentDevice].userInterfaceIdiom],
@"sdkVersion": [[UIDevice currentDevice] systemVersion],
@"browserName": application.label ?: [NSNull null],
@"CFBundleIdentifier": application.bundleID ?: [NSNull null],
Expand Down

0 comments on commit 8481b02

Please sign in to comment.