Skip to content

Commit

Permalink
calculate free space
Browse files Browse the repository at this point in the history
  • Loading branch information
nift4 committed Jan 19, 2025
1 parent ccb6449 commit aecf889
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/org/andbootmgr/app/CreatePartFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private fun StartSdLess(c: CreatePartDataHolder) {
if (c.freeSpace == null) {
LaunchedEffect(Unit) {
withContext(Dispatchers.IO) {
c.freeSpace = SDLessUtils.getFreeSpaceBytes()
c.freeSpace = SDLessUtils.getFreeSpaceBytes(c.vm.logic)
}
}
LoadingCircle(stringResource(R.string.loading), modifier = Modifier.fillMaxSize())
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/org/andbootmgr/app/util/SDLessUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import com.topjohnwu.superuser.Shell
import com.topjohnwu.superuser.io.SuFile
import org.andbootmgr.app.DeviceLogic
import java.io.File
import kotlin.math.max

object SDLessUtils {
fun getFreeSpaceBytes(): Long {
return 4L * 1024L * 1024L * 1024L // TODO
fun getFreeSpaceBytes(logic: DeviceLogic): Long {
val raw = Shell.cmd("stat -f ${logic.abmSdLessBootset} -c '%f:%S'").exec().out.joinToString("\n").split(":").map { it.trim().toLong() }
return max(raw[0] * raw[1] - 1024L * 1024L * 1024L, 0)
}

fun getSpaceUsageBytes(logic: DeviceLogic, fn: String): Long? {
Expand Down

0 comments on commit aecf889

Please sign in to comment.