Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Oct 12, 2024
1 parent 04a639a commit 9b7e367
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
8 changes: 6 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ android {
isDebuggable = false
isJniDebuggable = false
renderscriptOptimLevel = 3
multiDexEnabled = false
multiDexEnabled = true
}

debug {
Expand All @@ -76,7 +76,7 @@ android {
isDebuggable = true
renderscriptOptimLevel = 0
isMinifyEnabled = false
multiDexEnabled = false
multiDexEnabled = true
}

all {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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? {
Expand Down
8 changes: 8 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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" }
Expand Down

0 comments on commit 9b7e367

Please sign in to comment.