diff options
-rw-r--r-- | darwin-bootstrap/safemode-ui-hook.m | 1 | ||||
-rw-r--r-- | darwin-bootstrap/safety-dance/AutoGrid.m | 2 | ||||
-rw-r--r-- | darwin-bootstrap/safety-dance/Info.plist | 15 | ||||
-rw-r--r-- | darwin-bootstrap/safety-dance/main.m | 32 | ||||
-rwxr-xr-x | script/gen-deb.sh | 2 |
5 files changed, 49 insertions, 3 deletions
diff --git a/darwin-bootstrap/safemode-ui-hook.m b/darwin-bootstrap/safemode-ui-hook.m index 8fe228f..38b9fc8 100644 --- a/darwin-bootstrap/safemode-ui-hook.m +++ b/darwin-bootstrap/safemode-ui-hook.m @@ -31,6 +31,7 @@ static id my_setupApplication(id self, SEL sel) { id app = [self applicationWithBundleIdentifier:@"com.ex.SafetyDance"]; if (app) { /* definitely shouldn't be nil, given below check, but... */ + NSLog(@"=>%@", app); return app; } } diff --git a/darwin-bootstrap/safety-dance/AutoGrid.m b/darwin-bootstrap/safety-dance/AutoGrid.m index 2a8d3ed..74d72d2 100644 --- a/darwin-bootstrap/safety-dance/AutoGrid.m +++ b/darwin-bootstrap/safety-dance/AutoGrid.m @@ -66,7 +66,7 @@ break; } contentSize = CGSizeMake(tentativeWidth, tentativeHeight); - NSLog(@"%f", contentSize.height); + /* NSLog(@"%f", contentSize.height); */ if (contentSize.width == 0) break; diff --git a/darwin-bootstrap/safety-dance/Info.plist b/darwin-bootstrap/safety-dance/Info.plist index 59579b3..2647c36 100644 --- a/darwin-bootstrap/safety-dance/Info.plist +++ b/darwin-bootstrap/safety-dance/Info.plist @@ -86,5 +86,20 @@ <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> + <key>SBAppTags</key> + <array> + <string>hidden</string> + </array> + <key>UIBackgroundModes</key> + <array> + <string>continuous</string> + <string>unboundedTaskCompletion</string> + </array> + <key>_UILaunchAlwaysFullScreen</key> + <true/> + <key>SBIsLaunchableDuringSetup</key> + <true/> + <key>BKRequiresExtendedLaunchInterval</key> + <true/> </dict> </plist> diff --git a/darwin-bootstrap/safety-dance/main.m b/darwin-bootstrap/safety-dance/main.m index 21d4803..39ee491 100644 --- a/darwin-bootstrap/safety-dance/main.m +++ b/darwin-bootstrap/safety-dance/main.m @@ -1,6 +1,16 @@ #import <UIKit/UIKit.h> +#include <notify.h> #import "AutoGrid.h" +@interface UIApplication (Private) +- (void)terminateWithSuccess; +- (void)suspend; + +- (void)setGlowAnimationEnabled:(BOOL)enabled forStyle:(int)style; +- (void)addStatusBarStyleOverrides:(int)overrides; +- (void)setDoubleHeightStatusText:(NSString *)text forStyle:(int)style; +@end + @interface ViewController : UIViewController { AutoGrid *autoGrid; } @@ -24,6 +34,16 @@ [autoGrid setViews:views]; } +- (void)exitReturnToNormal { + notify_post("com.ex.substitute.safemode-restart-springboard-plz"); +} + +- (void)exitContinueSafe { + /* mimic Setup.app, but we don't want to actually quit */ + UIApplication *app = [UIApplication sharedApplication]; + [app suspend]; +} + #define EXPLANATION \ @"SpringBoard seems to have crashed. This might have been caused by Substitute jailbreak extension, or it could be unrelated. Just to be safe, extensions in SpringBoard have been temporarily disabled.\n\nThe following extensions were running:" @@ -75,6 +95,8 @@ static void compression(UIView *view, UILayoutPriority pri) { returnButton.titleLabel.font = [UIFont systemFontOfSize:17]; [returnButton setTitle:@"Return to Normal" forState:UIControlStateNormal]; [self.view addSubview:returnButton]; + [returnButton addTarget:self action:@selector(exitReturnToNormal) + forControlEvents:UIControlEventTouchUpInside]; UIButton *continueButton = [UIButton buttonWithType:UIButtonTypeSystem]; continueButton.translatesAutoresizingMaskIntoConstraints = NO; @@ -85,6 +107,8 @@ static void compression(UIView *view, UILayoutPriority pri) { continueButton.titleLabel.font = [UIFont systemFontOfSize:17]; [continueButton setTitle:@"Continue in Safe Mode" forState:UIControlStateNormal]; [self.view addSubview:continueButton]; + [continueButton addTarget:self action:@selector(exitContinueSafe) + forControlEvents:UIControlEventTouchUpInside]; autoGrid = [[AutoGrid alloc] init]; autoGrid.translatesAutoresizingMaskIntoConstraints = NO; @@ -140,7 +164,6 @@ static void compression(UIView *view, UILayoutPriority pri) { @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - NSLog(@"dflwo"); self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; ViewController *viewController = [[ViewController alloc] init]; self.window.rootViewController = viewController; @@ -148,6 +171,13 @@ static void compression(UIView *view, UILayoutPriority pri) { return YES; } +- (void)applicationDidEnterBackground:(UIApplication *)application { + /* mimic Voice Memos... */ + [application setGlowAnimationEnabled:YES forStyle:202]; + [application setDoubleHeightStatusText:@"Safe Mode" forStyle:202]; + [application addStatusBarStyleOverrides:4]; +} + @end int main(int argc, char *argv[]) { diff --git a/script/gen-deb.sh b/script/gen-deb.sh index 5a0d599..999765c 100755 --- a/script/gen-deb.sh +++ b/script/gen-deb.sh @@ -14,7 +14,7 @@ mkdir -p $debroot/usr/include/substitute cp lib/substitute.h $debroot/usr/include/substitute/ cp substrate/substrate.h $debroot/usr/include/substitute/ mkdir -p $debroot/Library/Substitute/DynamicLibraries -#cp darwin-bootstrap/safemode-ui-hook.plist out/safemode-ui-hook.dylib $debroot/Library/Substitute/DynamicLibraries/ +cp darwin-bootstrap/safemode-ui-hook.plist out/safemode-ui-hook.dylib $debroot/Library/Substitute/DynamicLibraries/ mkdir -p $debroot/Library/Substitute/Helpers cp out/{posixspawn-hook.dylib,bundle-loader.dylib,unrestrict,inject-into-launchd,substituted} $debroot/Library/Substitute/Helpers/ mkdir -p $debroot/etc/rc.d |