Skip to content

Commit

Permalink
support for executing binaries in API30+
Browse files Browse the repository at this point in the history
  • Loading branch information
pazos committed May 10, 2021
1 parent 617eb17 commit 0b5903d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/src/main/java/org/koreader/launcher/Assets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.view.ViewGroup
import android.widget.ProgressBar
import androidx.annotation.Keep
import androidx.core.content.ContextCompat
import org.koreader.launcher.utils.FileUtils
import java.io.*

@Keep
Expand Down Expand Up @@ -81,6 +82,29 @@ class Assets {
return false
}
}
(assetName == "module/map.txt") -> {
/* Symlink binaries stored as shared libraries */
val nativeLibsDir = activity.applicationInfo.nativeLibraryDir
activity.assets.open(assetName).bufferedReader().use { text ->
Logger.v("Reading symlink from $assetName")
text.forEachLine { line ->
try {
val array = line.split(" ").toTypedArray()
if (array.size == 2) {
val link = "$filesDir/${array[0]}"
val file = "$nativeLibsDir/${array[1]}"
if (File(file).exists()) {
FileUtils.symlink(link, file)
} else {
Logger.w("File $file does not exist, skipping")
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}
else -> {
/* Copy all regular files in assets store */
Logger.v(tag, "Extracting $assetName")
Expand Down

0 comments on commit 0b5903d

Please sign in to comment.