Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Upstreamify
Browse files Browse the repository at this point in the history
  • Loading branch information
artdeell committed Feb 4, 2022
2 parents b85dd16 + 97dace3 commit d7556c3
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ body:
Tip: You can attach files by clicking this area to highlight it and then dragging files in or select them on 🖼 option at the toolbar.
validations:
required: false
required: true

- type: textarea
attributes:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
- name: Install gl4es
if: github.ref == 'refs/heads/v3_openjdk' && steps.gl4es-cache.outputs.cache-hit != 'true'
continue-on-error: true
run: |
cp -R gl4es/libs/* app_pojavlauncher/src/main/jniLibs/
mv gl4es ..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public void installJarFile(View view){

public static final int RUN_MOD_INSTALLER = 2050;
private void installMod(boolean customJavaArgs) {
if (MultiRTUtils.getExactJREName(8) == null) {
Toast.makeText(this, R.string.multirt_nojava8rt, Toast.LENGTH_LONG).show();
return;
}
if (customJavaArgs) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.alerttitle_installmod);
Expand Down Expand Up @@ -259,6 +263,11 @@ protected void onResumeFragments() {
mRuntimeConfigDialog = new MultiRTConfigDialog();
mRuntimeConfigDialog.prepare(this);

((Button)findViewById(R.id.installJarButton)).setOnLongClickListener(view -> {
installMod(true);
return true;
});

//TODO ADD CRASH CHECK AND FOCUS
System.out.println("call to onResumeFragments; E");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private void runCraft() throws Throwable {
checkLWJGL3Installed();

JREUtils.jreReleaseList = JREUtils.readJREReleaseProperties();
JREUtils.checkJavaArchitecture(this, JREUtils.jreReleaseList.get("OS_ARCH"));
Logger.getInstance().appendToLog("Architecture: " + Architecture.archAsString(Tools.DEVICE_ARCHITECTURE));
checkJavaArgsIsLaunchable(JREUtils.jreReleaseList.get("JAVA_VERSION"));
// appendlnToLog("Info: Custom Java arguments: \"" + LauncherPreferences.PREF_CUSTOM_JAVA_ARGS + "\"");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,15 @@ protected void onCreate(Bundle savedInstanceState) {
Logger.getInstance().reset();

try {
JREUtils.jreReleaseList = JREUtils.readJREReleaseProperties(LauncherPreferences.PREF_DEFAULT_RUNTIME);
if (JREUtils.jreReleaseList.get("JAVA_VERSION").equals("1.8.0")) {
MultiRTUtils.setRuntimeNamed(this,LauncherPreferences.PREF_DEFAULT_RUNTIME);
} else {
MultiRTUtils.setRuntimeNamed(this,MultiRTUtils.getExactJREName(8));
JREUtils.jreReleaseList = JREUtils.readJREReleaseProperties();
}

loggerView = findViewById(R.id.launcherLoggerView);
MultiRTUtils.setRuntimeNamed(this,LauncherPreferences.PREF_DEFAULT_RUNTIME);
gestureDetector = new GestureDetector(this, new SingleTapConfirm());

findViewById(R.id.installmod_mouse_pri).setOnTouchListener(this);
Expand Down Expand Up @@ -278,14 +285,6 @@ private int doCustomInstall(File modFile, String javaArgs) throws IOException {
public int launchJavaRuntime(File modFile, String javaArgs) {
JREUtils.redirectAndPrintJRELog(this);
try {
JREUtils.jreReleaseList = JREUtils.readJREReleaseProperties();

// Fail immediately when Java 8 is not selected
// TODO: auto override Java 8 if installed
if (!JREUtils.jreReleaseList.get("JAVA_VERSION").equals("1.8.0")) {
throw new RuntimeException("Cannot use the mod installer. In order to use the mod installer, you need to install Java 8 and specify it in the Preferences menu.");
}

List<String> javaArgList = new ArrayList<String>();

// Enable Caciocavallo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ public static List<Runtime> getRuntimes() {

return ret;
}
public static String getExactJREName(int majorVersion) {
List<Runtime> runtimes = getRuntimes();
for(Runtime r : runtimes) {
if(r.javaVersion == majorVersion) {
return r.name;
}
}
return null;
}
public static String getNearestJREName(int majorVersion) {
List<Runtime> runtimes = getRuntimes();
int diff_factor = Integer.MAX_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.RecyclerView;

import net.kdt.pojavlaunch.Architecture;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
Expand Down Expand Up @@ -71,7 +72,7 @@ public RTViewHolder(View itemView) {
public void bindRuntime(MultiRTUtils.Runtime rt, int pos) {
currentRuntime = rt;
currentPosition = pos;
if(rt.versionString != null) {
if(rt.versionString != null && Tools.DEVICE_ARCHITECTURE == Architecture.archAsInt(rt.arch)) {
javaVersionView.setText(ctx.getString(R.string.multirt_java_ver, rt.name, rt.javaVersion));
fullJavaVersionView.setText(rt.versionString);
fullJavaVersionView.setTextColor(defaultColors);
Expand All @@ -80,8 +81,12 @@ public void bindRuntime(MultiRTUtils.Runtime rt, int pos) {
setDefaultButton.setEnabled(!default_);
setDefaultButton.setText(default_?R.string.multirt_config_setdefault_already:R.string.multirt_config_setdefault);
}else{
if(rt.versionString == null){
fullJavaVersionView.setText(R.string.multirt_runtime_corrupt);
}else{
fullJavaVersionView.setText(ctx.getString(R.string.multirt_runtime_incompatiblearch, rt.arch));
}
javaVersionView.setText(rt.name);
fullJavaVersionView.setText(R.string.multirt_runtime_corrupt);
fullJavaVersionView.setTextColor(Color.RED);
setDefaultButton.setVisibility(View.GONE);
}
Expand All @@ -91,7 +96,7 @@ public void bindRuntime(MultiRTUtils.Runtime rt, int pos) {
public void onClick(View v) {
if(v.getId() == R.id.multirt_view_removebtn) {
if (currentRuntime != null) {
if(MultiRTUtils.getRuntimes().size() < 2) {
if(MultiRTUtils.getRuntimes().size() < 2 && setDefaultButton.isShown()) {
AlertDialog.Builder bldr = new AlertDialog.Builder(ctx);
bldr.setTitle(R.string.global_error);
bldr.setMessage(R.string.multirt_config_removeerror_last);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void updateProgress(int curr, int max) {
mActivity.runOnUiThread(()->{
AlertDialog.Builder bldr = new AlertDialog.Builder(mActivity);
bldr.setTitle(R.string.global_error);
bldr.setMessage(R.string.multirt_nocompartiblert);
bldr.setMessage(mActivity.getString(R.string.multirt_nocompartiblert, verInfo.javaVersion.majorVersion));
bldr.setPositiveButton(android.R.string.ok,(dialog, which)->{
dialog.dismiss();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ private JREUtils() {}
private static String nativeLibDir;
public static Map<String, String> jreReleaseList;

/**
* Checks if the java architecture is correct for the device architecture.
* @param activity Some context to load resources from
* @param jreArch The java architecture to compare as a String.
*/
public static void checkJavaArchitecture(Activity activity, String jreArch) {
Logger.getInstance().appendToLog("Architecture: " + archAsString(Tools.DEVICE_ARCHITECTURE));
if(Tools.DEVICE_ARCHITECTURE == Architecture.archAsInt(jreArch)) return;

Logger.getInstance().appendToLog("Architecture " + archAsString(Tools.DEVICE_ARCHITECTURE) + " is incompatible with Java Runtime " + jreArch);
Tools.dialogOnUiThread(activity, "", activity.getString(R.string.mcn_check_fail_incompatiblearch, archAsString(Tools.DEVICE_ARCHITECTURE), jreArch));
}

