diff --git a/app/AboutViewController.h b/app/AboutViewController.h index 25b3189f..3e4b34a9 100644 --- a/app/AboutViewController.h +++ b/app/AboutViewController.h @@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @interface AboutViewController : UITableViewController @property BOOL includeDebugPanel; +@property BOOL recoveryMode; @end diff --git a/app/AboutViewController.m b/app/AboutViewController.m index 273b3557..4f42dfd0 100644 --- a/app/AboutViewController.m +++ b/app/AboutViewController.m @@ -36,6 +36,20 @@ - (void)viewDidLoad { [super viewDidLoad]; [self _updatePreferenceUI]; + if (self.recoveryMode) { + self.includeDebugPanel = YES; + self.navigationItem.title = @"Recovery Mode"; + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Exit" + style:UIBarButtonItemStyleDone + target:self + action:@selector(exitRecovery:)]; + self.navigationItem.leftBarButtonItem = nil; + } +} + +- (void)exitRecovery:(id)sender { + [NSUserDefaults.standardUserDefaults setBool:NO forKey:@"recovery"]; + exit(0); } - (void)dealloc { diff --git a/app/AppDelegate.m b/app/AppDelegate.m index 0bd3b0c6..1ccec5bd 100644 --- a/app/AppDelegate.m +++ b/app/AppDelegate.m @@ -9,6 +9,7 @@ #include #include #import +#import "AboutViewController.h" #import "AppDelegate.h" #import "AppGroup.h" #import "iOSFS.h" @@ -208,7 +209,9 @@ static int bootError; [defaults removeObjectForKey:kPreferenceLaunchCommandKey]; [defaults setBool:NO forKey:@"hail mary"]; } - + if ([NSUserDefaults.standardUserDefaults boolForKey:@"recovery"]) + return YES; + bootError = [self boot]; return YES; } @@ -243,6 +246,13 @@ void NetworkReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach if (self.window != nil) { // For iOS <13, where the app delegate owns the window instead of the scene + if ([NSUserDefaults.standardUserDefaults boolForKey:@"recovery"]) { + UINavigationController *vc = [[UIStoryboard storyboardWithName:@"About" bundle:nil] instantiateInitialViewController]; + AboutViewController *avc = vc.topViewController; + avc.recoveryMode = YES; + self.window.rootViewController = vc; + return YES; + } TerminalViewController *vc = (TerminalViewController *) self.window.rootViewController; currentTerminalViewController = vc; [vc startNewSession]; diff --git a/app/Base.lproj/Main.storyboard b/app/Base.lproj/Terminal.storyboard similarity index 100% rename from app/Base.lproj/Main.storyboard rename to app/Base.lproj/Terminal.storyboard diff --git a/app/Info.plist b/app/Info.plist index 2e3f8b73..07a260b8 100644 --- a/app/Info.plist +++ b/app/Info.plist @@ -42,9 +42,9 @@ UISceneDelegateClassName SceneDelegate UISceneConfigurationName - Terminal + Main App UISceneStoryboardFile - Main + Terminal @@ -60,7 +60,7 @@ UILaunchStoryboardName LaunchScreen UIMainStoryboardFile - Main + Terminal UIRequiredDeviceCapabilities armv7 diff --git a/app/SceneDelegate.m b/app/SceneDelegate.m index bb9a526a..66d4d0b6 100644 --- a/app/SceneDelegate.m +++ b/app/SceneDelegate.m @@ -6,6 +6,7 @@ // #import "SceneDelegate.h" +#import "AboutViewController.h" TerminalViewController *currentTerminalViewController = NULL; @@ -20,6 +21,14 @@ static NSString *const TerminalUUID = @"TerminalUUID"; @implementation SceneDelegate - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + if ([NSUserDefaults.standardUserDefaults boolForKey:@"recovery"]) { + UINavigationController *vc = [[UIStoryboard storyboardWithName:@"About" bundle:nil] instantiateInitialViewController]; + AboutViewController *avc = vc.topViewController; + avc.recoveryMode = YES; + self.window.rootViewController = vc; + return; + } + TerminalViewController *vc = (TerminalViewController *) self.window.rootViewController; vc.sceneSession = session; if (session.stateRestorationActivity == nil) { diff --git a/app/Settings.bundle/Root.plist b/app/Settings.bundle/Root.plist index 6aa5a43e..5b090b4c 100644 --- a/app/Settings.bundle/Root.plist +++ b/app/Settings.bundle/Root.plist @@ -8,15 +8,15 @@ Type PSGroupSpecifier FooterText - Danger zone: Only touch this if you know what you're doing but you messed up anyway + Opens the app straight to the settings menu. Useful if you changed anything there and need to change it back but the app won't start. Type PSToggleSwitchSpecifier Title - Reset launch and boot commands + Recovery Mode Key - hail mary + recovery DefaultValue diff --git a/iSH.xcodeproj/project.pbxproj b/iSH.xcodeproj/project.pbxproj index 54722492..fdd642ce 100644 --- a/iSH.xcodeproj/project.pbxproj +++ b/iSH.xcodeproj/project.pbxproj @@ -33,7 +33,7 @@ BB78AB2B1FAD22440013E782 /* TerminalView.m in Sources */ = {isa = PBXBuildFile; fileRef = BB78AB2A1FAD22440013E782 /* TerminalView.m */; }; BB792B551F96D90D00FFB7A4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = BB792B541F96D90D00FFB7A4 /* AppDelegate.m */; }; BB792B581F96D90D00FFB7A4 /* TerminalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BB792B571F96D90D00FFB7A4 /* TerminalViewController.m */; }; - BB792B5B1F96D90D00FFB7A4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BB792B591F96D90D00FFB7A4 /* Main.storyboard */; }; + BB792B5B1F96D90D00FFB7A4 /* Terminal.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BB792B591F96D90D00FFB7A4 /* Terminal.storyboard */; }; BB792B5D1F96D90D00FFB7A4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BB792B5C1F96D90D00FFB7A4 /* Assets.xcassets */; }; BB792B601F96D90D00FFB7A4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BB792B5E1F96D90D00FFB7A4 /* LaunchScreen.storyboard */; }; BB792B631F96D90D00FFB7A4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BB792B621F96D90D00FFB7A4 /* main.m */; }; @@ -204,7 +204,7 @@ BB792B541F96D90D00FFB7A4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; BB792B561F96D90D00FFB7A4 /* TerminalViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TerminalViewController.h; sourceTree = ""; }; BB792B571F96D90D00FFB7A4 /* TerminalViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TerminalViewController.m; sourceTree = ""; }; - BB792B5A1F96D90D00FFB7A4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + BB792B5A1F96D90D00FFB7A4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Terminal.storyboard; sourceTree = ""; }; BB792B5C1F96D90D00FFB7A4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; BB792B5F1F96D90D00FFB7A4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; BB792B611F96D90D00FFB7A4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -501,7 +501,7 @@ BBCC9D952365430800424C83 /* SceneDelegate.m */, BB792B561F96D90D00FFB7A4 /* TerminalViewController.h */, BB792B571F96D90D00FFB7A4 /* TerminalViewController.m */, - BB792B591F96D90D00FFB7A4 /* Main.storyboard */, + BB792B591F96D90D00FFB7A4 /* Terminal.storyboard */, BBFB557D21587B2B00DFE6DE /* Bar */, BB78AB291FAD22440013E782 /* TerminalView.h */, BB78AB2A1FAD22440013E782 /* TerminalView.m */, @@ -976,7 +976,7 @@ BB792B601F96D90D00FFB7A4 /* LaunchScreen.storyboard in Resources */, BBBF7B5C2415CDBB00EC4C14 /* Settings.bundle in Resources */, BBBCE7E321D2F02200CA00B3 /* About.storyboard in Resources */, - BB792B5B1F96D90D00FFB7A4 /* Main.storyboard in Resources */, + BB792B5B1F96D90D00FFB7A4 /* Terminal.storyboard in Resources */, BB2B4DAF231D998300CB578B /* term.html in Resources */, BB10E5D0248DC21D009C7A74 /* Roots.storyboard in Resources */, BBCE66E2249A807700F45269 /* alpine.tar.gz in Resources */, @@ -1122,12 +1122,12 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ - BB792B591F96D90D00FFB7A4 /* Main.storyboard */ = { + BB792B591F96D90D00FFB7A4 /* Terminal.storyboard */ = { isa = PBXVariantGroup; children = ( BB792B5A1F96D90D00FFB7A4 /* Base */, ); - name = Main.storyboard; + name = Terminal.storyboard; sourceTree = ""; }; BB792B5E1F96D90D00FFB7A4 /* LaunchScreen.storyboard */ = {