diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2013-02-03 18:58:23 -0800 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2013-02-03 18:58:23 -0800 |
commit | 43b2fcfaa032139e95e3eddf6ee8f0e928ff2c4a (patch) | |
tree | 1394c33c649531f80a080a47f4610cf7c056d338 | |
parent | 8d6b6bf4a17335e653be11ec2da25014441e2adc (diff) |
Reset the brightness while in Safe Mode on iOS 6+.
-rw-r--r-- | MobileSafety.mm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/MobileSafety.mm b/MobileSafety.mm index a3e8960..0d9d7ad 100644 --- a/MobileSafety.mm +++ b/MobileSafety.mm @@ -300,3 +300,19 @@ MSInstanceMessageHook1(void, BKSApplicationLaunchSettings, setEnvironment, NSDic [modified setObject:@"1" forKey:@"_MSSafeMode"]; return MSOldCall(modified); } + +MSInitialize { + NSAutoreleasePool *pool([[NSAutoreleasePool alloc] init]); + + // on iOS 6, backboardd is in charge of brightness, and freaks out when SpringBoard restarts :( + // the result is that the device is super dark until we attempt to update the brightness here. + + if (kCFCoreFoundationVersionNumber >= 700) { + if (void (*GSEventSetBacklightLevel)(float) = reinterpret_cast<void (*)(float)>(dlsym(RTLD_DEFAULT, "GSEventSetBacklightLevel"))) + if (NSMutableDictionary *defaults = [NSMutableDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.apple.springboard.plist", NSHomeDirectory()]]) + if (NSNumber *level = [defaults objectForKey:@"SBBacklightLevel2"]) + GSEventSetBacklightLevel([level floatValue]); + } + + [pool release]; +} |