mirror of https://github.com/opa334/TrollStore.git
Add reboot code
This commit is contained in:
parent
f1f42778d8
commit
8dc50d7555
|
@ -75,7 +75,7 @@ extern NSUserDefaults* trollStoreUserDefaults();
|
|||
errorDescription = @"The app you tried to install has the same identifier as a system app already installed on the device. The installation has been prevented to protect you from possible bootloops or other issues.";
|
||||
break;
|
||||
case 180:
|
||||
errorDescription = @"The app was installed successfully, but requires developer mode to be enabled to run.";
|
||||
errorDescription = @"The app was installed successfully, but requires developer mode to be enabled to run. After rebooting, select \"Turn On\" to enable developer mode.";
|
||||
break;
|
||||
case 181:
|
||||
errorDescription = @"Failed to enable developer mode.";
|
||||
|
|
|
@ -63,6 +63,7 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
|||
UIAlertAction* rebootAction = [UIAlertAction actionWithTitle:@"Reboot Now" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
if(completionBlock) completionBlock(YES, nil);
|
||||
spawnRoot(rootHelperPath(), @[@"reboot"], nil, nil);
|
||||
}];
|
||||
[rebootNotification addAction:rebootAction];
|
||||
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
PSSpecifier* _installPersistenceHelperSpecifier;
|
||||
NSString* _newerVersion;
|
||||
NSString* _newerLdidVersion;
|
||||
BOOL _devModeEnabled;
|
||||
}
|
||||
@end
|
|
@ -55,6 +55,15 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
|||
}
|
||||
});
|
||||
//}
|
||||
|
||||
if (@available(iOS 16, *))
|
||||
{
|
||||
_devModeEnabled = spawnRoot(rootHelperPath(), @[@"check-dev-mode"], nil, nil) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_devModeEnabled = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableArray*)specifiers
|
||||
|
@ -82,6 +91,26 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
|||
[_specifiers addObject:updateTrollStoreSpecifier];
|
||||
}
|
||||
|
||||
if(!_devModeEnabled)
|
||||
{
|
||||
PSSpecifier* enableDevModeGroupSpecifier = [PSSpecifier emptyGroupSpecifier];
|
||||
enableDevModeGroupSpecifier.name = @"Developer Mode";
|
||||
[enableDevModeGroupSpecifier setProperty:@"Some apps require developer mode enabled to launch. This requires a reboot to take effect." forKey:@"footerText"];
|
||||
[_specifiers addObject:enableDevModeGroupSpecifier];
|
||||
|
||||
PSSpecifier* enableDevModeSpecifier = [PSSpecifier preferenceSpecifierNamed:@"Enable Developer Mode"
|
||||
target:self
|
||||
set:nil
|
||||
get:nil
|
||||
detail:nil
|
||||
cell:PSButtonCell
|
||||
edit:nil];
|
||||
enableDevModeSpecifier.identifier = @"enableDevMode";
|
||||
[enableDevModeSpecifier setProperty:@YES forKey:@"enabled"];
|
||||
enableDevModeSpecifier.buttonAction = @selector(enableDevModePressed);
|
||||
[_specifiers addObject:enableDevModeSpecifier];
|
||||
}
|
||||
|
||||
PSSpecifier* utilitiesGroupSpecifier = [PSSpecifier emptyGroupSpecifier];
|
||||
utilitiesGroupSpecifier.name = @"Utilities";
|
||||
[utilitiesGroupSpecifier setProperty:@"If an app does not immediately appear after installation, respring here and it should appear afterwards." forKey:@"footerText"];
|
||||
|
@ -369,6 +398,37 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
|||
[TSInstallationController installLdid];
|
||||
}
|
||||
|
||||
- (void)enableDevModePressed
|
||||
{
|
||||
int ret = spawnRoot(rootHelperPath(), @[@"arm-dev-mode"], nil, nil);
|
||||
|
||||
if (ret == 0) {
|
||||
UIAlertController* rebootNotification = [UIAlertController alertControllerWithTitle:@"Reboot Required"
|
||||
message:@"After rebooting, select \"Turn On\" to enable developer mode."
|
||||
preferredStyle:UIAlertControllerStyleAlert
|
||||
];
|
||||
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
[self reloadSpecifiers];
|
||||
}];
|
||||
[rebootNotification addAction:closeAction];
|
||||
|
||||
UIAlertAction* rebootAction = [UIAlertAction actionWithTitle:@"Reboot Now" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
spawnRoot(rootHelperPath(), @[@"reboot"], nil, nil);
|
||||
}];
|
||||
[rebootNotification addAction:rebootAction];
|
||||
|
||||
[TSPresentationDelegate presentViewController:rebootNotification animated:YES completion:nil];
|
||||
} else {
|
||||
UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Error %d", ret] message:@"Failed to enable developer mode." preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:nil];
|
||||
[errorAlert addAction:closeAction];
|
||||
|
||||
[TSPresentationDelegate presentViewController:errorAlert animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)installPersistenceHelperPressed
|
||||
{
|
||||
NSMutableArray* appCandidates = [NSMutableArray new];
|
||||
|
|
Loading…
Reference in New Issue