Skip to content

Commit

Permalink
Also enable the AX inspector, as seen in KIF and EarlGrey
Browse files Browse the repository at this point in the history
  • Loading branch information
qmfrederik committed Apr 7, 2016
1 parent 86d4eb8 commit 8bc11f2
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/FrankLoader.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ + (void)load{

void *appSupportLibrary = dlopen([appSupportLocation fileSystemRepresentation], RTLD_LAZY);

if(!appSupportLibrary) {
NSLog(@"Unable to dlopen AppSupport. Cannot automatically enable accessibility.");
}

CFStringRef (*copySharedResourcesPreferencesDomainForDomain)(CFStringRef domain) = dlsym(appSupportLibrary, "CPCopySharedResourcesPreferencesDomainForDomain");

if (copySharedResourcesPreferencesDomainForDomain) {
Expand All @@ -71,9 +75,38 @@ + (void)load{
if (accessibilityDomain) {
CFPreferencesSetValue(CFSTR("ApplicationAccessibilityEnabled"), kCFBooleanTrue, accessibilityDomain, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
CFRelease(accessibilityDomain);
NSLog(@"Successfully updated the ApplicationAccessibilityEnabled value.");
}
else {
NSLog(@"Unable to copy accessibility preferences. Cannot automatically enable accessibility.");
}
}

else {
NSLog(@"Unable to dlsym CPCopySharedResourcesPreferencesDomainForDomain. Cannot automatically enable accessibility.");
}

NSString* accessibilitySettingsBundleLocation = @"/System/Library/PreferenceBundles/AccessibilitySettings.bundle/AccessibilitySettings";

if (simulatorRoot) {
accessibilitySettingsBundleLocation = [simulatorRoot stringByAppendingString:accessibilitySettingsBundleLocation];
}

const char *accessibilitySettingsBundlePath = [accessibilitySettingsBundleLocation fileSystemRepresentation];
void* accessibilitySettingsBundle = dlopen(accessibilitySettingsBundlePath, RTLD_LAZY);

if (accessibilitySettingsBundle) {
Class axSettingsPrefControllerClass = NSClassFromString(@"AccessibilitySettingsController");
id axSettingPrefController = [[axSettingsPrefControllerClass alloc] init];

id initialAccessibilityInspectorSetting = [axSettingPrefController AXInspectorEnabled:nil];
[axSettingPrefController setAXInspectorEnabled:@(YES) specifier:nil];

NSLog(@"Successfully enabled the AXInspector.");
}
else {
NSLog(@"Unable to dlopen AccessibilitySettings. Cannout automatically enable accessibility.");
}

[autoreleasePool drain];

#if TARGET_OS_IPHONE
Expand Down

0 comments on commit 8bc11f2

Please sign in to comment.