Compare commits

..
Author SHA1 Message Date
artdeell ba39cd7213 Revert[build]: downgrade bytehook 2025-01-23 20:14:46 +03:00
artdeell 91b6820410 Tweak[jre_launcher]: even better sigabrt reporting(maybe) 2025-01-23 20:11:05 +03:00
artdeell 88cadf9626 Chore[build]: next codename 2025-01-17 08:34:56 +03:00
artdeell 06c8930288 Fix[workflow]: update upload-artifact to v4 2025-01-16 21:57:15 +03:00
artdeell 090bb0ab41 Hack[jre_launcher]: raise SIGSEGV in abort handler to get backtrace 2025-01-16 21:55:38 +03:00
artdeell d3cdc8ee2c Feat[touch_char_input]: directly modify the Editable instead of relying on the internal TextView methods. 2025-01-15 20:22:01 +03:00
artdeell 2275ac5e27 Fix[file_provider]: check for storage before initializing 2025-01-15 18:40:44 +03:00
artdeell 6ed5f7c953 Fix[fabriclike_install]: ensure array readiness before creating adapter 2025-01-15 18:22:42 +03:00
artdeell 5067dba275 Fix[storage]: fix previous commit not starting the game 2025-01-15 18:06:04 +03:00
artdeell f446e11bd7 Fix[storage]: better ensure mounted storage
Avoids several crashes caused by Pojav running on devices without always-mounted external storage.
2025-01-15 17:55:03 +03:00
artdeell e6ccde2343 Fix[exit_hook]: move exit hook into a separate library
Fixes an issue on some devices where namespacing issues caused libbytehook to not be found when pojavexec was loaded by LWJGL.
2025-01-15 16:58:35 +03:00
artdeell 9514685337 Fix[touch_char_input]: use TextWatcher instead of onTextChanged override
Avoids a bug on some devices caused by setText called by the framework early
2025-01-15 16:07:35 +03:00
9 changed files with 75 additions and 98 deletions

No files matched your search

