From 781e643b64c2f3cb922d8d63eb6fc792c0554537 Mon Sep 17 00:00:00 2001 From: Eilionoir Tunnicliff Date: Mon, 3 Oct 2022 00:21:32 -0400 Subject: [PATCH] Move to sandboxed directory for all users This commit fixes issues where users migrating from the debian package to TrollStore will lose access to existing PojavLauncher data, by beginning a final migration to a sandboxed directory. We also remove the compatibility symlink option, to get people familiar with the new location and prepare for .pojavpack. This commit breaks installations of PojavLauncher installed with AppSync Unified. Recommend installing with TrollStore or sideloading as if it were an unjailbroken device. --- Natives/LauncherPreferences.m | 6 ---- Natives/LauncherPreferencesViewController2.m | 8 ----- Natives/en.lproj/Localizable.strings | 3 -- Natives/main.m | 34 ++++---------------- 4 files changed, 6 insertions(+), 45 deletions(-) diff --git a/Natives/LauncherPreferences.m b/Natives/LauncherPreferences.m index 65d5e88c..4d96a6e1 100644 --- a/Natives/LauncherPreferences.m +++ b/Natives/LauncherPreferences.m @@ -136,12 +136,6 @@ void loadPreferences(BOOL reset) { setDefaultValueForPref(prefDict, @"check_sha", @YES); setDefaultValueForPref(prefDict, @"auto_ram", @(!getEntitlementValue(@"com.apple.private.memorystatus"))); setDefaultValueForPref(prefDict, @"unsupported_warn_counter", @(0)); - - if (0 != [fileManager fileExistsAtPath:@"/var/mobile/Documents/.pojavlauncher"]) { - setDefaultValueForPref(prefDict, @"disable_home_symlink", @NO); - } else { - setDefaultValueForPref(prefDict, @"disable_home_symlink", @YES); - } // Debug settings setDefaultValueForPref(debugPrefDict, @"debug_ipad_ui", @(UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)); diff --git a/Natives/LauncherPreferencesViewController2.m b/Natives/LauncherPreferencesViewController2.m index cfbe2afd..677816e2 100644 --- a/Natives/LauncherPreferencesViewController2.m +++ b/Natives/LauncherPreferencesViewController2.m @@ -52,14 +52,6 @@ typedef void(^CreateView)(UITableViewCell *, NSString *, NSDictionary *); @"enableCondition": whenNotInGame, @"class": LauncherPrefGameDirViewController.class, }, - @{@"key": @"home_symlink", - @"hasDetail": @YES, - @"icon": @"link", - @"type": self.typeSwitch, - @"enableCondition": ^BOOL(){ - return getenv("POJAV_DETECTEDJB") != NULL && whenNotInGame(); - } - }, @{@"key": @"check_sha", @"hasDetail": @YES, @"icon": @"lock.shield", diff --git a/Natives/en.lproj/Localizable.strings b/Natives/en.lproj/Localizable.strings index 3ad2b159..3dc829e8 100644 --- a/Natives/en.lproj/Localizable.strings +++ b/Natives/en.lproj/Localizable.strings @@ -86,7 +86,6 @@ "Settings" = "Settings"; "preference.section.general" = "General Settings"; -"preference.section.footer.general" = "* Compatibility symlink option is planned to be removed in a future release."; "preference.section.video" = "Video Settings"; "preference.section.footer.video" = "Auto renderer allows Minecraft to decide which renderer to use. Decreasing resolution reduces GPU workload for better performance."; "preference.section.control" = "Control customization"; @@ -102,8 +101,6 @@ "preference.title.confirm.delete_game_directory" = "The instance %@ will be deleted forever and cannot be restored."; "preference.multidir.add_directory" = "add game directory"; -"preference.title.home_symlink" = "Enable compatibility symlink *"; -"preference.detail.home_symlink" = "Make a symlink at /var/mobile/Documents/.pojavlauncher. Unavailable in sandboxed environment."; "preference.title.check_sha" = "Check files after downloading"; "preference.detail.check_sha" = "This option forces launcher to check the file hash if it's available. Prevents broken downloads."; "preference.title.cosmetica" = "Cosmetica Capes"; diff --git a/Natives/main.m b/Natives/main.m index 7c2f8bfd..c29ffa9e 100644 --- a/Natives/main.m +++ b/Natives/main.m @@ -132,20 +132,11 @@ void init_logDeviceAndVer(char *argument) { } void init_migrateDirIfNecessary() { - // TODO: Rewrite to migrate from /usr/share -> new Docs in 2.2 - NSString *completeFile = @"/var/mobile/Documents/.pojavlauncher/migration_complete"; - NSString *oldDir = @"/var/mobile/Documents/.pojavlauncher"; - if ([fm fileExistsAtPath:oldDir] && ![fm fileExistsAtPath:completeFile]) { - NSString *newDir = @"/usr/share/pojavlauncher"; - if (@available(iOS 15, *)) { - newDir = @"/private/preboot/procursus/usr/share/pojavlauncher"; - } - + NSString *oldDir = @"/usr/share/pojavlauncher"; + if ([fm fileExistsAtPath:oldDir]) { + NSString *newDir = [NSString stringWithFormat:@"%s/Documents", getenv("HOME")]; [fm moveItemAtPath:oldDir toPath:newDir error:nil]; - [fm createSymbolicLinkAtPath:oldDir withDestinationPath:newDir error:nil]; - - NSString *message = [NSString stringWithFormat:NSLocalizedString(@"init.migrateDir", nil), newDir]; - [message writeToFile:completeFile atomically:YES encoding:NSUTF8StringEncoding error:nil]; + [fm removeItemAtPath:oldDir error:nil]; } } @@ -310,21 +301,8 @@ int main(int argc, char * argv[]) { setenv("BUNDLE_PATH", dirname(argv[0]), 1); setenv("HOME", [NSFileManager.defaultManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] .lastObject.path.stringByDeletingLastPathComponent.UTF8String, 1); - - if (getenv("POJAV_DETECTEDJB")) { - // TODO: Set to new Docs for both jben and unjben in 2.2 - if (0 == access("/usr/share/pojavlauncher", F_OK)) { - // If /usr/share/pojavlauncher isnt already available - // this code will crash the app on launch - setenv("HOME", "/usr/share", 1); - setenv("OLD_POJAV_HOME", "/var/mobile/Documents/.pojavlauncher", 1); - setenv("POJAV_HOME", "/usr/share/pojavlauncher", 1); - } else { - setenv("POJAV_HOME", [NSString stringWithFormat:@"%s/Documents", getenv("HOME")].UTF8String, 1); - } - } else { - setenv("POJAV_HOME", [NSString stringWithFormat:@"%s/Documents", getenv("HOME")].UTF8String, 1); - } + // WARNING: THIS DIRECTS TO /var/mobile/Documents IF INSTALLED WITH APPSYNC UNIFIED + setenv("POJAV_HOME", [NSString stringWithFormat:@"%s/Documents", getenv("HOME")].UTF8String, 1); [fm createDirectoryAtPath:@(getenv("POJAV_HOME")) withIntermediateDirectories:NO attributes:nil error:nil];