mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-14 23:28:52 -04:00
Bridge between 'libcore.io.Os' and 'android.system.Os'
This commit is contained in:
parent
8686c8e196
commit
12aa445870
@ -1,9 +1,11 @@
|
|||||||
package net.kdt.pojavlaunch;
|
package net.kdt.pojavlaunch;
|
||||||
|
|
||||||
import android.content.*;
|
import android.content.*;
|
||||||
|
import android.os.*;
|
||||||
import android.system.*;
|
import android.system.*;
|
||||||
import android.util.*;
|
import android.util.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.reflect.*;
|
||||||
import net.kdt.pojavlaunch.prefs.*;
|
import net.kdt.pojavlaunch.prefs.*;
|
||||||
|
|
||||||
public class JREUtils
|
public class JREUtils
|
||||||
@ -91,7 +93,7 @@ public class JREUtils
|
|||||||
// setEnvironment(launchType, "LIBGL_MIPMAP", "3");
|
// setEnvironment(launchType, "LIBGL_MIPMAP", "3");
|
||||||
setEnvironment(launchType, "MESA_GLSL_CACHE_DIR", ctx.getCacheDir().getAbsolutePath());
|
setEnvironment(launchType, "MESA_GLSL_CACHE_DIR", ctx.getCacheDir().getAbsolutePath());
|
||||||
setEnvironment(launchType, "LD_LIBRARY_PATH", ldLibraryPath);
|
setEnvironment(launchType, "LD_LIBRARY_PATH", ldLibraryPath);
|
||||||
setEnvironment(launchType, "PATH", Tools.homeJreDir + "/bin:" + libcore.io.Libcore.os.getenv("PATH"));
|
setEnvironment(launchType, "PATH", Tools.homeJreDir + "/bin:" + getBridgeOs("getenv", "PATH"));
|
||||||
|
|
||||||
setEnvironment(launchType, "REGAL_GL_VENDOR", "Android");
|
setEnvironment(launchType, "REGAL_GL_VENDOR", "Android");
|
||||||
setEnvironment(launchType, "REGAL_GL_RENDERER", "Regal");
|
setEnvironment(launchType, "REGAL_GL_RENDERER", "Regal");
|
||||||
@ -108,7 +110,7 @@ public class JREUtils
|
|||||||
Tools.mLaunchShell.writeToProcess("export " + name + "=" + value);
|
Tools.mLaunchShell.writeToProcess("export " + name + "=" + value);
|
||||||
} else {
|
} else {
|
||||||
// Libcore one support all Android versions
|
// Libcore one support all Android versions
|
||||||
libcore.io.Libcore.os.setenv(name, value, true);
|
getBridgeOs("setenv", name, value, true);
|
||||||
// Class.forName("libcore.io.Os").getMethod("setenv", String.class, String.class, boolean.class).invoke(null, name, value, true);
|
// Class.forName("libcore.io.Os").getMethod("setenv", String.class, String.class, boolean.class).invoke(null, name, value, true);
|
||||||
/*
|
/*
|
||||||
if (Build.VERSION.SDK_INT < 21) {
|
if (Build.VERSION.SDK_INT < 21) {
|
||||||
@ -120,6 +122,21 @@ public class JREUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object getBridgeOs(String methodName, Object... objs) throws Throwable {
|
||||||
|
Class[] classes = new Class[objs.length];
|
||||||
|
for (int i = 0; i < classes.length; i++) {
|
||||||
|
classes[i] = objs[i].getClass();
|
||||||
|
}
|
||||||
|
if (Build.VERSION.SDK_INT < 21) {
|
||||||
|
Class libcoreClass = Class.forName("libcore.io.Libcore");
|
||||||
|
Object libcoreOs = libcoreClass.getField("os").get(null);
|
||||||
|
return Class.forName("libcore.io.Os").getMethod(methodName, classes).invoke(libcoreOs, objs);
|
||||||
|
} else {
|
||||||
|
// Avoid Android < 5 get ClassNotFoundException
|
||||||
|
return Class.forName("android.system.Os").getMethod(methodName, classes).invoke(null, objs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static native int chdir(String path);
|
public static native int chdir(String path);
|
||||||
public static native boolean dlopen(String libPath);
|
public static native boolean dlopen(String libPath);
|
||||||
public static native void redirectLogcat();
|
public static native void redirectLogcat();
|
||||||
|
@ -17,7 +17,6 @@ import com.kdt.filermod.*;
|
|||||||
import com.kdt.mojangauth.*;
|
import com.kdt.mojangauth.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import libcore.io.*;
|
|
||||||
import net.kdt.pojavlaunch.update.*;
|
import net.kdt.pojavlaunch.update.*;
|
||||||
import net.kdt.pojavlaunch.value.customcontrols.*;
|
import net.kdt.pojavlaunch.value.customcontrols.*;
|
||||||
import org.apache.commons.compress.archivers.tar.*;
|
import org.apache.commons.compress.archivers.tar.*;
|
||||||
@ -427,7 +426,7 @@ public class PojavLoginActivity extends AppCompatActivity
|
|||||||
try {
|
try {
|
||||||
// android.system.Os
|
// android.system.Os
|
||||||
// Libcore one support all Android versions
|
// Libcore one support all Android versions
|
||||||
libcore.io.Libcore.os.symlink(tarEntry.getName(), tarEntry.getLinkName());
|
JREUtils.getBridgeOs("symlink", tarEntry.getName(), tarEntry.getLinkName());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user