From cd532d03a78e60e5a279f98acf00e08992220c97 Mon Sep 17 00:00:00 2001 From: comex Date: Mon, 13 Jul 2015 16:13:05 -0400 Subject: be beta --- darwin-bootstrap/safemode-ui-hook.m | 23 +++++++++++++++++++++-- darwin-bootstrap/safemode-ui-hook.plist | 2 -- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'darwin-bootstrap') diff --git a/darwin-bootstrap/safemode-ui-hook.m b/darwin-bootstrap/safemode-ui-hook.m index a64f729..dbae60c 100644 --- a/darwin-bootstrap/safemode-ui-hook.m +++ b/darwin-bootstrap/safemode-ui-hook.m @@ -4,8 +4,10 @@ #include #import #import +#include -Class SpringBoard, SBApplicationController; +static Class SpringBoard, SBApplicationController; +static bool g_did_activate_safetydance; @interface _SBApplicationController - (id)applicationWithBundleIdentifier:(NSString *)identifier; @@ -24,9 +26,25 @@ Class SpringBoard, SBApplicationController; - (void)activate; @end +static bool detect_substrate_safe_mode() { + /* Defer to Substrate's safe mode. On my device, this doesn't seem to be + * strictly necessary, because for whatever reason SafetyDance doesn't get + * launched when MobileSafety is loaded, but let's not rely on that + * quirk... */ + for (uint32_t i = 0, count = _dyld_image_count(); + i < count; i++) { + const char *name = _dyld_get_image_name(i); + if (name && strstr(name, "MobileSafety")) + return true; + } + return false; +} + void (*old_applicationDidFinishLaunching)(id, SEL, id); static void my_applicationDidFinishLaunching(id self, SEL sel, id app) { old_applicationDidFinishLaunching(self, sel, app); + if (detect_substrate_safe_mode()) + return; id controller = [SBApplicationController sharedInstanceIfExists]; if (!controller) { NSLog(@"substitute safe mode: sharedInstanceIfExists => nil!"); @@ -42,11 +60,12 @@ static void my_applicationDidFinishLaunching(id self, SEL sel, id app) { [sbapp setFlag:1 forActivationSetting:1]; /* noAnimate */ /* [sbapp setFlag:1 forActivationSetting:5]; */ /* seo */ [self launchApplicationWithIdentifier:bundle_id suspended:NO]; + g_did_activate_safetydance = true; } BOOL (*old_handleDoubleHeightStatusBarTap)(id, SEL, int64_t); static BOOL my_handleDoubleHeightStatusBarTap(id self, SEL sel, int64_t number) { - if (number == 202) { + if (g_did_activate_safetydance && number == 202) { NSString *bundle_id = @"com.ex.SafetyDance"; id controller = [SBApplicationController sharedInstanceIfExists]; id sbapp = [controller applicationWithBundleIdentifier:bundle_id]; diff --git a/darwin-bootstrap/safemode-ui-hook.plist b/darwin-bootstrap/safemode-ui-hook.plist index 3a0e3a6..900f42a 100644 --- a/darwin-bootstrap/safemode-ui-hook.plist +++ b/darwin-bootstrap/safemode-ui-hook.plist @@ -6,10 +6,8 @@ /System/Library/CoreServices/SpringBoard.app/SpringBoard - -- cgit v1.2.3