Skip to content

Commit

Permalink
Enable Application Accessibility before starting FrankServer.
Browse files Browse the repository at this point in the history
Used code from http://sgleadow.github.com/blog/2011/11/16/enabling-accessibility-programatically-on-ios-devices/ to set ApplicationAccessibilityEnabled to true in /Library/Preferences/com.apple.Accessibility.plist on the simulator and device.
  • Loading branch information
hborders committed Dec 12, 2011
1 parent b90c99a commit 61d4bc8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/FrankLoader.m
Expand Up @@ -10,6 +10,8 @@

#import "FrankServer.h"

#import <dlfcn.h>

@implementation FrankLoader

+ (void)applicationDidBecomeActive:(NSNotification *)notification{
Expand All @@ -20,6 +22,30 @@ + (void)applicationDidBecomeActive:(NSNotification *)notification{
+ (void)load{
NSLog(@"Injecting Frank loader");

NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
NSString *appSupportLocation = @"/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport";

NSDictionary *environment = [[NSProcessInfo processInfo] environment];
NSString *simulatorRoot = [environment objectForKey:@"IPHONE_SIMULATOR_ROOT"];
if (simulatorRoot) {
appSupportLocation = [simulatorRoot stringByAppendingString:appSupportLocation];
}

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

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

if (copySharedResourcesPreferencesDomainForDomain) {
CFStringRef accessibilityDomain = copySharedResourcesPreferencesDomainForDomain(CFSTR("com.apple.Accessibility"));

if (accessibilityDomain) {
CFPreferencesSetValue(CFSTR("ApplicationAccessibilityEnabled"), kCFBooleanTrue, accessibilityDomain, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
CFRelease(accessibilityDomain);
}
}

[autoreleasePool drain];

[[NSNotificationCenter defaultCenter] addObserver:[self class]
selector:@selector(applicationDidBecomeActive:)
name:@"UIApplicationDidBecomeActiveNotification"
Expand Down

0 comments on commit 61d4bc8

Please sign in to comment.