mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-28 01:59:50 +00:00
load geode by system abi
This commit is contained in:
2 files changed
+24
-16
No files matched your search
@@ -128,15 +128,13 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
// these libraries are available to the application after merging
|
// these libraries are available to the application after merging
|
||||||
|
|
||||||
// find the first instance of the library in preferred abi order
|
// find the first instance of the library in preferred abi order
|
||||||
val libraryFd = Build.SUPPORTED_ABIS.asSequence()
|
val arch = LaunchUtils.getApplicationArchitecture()
|
||||||
.mapNotNull {
|
|
||||||
try {
|
val libraryFd = try {
|
||||||
assets.openNonAssetFd("lib/$it/lib$libraryName.so")
|
assets.openNonAssetFd("lib/$arch/lib$libraryName.so")
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
null
|
throw UnsatisfiedLinkError("Could not find library lib$libraryName.so for abi $arch")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.firstOrNull() ?: throw UnsatisfiedLinkError("Could not find library lib$libraryName.so")
|
|
||||||
|
|
||||||
val fdOffset = libraryFd.startOffset
|
val fdOffset = libraryFd.startOffset
|
||||||
val fdDescriptor = libraryFd.parcelFileDescriptor.detachFd()
|
val fdDescriptor = libraryFd.parcelFileDescriptor.detachFd()
|
||||||
@@ -166,15 +164,12 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
System.load(geodePath.path)
|
System.load(geodePath.path)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// you know zmx i have 0 clue what this does so im
|
// you know zmx i have 0 clue what this does so im
|
||||||
// just gonna like copy the binary from external
|
// just gonna like copy the binary from external
|
||||||
// also i get 20 million permission denied errors
|
// also i get 20 million permission denied errors
|
||||||
getExternalFilesDir(null)?.let { dir ->
|
getExternalFilesDir(null)?.let { dir ->
|
||||||
val externalGeodePath = LaunchUtils.getInstalledGeodePath(this)
|
val externalGeodePath = LaunchUtils.getInstalledGeodePath(this) ?: return false
|
||||||
if (externalGeodePath == null) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
val copiedPath = File(filesDir.path, "copied")
|
val copiedPath = File(filesDir.path, "copied")
|
||||||
if (copiedPath.exists()) {
|
if (copiedPath.exists()) {
|
||||||
@@ -197,7 +192,7 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.geode.launcher.utils
|
package com.geode.launcher.utils
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.pm.PackageInfo
|
import android.content.pm.PackageInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
object LaunchUtils {
|
object LaunchUtils {
|
||||||
@@ -16,18 +18,28 @@ object LaunchUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getApplicationArchitecture(): String {
|
||||||
|
// supposedly CPU_ABI returns the current arch for the running application
|
||||||
|
// despite being deprecated, this is also one of the few ways to get this information
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
return Build.CPU_ABI
|
||||||
|
}
|
||||||
|
|
||||||
fun getInstalledGeodePath(context: Context): File? {
|
fun getInstalledGeodePath(context: Context): File? {
|
||||||
val internalGeodePath = File(context.filesDir.path, "launcher/Geode.so")
|
val arch = getApplicationArchitecture()
|
||||||
|
val geodeName = "Geode.$arch.so"
|
||||||
|
|
||||||
|
val internalGeodePath = File(context.filesDir.path, "launcher/$geodeName")
|
||||||
if (internalGeodePath.exists()) {
|
if (internalGeodePath.exists()) {
|
||||||
return internalGeodePath
|
return internalGeodePath
|
||||||
}
|
}
|
||||||
context.getExternalFilesDir(null)?.let { dir->
|
context.getExternalFilesDir(null)?.let { dir->
|
||||||
val updateGeodePath = File(dir.path, "game/geode/update/Geode.so")
|
val updateGeodePath = File(dir.path, "game/geode/update/$geodeName")
|
||||||
if (updateGeodePath.exists()) {
|
if (updateGeodePath.exists()) {
|
||||||
return updateGeodePath
|
return updateGeodePath
|
||||||
}
|
}
|
||||||
|
|
||||||
val externalGeodePath = File(dir.path, "Geode.so")
|
val externalGeodePath = File(dir.path, geodeName)
|
||||||
if (externalGeodePath.exists()) {
|
if (externalGeodePath.exists()) {
|
||||||
return externalGeodePath
|
return externalGeodePath
|
||||||
}
|
}
|
||||||
@@ -39,6 +51,7 @@ object LaunchUtils {
|
|||||||
return getInstalledGeodePath(context) != null
|
return getInstalledGeodePath(context) != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("DiscouragedPrivateApi")
|
||||||
fun addAssetsFromPackage(assetManager: AssetManager, packageInfo: PackageInfo) {
|
fun addAssetsFromPackage(assetManager: AssetManager, packageInfo: PackageInfo) {
|
||||||
// this method is officially marked as deprecated but it is the only method we are allowed to reflect
|
// this method is officially marked as deprecated but it is the only method we are allowed to reflect
|
||||||
// (the source recommends replacing with AssetManager.setApkAssets(ApkAssets[], boolean) lol)
|
// (the source recommends replacing with AssetManager.setApkAssets(ApkAssets[], boolean) lol)
|
||||||
|
|||||||
Reference in new issue
Block a user