Skip to content

Commit 0d0df60

Browse files
committed
Merge branch 'modified_appium_wda' of ssh://git-qa.gz.netease.com:32200/maki/wda-eov into modified_appium_wda
2 parents 44269cd + b552b29 commit 0d0df60

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

WebDriverAgent.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4229,6 +4229,7 @@
42294229
buildSettings = {
42304230
CLANG_STATIC_ANALYZER_MODE = deep;
42314231
DEBUG_INFORMATION_FORMAT = dwarf;
4232+
DEVELOPMENT_TEAM = CGWUCLNJM7;
42324233
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
42334234
INFOPLIST_FILE = WebDriverAgentRunner/Info.plist;
42344235
LD_RUNPATH_SEARCH_PATHS = (
@@ -4276,6 +4277,7 @@
42764277
baseConfigurationReference = EEE5CABF1C80361500CBBDD9 /* IOSSettings.xcconfig */;
42774278
buildSettings = {
42784279
CLANG_STATIC_ANALYZER_MODE = deep;
4280+
DEVELOPMENT_TEAM = CGWUCLNJM7;
42794281
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
42804282
INFOPLIST_FILE = WebDriverAgentRunner/Info.plist;
42814283
LD_RUNPATH_SEARCH_PATHS = (

WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ typedef NS_ENUM(NSUInteger, FBUIInterfaceAppearance) {
7474
*/
7575
- (nullable NSString *)fb_wifiIPAddress;
7676

77+
/**
78+
Returns device current actural wifi ip4 address
79+
*/
80+
- (nullable NSString *)fb_acturalWifiIPAddress;
81+
7782
/**
7883
Opens the particular url scheme using the default application assigned to it.
7984
This API only works since XCode 14.3/iOS 16.4

WebDriverAgentLib/Categories/XCUIDevice+FBHelpers.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,38 @@ - (NSString *)fb_wifiIPAddress
153153
return address;
154154
}
155155

156+
- (NSString *)fb_acturalWifiIPAddress
157+
{
158+
struct ifaddrs *interfaces = NULL;
159+
struct ifaddrs *temp_addr = NULL;
160+
int success = getifaddrs(&interfaces);
161+
if (success != 0) {
162+
freeifaddrs(interfaces);
163+
return nil;
164+
}
165+
166+
NSString *address = nil;
167+
temp_addr = interfaces;
168+
bool has_wifi = FALSE;
169+
while(temp_addr != NULL) {
170+
if(temp_addr->ifa_addr->sa_family != AF_INET) {
171+
temp_addr = temp_addr->ifa_next;
172+
continue;
173+
}
174+
NSString *interfaceName = [NSString stringWithUTF8String:temp_addr->ifa_name];
175+
address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
176+
// [FBLogger logFmt:@"interface: %@, address: %@", interfaceName, address];
177+
178+
if([interfaceName containsString:@"en"] && ![address containsString:@"169.254"]) {
179+
has_wifi = TRUE;
180+
break;
181+
}
182+
temp_addr = temp_addr->ifa_next;
183+
}
184+
freeifaddrs(interfaces);
185+
return has_wifi ? address : nil;
186+
}
187+
156188
- (BOOL)fb_openUrl:(NSString *)url error:(NSError **)error
157189
{
158190
NSURL *parsedUrl = [NSURL URLWithString:url];

WebDriverAgentLib/Commands/FBSessionCommands.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ + (NSArray *)routes
255255
#if TARGET_OS_SIMULATOR
256256
@"simulatorVersion" : [[UIDevice currentDevice] systemVersion],
257257
#endif
258-
@"ip" : [XCUIDevice sharedDevice].fb_wifiIPAddress ?: [NSNull null]
258+
@"ip" : [XCUIDevice sharedDevice].fb_wifiIPAddress ?: [NSNull null],
259+
@"wifiIP" : [XCUIDevice sharedDevice].fb_acturalWifiIPAddress ?: [NSNull null],
259260
},
260261
@"build" : buildInfo.copy,
261262
@"Version":@("1.1"),

0 commit comments

Comments
 (0)