#300 fixed launch with faulty storage volumes on Android <11
This commit is contained in:
parent
73e9073407
commit
a65cd84275
2 changed files with 16 additions and 3 deletions
|
@ -11,6 +11,14 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- status and navigation bar transparency
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- app launch despite faulty storage volumes on Android <11
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
- upgraded Flutter to beta v3.3.0-0.2.pre
|
- upgraded Flutter to beta v3.3.0-0.2.pre
|
||||||
|
|
||||||
## <a id="v1.6.11"></a>[v1.6.11] - 2022-07-26
|
## <a id="v1.6.11"></a>[v1.6.11] - 2022-07-26
|
||||||
|
|
|
@ -162,22 +162,27 @@ object StorageUtils {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
lateinit var files: List<File>
|
lateinit var files: List<File>
|
||||||
var validFiles: Boolean
|
var validFiles: Boolean
|
||||||
|
val retryInterval = 100L
|
||||||
|
val maxDelay = 1000L
|
||||||
|
var totalDelay = 0L
|
||||||
do {
|
do {
|
||||||
// `getExternalFilesDirs` sometimes include `null` when called right after getting read access
|
// `getExternalFilesDirs` sometimes include `null` when called right after getting read access
|
||||||
// (e.g. on API 30 emulator) so we retry until the file system is ready.
|
// (e.g. on API 30 emulator) so we retry until the file system is ready.
|
||||||
// TODO TLAD It can also include `null` when there is a faulty SD card.
|
// It can also include `null` when there is a faulty SD card.
|
||||||
val externalFilesDirs = context.getExternalFilesDirs(null)
|
val externalFilesDirs = context.getExternalFilesDirs(null)
|
||||||
validFiles = !externalFilesDirs.contains(null)
|
validFiles = !externalFilesDirs.contains(null)
|
||||||
if (validFiles) {
|
if (validFiles) {
|
||||||
files = externalFilesDirs.filterNotNull()
|
files = externalFilesDirs.filterNotNull()
|
||||||
} else {
|
} else {
|
||||||
|
Log.d(LOG_TAG, "External files dirs contain `null`. Retrying...")
|
||||||
|
totalDelay += retryInterval
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100)
|
Thread.sleep(retryInterval)
|
||||||
} catch (e: InterruptedException) {
|
} catch (e: InterruptedException) {
|
||||||
Log.e(LOG_TAG, "insomnia", e)
|
Log.e(LOG_TAG, "insomnia", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!validFiles)
|
} while (!validFiles && totalDelay < maxDelay)
|
||||||
paths.addAll(files.mapNotNull(::appSpecificVolumePath))
|
paths.addAll(files.mapNotNull(::appSpecificVolumePath))
|
||||||
} else {
|
} else {
|
||||||
// Primary physical SD-CARD (not emulated)
|
// Primary physical SD-CARD (not emulated)
|
||||||
|
|
Loading…
Reference in a new issue