public static String findInLdLibPath(String libName) {
if(Os.getenv("LD_LIBRARY_PATH")==null) {
try {
Expand Down Expand Up @@ -104,8 +91,14 @@ public static void initJavaRuntime() {
}

public static Map<String, String> readJREReleaseProperties() throws IOException {
return readJREReleaseProperties(Tools.DIR_HOME_JRE);
}
public static Map<String, String> readJREReleaseProperties(String name) throws IOException {
Map<String, String> jreReleaseMap = new ArrayMap<>();
BufferedReader jreReleaseReader = new BufferedReader(new FileReader(Tools.DIR_HOME_JRE + "/release"));
if (!name.contains("/")) {
name = Tools.MULTIRT_HOME + "/" + name;
}
BufferedReader jreReleaseReader = new BufferedReader(new FileReader(name + "/release"));
String currLine;
while ((currLine = jreReleaseReader.readLine()) != null) {
if (!currLine.isEmpty() || currLine.contains("=")) {
Expand Down Expand Up @@ -324,6 +317,7 @@ public static int launchJavaVM(final Activity activity,final List<String> JVMArg
initJavaRuntime();
setupExitTrap(activity.getApplication());
chdir(Tools.DIR_GAME_NEW);
userArgs.add(0,"java"); //argv[0] is the program name according to C standard.

final int exitCode = VMLauncher.launchJVM(userArgs.toArray(new String[0]));
Logger.getInstance().appendToLog("Java Exit code: " + exitCode);
Expand All @@ -347,6 +341,8 @@ public static int launchJavaVM(final Activity activity,final List<String> JVMArg
*/
public static List<String> getJavaArgs(Context ctx) {
List<String> userArguments = parseJavaArguments(LauncherPreferences.PREF_CUSTOM_JAVA_ARGS);
String resolvFile;
resolvFile = new File(Tools.DIR_DATA,"resolv.conf").getAbsolutePath();
String[] overridableArguments = new String[]{
"-Djava.home=" + Tools.DIR_HOME_JRE,
"-Djava.io.tmpdir=" + ctx.getCacheDir().getAbsolutePath(),
Expand All @@ -365,29 +361,30 @@ public static List<String> getJavaArgs(Context ctx) {
"-Dglfwstub.windowWidth=" + CallbackBridge.windowWidth,
"-Dglfwstub.windowHeight=" + CallbackBridge.windowHeight,
"-Dglfwstub.initEgl=false",

"-Dext.net.resolvPath=" +new File(Tools.DIR_DATA,"resolv.conf").getAbsolutePath(),

"-Dext.net.resolvPath=" +resolvFile,
"-Dlog4j2.formatMsgNoLookups=true", //Log4j RCE mitigation

"-Dnet.minecraft.clientmodname=" + Tools.APP_NAME,
"-Dfml.earlyprogresswindow=false" //Forge 1.14+ workaround
};


for (String userArgument : userArguments) {
for(int i=0; i < overridableArguments.length; ++i){
String overridableArgument = overridableArguments[i];
//Only java properties are considered overridable for now
if(userArgument.startsWith("-D") && userArgument.startsWith(overridableArgument.substring(0, overridableArgument.indexOf("=")))){
overridableArguments[i] = ""; //Remove the argument since it is overridden
List<String> additionalArguments = new ArrayList<>();
for(String arg : overridableArguments) {
String strippedArg = arg.substring(0,arg.indexOf('='));
boolean add = true;
for(String uarg : userArguments) {
if(uarg.startsWith(strippedArg)) {
add = false;
break;
}
}
if(add)
additionalArguments.add(arg);
else
Log.i("ArgProcessor","Arg skipped: "+arg);
}

//Add all the arguments
userArguments.addAll(Arrays.asList(overridableArguments));
userArguments.addAll(additionalArguments);
return userArguments;
}

Expand Down
Binary file modified app_pojavlauncher/src/main/jniLibs/arm64-v8a/libvgpu.so
Binary file not shown.
Binary file modified app_pojavlauncher/src/main/jniLibs/armeabi-v7a/libvgpu.so
Binary file not shown.
Binary file modified app_pojavlauncher/src/main/jniLibs/x86/libvgpu.so
Binary file not shown.
Binary file modified app_pojavlauncher/src/main/jniLibs/x86_64/libvgpu.so
Binary file not shown.
9 changes: 6 additions & 3 deletions app_pojavlauncher/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,10 @@
<string name="global_waiting">Wait</string>

<!-- MainActivity: strings -->
<string name="mcn_exit_title">Application/Game exited with code %d</string>
<string name="mcn_exit_title">Application/Game exited with code %d, check latestlog.txt for more details.</string>
<string name="mcn_exit_call">Exit</string>
<string name="mcn_exit_confirm">Are you sure want to force close?</string>
<string name="mcn_check_fail_lwjgl">LWJGL3 was not installed!</string>
<string name="mcn_check_fail_incompatiblearch">Architecture %1$s is incompatible with Java Runtime %2$s.</string>
<string name="mcn_check_fail_vulkan_support">Vulkan Zink renderer is not supported on this device!</string>

<!-- MainActivity: Control buttons -->
Expand Down Expand Up @@ -238,6 +237,7 @@
<string name="mcl_memory_allocation_subtitle">Controls how much memory is given to Minecraft</string>
<string name="multirt_java_ver">%s (Java %d)</string>
<string name="multirt_runtime_corrupt">Corrupted Java Runtime</string>
<string name="multirt_runtime_incompatiblearch">Incompatible architecture: %s</string>
<string name="multirt_config_title">Java VMs</string>
<string name="multirt_config_add">Add new</string>
<string name="multirt_config_add_subtitle">Import new Java VM</string>
Expand All @@ -247,7 +247,8 @@
<string name="multirt_config_setdefault">Set default</string>
<string name="multirt_config_setdefault_already">Default</string>
<string name="multirt_config_removeerror_last">You must have at least one Java Runtime installed</string>
<string name="multirt_nocompartiblert">Can\'t find any compartible Java Runtime</string>
<string name="multirt_nocompartiblert">Can\'t find any compartible Java Runtime. This version requires Java %d or newer.</string>
<string name="multirt_nojava8rt">Can\'t find Java 8. In order to use this option, you need to install Java 8.</string>

<string name="compat_117_message">Minecraft 21w10a+ requires the OpenGL 3.2 core profile. Sadly, GL4ES wrapper doesn\'t fully support it at the moment, but there are some additional resources you can install to run these versions. Press OK to confirm installation, and press Cancel to abort launch.</string>
<string name="compat_11x_playanyway">Play anyway</string>
Expand Down Expand Up @@ -300,4 +301,6 @@
<string name="pedit_renderer">Renderer</string>
<string name="gles_version_hack_title">Force openGL 1</string>
<string name="gles_version_hack_description">Help with compatibility on some old versions</string>
<string name="arc_capes_title">Arc Capes</string>
<string name="arc_capes_desc">Enables capes from Arc. For more information please visit https://arccapes.com</string>
</resources>
1 change: 1 addition & 0 deletions gl4es
Submodule gl4es added at baf1c7

0 comments on commit d7556c3

Please sign in to comment.