forked from hardcoresushi/DroidFS
Avoid being killed by SELinux when retrieving volume path
This commit is contained in:
parent
c26ab661c2
commit
6f43bc7417
@ -3,6 +3,7 @@ package sushi.hardcore.droidfs.util
|
|||||||
import android.content.ActivityNotFoundException
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
import android.os.storage.StorageManager
|
import android.os.storage.StorageManager
|
||||||
import android.provider.DocumentsContract
|
import android.provider.DocumentsContract
|
||||||
@ -111,6 +112,8 @@ object PathUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.d(PATH_RESOLVER_TAG, "getExternalFilesDirs failed")
|
Log.d(PATH_RESOLVER_TAG, "getExternalFilesDirs failed")
|
||||||
|
// Don't risk to be killed by SELinux on newer Android versions
|
||||||
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||||
try {
|
try {
|
||||||
val process = ProcessBuilder("mount").redirectErrorStream(true).start().apply { waitFor() }
|
val process = ProcessBuilder("mount").redirectErrorStream(true).start().apply { waitFor() }
|
||||||
process.inputStream.readBytes().decodeToString().split("\n").forEach { line ->
|
process.inputStream.readBytes().decodeToString().split("\n").forEach { line ->
|
||||||
@ -129,6 +132,7 @@ object PathUtils {
|
|||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
Log.d(PATH_RESOLVER_TAG, "mount processing failed")
|
Log.d(PATH_RESOLVER_TAG, "mount processing failed")
|
||||||
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user