diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6c963a6b..41446588 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -66,7 +66,7 @@ android { isDebuggable = false isJniDebuggable = false renderscriptOptimLevel = 3 - multiDexEnabled = false + multiDexEnabled = true } debug { @@ -76,7 +76,7 @@ android { isDebuggable = true renderscriptOptimLevel = 0 isMinifyEnabled = false - multiDexEnabled = false + multiDexEnabled = true } all { @@ -147,13 +147,17 @@ dependencies { implementation(libs.androidx.lifecycle.service) implementation(libs.androidx.lifecycle.viewModel.compose) implementation(libs.androidx.compose.runtime) + implementation(libs.androidx.compose.ui) implementation(libs.androidx.navigation.compose) + implementation(libs.androidx.foundation) + implementation(libs.androidx.navigation.runtime.ktx) implementation(libs.kotlinx.coroutines.android) implementation(libs.kotlinx.serialization.json) implementation(libs.kotlinx.datetime) implementation(libs.kotlin.reflect) implementation(libs.protobuf.kotlin.lite) implementation(libs.compose.markdown) + implementation(libs.androidx.multidex) implementation(libs.timber) implementation(libs.semver) diff --git a/compat/src/main/kotlin/dev/dergoogler/mmrl/compat/impl/BaseModuleManagerImpl.kt b/compat/src/main/kotlin/dev/dergoogler/mmrl/compat/impl/BaseModuleManagerImpl.kt index 87b2d4c7..f88eebf8 100644 --- a/compat/src/main/kotlin/dev/dergoogler/mmrl/compat/impl/BaseModuleManagerImpl.kt +++ b/compat/src/main/kotlin/dev/dergoogler/mmrl/compat/impl/BaseModuleManagerImpl.kt @@ -9,6 +9,10 @@ import dev.dergoogler.mmrl.compat.content.State import dev.dergoogler.mmrl.compat.stub.IInstallCallback import dev.dergoogler.mmrl.compat.stub.IModuleManager import java.io.File +import java.nio.file.FileSystems +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths import java.util.zip.ZipFile internal abstract class BaseModuleManagerImpl( @@ -51,13 +55,36 @@ internal abstract class BaseModuleManagerImpl( } private fun hasModConf(moduleDir: File, id: String): Boolean { - val mId = id.replace(Regex("[^a-zA-Z0-9._]"), "_") + val fixedModId = id.replace(Regex("[^a-zA-Z0-9._]"), "_") - if (Build.SUPPORTED_64_BIT_ABIS.isNotEmpty()) { - return moduleDir.resolve("/system/lib64/$mId.dex").exists() + val dexFilePath = if (Build.SUPPORTED_64_BIT_ABIS.isNotEmpty()) { + findFirstMatch("/system/lib64", fixedModId) + } else { + findFirstMatch("/system/lib", fixedModId) + } ?: return false + + return dexFilePath.toFile().exists() + } + + private fun findFirstMatch(directory: String, prefix: String): Path? { + val dirPath: Path = Paths.get(directory) + + val patterns = listOf("*.apk", "*.jar", "*.dex") + + Files.newDirectoryStream(dirPath).use { directoryStream -> + for (path in directoryStream) { + for (pattern in patterns) { + val pathMatcher = FileSystems.getDefault().getPathMatcher("glob:$pattern") + if (pathMatcher.matches(path.fileName) && path.fileName.toString() + .startsWith(prefix) + ) { + return path + } + } + } } - return moduleDir.resolve("/system/lib/$mId.dex").exists() + return null } override fun getModuleById(id: String): LocalModule? { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 23c308ec..e17471db 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,6 +12,9 @@ androidxDocumentFile = "1.0.1" androidxHiltNavigationCompose = "1.2.0" androidxLifecycle = "2.8.0" androidxNavigation = "2.7.7" +foundation = "1.7.3" +multidex = "2.0.1" +navigationRuntimeKtx = "2.8.2" androidxRoom = "2.6.1" browser = "1.8.0" coilCompose = "2.1.0" @@ -49,15 +52,20 @@ androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "androidxCoreSplashscreen" } androidx-datastore-core = { group = "androidx.datastore", name = "datastore", version.ref = "androidxDataStore" } androidx-documentfile = { group = "androidx.documentfile", name = "documentfile", version.ref = "androidxDocumentFile" } +androidx-foundation = { module = "androidx.compose.foundation:foundation" } androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "androidxLifecycle" } androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "androidxLifecycle" } androidx-lifecycle-service = { group = "androidx.lifecycle", name = "lifecycle-service", version.ref = "androidxLifecycle" } androidx-lifecycle-viewModel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "androidxLifecycle" } +androidx-material = { module = "androidx.compose.material:material" } +androidx-multidex = { module = "androidx.multidex:multidex", version.ref = "multidex" } +androidx-navigation-runtime-ktx = { group = "androidx.navigation", name = "navigation-runtime-ktx", version.ref = "navigationRuntimeKtx" } androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidxNavigation" } androidx-room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "androidxRoom" } androidx-room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "androidxRoom" } androidx-room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "androidxRoom" } +androidx-ui = { module = "androidx.compose.ui:ui" } coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coilCompose" } compose-markdown = { module = "com.github.jeziellago:compose-markdown", version.ref = "composeMarkdown" } hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }