mirror of
https://github.com/opa334/TrollStore.git
synced 2025-07-07 00:38:46 +08:00
Update TSTrollStore.m
This commit is contained in:
parent
6d261c09ce
commit
b9c6160905
@ -2,20 +2,53 @@
|
|||||||
#import "TSExploitManager.h"
|
#import "TSExploitManager.h"
|
||||||
|
|
||||||
- (void)installIPAAtPath:(NSString *)ipaPath {
|
- (void)installIPAAtPath:(NSString *)ipaPath {
|
||||||
// 选择最佳漏洞
|
TSExploitDescriptor *descriptor = [[TSExploitManager sharedManager] bestExploitDescriptorForCurrentDevice];
|
||||||
TSExploitDescriptor *descriptor = [[TSExploitManager sharedManager] bestDescriptorForCurrentDevice];
|
|
||||||
if (!descriptor) {
|
if (!descriptor) {
|
||||||
[self showErrorAlert:@"No compatible exploit"];
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"错误"
|
||||||
|
message:@"当前设备或iOS版本没有可用的漏洞"
|
||||||
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
|
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
|
||||||
|
[self presentViewController:alert animated:YES completion:nil];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (![[TSExploitManager sharedManager] applyExploitWithDescriptor:descriptor]) {
|
||||||
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"错误"
|
||||||
|
message:@"漏洞应用失败"
|
||||||
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
|
[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil]];
|
||||||
|
[self presentViewController:alert animated:YES completion:nil];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用流式安装器
|
|
||||||
TSStreamingInstaller *installer = [[TSStreamingInstaller alloc] initWithIPAAtPath:ipaPath];
|
TSStreamingInstaller *installer = [[TSStreamingInstaller alloc] initWithIPAAtPath:ipaPath];
|
||||||
|
|
||||||
|
__weak typeof(self) weakSelf = self;
|
||||||
installer.progressHandler = ^(float progress) {
|
installer.progressHandler = ^(float progress) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self updateProgress:progress];
|
[weakSelf.progressView setProgress:progress animated:YES];
|
||||||
|
weakSelf.statusLabel.text = [NSString stringWithFormat:@"安装中: %.0f%%", progress * 100];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
[installer installToDestination:[self installationPath]];
|
installer.completionHandler = ^(BOOL success, NSError *error) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
if (success) {
|
||||||
|
[weakSelf showSuccessAlert:@"安装成功"];
|
||||||
|
} else {
|
||||||
|
[weakSelf showErrorAlert:[NSString stringWithFormat:@"安装失败: %@", error.localizedDescription]];
|
||||||
|
}
|
||||||
|
[weakSelf.progressView setHidden:YES];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
NSString *destinationPath = [self trollStoreInstallPath];
|
||||||
|
[self.progressView setHidden:NO];
|
||||||
|
[self.progressView setProgress:0 animated:NO];
|
||||||
|
self.statusLabel.text = @"准备安装...";
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
[installer installToDestination:destinationPath];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user