33
mobile/src/main/java/be/mygod/vpnhotspot/root/RootManager.kt
Normal file
33
mobile/src/main/java/be/mygod/vpnhotspot/root/RootManager.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
package be.mygod.vpnhotspot.root
|
||||
|
||||
import android.os.Parcelable
|
||||
import be.mygod.librootkotlinx.RootCommandNoResult
|
||||
import be.mygod.librootkotlinx.RootServer
|
||||
import be.mygod.librootkotlinx.RootSession
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.BuildConfig
|
||||
import be.mygod.vpnhotspot.util.Services
|
||||
import eu.chainfire.librootjava.RootJava
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import timber.log.Timber
|
||||
|
||||
object RootManager : RootSession() {
|
||||
@Parcelize
|
||||
class RootInit : RootCommandNoResult {
|
||||
override suspend fun execute(): Parcelable? {
|
||||
Services.init(RootJava.getSystemContext())
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
override fun createServer() = RootServer { Timber.w(it) }
|
||||
override suspend fun initServer(server: RootServer) {
|
||||
RootServer.DEBUG = BuildConfig.DEBUG
|
||||
try {
|
||||
server.init(app)
|
||||
} finally {
|
||||
server.readUnexpectedStderr()?.let { Timber.e(it) }
|
||||
}
|
||||
server.execute(RootInit())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user