-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3fd4012
commit 40361eb
Showing
13 changed files
with
93 additions
and
17 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
app/src/main/aidl/dev/dergoogler/mmrl/compat/content/ModuleCompatibility.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package dev.dergoogler.mmrl.compat.content; | ||
|
||
parcelable ModuleCompatibility; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/src/main/kotlin/dev/dergoogler/mmrl/compat/content/ModuleCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dev.dergoogler.mmrl.compat.content | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class ModuleCompatibility( | ||
val hasMagicMount: Boolean, | ||
val canRestoreModules: Boolean, | ||
) : Parcelable { | ||
val canNotRestoreModules get() = !canRestoreModules | ||
val hasNotMagicMount get() = !hasMagicMount | ||
|
||
companion object | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 30 additions & 1 deletion
31
app/src/main/kotlin/dev/dergoogler/mmrl/compat/impl/KsuNextModuleManagerImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,41 @@ | ||
package dev.dergoogler.mmrl.compat.impl | ||
|
||
import com.topjohnwu.superuser.Shell | ||
import dev.dergoogler.mmrl.compat.content.ModuleCompatibility | ||
import dev.dergoogler.mmrl.compat.stub.IModuleOpsCallback | ||
|
||
internal class KsuNextModuleManagerImpl( | ||
shell: Shell, | ||
seLinuxContext: String, | ||
) : KernelSUModuleManagerImpl( | ||
shell, seLinuxContext | ||
) { | ||
override fun hasMagicMount(): Boolean = true | ||
override fun getModuleCompatibility() = ModuleCompatibility( | ||
hasMagicMount = true, | ||
canRestoreModules = true | ||
) | ||
|
||
override fun enable(id: String, useShell: Boolean, callback: IModuleOpsCallback) { | ||
val dir = modulesDir.resolve(id) | ||
if (!dir.exists()) callback.onFailure(id, null) | ||
|
||
if (useShell) { | ||
"ksud module restore $id && ksud module enable $id".submit { | ||
if (it.isSuccess) { | ||
callback.onSuccess(id) | ||
} else { | ||
callback.onFailure(id, it.out.joinToString()) | ||
} | ||
} | ||
} else { | ||
runCatching { | ||
dir.resolve("remove").apply { if (exists()) delete() } | ||
dir.resolve("disable").apply { if (exists()) delete() } | ||
}.onSuccess { | ||
callback.onSuccess(id) | ||
}.onFailure { | ||
callback.onFailure(id, it.message) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters