]> git.saurik.com Git - safemode-ios.git/commitdiff
Reset the brightness while in Safe Mode on iOS 6+. v0.9.3999.6
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 4 Feb 2013 02:58:23 +0000 (18:58 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 4 Feb 2013 02:58:23 +0000 (18:58 -0800)
MobileSafety.mm

index a3e89606a951c79549ee5b4efe6eefc787d7b3ba..0d9d7ad38b7a1047d4ec4f0f5b43b056827f08fc 100644 (file)
@@ -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];
+}