diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dd0734f7..94212c02b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,14 @@ All notable changes to this project will be documented in this file. ### 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 ## [v1.6.11] - 2022-07-26 diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/utils/StorageUtils.kt b/android/app/src/main/kotlin/deckers/thibault/aves/utils/StorageUtils.kt index 62400b4f2..f61aa79d1 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/utils/StorageUtils.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/utils/StorageUtils.kt @@ -162,22 +162,27 @@ object StorageUtils { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { lateinit var files: List var validFiles: Boolean + val retryInterval = 100L + val maxDelay = 1000L + var totalDelay = 0L do { // `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. - // 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) validFiles = !externalFilesDirs.contains(null) if (validFiles) { files = externalFilesDirs.filterNotNull() } else { + Log.d(LOG_TAG, "External files dirs contain `null`. Retrying...") + totalDelay += retryInterval try { - Thread.sleep(100) + Thread.sleep(retryInterval) } catch (e: InterruptedException) { Log.e(LOG_TAG, "insomnia", e) } } - } while (!validFiles) + } while (!validFiles && totalDelay < maxDelay) paths.addAll(files.mapNotNull(::appSpecificVolumePath)) } else { // Primary physical SD-CARD (not emulated)