diff --git a/Natives/CMakeLists.txt b/Natives/CMakeLists.txt index ae6fcd6e..6a1fe9d2 100644 --- a/Natives/CMakeLists.txt +++ b/Natives/CMakeLists.txt @@ -18,6 +18,7 @@ include_directories( "external/TOInsetGroupedTableView/TOInsetGroupedTableView" "external/fishhook" "external/mesa" + "external/AltKit" "external/Apple" ) @@ -146,7 +147,9 @@ endif() target_link_libraries(PojavLauncher "-F'${CMAKE_CURRENT_LIST_DIR}/build'" "-F'${CMAKE_CURRENT_LIST_DIR}/resources/Frameworks'" + "-framework AltKit" "-framework AuthenticationServices" + "-framework CAltKit" "-framework CoreGraphics" "-framework CoreServices" "-framework GameController" diff --git a/Natives/Info.plist b/Natives/Info.plist index 669b532b..bca09c08 100644 --- a/Natives/Info.plist +++ b/Natives/Info.plist @@ -2,6 +2,8 @@ + ALTDeviceID + CADisableMinimumFrameDurationOnPhone CFBundleDevelopmentRegion @@ -80,7 +82,13 @@ LSSupportsOpeningDocumentsInPlace MinimumOSVersion - 12.0 + 12.2 + NSBonjourServices + + _altserver._tcp + + NSLocalNetworkUsageDescription + PojavLauncher uses the local network to find and communicate with AltServer. UIApplicationSceneManifest UIApplicationSupportsMultipleScenes diff --git a/Natives/LoginViewController.m b/Natives/LoginViewController.m index 5112cb88..b71493f4 100644 --- a/Natives/LoginViewController.m +++ b/Natives/LoginViewController.m @@ -4,6 +4,7 @@ #import "AFNetworking.h" #import #import "authenticator/BaseAuthenticator.h" +#import "ALTServerConnection.h" #import "AppDelegate.h" #import "AccountListViewController.h" @@ -353,6 +354,33 @@ extern NSMutableDictionary *prefDict; [self presentViewController:vc animated:YES completion:nil]; } +- (void)enableJITWithAltJIT +{ + self.title = NSLocalizedString(@"login.jit.start.AltKit", nil); + [ALTServerManager.sharedManager startDiscovering]; + [ALTServerManager.sharedManager autoconnectWithCompletionHandler:^(ALTServerConnection *connection, NSError *error) { + if (error) { + NSLog(@"[AltKit] Could not auto-connect to server. %@", error); + self.title = NSLocalizedString(@"login.jit.fail.AltKit", nil); + return; + } + [connection enableUnsignedCodeExecutionWithCompletionHandler:^(BOOL success, NSError *error) { + if (success) { + NSLog(@"[AltKit] Successfully enabled JIT compilation!"); + [ALTServerManager.sharedManager stopDiscovering]; + self.title = NSLocalizedString(@"login.jit.enabled", nil); + self.navigationItem.leftBarButtonItem = nil; + } else { + NSLog(@"[AltKit] Could not enable JIT compilation. %@", error); + self.title = NSLocalizedString(@"login.jit.fail.AltKit", nil); + self.navigationItem.leftBarButtonItem = nil; + showDialog(self, NSLocalizedString(@"Error", nil), error.description); + } + [connection disconnect]; + }]; + }]; +} + - (void)enableJITWithJitStreamer { [self displayProgress:NSLocalizedString(@"login.jit.checking", nil)]; @@ -384,18 +412,17 @@ extern NSMutableDictionary *prefDict; } if ([responseDict[@"success"] boolValue]) { self.title = NSLocalizedString(@"login.jit.enabled", nil); + self.navigationItem.leftBarButtonItem = nil; } else { self.title = [NSString stringWithFormat:NSLocalizedString(@"login.jit.fail.JitStreamer", nil), responseDict[@"message"]]; + self.navigationItem.leftBarButtonItem = nil; showDialog(self, NSLocalizedString(@"Error", nil), responseDict[@"message"]); - // TODO: [self enableJITWithAltJIT]; + [self enableJITWithAltJIT]; } }; [manager POST:[NSString stringWithFormat:@"http://%@/attach/%d/", address, getpid()] parameters:nil headers:nil progress:nil success:handleResponse failure:handleResponse]; } failure:^(NSURLSessionDataTask *task, NSError *error) { - self.title = @""; - self.navigationItem.leftBarButtonItem = nil; - //showDialog(self, @"Error", [NSString stringWithFormat:@"%@", error]); - // TODO: [self enableJITWithAltJIT]; + [self enableJITWithAltJIT]; }]; } diff --git a/Natives/en.lproj/Localizable.strings b/Natives/en.lproj/Localizable.strings index c7e24de4..da33b645 100644 --- a/Natives/en.lproj/Localizable.strings +++ b/Natives/en.lproj/Localizable.strings @@ -79,6 +79,8 @@ "login.jit.enabled" = "JIT has been enabled"; "login.jit.fail.JitStreamer" = "JitStreamer error: %@"; "login.jit.found.JitStreamer" = "Found JitStreamer, enabling JIT"; +"login.jit.start.AltKit" = "Attempting to use AltJIT"; +"login.jit.fail.AltKit" = "AltKit error: %@"; // Login buttons "Sign in" = "Sign in"; diff --git a/Natives/external/AltKit/ALTServerConnection.h b/Natives/external/AltKit/ALTServerConnection.h new file mode 100644 index 00000000..a8f13d2d --- /dev/null +++ b/Natives/external/AltKit/ALTServerConnection.h @@ -0,0 +1,19 @@ +#import + +@interface ALTServerConnection + +- (void)disconnect; +- (void)enableUnsignedCodeExecutionWithCompletionHandler:(void(^)(BOOL success, NSError *error))handler; + +@end + + +@interface ALTServerManager + ++ (ALTServerManager *)sharedManager; + +- (void)autoconnectWithCompletionHandler:(void(^)(ALTServerConnection *connection, NSError *error))handler; +- (void)startDiscovering; +- (void)stopDiscovering; + +@end diff --git a/Natives/log.m b/Natives/log.m index 8b62e957..ff2eafaa 100644 --- a/Natives/log.m +++ b/Natives/log.m @@ -20,6 +20,6 @@ void debugLog(const char *message,...) static BOOL debugLog_warned = NO; if (debugLog_warned) return; debugLog_warned = YES; - NSLog(@"WARNING!!! DEBUG LOG DISABLED"); + NSLog(@"Debug log not enabled."); } } diff --git a/Natives/resources/Frameworks/AltKit.framework/AltKit b/Natives/resources/Frameworks/AltKit.framework/AltKit new file mode 100755 index 00000000..ca4d0558 Binary files /dev/null and b/Natives/resources/Frameworks/AltKit.framework/AltKit differ diff --git a/Natives/resources/Frameworks/AltKit.framework/Info.plist b/Natives/resources/Frameworks/AltKit.framework/Info.plist new file mode 100644 index 00000000..a74a4940 Binary files /dev/null and b/Natives/resources/Frameworks/AltKit.framework/Info.plist differ diff --git a/Natives/resources/Frameworks/CAltKit.framework/CAltKit b/Natives/resources/Frameworks/CAltKit.framework/CAltKit new file mode 100755 index 00000000..7e9603c2 Binary files /dev/null and b/Natives/resources/Frameworks/CAltKit.framework/CAltKit differ diff --git a/Natives/resources/Frameworks/CAltKit.framework/Info.plist b/Natives/resources/Frameworks/CAltKit.framework/Info.plist new file mode 100644 index 00000000..843593a6 Binary files /dev/null and b/Natives/resources/Frameworks/CAltKit.framework/Info.plist differ diff --git a/README.md b/README.md index 4f2ca7cd..9820cf97 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ PojavLauncher is amazing, and surprisingly stable, and it wouldn't be this way w - [Java Native Access](https://github.com/java-native-access/jna): [Apache 2.0 License](https://github.com/java-native-access/jna/blob/master/LICENSE). - [shaderc](https://github.com/google/shaderc) (used by mods that uses Vulkan for rendering): [Apache 2.0 License](https://github.com/google/shaderc/blob/main/LICENSE). - [TOInsetGroupedTableView](https://github.com/TimOliver/TOInsetGroupedTableView): [MIT License](https://github.com/TimOliver/TOInsetGroupedTableView/blob/master/LICENSE). +- [AltKit](https://github.com/rileytestut/AltKit) - Thanks to [MCHeads](https://mc-heads.net) for providing Minecraft avatars. ## Special thanks to MacStadium!