Fix direct boot

This commit is contained in:
Mygod
2018-07-22 00:25:42 +08:00
parent 9220f9f113
commit 2578c1c6ec
5 changed files with 35 additions and 9 deletions

View File

@@ -0,0 +1,20 @@
package be.mygod.vpnhotspot.util
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.app.Application
import android.content.Context
@SuppressLint("Registered")
@TargetApi(24)
class DeviceStorageApp(context: Context) : Application() {
init {
attachBaseContext(context.createDeviceProtectedStorageContext())
}
/**
* Thou shalt not get the REAL underlying application context which would no longer be operating under device
* protected storage.
*/
override fun getApplicationContext(): Context = this
}

View File

@@ -14,7 +14,7 @@ private class SuFailure : RuntimeException()
fun loggerSuStream(command: String): InputStream? {
val process = try {
ProcessBuilder("su", "-c", command)
.directory(app.deviceContext.cacheDir)
.directory(app.deviceStorage.cacheDir)
.redirectErrorStream(true)
.start()
} catch (e: IOException) {