Skip to content

Commit

Permalink
implement enough to launch 2.2 (#2)
Browse files Browse the repository at this point in the history
* generic maintenance and allow armv8

* implement missing java functions

* Update build.yml

* add missing audiodevice code

* split apk support

* ignore (gitignore)

* replace library load with native code

* set supported abis again

---------

Co-authored-by: alk <45172705+altalk23@users.noreply.github.com>
  • Loading branch information
qimiko and altalk23 authored Dec 22, 2023
1 parent c08ae0e commit c854700
Show file tree
Hide file tree
Showing 24 changed files with 521 additions and 251 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build launcher
on:
workflow_dispatch:
push:
branches: ["main"]
branches: '*'

jobs:
build:
Expand Down
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/*
.DS_Store
/build
/captures
Expand Down
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

123 changes: 0 additions & 123 deletions .idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

20 changes: 0 additions & 20 deletions .idea/gradle.xml

This file was deleted.

23 changes: 0 additions & 23 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/kotlinc.xml

This file was deleted.

31 changes: 0 additions & 31 deletions .idea/misc.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

15 changes: 7 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
defaultConfig {
applicationId "com.geode.launcher"
minSdk 23
targetSdk 33
targetSdk 34
versionCode 1
versionName "0.6.0-alpha.1"

Expand All @@ -21,8 +21,8 @@ android {
arguments "-DDOBBY_DEBUG=OFF"
}
}
// support only armv7 as GD only supports armv7
ndkConfig.abiFilters "armeabi-v7a"

ndkConfig.abiFilters "arm64-v8a", "armeabi-v7a"
}

buildTypes {
Expand Down Expand Up @@ -62,14 +62,13 @@ android {
dependencies {
implementation 'androidx.core:core-ktx:1.12.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation 'androidx.compose.material3:material3:1.1.1'
implementation 'androidx.compose.material3:material3:1.1.2'
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
implementation 'androidx.activity:activity-compose:1.7.2'
implementation 'androidx.activity:activity-ktx:1.7.2'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.activity:activity-ktx:1.8.2'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation files('../libs/fmod.jar')
implementation 'com.google.android.material:material:1.11.0'
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
4 changes: 3 additions & 1 deletion app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ if(NOT dobby_POPULATED)
add_subdirectory("${dobby_SOURCE_DIR}" ${dobby_BINARY_DIR} EXCLUDE_FROM_ALL)
target_include_directories(launcherfix PRIVATE ${dobby_SOURCE_DIR}/include)
target_link_libraries(launcherfix dobby)
endif()
endif()

target_link_libraries(launcherfix log)
44 changes: 43 additions & 1 deletion app/src/main/cpp/launcher-fix.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#include <android/dlext.h>
#include <android/log.h>
#include <dlfcn.h>
#include <jni.h>
#include <string>
#include <unistd.h>

#ifndef DISABLE_LAUNCHER_FIX
#include <dobby.h>
#include <jni.h>
#endif

class DataPaths {
public:
Expand All @@ -27,6 +33,8 @@ JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setDataPath(
auto data_path_str = env->GetStringUTFChars(data_path, &is_copy);

DataPaths::get_instance().data_path = std::string(data_path_str);

env->ReleaseStringUTFChars(data_path, data_path_str);
}

extern "C"
Expand All @@ -39,6 +47,38 @@ JNIEXPORT void JNICALL Java_com_geode_launcher_LauncherFix_setOriginalDataPath(
auto data_path_str = env->GetStringUTFChars(data_path, &is_copy);

DataPaths::get_instance().original_data_path = std::string(data_path_str);

env->ReleaseStringUTFChars(data_path, data_path_str);
}

extern "C"
JNIEXPORT jboolean JNICALL Java_com_geode_launcher_LauncherFix_loadLibraryFromOffset(JNIEnv *env, jobject, jstring library_name, jint fd, jlong offset) {
// loads a given library at an offset and file descriptor
// assumes we have ownership of the file passed in fd

auto is_copy = jboolean();
auto library_cname = env->GetStringUTFChars(library_name, &is_copy);

android_dlextinfo ext_info{};
ext_info.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET;
ext_info.library_fd = fd;
ext_info.library_fd_offset = offset;

auto handle = android_dlopen_ext(library_cname, RTLD_NOW | RTLD_GLOBAL, &ext_info);
env->ReleaseStringUTFChars(library_name, library_cname);
close(fd);

if (handle == nullptr) {
auto error = dlerror();
__android_log_print(ANDROID_LOG_WARN, "GeodeLauncher-Fix", "dlopen_ext failed. given: %s\n", error);

return false;
}

// we don't need the library anymore
dlclose(handle);

return true;
}

FILE* (*fopen_original)(const char *pathname, const char *mode);
Expand All @@ -60,11 +100,13 @@ FILE* fopen_hook(const char* pathname, const char* mode) {
}

[[gnu::constructor]] [[gnu::used]] void setup_hooks() {
#ifndef DISABLE_LAUNCHER_FIX
auto fopen_addr = dlsym(RTLD_NEXT, "fopen");

DobbyHook(
fopen_addr,
reinterpret_cast<dobby_dummy_func_t>(&fopen_hook),
reinterpret_cast<dobby_dummy_func_t*>(&fopen_original)
);
#endif
}
Loading

0 comments on commit c854700

Please sign in to comment.