mirror of
https://github.com/opa334/TrollStore.git
synced 2026-07-02 11:17:51 +08:00
Add code to check and arm developer mode
This commit is contained in:
@@ -74,6 +74,12 @@ extern NSUserDefaults* trollStoreUserDefaults();
|
||||
case 179:
|
||||
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.";
|
||||
break;
|
||||
case 181:
|
||||
errorDescription = @"Failed to enable developer mode.";
|
||||
break;
|
||||
}
|
||||
|
||||
NSError* error = [NSError errorWithDomain:TrollStoreErrorDomain code:code userInfo:@{NSLocalizedDescriptionKey : errorDescription}];
|
||||
|
||||
@@ -32,42 +32,57 @@ extern NSUserDefaults* trollStoreUserDefaults(void);
|
||||
{
|
||||
[TSPresentationDelegate stopActivityWithCompletion:^
|
||||
{
|
||||
if(ret != 0)
|
||||
{
|
||||
if (ret == 0) {
|
||||
// success
|
||||
if(completionBlock) completionBlock(YES, nil);
|
||||
} else if (ret == 171) {
|
||||
// recoverable error
|
||||
UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Install Error %d", ret] message:[error localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
if(ret == 171)
|
||||
{
|
||||
if(completionBlock) completionBlock(NO, error);
|
||||
}
|
||||
if(completionBlock) completionBlock(NO, error);
|
||||
}];
|
||||
[errorAlert addAction:closeAction];
|
||||
|
||||
if(ret == 171)
|
||||
UIAlertAction* forceInstallAction = [UIAlertAction actionWithTitle:@"Force Installation" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
UIAlertAction* forceInstallAction = [UIAlertAction actionWithTitle:@"Force Installation" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
[self handleAppInstallFromFile:pathToIPA forceInstall:YES completion:completionBlock];
|
||||
}];
|
||||
[errorAlert addAction:forceInstallAction];
|
||||
}
|
||||
else
|
||||
{
|
||||
UIAlertAction* copyLogAction = [UIAlertAction actionWithTitle:@"Copy Debug Log" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
|
||||
pasteboard.string = log;
|
||||
}];
|
||||
[errorAlert addAction:copyLogAction];
|
||||
}
|
||||
[self handleAppInstallFromFile:pathToIPA forceInstall:YES completion:completionBlock];
|
||||
}];
|
||||
[errorAlert addAction:forceInstallAction];
|
||||
|
||||
[TSPresentationDelegate presentViewController:errorAlert animated:YES completion:nil];
|
||||
}
|
||||
} else if (ret == 180) {
|
||||
// non-fatal informative message
|
||||
UIAlertController* rebootNotification = [UIAlertController alertControllerWithTitle:@"Reboot Required" message:[error localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
if(completionBlock) completionBlock(YES, nil);
|
||||
}];
|
||||
[rebootNotification addAction:closeAction];
|
||||
|
||||
if(ret != 171)
|
||||
{
|
||||
if(completionBlock) completionBlock((BOOL)error, error);
|
||||
UIAlertAction* rebootAction = [UIAlertAction actionWithTitle:@"Reboot Now" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
if(completionBlock) completionBlock(YES, nil);
|
||||
}];
|
||||
[rebootNotification addAction:rebootAction];
|
||||
|
||||
[TSPresentationDelegate presentViewController:rebootNotification animated:YES completion:nil];
|
||||
} else {
|
||||
// unrecoverable error
|
||||
UIAlertController* errorAlert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"Install Error %d", ret] message:[error localizedDescription] preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction* closeAction = [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleDefault handler:nil];
|
||||
[errorAlert addAction:closeAction];
|
||||
|
||||
UIAlertAction* copyLogAction = [UIAlertAction actionWithTitle:@"Copy Debug Log" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action)
|
||||
{
|
||||
UIPasteboard* pasteboard = [UIPasteboard generalPasteboard];
|
||||
pasteboard.string = log;
|
||||
}];
|
||||
[errorAlert addAction:copyLogAction];
|
||||
|
||||
[TSPresentationDelegate presentViewController:errorAlert animated:YES completion:nil];
|
||||
|
||||
if(completionBlock) completionBlock(NO, error);
|
||||
}
|
||||
}];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user