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.
This commit is contained in:
Eilionoir Tunnicliff committed 2022-10-03 00:21:32 -04:00
1 parent b46c64cc59
commit 781e643b64
4 files changed
+6 -45

No files matched your search

-6
View File
@@ -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));
@@ -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",
-3
View File
@@ -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";
+6 -28
View File
@@ -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];