Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Feat[Unpack]: Auto Unpack Jre21" #15

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 76 additions & 70 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -1,112 +1,118 @@
name: Android CI

on:
push:
pull_request:
branches-ignore:
- 'l10n_v3_openjdk2'
types: [ opened, reopened ]
push:
branches-ignore:
- 'l10n_v3_openjdk2'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-22.04
env:
GPLAY_KEYSTORE_PASSWORD: ${{ secrets.GPLAY_KEYSTORE_PASSWORD }}
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'

- name: Get JRE 8
uses: dawidd6/action-download-artifact@v3
uses: dawidd6/action-download-artifact@v2
with:
workflow: buildjre8.yml
path: app_pojavlauncher/src/main/assets/components/jre-8
workflow: build.yml
path: app_pojavlauncher/src/main/assets/components/jre
workflow_conclusion: success
repo: Vera-Firefly/android-openjdk-autobuild
branch: main
repo: PojavLauncherTeam/android-openjdk-build-multiarch
branch: buildjre8
name: jre8-pojav

- name: Get JRE 17
uses: dawidd6/action-download-artifact@v3
- name: Get JRE17
uses: dawidd6/action-download-artifact@v2
with:
workflow: buildjre17.yml
path: app_pojavlauncher/src/main/assets/components/jre-17
workflow: build.yml
path: app_pojavlauncher/src/main/assets/components/jre-new
workflow_conclusion: success
repo: Vera-Firefly/android-openjdk-autobuild
branch: main
repo: PojavLauncherTeam/android-openjdk-build-multiarch
branch: buildjre17
name: jre17-pojav

- name: Get JRE 21
uses: dawidd6/action-download-artifact@v3
- uses: gradle/gradle-build-action@v2
with:
workflow: buildjre21.yml
path: app_pojavlauncher/src/main/assets/components/jre-21
workflow_conclusion: success
repo: Vera-Firefly/android-openjdk-autobuild
branch: main
name: jre21-pojav
gradle-version: 7.6.1

- name: Get LWJGL3
uses: dawidd6/action-download-artifact@v3
with:
workflow: main.yml
path: app_pojavlauncher/src/main/assets/components/lwjgl3
workflow_conclusion: success
repo: Vera-Firefly/lwjgl3-build
branch: official
name: lwjgl
- name: Build JRE JAR files
run: |
./scripts/languagelist_updater.sh

- uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 7.6.1
mkdir out
# Build JRE JAR files (security manager, etc...)
gradle :jre_lwjgl3glfw:build --no-daemon

- name: Set up JDK 17
uses: actions/setup-java@v4
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Build Debug
- name: Build Google Play .aab
if: github.repository_owner == 'PojavLauncherTeam' && github.ref_name == 'v3_openjdk'
run: |
gradle :app_pojavlauncher:bundleGplay
mv app_pojavlauncher/build/outputs/bundle/gplay/app_pojavlauncher-gplay.aab out/app-gplay.aab

- name: Build Debug .apk
run: |
# Build the launcher
gradle :app_pojavlauncher:assembleDebug
mv app_pojavlauncher/build/outputs/apk/debug/app_pojavlauncher-debug.apk out/app-debug.apk

- name: Upload Debug
uses: actions/upload-artifact@v4
- name: Build APK without runtime
run: |
rm -r app_pojavlauncher/src/main/assets/components/jre
rm -r app_pojavlauncher/src/main/assets/components/jre-new
gradle assembleDebug
mv app_pojavlauncher/build/outputs/apk/debug/app_pojavlauncher-debug.apk out/app-debug-noruntime.apk
- name: Gen md5sums
run: |
md5sum out/app-debug.apk > out/app-debug.md5
md5sum out/app-debug-noruntime.apk > out/app-debug-noruntime.md5

- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: app-debug
path: app_pojavlauncher/build/outputs/apk/debug/*

buildnoruntime:
runs-on: ubuntu-22.04
env:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get LWJGL3
uses: dawidd6/action-download-artifact@v3
path: out/app-debug.*

- name: Upload AAB
uses: actions/upload-artifact@v3
with:
workflow: main.yml
path: app_pojavlauncher/src/main/assets/components/lwjgl3
workflow_conclusion: success
repo: Vera-Firefly/lwjgl3-build
branch: official
name: lwjgl
name: app-release-aab
path: out/app-gplay.aab

- uses: gradle/actions/setup-gradle@v3
- name: Upload onto the Google Play testing track
continue-on-error: true
if: github.repository_owner == 'PojavLauncherTeam' && github.ref_name == 'v3_openjdk'
uses: r0adkll/[email protected]
with:
gradle-version: 7.6.1
serviceAccountJsonPlainText: ${{ secrets.GPLAY_SERVICE_JSON }}
packageName: net.kdt.pojavlaunch
releaseFiles: out/app-gplay.aab
track: internal
inAppUpdatePriority: 5

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Build Debug-noruntime
run: |
gradle :app_pojavlauncher:assembleDebug

- name: Upload Debug-noruntime
uses: actions/upload-artifact@v4
- name: Upload APK (without runtime)
uses: actions/upload-artifact@v3
with:
name: app-debug-noruntime
path: app_pojavlauncher/build/outputs/apk/debug/*
path: out/app-debug-noruntime.*

Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,53 @@
import android.app.Activity;
import android.content.res.AssetManager;
import android.util.Log;

import net.kdt.pojavlaunch.multirt.MultiRTUtils;
import net.kdt.pojavlaunch.multirt.Runtime;
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;

import java.io.IOException;

public class JRE21Util {
public static final String JRE_21_NAME = "Internal-21";
public static boolean checkInternalJre21(AssetManager assetManager) {
String launcher_jre21_version;
String installed_jre21_version = MultiRTUtils.__internal__readBinpackVersion(JRE_21_NAME);
public class JRE17Util {
public static final String NEW_JRE_NAME = "Internal-17";
public static boolean checkInternalNewJre(AssetManager assetManager) {
String launcher_jre17_version;
String installed_jre17_version = MultiRTUtils.__internal__readBinpackVersion(NEW_JRE_NAME);
try {
launcher_jre21_version = Tools.read(assetManager.open("components/jre-21/version"));
} catch (IOException exc) {
return installed_jre21_version != null;
launcher_jre17_version = Tools.read(assetManager.open("components/jre-new/version"));
}catch (IOException exc) {
//we don't have a runtime included!
return installed_jre17_version != null; //if we have one installed -> return true -> proceed (no updates but the current one should be functional)
//if we don't -> return false -> Cannot find compatible Java runtime
}
if(!launcher_jre21_version.equals(installed_jre21_version))
return unpackJre21(assetManager, launcher_jre21_version);
if(!launcher_jre17_version.equals(installed_jre17_version)) // this implicitly checks for null, so it will unpack the runtime even if we don't have one installed
return unpackJre17(assetManager, launcher_jre17_version);
else return true;
}

private static boolean unpackJre21(AssetManager assetManager, String rt_version) {
private static boolean unpackJre17(AssetManager assetManager, String rt_version) {
try {
MultiRTUtils.installRuntimeNamedBinpack(
assetManager.open("components/jre-21/universal.tar.xz"),
assetManager.open("components/jre-21/bin-" + archAsString(Tools.DEVICE_ARCHITECTURE) + ".tar.xz"),
"Internal-21", rt_version);
MultiRTUtils.postPrepare("Internal-21");
assetManager.open("components/jre-new/universal.tar.xz"),
assetManager.open("components/jre-new/bin-" + archAsString(Tools.DEVICE_ARCHITECTURE) + ".tar.xz"),
"Internal-17", rt_version);
MultiRTUtils.postPrepare("Internal-17");
return true;
}catch (IOException e) {
Log.e("JRE21Auto", "Internal JRE unpack failed", e);
Log.e("JRE17Auto", "Internal JRE unpack failed", e);
return false;
}
}
public static boolean isInternalJRE21(String s_runtime) {
public static boolean isInternalNewJRE(String s_runtime) {
Runtime runtime = MultiRTUtils.read(s_runtime);
if(runtime == null) return false;
return JRE_21_NAME.equals(runtime.name);
return NEW_JRE_NAME.equals(runtime.name);
}

/** @return true if everything is good, false otherwise. */
public static boolean installJre21IfNeeded(Activity activity, JMinecraftVersionList.Version versionInfo) {
public static boolean installNewJreIfNeeded(Activity activity, JMinecraftVersionList.Version versionInfo) {
//Now we have the reliable information to check if our runtime settings are good enough
if (versionInfo.javaVersion == null || versionInfo.javaVersion.component.equalsIgnoreCase("jre-legacy"))
return true;

Expand All @@ -63,18 +67,18 @@ public static boolean installJre21IfNeeded(Activity activity, JMinecraftVersionL

String appropriateRuntime = MultiRTUtils.getNearestJreName(versionInfo.javaVersion.majorVersion);
if (appropriateRuntime != null) {
if (JRE21Util.isInternalJRE21(appropriateRuntime)) {
JRE21Util.checkInternalJre21(activity.getAssets());
if (JRE17Util.isInternalNewJRE(appropriateRuntime)) {
JRE17Util.checkInternalNewJre(activity.getAssets());
}
minecraftProfile.javaDir = Tools.LAUNCHERPROFILES_RTPREFIX + appropriateRuntime;
LauncherProfiles.load();
} else {
if (versionInfo.javaVersion.majorVersion <= 17) {
if (!JRE21Util.checkInternalJre21(activity.getAssets())){
if (versionInfo.javaVersion.majorVersion <= 17) { // there's a chance we have an internal one for this case
if (!JRE17Util.checkInternalNewJre(activity.getAssets())){
showRuntimeFail(activity, versionInfo);
return false;
} else {
minecraftProfile.javaDir = Tools.LAUNCHERPROFILES_RTPREFIX + JRE21Util.JRE_21_NAME;
minecraftProfile.javaDir = Tools.LAUNCHERPROFILES_RTPREFIX + JRE17Util.NEW_JRE_NAME;
LauncherProfiles.load();
}
} else {
Expand All @@ -91,4 +95,4 @@ private static void showRuntimeFail(Activity activity, JMinecraftVersionList.Ver
activity.getString(R.string.multirt_nocompatiblert, verInfo.javaVersion.majorVersion));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public void onCreate() {
.concat("/x86");
}
AsyncAssetManager.unpackRuntime(getAssets());
AsyncAssetManager.unpackRuntime17(getAssets());
} catch (Throwable throwable) {
Intent ferrorIntent = new Intent(this, FatalErrorActivity.class);
ferrorIntent.putExtra("throwable", throwable);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.kdt.pojavlaunch.tasks;


import static net.kdt.pojavlaunch.Architecture.archAsString;
import static net.kdt.pojavlaunch.JRE21Util.checkInternalJre21;
import static net.kdt.pojavlaunch.PojavApplication.sExecutorService;

import android.content.Context;
Expand Down Expand Up @@ -31,14 +31,14 @@ private AsyncAssetManager(){}
public static void unpackRuntime(AssetManager am) {
/* Check if JRE is included */
String rt_version = null;
String current_rt_version = MultiRTUtils.__internal__readBinpackVersion("Internal-8");
String current_rt_version = MultiRTUtils.__internal__readBinpackVersion("Internal");
try {
rt_version = Tools.read(am.open("components/jre-8/version"));
rt_version = Tools.read(am.open("components/jre/version"));
} catch (IOException e) {
Log.e("JREAuto", "JRE was not included on this APK.", e);
}
String exactJREName = MultiRTUtils.getExactJreName(8);
if(current_rt_version == null && exactJREName != null && !exactJREName.equals("Internal-8")/*this clause is for when the internal runtime is goofed*/) return;
if(current_rt_version == null && exactJREName != null && !exactJREName.equals("Internal")/*this clause is for when the internal runtime is goofed*/) return;
if(rt_version == null) return;
if(rt_version.equals(current_rt_version)) return;

Expand All @@ -48,43 +48,13 @@ public static void unpackRuntime(AssetManager am) {

try {
MultiRTUtils.installRuntimeNamedBinpack(
am.open("components/jre-8/universal.tar.xz"),
am.open("components/jre-8/bin-" + archAsString(Tools.DEVICE_ARCHITECTURE) + ".tar.xz"),
"Internal-8", finalRt_version);
MultiRTUtils.postPrepare("Internal-8");
}catch (IOException e) {
Log.e("JREAuto", "Internal-8 JRE unpack failed", e);
}
});
}

public static void unpackRuntime17(AssetManager am) {
String rt_version = null;
String current_rt_version = MultiRTUtils.__internal__readBinpackVersion("Internal-17");
try {
rt_version = Tools.read(am.open("components/jre-17/version"));
} catch (IOException e) {
Log.e("JREAuto", "JRE was not included on this APK.", e);
}
String exactJREName = MultiRTUtils.getExactJreName(17);
if(current_rt_version == null && exactJREName != null && !exactJREName.equals("Internal-17")) return;
if(rt_version == null) return;
if(rt_version.equals(current_rt_version)) return;

String finalRt_version = rt_version;
sExecutorService.execute(() -> {

try {
MultiRTUtils.installRuntimeNamedBinpack(
am.open("components/jre-17/universal.tar.xz"),
am.open("components/jre-17/bin-" + archAsString(Tools.DEVICE_ARCHITECTURE) + ".tar.xz"),
"Internal-17", finalRt_version);
MultiRTUtils.postPrepare("Internal-17");
am.open("components/jre/universal.tar.xz"),
am.open("components/jre/bin-" + archAsString(Tools.DEVICE_ARCHITECTURE) + ".tar.xz"),
"Internal", finalRt_version);
MultiRTUtils.postPrepare("Internal");
}catch (IOException e) {
Log.e("JREAuto", "Internal-17 JRE unpack failed", e);
Log.e("JREAuto", "Internal JRE unpack failed", e);
}

checkInternalJre21(am);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import net.kdt.pojavlaunch.JAssetInfo;
import net.kdt.pojavlaunch.JAssets;
import net.kdt.pojavlaunch.JMinecraftVersionList;
import net.kdt.pojavlaunch.JRE21Util;
import net.kdt.pojavlaunch.JRE17Util;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.mirrors.DownloadMirror;
Expand Down Expand Up @@ -203,7 +203,7 @@ private boolean downloadAndProcessMetadata(Activity activity, JMinecraftVersionL
throw new IOException("Unable to read Version JSON for version " + versionName);
}

if(activity != null && !JRE21Util.installJre21IfNeeded(activity, verInfo)){
if(activity != null && !JRE17Util.installNewJreIfNeeded(activity, verInfo)){
return false;
}

Expand Down
Loading
Loading