mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-15 20:10:30 +00:00
add auto quit feature
This commit is contained in:
parent
a49c7adc7e
commit
1a946c422c
6 changed files with 35 additions and 11 deletions
|
|
@ -51,10 +51,6 @@ struct HeartbeatApp: App {
|
|||
}
|
||||
return
|
||||
}
|
||||
var log_path = URL.documentsDirectory.appendingPathComponent("idevice_log.txt").path.utf8CString
|
||||
log_path.withUnsafeMutableBufferPointer { buffer in
|
||||
idevice_init_logger(Debug, Debug, buffer.baseAddress)
|
||||
}
|
||||
startProxy() { result, error in
|
||||
if result {
|
||||
checkVPNConnection() { result, vpn_error in
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ extension UIDocumentPickerViewController {
|
|||
struct HomeView: View {
|
||||
@AppStorage("username") private var username = "User"
|
||||
@AppStorage("customBackgroundColor") private var customBackgroundColorHex: String = Color.primaryBackground.toHex() ?? "#000000"
|
||||
@AppStorage("autoQuitAfterEnablingJIT") private var doAutoQuitAfterEnablingJIT = false
|
||||
@State private var selectedBackgroundColor: Color = Color(hex: UserDefaults.standard.string(forKey: "customBackgroundColor") ?? "#000000") ?? Color.primaryBackground
|
||||
let timer = Timer.publish(every: 1, on: .main, in: .common).autoconnect()
|
||||
@AppStorage("bundleID") private var bundleID: String = ""
|
||||
|
|
@ -264,7 +265,7 @@ struct HomeView: View {
|
|||
LogManager.shared.addInfoLog("Starting JIT for \(bundleID)")
|
||||
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
JITEnableContext.shared.debugApp(withBundleID: bundleID, logger: { message in
|
||||
let success = JITEnableContext.shared.debugApp(withBundleID: bundleID, logger: { message in
|
||||
if let message = message {
|
||||
// Log messages from the JIT process
|
||||
LogManager.shared.addInfoLog(message)
|
||||
|
|
@ -274,6 +275,10 @@ struct HomeView: View {
|
|||
DispatchQueue.main.async {
|
||||
LogManager.shared.addInfoLog("JIT process completed for \(bundleID)")
|
||||
isProcessing = false
|
||||
|
||||
if success && doAutoQuitAfterEnablingJIT {
|
||||
exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ struct SettingsView: View {
|
|||
@AppStorage("username") private var username = "User"
|
||||
@AppStorage("customBackgroundColor") private var customBackgroundColorHex: String = Color.primaryBackground.toHex() ?? "#000000"
|
||||
@AppStorage("selectedAppIcon") private var selectedAppIcon: String = "AppIcon"
|
||||
@AppStorage("autoQuitAfterEnablingJIT") private var doAutoQuitAfterEnablingJIT = false
|
||||
@State private var isShowingPairingFilePicker = false
|
||||
|
||||
@State private var selectedBackgroundColor: Color = Color.primaryBackground
|
||||
|
|
@ -32,7 +33,7 @@ struct SettingsView: View {
|
|||
"Stossy11": "https://github.com/Stossy11.png",
|
||||
"Neo": "https://github.com/neoarz.png",
|
||||
"Se2crid": "https://github.com/Se2crid.png",
|
||||
"HugeBlack": "https://github.com/HugeBlack.png"
|
||||
"Huge_Black": "https://github.com/HugeBlack.png"
|
||||
]
|
||||
|
||||
var body: some View {
|
||||
|
|
@ -95,6 +96,21 @@ struct SettingsView: View {
|
|||
.padding(.horizontal, 16)
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
Text("Behavior")
|
||||
.font(.headline)
|
||||
.foregroundColor(.primary)
|
||||
.padding(.bottom, 4)
|
||||
|
||||
Toggle("Automatically Quit After Enabling JIT", isOn: $doAutoQuitAfterEnablingJIT)
|
||||
.foregroundColor(.primary)
|
||||
.padding(.vertical, 6)
|
||||
}
|
||||
.padding(.vertical, 20)
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
|
||||
// Pairing File section
|
||||
SettingsCard {
|
||||
VStack(alignment: .leading, spacing: 20) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ typedef void (^LogFunc)(NSString *message);
|
|||
@property (class, readonly)JITEnableContext* shared;
|
||||
- (IdevicePairingFile*)getPairingFileWithError:(NSError**)error;
|
||||
- (void)startHeartbeatWithCompletionHandler:(HeartbeatCompletionHandler)completionHandler logger:(LogFunc)logger;
|
||||
- (void)debugAppWithBundleID:(NSString*)bundleID logger:(LogFunc)logger;
|
||||
- (BOOL)debugAppWithBundleID:(NSString*)bundleID logger:(LogFunc)logger;
|
||||
- (NSDictionary<NSString*, NSString*>*)getAppListWithError:(NSError**)error;
|
||||
- (UIImage*)getAppIconWithBundleId:(NSString*)bundleId error:(NSError**)error;
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -29,6 +29,14 @@ JITEnableContext* sharedJITContext = nil;
|
|||
return sharedJITContext;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
NSFileManager* fm = [NSFileManager defaultManager];
|
||||
NSURL* docPathUrl = [fm URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].firstObject;
|
||||
NSURL* pairingFileURL = [docPathUrl URLByAppendingPathComponent:@"idevice_log.txt"];
|
||||
idevice_init_logger(Debug, Debug, (char*)pairingFileURL.path.UTF8String);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSError*)errorWithStr:(NSString*)str code:(int)code {
|
||||
return [NSError errorWithDomain:@"StikJIT" code:code userInfo:@{NSLocalizedDescriptionKey: str}];
|
||||
}
|
||||
|
|
@ -96,16 +104,16 @@ JITEnableContext* sharedJITContext = nil;
|
|||
completionHandler(result,[NSString stringWithCString:message encoding:NSASCIIStringEncoding]);
|
||||
}, [self createCLogger:logger]);
|
||||
}
|
||||
- (void)debugAppWithBundleID:(NSString*)bundleID logger:(LogFunc)logger {
|
||||
- (BOOL)debugAppWithBundleID:(NSString*)bundleID logger:(LogFunc)logger {
|
||||
if(!provider) {
|
||||
if(logger) {
|
||||
logger(@"Provider not initialized!");
|
||||
}
|
||||
NSLog(@"Provider not initialized!");
|
||||
return;
|
||||
return NO;
|
||||
}
|
||||
|
||||
debug_app(provider, [bundleID UTF8String], [self createCLogger:logger]);
|
||||
return debug_app(provider, [bundleID UTF8String], [self createCLogger:logger]) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
void startHeartbeat(IdevicePairingFile* pairing_file, TcpProviderHandle** provider, int* heartbeatSessionId, HeartbeatCompletionHandlerC completion, LogFuncC logger) {
|
||||
int currentSessionId = *heartbeatSessionId;
|
||||
logger("DEBUG: Initializing logger...");
|
||||
|
||||
struct sockaddr_in addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue