feat: improve low nvram estimate #182
1 changed files with 10 additions and 3 deletions
|
@ -23,8 +23,7 @@ import net.typeblog.lpac_jni.LocalProfileInfo
|
||||||
|
|
||||||
class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardStepFragment() {
|
class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardStepFragment() {
|
||||||
companion object {
|
companion object {
|
||||||
const val LOW_NVRAM_THRESHOLD =
|
const val TYPICAL_PROFILE_SIZE = 40 * 1024 // 40 KiB
|
||||||
30 * 1024 // < 30 KiB, alert about potential download failure
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private data class SlotInfo(
|
private data class SlotInfo(
|
||||||
|
@ -36,6 +35,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
|
||||||
val freeSpace: Int,
|
val freeSpace: Int,
|
||||||
val imei: String,
|
val imei: String,
|
||||||
val enabledProfileName: String?,
|
val enabledProfileName: String?,
|
||||||
|
val profileCount: Int,
|
||||||
val intrinsicChannelName: String?,
|
val intrinsicChannelName: String?,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,7 +60,13 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
|
||||||
override fun beforeNext() {
|
override fun beforeNext() {
|
||||||
super.beforeNext()
|
super.beforeNext()
|
||||||
|
|
||||||
if (adapter.selected.freeSpace < LOW_NVRAM_THRESHOLD) {
|
val lowThreshold = adapter.selected
|
||||||
|
// freeSpace + (profileCount * TYPICAL_PROFILE_SIZE)
|
||||||
|
.let { it.freeSpace + (it.profileCount * TYPICAL_PROFILE_SIZE) }
|
||||||
|
.times(0.25) // 25% overhead
|
||||||
|
.toInt()
|
||||||
|
|
||||||
|
if (adapter.selected.freeSpace < lowThreshold) {
|
||||||
val activity = requireActivity()
|
val activity = requireActivity()
|
||||||
|
|
||||||
AlertDialog.Builder(requireContext()).apply {
|
AlertDialog.Builder(requireContext()).apply {
|
||||||
|
@ -116,6 +122,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
|
||||||
""
|
""
|
||||||
},
|
},
|
||||||
channel.lpa.profiles.enabled?.displayName,
|
channel.lpa.profiles.enabled?.displayName,
|
||||||
|
channel.lpa.profiles.size,
|
||||||
channel.intrinsicChannelName,
|
channel.intrinsicChannelName,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue