Microsoft Word - iOSAppReverseEngineering.docx

(Romina) #1

After compiling, installing and respring, I pressed home button with my eyes closed, and


then checked “Settings” → “General” → “Accessibility” → “Incoming Calls” with excitement. Aha,


“Speaker” was chosen. I’ve made it!


5.3.5 Write tweak


Since the core function has been verified, writing code was a piece of cake. Following


SBSettings toggle spec (http://thebigboss.org/guides-iphone-ipod-ipad/sbsettings-toggle-spec),


the contents of Tweak.xm are as follows.


#import <notify.h>
#define ACCESSBILITY @"/var/mobile/Library/Preferences/com.apple.Accessibility.plist"

// Required
extern "C" BOOL isCapable() {
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_5_0 &&
[[[UIDevice currentDevice] model] isEqualToString:@"iPhone"])
return YES;
return NO;
}

// Required
extern "C" BOOL isEnabled() {
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithCont
entsOfFile:ACCESSBILITY];
BOOL result = [[dictionary objectForKey:@"DefaultRouteForCallPreference"]
intValue] == 0? NO : YES;
[dictionary release];
return result;
}

// Optional
// Faster isEnabled. Remove this if it’s not necessary. Keep it if isEnabled() is
expensive and you can make it faster here.
extern "C" BOOL getStateFast() {
return isEnabled();
}

// Required
extern "C" void setState(BOOL enabled) {
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithCont
entsOfFile:ACCESSBILITY];
[dictionary setObject:[NSNumber numberWithInt:(enabled? 2 : 0)] forKey:@"D
efaultRouteForCallPreference"];
[dictionary writeToFile:ACCESSBILITY atomically:YES]; [dictionary release];
notify_post("com.apple.accessibility.defaultrouteforcall");
}

// Required
// How long the toggle takes to toggle, in seconds.
extern "C" float getDelayTime() {
return 0.6f;
}
Free download pdf