Merge pull request #82 from hugeBlack/main

Warn user of no get-task-allow, fix ui hang after showAlert
This commit is contained in:
Stephen 2025-04-06 11:05:52 -04:00 • committed by GitHub
commit e7b17da68c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 50 additions and 2 deletions

View file

@ -507,6 +507,7 @@ public func showAlert(title: String, message: String, showOk: Bool, showTryAgain
message: message,
onDismiss: {
// Called when tapped outside
rootViewController?.presentedViewController?.dismiss(animated: true)
completion(false)
},
showButton: true,
@ -529,12 +530,14 @@ public func showAlert(title: String, message: String, showOk: Bool, showTryAgain
message: message,
onDismiss: {
// Called when tapped outside
rootViewController?.presentedViewController?.dismiss(animated: true)
completion(true)
},
showButton: true,
primaryButtonText: "OK",
onPrimaryButtonTap: {
// OK was tapped
rootViewController?.presentedViewController?.dismiss(animated: true)
completion(true)
}
)
@ -550,6 +553,7 @@ public func showAlert(title: String, message: String, showOk: Bool, showTryAgain
title: title,
message: message,
onDismiss: {
rootViewController?.presentedViewController?.dismiss(animated: true)
completion(false)
},
showButton: false

View file

@ -0,0 +1,35 @@
//
// Security.swift
// StikJIT
// from MeloNX
// Created by s s on 2025/4/6.
//
import Security
typealias SecTaskRef = OpaquePointer
@_silgen_name("SecTaskCopyValueForEntitlement")
func SecTaskCopyValueForEntitlement(
_ task: SecTaskRef,
_ entitlement: NSString,
_ error: NSErrorPointer
) -> CFTypeRef?
@_silgen_name("SecTaskCreateFromSelf")
func SecTaskCreateFromSelf(
_ allocator: CFAllocator?
) -> SecTaskRef?
func checkAppEntitlement(_ ent: String) -> Bool {
guard let task = SecTaskCreateFromSelf(nil) else {
print("Failed to create SecTask")
return false
}
guard let entitlements = SecTaskCopyValueForEntitlement(task, ent as NSString, nil) else {
print("Failed to get entitlements")
return false
}
return entitlements.boolValue != nil && entitlements.boolValue
}

View file

@ -68,7 +68,7 @@ struct CustomErrorView: View {
.padding(.horizontal, 12)
// Message
Text(message)
Text(LocalizedStringKey(message))
.font(.system(size: 15, design: .rounded))
.foregroundColor(colorScheme == .dark ? .white.opacity(0.9) : .black.opacity(0.9))
.multilineTextAlignment(.center)

View file

@ -317,7 +317,12 @@ class InstalledAppsViewModel: ObservableObject {
print(error)
self.apps = [:]
}
if self.apps.count == 0 && !checkAppEntitlement("get-task-allow") && !UserDefaults.standard.bool(forKey: "skipGetTaskAllowCheck") {
showAlert(title: "Warning", message: "StikJIT is not signed with **get-task-allow**. It's OK, but if you also sign the app you want to enable JIT for with the same method, it\n\n ***WILL NOT WORK***.\n\nPlease sign the app you want to enable JIT for using a development certificate. You can disable this alert in settings.", showOk: true) { _ in
}
}
}
}

View file

@ -11,6 +11,7 @@ struct SettingsView: View {
@AppStorage("customBackgroundColor") private var customBackgroundColorHex: String = ""
@AppStorage("selectedAppIcon") private var selectedAppIcon: String = "AppIcon"
@AppStorage("autoQuitAfterEnablingJIT") private var doAutoQuitAfterEnablingJIT = false
@AppStorage("skipGetTaskAllowCheck") private var doSkipGetTaskAllowCheck = false
@State private var isShowingPairingFilePicker = false
@Environment(\.colorScheme) private var colorScheme
@ -183,6 +184,9 @@ struct SettingsView: View {
Toggle("Automatically Quit After Enabling JIT", isOn: $doAutoQuitAfterEnablingJIT)
.foregroundColor(.primary)
.padding(.vertical, 6)
Toggle("Skip get-task-allow Check", isOn: $doSkipGetTaskAllowCheck)
.foregroundColor(.primary)
.padding(.vertical, 6)
}
.padding(.vertical, 20)
.padding(.horizontal, 16)