mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-21 08:19:33 +00:00
use base directory for geode libraries
This commit is contained in:
3 files changed
+18
-43
No files matched your search
@@ -146,29 +146,6 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
return "$sourceDir!/lib/$architecture/"
|
return "$sourceDir!/lib/$architecture/"
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeDynamicallyLoadedCode")
|
|
||||||
private fun loadLibraryFromAssetsCopy(libraryName: String) {
|
|
||||||
// loads a library loaded in assets
|
|
||||||
// this copies the library to a non-compressed directory
|
|
||||||
|
|
||||||
val arch = LaunchUtils.getApplicationArchitecture()
|
|
||||||
val libraryFd = try {
|
|
||||||
assets.openNonAssetFd("lib/$arch/lib$libraryName.so")
|
|
||||||
} catch (_: Exception) {
|
|
||||||
throw UnsatisfiedLinkError("Could not find library lib$libraryName.so for abi $arch")
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy the library to a path we can access
|
|
||||||
// there doesn't seem to be a way to load a library from a file descriptor
|
|
||||||
val libraryCopy = File(cacheDir, "lib$libraryName.so")
|
|
||||||
val libraryOutput = libraryCopy.outputStream()
|
|
||||||
DownloadUtils.copyFile(libraryFd.createInputStream(), libraryOutput)
|
|
||||||
|
|
||||||
System.load(libraryCopy.path)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("UnsafeDynamicallyLoadedCode")
|
@SuppressLint("UnsafeDynamicallyLoadedCode")
|
||||||
private fun loadGeodeLibrary(): Boolean {
|
private fun loadGeodeLibrary(): Boolean {
|
||||||
// Load Geode if exists
|
// Load Geode if exists
|
||||||
@@ -189,7 +166,6 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
// 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 ->
|
|
||||||
val externalGeodePath = LaunchUtils.getInstalledGeodePath(this) ?: return false
|
val externalGeodePath = LaunchUtils.getInstalledGeodePath(this) ?: return false
|
||||||
|
|
||||||
val copiedPath = File(filesDir.path, "copied")
|
val copiedPath = File(filesDir.path, "copied")
|
||||||
@@ -198,18 +174,18 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
}
|
}
|
||||||
copiedPath.mkdir()
|
copiedPath.mkdir()
|
||||||
|
|
||||||
val geodePath = File(copiedPath.path, "Geode.so")
|
val copiedGeodePath = File(copiedPath.path, "Geode.so")
|
||||||
|
|
||||||
if (externalGeodePath.exists()) {
|
if (externalGeodePath.exists()) {
|
||||||
DownloadUtils.copyFile(
|
DownloadUtils.copyFile(
|
||||||
FileInputStream(externalGeodePath),
|
FileInputStream(externalGeodePath),
|
||||||
FileOutputStream(geodePath)
|
FileOutputStream(copiedGeodePath)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (geodePath.exists()) {
|
if (copiedGeodePath.exists()) {
|
||||||
try {
|
try {
|
||||||
println("Loading Geode from ${externalGeodePath.name}")
|
println("Loading Geode from ${externalGeodePath.name}")
|
||||||
System.load(geodePath.path)
|
System.load(copiedGeodePath.path)
|
||||||
} catch (e: UnsatisfiedLinkError) {
|
} catch (e: UnsatisfiedLinkError) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
@@ -217,8 +193,6 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,6 +231,7 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
hideSystemUi()
|
hideSystemUi()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
private fun hideSystemUi() {
|
private fun hideSystemUi() {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
// window compat is dumb!!
|
// window compat is dumb!!
|
||||||
@@ -275,6 +250,7 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
private fun setLegacyVisibility() {
|
private fun setLegacyVisibility() {
|
||||||
// setDecorFitsSystemWindows doesn't hide anything
|
// setDecorFitsSystemWindows doesn't hide anything
|
||||||
window.decorView.systemUiVisibility =
|
window.decorView.systemUiVisibility =
|
||||||
@@ -401,13 +377,13 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
}
|
}
|
||||||
testDirPath.mkdir()
|
testDirPath.mkdir()
|
||||||
|
|
||||||
getExternalFilesDir(null)?.let { dir ->
|
val dir = LaunchUtils.getBaseDirectory(this)
|
||||||
val testingPath = dir.path + File.separator + "test" + File.separator
|
val testingPath = File(dir, "test")
|
||||||
|
|
||||||
File(testingPath).walk().forEach {
|
testingPath.walk().forEach {
|
||||||
if (it.isFile) {
|
if (it.isFile) {
|
||||||
// welcome to the world of Android classloader permissions
|
// welcome to the world of Android classloader permissions
|
||||||
val outputFile = File(testDirPath.path + File.separator + it.name)
|
val outputFile = File(testDirPath, it.name)
|
||||||
DownloadUtils.copyFile(
|
DownloadUtils.copyFile(
|
||||||
FileInputStream(it),
|
FileInputStream(it),
|
||||||
FileOutputStream(outputFile)
|
FileOutputStream(outputFile)
|
||||||
@@ -422,5 +398,4 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -33,21 +33,23 @@ object LaunchUtils {
|
|||||||
fun getInstalledGeodePath(context: Context): File? {
|
fun getInstalledGeodePath(context: Context): File? {
|
||||||
val geodeName = getGeodeFilename()
|
val geodeName = getGeodeFilename()
|
||||||
|
|
||||||
val internalGeodePath = File(context.filesDir.path, "launcher/$geodeName")
|
val internalGeodePath = File(context.filesDir, "launcher/$geodeName")
|
||||||
if (internalGeodePath.exists()) {
|
if (internalGeodePath.exists()) {
|
||||||
return internalGeodePath
|
return internalGeodePath
|
||||||
}
|
}
|
||||||
context.getExternalFilesDir(null)?.let { dir->
|
|
||||||
val updateGeodePath = File(dir.path, "game/geode/update/$geodeName")
|
val externalGeodeDir = getBaseDirectory(context)
|
||||||
|
|
||||||
|
val updateGeodePath = File(externalGeodeDir, "launcher/$geodeName")
|
||||||
if (updateGeodePath.exists()) {
|
if (updateGeodePath.exists()) {
|
||||||
return updateGeodePath
|
return updateGeodePath
|
||||||
}
|
}
|
||||||
|
|
||||||
val externalGeodePath = File(dir.path, geodeName)
|
val externalGeodePath = File(externalGeodeDir, geodeName)
|
||||||
if (externalGeodePath.exists()) {
|
if (externalGeodePath.exists()) {
|
||||||
return externalGeodePath
|
return externalGeodePath
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,9 +176,7 @@ class ReleaseManager private constructor(
|
|||||||
|
|
||||||
private fun getGeodeOutputPath(): File {
|
private fun getGeodeOutputPath(): File {
|
||||||
val geodeName = LaunchUtils.getGeodeFilename()
|
val geodeName = LaunchUtils.getGeodeFilename()
|
||||||
|
val geodeDirectory = LaunchUtils.getBaseDirectory(applicationContext)
|
||||||
val fallbackPath = File(applicationContext.filesDir, "launcher")
|
|
||||||
val geodeDirectory = applicationContext.getExternalFilesDir("") ?: fallbackPath
|
|
||||||
|
|
||||||
return File(geodeDirectory, geodeName)
|
return File(geodeDirectory, geodeName)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user