mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 07:39:00 -04:00
[Probably should not try] Changes
- Bug fix on migrate to new game dir - Update sandbox policies
This commit is contained in:
parent
e300b6ff16
commit
cebf474350
@ -3,7 +3,7 @@
|
||||
// This file is important to protect you against viruses/malwares that could be come from unknown Java Programs (run on mod install) or a mod.
|
||||
|
||||
grant {
|
||||
permission java.io.FilePermission "${pojav.path.cache}/*", "read, write, delete";
|
||||
permission java.io.FilePermission "${java.io.tmpdir}/*", "read, write, delete";
|
||||
permission java.io.FilePermission "${pojav.path.minecraft}/*", "read, write, delete";
|
||||
};
|
||||
|
||||
|
@ -298,16 +298,15 @@ public class PojavLoginActivity extends BaseActivity
|
||||
}
|
||||
|
||||
private void initMain() throws Throwable {
|
||||
mkdirs(Tools.DIR_HOME_VERSION);
|
||||
mkdirs(Tools.DIR_HOME_LIBRARY);
|
||||
|
||||
PojavMigrator.migrateAccountData(this);
|
||||
if (!PojavMigrator.migrateGameDir()) {
|
||||
mkdirs(Tools.DIR_GAME_NEW);
|
||||
mkdirs(Tools.DIR_GAME_NEW + "/config");
|
||||
mkdirs(Tools.DIR_GAME_NEW + "/lwjgl3");
|
||||
mkdirs(Tools.DIR_GAME_NEW + "/mods");
|
||||
|
||||
PojavMigrator.migrateAccountData(this);
|
||||
PojavMigrator.migrateGameDir();
|
||||
mkdirs(Tools.DIR_HOME_VERSION);
|
||||
mkdirs(Tools.DIR_HOME_LIBRARY);
|
||||
}
|
||||
|
||||
File forgeSplashFile = new File(Tools.DIR_GAME_NEW, "config/splash.properties");
|
||||
String forgeSplashContent = "enabled=true";
|
||||
@ -330,7 +329,7 @@ public class PojavLoginActivity extends BaseActivity
|
||||
|
||||
Tools.copyAssetFile(this, "components/ForgeInstallerHeadless/forge-installer-headless-1.0.1.jar", Tools.DIR_GAME_NEW + "/config", "forge-installer-headless.jar", true);
|
||||
Tools.copyAssetFile(this, "options.txt", Tools.DIR_GAME_NEW, false);
|
||||
Tools.copyAssetFile(this, "java_sandbox.policy", Tools.DIR_GAME_NEW, true);
|
||||
Tools.copyAssetFile(this, "java_sandbox.policy", Tools.DIR_GAME_HOME, true);
|
||||
// TODO: Remove after implement.
|
||||
Tools.copyAssetFile(this, "launcher_profiles.json", Tools.DIR_GAME_NEW, false);
|
||||
|
||||
|
@ -7,7 +7,6 @@ public class PojavMigrator
|
||||
{
|
||||
public static void migrateAccountData(Context ctx) {
|
||||
File oldAccDir = new File(Tools.DIR_ACCOUNT_OLD);
|
||||
|
||||
if (oldAccDir.exists() && oldAccDir.isDirectory()) {
|
||||
for (String account : oldAccDir.list()) {
|
||||
File oldAccFile = new File(oldAccDir, account);
|
||||
@ -32,16 +31,42 @@ public class PojavMigrator
|
||||
}
|
||||
}
|
||||
|
||||
public static void migrateGameDir() throws IOException, InterruptedException {
|
||||
public static boolean migrateGameDir() throws IOException, InterruptedException {
|
||||
File oldGameDir = new File(Tools.DIR_GAME_OLD);
|
||||
if (oldGameDir.exists() && oldGameDir.isDirectory()) {
|
||||
|
||||
boolean moved = oldGameDir.exists() && oldGameDir.isDirectory();
|
||||
if (!migrateBugFix20201217() && moved) {
|
||||
command("mv " + Tools.DIR_GAME_OLD + " " + Tools.DIR_GAME_HOME + "/");
|
||||
}
|
||||
|
||||
return moved;
|
||||
}
|
||||
|
||||
public static boolean migrateBugFix20201217() throws IOException, InterruptedException {
|
||||
File bugGameDir = new File(Tools.DIR_GAME_NEW + "/.minecraft");
|
||||
File oldGameDir = new File(Tools.DIR_GAME_OLD);
|
||||
boolean moved = bugGameDir.exists() && bugGameDir.isDirectory();
|
||||
|
||||
if (oldGameDir.exists() && oldGameDir.isDirectory() && moved) {
|
||||
command("rm -rf " + oldGameDir.getAbsolutePath());
|
||||
}
|
||||
|
||||
if (moved) {
|
||||
command("mv " + bugGameDir.getAbsolutePath() + " " + Tools.DIR_GAME_OLD);
|
||||
command("rm -rf " + Tools.DIR_GAME_HOME);
|
||||
command("mv " + Tools.DIR_GAME_OLD + " " + Tools.DIR_GAME_HOME + "/");
|
||||
}
|
||||
|
||||
return moved;
|
||||
}
|
||||
|
||||
private static void command(String cmd) throws IOException, InterruptedException {
|
||||
Process p = Runtime.getRuntime().exec(
|
||||
new String[]{"mv", Tools.DIR_GAME_OLD, Tools.DIR_GAME_NEW});
|
||||
new String[]{cmd});
|
||||
int exitCode = p.waitFor();
|
||||
if (exitCode != 0) {
|
||||
throw new IOException("Could not move game dir! Exit code " + exitCode +
|
||||
throw new IOException("Exit code " + exitCode +
|
||||
", message:\n" + Tools.read(p.getErrorStream()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,9 +35,10 @@ public final class Tools
|
||||
public static String CURRENT_ARCHITECTURE;
|
||||
|
||||
// New since 3.3.1
|
||||
public static String DIR_ACCOUNT_OLD;
|
||||
public static String DIR_ACCOUNT_NEW;
|
||||
public static final String DIR_GAME_NEW = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/PojavLauncher/.minecraft";
|
||||
public static String DIR_ACCOUNT_OLD;
|
||||
public static final String DIR_GAME_HOME = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/PojavLauncher";
|
||||
public static final String DIR_GAME_NEW = DIR_GAME_NEW + "/.minecraft";
|
||||
public static final String DIR_GAME_OLD = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/.minecraft";
|
||||
|
||||
// New since 3.0.0
|
||||
@ -84,8 +85,6 @@ public final class Tools
|
||||
overrideableArgList.add("-Duser.language=" + System.getProperty("user.language"));
|
||||
// overrideableArgList.add("-Duser.timezone=GMT");
|
||||
|
||||
// Should be compatible?
|
||||
// overrideableArgList.add("-Dos.name=Android");
|
||||
overrideableArgList.add("-Dos.name=Linux");
|
||||
overrideableArgList.add("-Dos.version=Android-" + Build.VERSION.RELEASE);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user