Skip to content

Commit

Permalink
Update from upstream
Browse files Browse the repository at this point in the history
or at least try to update from upstream

Use this if the upd33 branch doesn't work
  • Loading branch information
SolDev69 committed Nov 7, 2024
2 parents 11bbbc3 + ce2d81e commit a3178c4
Show file tree
Hide file tree
Showing 85 changed files with 1,673 additions and 1,005 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
open_collective: pojavlauncher
patreon: pojavlauncher
827 changes: 159 additions & 668 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ SolCraftLauncher is a fork of PojavLauncher with more technical added features,

* It can run almost every version of Minecraft, allowing you to use .jar only installers to install modloaders such as [Forge](https://files.minecraftforge.net/) and [Fabric](http://fabricmc.net/), mods like [OptiFine](https://optifine.net) and [LabyMod](https://www.labymod.net/en), as well as hack clients like [Wurst](https://www.wurstclient.net/), and much more!

* For more details [check out our wiki](https://github.com/PojavLauncherTeam/PojavLauncher/wiki)
* For more details [check out our wiki](https://pojavlauncherteam.github.io/)
## Some notes to start with
- We do not have an official TikTok account. No one from the dev team makes TikTok videos.
- The official Twitter for PojavLauncher is [@PLaunchTeam](https://twitter.com/PLaunchTeam). Any others (most notably @PojavLauncher) are fake, please report them to Twitter's moderation team.
- The official Twitter for PojavLauncher is [@PLaunchTeam](https://twitter.com/PLaunchTeam). Any others (most notably @PojavLauncher) are fake.

## Navigation
- [Introduction](#introduction)
Expand Down
6 changes: 3 additions & 3 deletions app_pojavlauncher/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ configurations {
android {
namespace 'net.kdt.pojavlaunch'

compileSdk = 33
compileSdk = 34

lintOptions {
abortOnError false
Expand All @@ -114,7 +114,7 @@ android {
defaultConfig {
applicationId "net.kdt.pojavlaunch"
minSdkVersion 21
targetSdkVersion 33
targetSdkVersion 34
versionCode getDateSeconds()
versionName getVersionName()
multiDexEnabled true //important
Expand Down Expand Up @@ -203,7 +203,7 @@ dependencies {
implementation 'com.github.PojavLauncherTeam:portrait-sdp:ed33e89cbc'
implementation 'com.github.PojavLauncherTeam:portrait-ssp:6c02fd739b'
implementation 'com.github.Mathias-Boulay:ExtendedView:1.0.0'
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:06184ddbce'
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:2.0.3'
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:2e7aa25e50'

// implementation 'com.intuit.sdp:sdp-android:1.0.5'
Expand Down
13 changes: 9 additions & 4 deletions app_pojavlauncher/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/>

<application
android:name=".PojavApplication"
Expand Down Expand Up @@ -119,10 +121,13 @@
</intent-filter>
</provider>

<service android:name=".services.ProgressService" />
<service
android:name=".services.GameService"
android:process=":game" />
<service android:name=".services.ProgressService"
android:foregroundServiceType="dataSync"/>
<service android:name=".services.GameService" android:process=":game"
android:foregroundServiceType="specialUse">
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="This application is intended to run a 3rd-party piece of software which cannot be managed using the activity's saved instance state. This service is used for background persistence of this piece of software."/>
</service>
</application>
<queries>
<package android:name="net.kdt.pojavlaunch.ffmpeg"/>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1731000005291
1720909595576
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ public class Architecture {
public static final int ARCH_X86 = 0x4;
public static final int ARCH_X86_64 = 0x8;

/* On both 32-bit ARM and x86, the top 1GB is reserved for kernel use. */
public static final long ADDRESS_SPACE_LIMIT_32_BIT = 0xbfffffffL;
/*
* Technically, this is supposed to be 48 bits on x86_64, but nobody's allocating
* 524288 terabytes of RAM on Pojav any time soon.
*/
public static final long ADDRESS_SPACE_LIMIT_64_BIT = 0x7fffffffffL;

/**
* Get the highest byte accessible within the process's address space.
* @return the highest byte accessible within the process's address space.
*/
public static long getAddressSpaceLimit() {
return is64BitsDevice() ? ADDRESS_SPACE_LIMIT_64_BIT : ADDRESS_SPACE_LIMIT_32_BIT;
}

/**
* Tell us if the device supports 64 bits architecture
* @return If the device supports 64 bits architecture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static void execKeyIndex(int index){
sendKeyPress(getValueByIndex(index));
}

public static int getValueByIndex(int index) {
public static short getValueByIndex(int index) {
return sLwjglKeycodes[index];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;

Expand All @@ -21,21 +20,26 @@ public class ExitActivity extends AppCompatActivity {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int code = -1;
boolean isSignal = false;
Bundle extras = getIntent().getExtras();
if(extras != null) {
code = extras.getInt("code",-1);
isSignal = extras.getBoolean("isSignal", false);
}

int message = isSignal ? R.string.mcn_signal_title : R.string.mcn_exit_title;

new AlertDialog.Builder(this)
.setMessage(getString(R.string.mcn_exit_title,code))
.setMessage(getString(message,code))
.setPositiveButton(R.string.main_share_logs, (dialog, which) -> shareLog(this))
.setOnDismissListener(dialog -> ExitActivity.this.finish())
.show();
}

public static void showExitMessage(Context ctx, int code) {
public static void showExitMessage(Context ctx, int code, boolean isSignal) {
Intent i = new Intent(ctx,ExitActivity.class);
i.putExtra("code",code);
i.putExtra("isSignal", isSignal);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.widget.Toast;

import androidx.activity.OnBackPressedCallback;
import androidx.appcompat.app.AlertDialog;

import com.kdt.LoggerView;

Expand Down Expand Up @@ -185,6 +186,7 @@ private void startModInstallerWithUri(Uri uri) {
try {
File cacheFile = new File(getCacheDir(), "mod-installer-temp");
InputStream contentStream = getContentResolver().openInputStream(uri);
if(contentStream == null) throw new IOException("Failed to open content stream");
try (FileOutputStream fileOutputStream = new FileOutputStream(cacheFile)) {
IOUtils.copy(contentStream, fileOutputStream);
}
Expand All @@ -195,23 +197,71 @@ private void startModInstallerWithUri(Uri uri) {
}
}

public Runtime selectRuntime(File modFile) {
int javaVersion = getJavaVersion(modFile);
if(javaVersion == -1) {
finalErrorDialog(getString(R.string.execute_jar_failed_to_read_file));
return null;
}
String nearestRuntime = MultiRTUtils.getNearestJreName(javaVersion);
if(nearestRuntime == null) {
finalErrorDialog(getString(R.string.multirt_nocompatiblert, javaVersion));
return null;
}
Runtime selectedRuntime = MultiRTUtils.forceReread(nearestRuntime);
int selectedJavaVersion = Math.max(javaVersion, selectedRuntime.javaVersion);
// Don't allow versions higher than Java 17 because our caciocavallo implementation does not allow for it
if(selectedJavaVersion > 17) {
finalErrorDialog(getString(R.string.execute_jar_incompatible_runtime, selectedJavaVersion));
return null;
}
return selectedRuntime;
}

private File findModPath(List<String> argList) {
int argsSize = argList.size();
for(int i = 0; i < argsSize; i++) {
// Look for the -jar argument
if(!argList.get(i).equals("-jar")) continue;
int pathIndex = i+1;
// Check if the supposed path is out of the argument bounds
if(pathIndex >= argsSize) return null;
// Use the path as a file
return new File(argList.get(pathIndex));
}
return null;
}

private void startModInstaller(File modFile, String javaArgs) {
new Thread(() -> {
Runtime runtime = pickJreForMod(modFile);
launchJavaRuntime(runtime, modFile, javaArgs);
// Maybe replace with more advanced arg parsing logic later
List<String> argList = javaArgs != null ? Arrays.asList(javaArgs.split(" ")) : null;
File selectedMod = modFile;
if(selectedMod == null && argList != null) {
// If modFile is not specified directly, try to extract the -jar argument from the javaArgs
selectedMod = findModPath(argList);
}
Runtime selectedRuntime;
if(selectedMod == null) {
// We were unable to find out the path to the mod. In that case, use the default runtime.
selectedRuntime = MultiRTUtils.forceReread(LauncherPreferences.PREF_DEFAULT_RUNTIME);
}else {
// Autoselect it properly in the other case.
selectedRuntime = selectRuntime(selectedMod);
// If the selection failed, just return. The autoselect function has already shown the dialog.
if(selectedRuntime == null) return;
}
launchJavaRuntime(selectedRuntime, modFile, argList);
}, "JREMainThread").start();
}

private Runtime pickJreForMod(File modFile) {
String jreName = LauncherPreferences.PREF_DEFAULT_RUNTIME;
if(modFile != null) {
int javaVersion = getJavaVersion(modFile);
if(javaVersion != -1) {
String autoselectRuntime = MultiRTUtils.getNearestJreName(javaVersion);
if (autoselectRuntime != null) jreName = autoselectRuntime;
}
}
return MultiRTUtils.forceReread(jreName);
private void finalErrorDialog(CharSequence msg) {
runOnUiThread(()-> new AlertDialog.Builder(this)
.setTitle(R.string.global_error)
.setMessage(msg)
.setPositiveButton(android.R.string.ok, (d,w)->this.finish())
.setCancelable(false)
.show());
}

@Override
Expand Down Expand Up @@ -301,21 +351,20 @@ public void toggleVirtualMouse(View v) {
Toast.LENGTH_SHORT).show();
}

public void launchJavaRuntime(Runtime runtime, File modFile, String javaArgs) {
public void launchJavaRuntime(Runtime runtime, File modFile, List<String> javaArgs) {
JREUtils.redirectAndPrintJRELog();
try {
List<String> javaArgList = new ArrayList<>();

// Enable Caciocavallo
Tools.getCacioJavaArgs(javaArgList,runtime.javaVersion == 8);

if (javaArgs != null) {
javaArgList.addAll(Arrays.asList(javaArgs.split(" ")));
} else {
if(javaArgs != null) {
javaArgList.addAll(javaArgs);
}
if(modFile != null) {
javaArgList.add("-jar");
javaArgList.add(modFile.getAbsolutePath());
}


if (LauncherPreferences.PREF_JAVA_SANDBOX) {
Collections.reverse(javaArgList);
Expand Down Expand Up @@ -374,7 +423,7 @@ public int getJavaVersion(File modFile) {
Log.i("JavaGUILauncher", majorVersion+","+minorVersion);
return classVersionToJavaVersion(majorVersion);
}catch (Exception e) {
e.printStackTrace();
Log.e("JavaVersion", "Exception thrown", e);
return -1;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private void runCraft(String versionId, JMinecraftVersionList.Version version) t
Tools.releaseRenderersCache();
}
MinecraftAccount minecraftAccount = PojavProfile.getCurrentProfileContent(this, null);
Logger.appendToLog("--------- beginning with launcher debug");
Logger.appendToLog("--------- Starting game with Launcher Debug!");
printLauncherInfo(versionId, Tools.isValidString(minecraftProfile.javaArgs) ? minecraftProfile.javaArgs : LauncherPreferences.PREF_CUSTOM_JAVA_ARGS);
JREUtils.redirectAndPrintJRELog();
LauncherProfiles.load();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import androidx.annotation.RequiresApi;

import net.kdt.pojavlaunch.customcontrols.ControlLayout;
import net.kdt.pojavlaunch.customcontrols.gamepad.DefaultDataProvider;
import net.kdt.pojavlaunch.customcontrols.gamepad.Gamepad;
import net.kdt.pojavlaunch.customcontrols.mouse.AbstractTouchpad;
import net.kdt.pojavlaunch.customcontrols.mouse.AndroidPointerCapture;
Expand Down Expand Up @@ -62,7 +63,8 @@ public class MinecraftGLSurface extends View implements GrabListener {
.remapLeftShoulder(true)
.remapRightShoulder(true)
.remapLeftTrigger(true)
.remapRightTrigger(true));
.remapRightTrigger(true)
.remapDpad(true));

/* Resolution scaler option, allow downsizing a window */
private final float mScaleFactor = LauncherPreferences.PREF_SCALE_FACTOR/100f;
Expand Down Expand Up @@ -202,6 +204,10 @@ public boolean onTouchEvent(MotionEvent e) {
return mCurrentTouchProcessor.processTouchEvent(e);
}

private void createGamepad(View contextView, InputDevice inputDevice) {
mGamepad = new Gamepad(contextView, inputDevice, DefaultDataProvider.INSTANCE, true);
}

/**
* The event for mouse/joystick movements
*/
Expand All @@ -211,9 +217,7 @@ public boolean dispatchGenericMotionEvent(MotionEvent event) {
int mouseCursorIndex = -1;

if(Gamepad.isGamepadEvent(event)){
if(mGamepad == null){
mGamepad = new Gamepad(this, event.getDevice());
}
if(mGamepad == null) createGamepad(this, event.getDevice());

mInputManager.handleMotionEventInput(getContext(), event, mGamepad);
return true;
Expand Down Expand Up @@ -285,9 +289,7 @@ public boolean processKeyEvent(KeyEvent event) {
}

if(Gamepad.isGamepadEvent(event)){
if(mGamepad == null){
mGamepad = new Gamepad(this, event.getDevice());
}
if(mGamepad == null) createGamepad(this, event.getDevice());

mInputManager.handleKeyEventInput(getContext(), event, mGamepad);
return true;
Expand Down
32 changes: 31 additions & 1 deletion app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import net.kdt.pojavlaunch.lifecycle.ContextExecutor;
import net.kdt.pojavlaunch.lifecycle.ContextExecutorTask;
import net.kdt.pojavlaunch.lifecycle.LifecycleAwareAlertDialog;
import net.kdt.pojavlaunch.memory.MemoryHoleFinder;
import net.kdt.pojavlaunch.memory.SelfMapsParser;
import net.kdt.pojavlaunch.multirt.MultiRTUtils;
import net.kdt.pojavlaunch.multirt.Runtime;
import net.kdt.pojavlaunch.plugins.FFmpegPlugin;
Expand Down Expand Up @@ -170,9 +172,20 @@ public static void initContextConstants(Context ctx){
public static void launchMinecraft(final AppCompatActivity activity, MinecraftAccount minecraftAccount,
MinecraftProfile minecraftProfile, String versionId, int versionJavaRequirement) throws Throwable {
int freeDeviceMemory = getFreeDeviceMemory(activity);
int localeString;
int freeAddressSpace = Architecture.is32BitsDevice() ? getMaxContinuousAddressSpaceSize() : -1;
Log.i("MemStat", "Free RAM: " + freeDeviceMemory + " Addressable: " + freeAddressSpace);
if(freeDeviceMemory > freeAddressSpace && freeAddressSpace != -1) {
freeDeviceMemory = freeAddressSpace;
localeString = R.string.address_memory_warning_msg;
} else {
localeString = R.string.memory_warning_msg;
}

if(LauncherPreferences.PREF_RAM_ALLOCATION > freeDeviceMemory) {
int finalDeviceMemory = freeDeviceMemory;
LifecycleAwareAlertDialog.DialogCreator dialogCreator = (dialog, builder) ->
builder.setMessage(activity.getString(R.string.memory_warning_msg, freeDeviceMemory, LauncherPreferences.PREF_RAM_ALLOCATION))
builder.setMessage(activity.getString(localeString, finalDeviceMemory, LauncherPreferences.PREF_RAM_ALLOCATION))
.setPositiveButton(android.R.string.ok, (d, w)->{});

if(LifecycleAwareAlertDialog.haltOnDialog(activity.getLifecycle(), activity, dialogCreator)) {
Expand Down Expand Up @@ -923,6 +936,23 @@ public static int getFreeDeviceMemory(Context ctx){
return (int) (memInfo.availMem / 1048576L);
}

private static int internalGetMaxContinuousAddressSpaceSize() throws Exception{
MemoryHoleFinder memoryHoleFinder = new MemoryHoleFinder();
new SelfMapsParser(memoryHoleFinder).run();
long largestHole = memoryHoleFinder.getLargestHole();
if(largestHole == -1) return -1;
else return (int)(largestHole / 1048576L);
}

public static int getMaxContinuousAddressSpaceSize() {
try {
return internalGetMaxContinuousAddressSpaceSize();
}catch (Exception e){
Log.w("Tools", "Failed to find the largest uninterrupted address space");
return -1;
}
}

public static int getDisplayFriendlyRes(int displaySideRes, float scaling){
displaySideRes *= scaling;
if(displaySideRes % 2 != 0) displaySideRes --;
Expand Down
Loading

0 comments on commit a3178c4

Please sign in to comment.