Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use monitoredApplicationWithProcessIdentifier API to fetch application objects from PID #776

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions WebDriverAgentLib/FBApplication.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ + (instancetype)fb_activeApplication
NSMutableArray<FBApplication *> *result = [NSMutableArray array];
if (activeApplicationElements.count > 0) {
for (id<FBXCAccessibilityElement> applicationElement in activeApplicationElements) {
FBApplication *app = [FBApplication fb_applicationWithPID:applicationElement.processIdentifier];
FBApplication *app = [FBApplication applicationWithPID:applicationElement.processIdentifier];
if (nil != app) {
[result addObject:app];
}
Expand Down Expand Up @@ -107,7 +107,7 @@ + (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bun
}

if (nil != activeApplicationElement) {
FBApplication *application = [FBApplication fb_applicationWithPID:activeApplicationElement.processIdentifier];
FBApplication *application = [FBApplication applicationWithPID:activeApplicationElement.processIdentifier];
if (nil != application) {
return application;
}
Expand All @@ -117,7 +117,7 @@ + (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bun
if (activeApplicationElements.count > 0) {
[FBLogger logFmt:@"Getting the most recent active application (out of %@ total items)", @(activeApplicationElements.count)];
for (id<FBXCAccessibilityElement> appElement in activeApplicationElements) {
FBApplication *application = [FBApplication fb_applicationWithPID:appElement.processIdentifier];
FBApplication *application = [FBApplication applicationWithPID:appElement.processIdentifier];
if (nil != application) {
return application;
}
Expand All @@ -130,7 +130,7 @@ + (instancetype)fb_activeApplicationWithDefaultBundleId:(nullable NSString *)bun

+ (instancetype)fb_systemApplication
{
return [self fb_applicationWithPID:
return [self applicationWithPID:
[[FBXCAXClientProxy.sharedClient systemApplication] processIdentifier]];
}

Expand Down
2 changes: 0 additions & 2 deletions WebDriverAgentLib/Utilities/FBXCodeCompatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ extern NSString *const FBApplicationMethodNotSupportedException;

@interface XCUIApplication (FBCompatibility)

+ (nullable instancetype)fb_applicationWithPID:(pid_t)processID;

/**
Get the state of the application. This method only returns reliable results on Xcode SDK 9+

Expand Down
9 changes: 0 additions & 9 deletions WebDriverAgentLib/Utilities/FBXCodeCompatibility.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@

@implementation XCUIApplication (FBCompatibility)

+ (instancetype)fb_applicationWithPID:(pid_t)processID
{
if (0 == processID) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this protection is not needed? What happens if the requested pid is 0?

return nil;
}

return [self applicationWithPID:processID];
}

- (void)fb_activate
{
[self activate];
Expand Down
Loading