+3 -3
View File
@@ -111,13 +111,13 @@ jobs:
md5sum out/app-debug-noruntime.apk > out/app-debug-noruntime.md5
- name: Upload APK
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: app-debug
path: out/app-debug.*
- name: Upload AAB
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: app-release-aab
path: out/app-gplay.aab
@@ -134,7 +134,7 @@ jobs:
inAppUpdatePriority: 5
- name: Upload APK (without runtime)
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: app-debug-noruntime
path: out/app-debug-noruntime.*
@@ -654,27 +654,37 @@ public final class Tools {
}
public static void setFullscreen(Activity activity, boolean fullscreen) {
final View decorView = activity.getWindow().getDecorView();
View.OnSystemUiVisibilityChangeListener visibilityChangeListener = visibility -> {
boolean multiWindowMode = SDK_INT >= 24 && activity.isInMultiWindowMode();
// When in multi-window mode, asking for fullscreen makes no sense (cause the launcher runs in a window)
// So, ignore the fullscreen setting when activity is in multi window mode
if(fullscreen && !multiWindowMode){
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}else{
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
WindowInsetsControllerCompat windowInsetsController =
WindowCompat.getInsetsController(activity.getWindow(), activity.getWindow().getDecorView());
if (windowInsetsController == null) {
Log.w(APP_NAME, "WindowInsetsController is null, cannot set fullscreen");
return;
}
// Configure the behavior of the hidden system bars.
windowInsetsController.setSystemBarsBehavior(
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
);
ViewCompat.setOnApplyWindowInsetsListener(
activity.getWindow().getDecorView(),
(view, windowInsets) -> {
boolean fullscreenImpl = fullscreen;
if (SDK_INT >= Build.VERSION_CODES.N && activity.isInMultiWindowMode())
fullscreenImpl = false;
if (fullscreenImpl) {
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
} else {
windowInsetsController.show(WindowInsetsCompat.Type.systemBars());
}
if(SDK_INT >= Build.VERSION_CODES.R)
activity.getWindow().setDecorFitsSystemWindows(!fullscreenImpl);
return ViewCompat.onApplyWindowInsets(view, windowInsets);
});
};
decorView.setOnSystemUiVisibilityChangeListener(visibilityChangeListener);
visibilityChangeListener.onSystemUiVisibilityChange(decorView.getSystemUiVisibility()); //call it once since the UI state may not change after the call, so the activity wont become fullscreen
}
public static DisplayMetrics currentDisplayMetrics;
@@ -80,10 +80,6 @@ public class ControlLayout extends FrameLayout {
}
public void loadLayout(CustomControls controlLayout) {
boolean sanitizedModified = false;
if(controlLayout != null) {
sanitizedModified = LayoutSanitizer.sanitizeLayout(controlLayout);
}
if(mActionRow == null){
mActionRow = new ActionRow(getContext());
addView(mActionRow);
@@ -122,7 +118,7 @@ public class ControlLayout extends FrameLayout {
mLayout.scaledAt = LauncherPreferences.PREF_BUTTONSIZE;
setModified(sanitizedModified);
setModified(false);
mButtons = null;
getButtonChildren(); // Force refresh
} // loadLayout
@@ -1,52 +0,0 @@
package net.kdt.pojavlaunch.customcontrols;
import java.util.Iterator;
import java.util.List;
public class LayoutSanitizer {
// Maybe add more conditions here later?
private static boolean isInvalidFormula(String formula) {
return formula.contains("Infinity");
}
private static boolean isSaneData(ControlData controlData) {
if(controlData.getWidth() == 0 || controlData.getHeight() == 0) return false;
if(isInvalidFormula(controlData.dynamicX) || isInvalidFormula(controlData.dynamicY)) return false;
return true;
}
private static ControlData getControlData(Object dataEntry) {
if(dataEntry instanceof ControlData) {
return (ControlData) dataEntry;
}else if(dataEntry instanceof ControlDrawerData) {
return ((ControlDrawerData) dataEntry).properties;
}else throw new RuntimeException("Encountered wrong type during ControlData sanitization");
}
private static boolean sanitizeList(List<?> controlDataList) {
boolean madeChanges = false;
Iterator<?> iterator = controlDataList.iterator();
while(iterator.hasNext()) {
ControlData controlData = getControlData(iterator.next());
if(!isSaneData(controlData)) {
madeChanges = true;
iterator.remove();
}
}
return madeChanges;
}
/**
* Check all buttons in a control layout and ensure they're sane (contain values valid enough
* to be displayed properly). Removes any buttons deemed not sane.
* @param controls the original control layout.
* @return whether the sanitization process made any changes to the layout
*/
public static boolean sanitizeLayout(CustomControls controls) {
boolean madeChanges = sanitizeList(controls.mControlDataList);
if(sanitizeList(controls.mDrawerDataList)) madeChanges = true;
if(sanitizeList(controls.mJoystickDataList)) madeChanges = true;
return madeChanges;
}
}
@@ -23,8 +23,6 @@ public class CustomSeekBarPreference extends SeekBarPreference {
private int mMin;
/** The textview associated by default to the preference */
private TextView mTextView;
/** Seekbar increment in case the max gets set */
private final int mIncrement;
@SuppressLint("PrivateResource")
@@ -33,7 +31,6 @@ public class CustomSeekBarPreference extends SeekBarPreference {
try (TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.SeekBarPreference, defStyleAttr, defStyleRes)) {
mMin = a.getInt(R.styleable.SeekBarPreference_min, 0);
mIncrement = a.getInt(R.styleable.SeekBarPreference_seekBarIncrement, 0);
}
}
@@ -114,12 +111,7 @@ public class CustomSeekBarPreference extends SeekBarPreference {
*/
public void setRange(int min, int max){
setMin(min);
setMaxKeepIncrement(max);
}
public void setMaxKeepIncrement(int max) {
super.setMax(max);
setSeekBarIncrement(mIncrement);
setMax(max);
}
@@ -141,14 +141,14 @@ public class LauncherPreferences {
*/
private static int findBestRAMAllocation(Context ctx){
int deviceRam = Tools.getTotalDeviceMemory(ctx);
if (deviceRam < 1024) return 296;
if (deviceRam < 1536) return 448;
if (deviceRam < 2048) return 656;
if (deviceRam < 1024) return 300;
if (deviceRam < 1536) return 450;
if (deviceRam < 2048) return 600;
// Limit the max for 32 bits devices more harshly
if (is32BitsDevice()) return 696;
if (is32BitsDevice()) return 700;
if (deviceRam < 3064) return 936;
if (deviceRam < 4096) return 1144;
if (deviceRam < 4096) return 1148;
if (deviceRam < 6144) return 1536;
return 2048; //Default RAM allocation for 64 bits
}
@@ -38,7 +38,7 @@ public class LauncherPreferenceJavaFragment extends LauncherPreferenceFragment {
if(is32BitsDevice() || deviceRam < 2048) maxRAM = Math.min(1024, deviceRam);
else maxRAM = deviceRam - (deviceRam < 3064 ? 800 : 1024); //To have a minimum for the device to breathe
memorySeekbar.setMaxKeepIncrement(maxRAM);
memorySeekbar.setMax(maxRAM);
memorySeekbar.setValue(ramAllocation);
memorySeekbar.setSuffix(" MB");
+18 -1
View File
@@ -37,6 +37,22 @@ static void custom_atexit() {
nominal_exit(0, false);
}
typedef void (*android_set_abort_message_t)(const char* msg);
// Writes a string constant into stdout in a signal-safe fashion
#define PRINT_SIGSAFE(x) do { \
const char *msg = x; \
write(STDOUT_FILENO, msg, sizeof(msg));\
} while(0)
static void custom_set_abort_message(const char* amsg) {
PRINT_SIGSAFE("Abort message: ");
PRINT_SIGSAFE(amsg);
PRINT_SIGSAFE("\n");
BYTEHOOK_CALL_PREV(custom_set_abort_message, android_set_abort_message_t, amsg);
BYTEHOOK_POP_STACK();
}
static bool init_exit_hook() {
void* bytehook_handle = dlopen("libbytehook.so", RTLD_NOW);
if(bytehook_handle == NULL) {
@@ -56,7 +72,8 @@ static bool init_exit_hook() {
int bhook_status = bytehook_init_p(BYTEHOOK_MODE_AUTOMATIC, false);
if(bhook_status == BYTEHOOK_STATUS_CODE_OK) {
bytehook_stub_t stub = bytehook_hook_all_p(NULL, "exit", &custom_exit, NULL, NULL);
__android_log_print(ANDROID_LOG_INFO, "exit_hook", "Successfully initialized exit hook, stub=%p", stub);
bytehook_stub_t stub2 = bytehook_hook_all_p(NULL, "android_set_abort_message", &custom_set_abort_message, NULL, NULL);
__android_log_print(ANDROID_LOG_INFO, "exit_hook", "Successfully initialized exit hook, stub=%p %p", stub, stub2);
return true;
} else {
__android_log_print(ANDROID_LOG_INFO, "exit_hook", "bytehook_init failed (%i)", bhook_status);
+16 -2
View File
@@ -82,8 +82,19 @@ _Noreturn static void* abort_waiter_thread(void* extraArg) {
// Die
nominal_exit(signal, true);
}
static bool signal_vm_first = true;
_Noreturn static void abort_waiter_handler(int signal) {
int (*JVM_HANDLE_XXX_SIGNAL)(int sig, siginfo_t* info,
void* ucVoid, int abort_if_unrecognized);
_Noreturn static void abort_waiter_siginfo(int signal, siginfo_t* siginfo, void* ucVoid) {
if(signal_vm_first) {
signal_vm_first = false;
// This is nasty and evil, but does work
JVM_HANDLE_XXX_SIGNAL(signal, siginfo, ucVoid, 1);
// We are supposed to die after this but yeah
while(1) {}
}
// Write the final signal into the pipe and block forever.
write(abort_waiter_data.pipe[1], &signal, sizeof(int));
while(1) {}
@@ -99,7 +110,8 @@ static void abort_waiter_setup() {
sigemptyset(&abort_waiter_data.tracked_sigset);
for(size_t i = 0; i < ntracked; i++) {
sigaddset(&abort_waiter_data.tracked_sigset, tracked_signals[i]);
sigactions[i].sa_handler = abort_waiter_handler;
sigactions[i].sa_sigaction = abort_waiter_siginfo;
sigactions[i].sa_flags = SA_SIGINFO | SA_ONSTACK;
}
if(pipe(abort_waiter_data.pipe) != 0) {
printf("Failed to set up aborter pipe: %s\n", strerror(errno));
@@ -123,6 +135,8 @@ static void abort_waiter_setup() {
static jint launchJVM(int margc, char** margv) {
void* libjli = dlopen("libjli.so", RTLD_LAZY | RTLD_GLOBAL);
void* libjvm = dlopen("libjvm.so", RTLD_NOLOAD);
JVM_HANDLE_XXX_SIGNAL = dlsym(libjvm, "JVM_handle_linux_signal");
// Unset all signal handlers to create a good slate for JVM signal detection.
struct sigaction clean_sa;