Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Bump compat to 313bd38
Browse files Browse the repository at this point in the history
  • Loading branch information
SanmerDev committed Jun 30, 2024
1 parent 517f30d commit 4ee639d
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 37 deletions.
9 changes: 7 additions & 2 deletions app/src/main/kotlin/dev/sanmer/mrepo/Compat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import dev.sanmer.mrepo.datastore.model.WorkingMode
import dev.sanmer.mrepo.stub.IModuleManager
import dev.sanmer.su.IServiceManager
import dev.sanmer.su.ServiceManagerCompat
import dev.sanmer.su.ServiceManagerCompat.addService
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import timber.log.Timber
Expand All @@ -24,7 +25,11 @@ object Compat {
val isAliveFlow get() = _isAliveFlow.asStateFlow()

val moduleManager: IModuleManager by lazy {
ModuleManager.delegate(mService)
IModuleManager.Stub.asInterface(
mService.addService(
ModuleManager::class.java
)
)
}

private fun state(): Boolean {
Expand All @@ -44,7 +49,7 @@ object Compat {
}

state()
} catch (e: Exception) {
} catch (e: Throwable) {
Timber.e(e)

mServiceOrNull = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import dev.sanmer.mrepo.Compat
import dev.sanmer.mrepo.compat.MediaStoreCompat.copyToDir
import dev.sanmer.mrepo.compat.MediaStoreCompat.getPathForUri
import dev.sanmer.mrepo.content.State
import dev.sanmer.mrepo.content.ThrowableWrapper
import dev.sanmer.mrepo.model.local.LocalModule
import dev.sanmer.mrepo.repository.LocalRepository
import dev.sanmer.mrepo.repository.UserPreferencesRepository
import dev.sanmer.mrepo.stub.IInstallCallback
import dev.sanmer.mrepo.utils.extensions.now
import dev.sanmer.mrepo.utils.extensions.tmpDir
import dev.sanmer.su.wrap.ThrowableWrapper
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import dev.sanmer.mrepo.Compat
import dev.sanmer.mrepo.content.ThrowableWrapper
import dev.sanmer.mrepo.datastore.model.Homepage
import dev.sanmer.mrepo.datastore.model.ModulesMenu
import dev.sanmer.mrepo.datastore.model.Option
Expand All @@ -25,6 +24,7 @@ import dev.sanmer.mrepo.service.DownloadService
import dev.sanmer.mrepo.stub.IModuleOpsCallback
import dev.sanmer.mrepo.ui.activity.InstallActivity
import dev.sanmer.mrepo.utils.StrUtil
import dev.sanmer.su.wrap.ThrowableWrapper
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.sanmer.mrepo.stub;

import dev.sanmer.mrepo.content.Module;
import dev.sanmer.mrepo.content.ThrowableWrapper;
import dev.sanmer.su.wrap.ThrowableWrapper;

oneway interface IInstallCallback {
void onStdout(String msg);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dev.sanmer.mrepo.stub;

import dev.sanmer.mrepo.content.ThrowableWrapper;
import dev.sanmer.su.wrap.ThrowableWrapper;

oneway interface IModuleOpsCallback {
void onSuccess(String id);
Expand Down
13 changes: 2 additions & 11 deletions core/src/main/kotlin/dev/sanmer/mrepo/ModuleManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,16 @@ import dev.sanmer.mrepo.impl.APatchModuleManagerImpl
import dev.sanmer.mrepo.impl.KernelSUModuleManagerImpl
import dev.sanmer.mrepo.impl.MagiskModuleManagerImpl
import dev.sanmer.mrepo.impl.Shell.exec
import dev.sanmer.mrepo.stub.IModuleManager
import dev.sanmer.su.IService
import dev.sanmer.su.IServiceManager
import dev.sanmer.su.ServiceManagerCompat.delegate

class ModuleManager : IService {
override val name = "module"

override fun create(service: IServiceManager): IBinder = when {
override fun create(manager: IServiceManager): IBinder = when {
"which magisk".exec().isSuccess -> MagiskModuleManagerImpl()
"which ksud".exec().isSuccess -> KernelSUModuleManagerImpl()
"which apd".exec().isSuccess -> APatchModuleManagerImpl()
else -> throw IllegalArgumentException("Unsupported platform (${service.seLinuxContext})")
}

companion object {
fun delegate(service: IServiceManager): IModuleManager =
IModuleManager.Stub.asInterface(
service.delegate(ModuleManager::class.java)
)
else -> throw IllegalStateException("Unsupported platform (${manager.seLinuxContext})")
}
}
13 changes: 0 additions & 13 deletions core/src/main/kotlin/dev/sanmer/mrepo/content/ThrowableWrapper.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package dev.sanmer.mrepo.impl

import dev.sanmer.mrepo.Platform
import dev.sanmer.mrepo.content.ThrowableWrapper.Companion.wrap
import dev.sanmer.mrepo.impl.Shell.exec
import dev.sanmer.mrepo.stub.IInstallCallback
import dev.sanmer.mrepo.stub.IModuleOpsCallback
import dev.sanmer.su.wrap.ThrowableWrapper.Companion.wrap
import java.io.File
import java.io.FileNotFoundException

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package dev.sanmer.mrepo.impl

import dev.sanmer.mrepo.content.Module
import dev.sanmer.mrepo.content.State
import dev.sanmer.mrepo.content.ThrowableWrapper.Companion.wrap
import dev.sanmer.mrepo.impl.Shell.exec
import dev.sanmer.mrepo.stub.IInstallCallback
import dev.sanmer.mrepo.stub.IModuleManager
import dev.sanmer.su.wrap.ThrowableWrapper.Companion.wrap
import java.io.File
import java.util.zip.ZipFile

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package dev.sanmer.mrepo.impl

import dev.sanmer.mrepo.Platform
import dev.sanmer.mrepo.content.ThrowableWrapper.Companion.wrap
import dev.sanmer.mrepo.impl.Shell.exec
import dev.sanmer.mrepo.stub.IInstallCallback
import dev.sanmer.mrepo.stub.IModuleOpsCallback
import dev.sanmer.su.wrap.ThrowableWrapper.Companion.wrap
import java.io.File
import java.io.FileNotFoundException

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.sanmer.mrepo.impl

import dev.sanmer.mrepo.Platform
import dev.sanmer.mrepo.content.ThrowableWrapper.Companion.wrap
import dev.sanmer.mrepo.stub.IInstallCallback
import dev.sanmer.mrepo.stub.IModuleOpsCallback
import dev.sanmer.su.wrap.ThrowableWrapper.Companion.wrap
import java.io.File
import java.io.FileNotFoundException

Expand Down

0 comments on commit 4ee639d

Please sign in to comment.