feat(android): lower minSdk to 25 for Android 7.1.1 devices #1125
Loading…
Reference in a new issue
No description provided.
Delete branch "ux-android-minsdk"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What changed
Lowers
minSdkfrom 29 → 25 so the app installs on an older family phone stuck on Android 7.1.1 (API 25). The daily device (Galaxy Tab S5e, API 30) is unaffected. Three platform boundaries get explicit handling rather than being assumed away:Desugaring (java.time is API 26+)
The viewer date bar, day-sectioned timeline, and search year filter all use
java.time(Instant,OffsetDateTime,LocalDate,DateTimeFormatter,DateTimeParseException). At minSdk 25 that needs core-library desugaring, now enabled on:app(isCoreLibraryDesugaringEnabled = true+coreLibraryDesugaring(libs.desugar.jdk.libs)).com.android.tools:desugar_jdk_libs:2.1.5(standard, not_nio). 2.1.5 is the latest release per Google'smaven-metadata.xml. I picked the standard artifact overdesugar_jdk_libs_niobecause the NIO variant's only extra surface isjava.nio.file, which nothing in the app imports — the standard build backportsjava.timefully and keeps the dex footprint smaller. Compatible with AGP 9.4.1 / Java 17.:coreis plainkotlin-jvmand uses nojava.time, so only:appneeds desugaring (verified by grep acrosscore/src).Save-to-MediaStore: version-gated write path
Pictures/MemorieswithIS_PENDING, no runtime permission.Pictures/Memoriesdirectory (there is noRELATIVE_PATHand noIS_PENDINGcolumn pre-Q). The viewer requestsWRITE_EXTERNAL_STORAGEon first save viaActivityResultContracts.RequestPermission; the pending save is parked and resumed on a grant. Denial → friendly localized snackbar (de/da/en) and the save stays resumable — never a crash or a dead end. Manifest declares the permission withandroid:maxSdkVersion="28"so the dialog never appears on Q+.AndroidMediaDownloader.insertPending→insertEntrybranches on SDK; the post-writeIS_PENDING = 0update is skipped below Q (no column to clear).Scanner IS_PENDING predicate
AndroidMediaStoreScanner's selection drops theis_pending = 0predicate below Q — the constant resolves everywhere (it is a plain string) but the column does not exist pre-Q, so including it would fail the query rather than merely filter.Notifications
Checked
BackupWorkerand the whole tree: the app posts no notifications, so notification-channel work is correctly out of scope and none was added.Gating design
Every SDK-dependent decision lives in a new pure object,
dev.memories.android.storage.StorageCompat, as a function of the SDK number (usesScopedStorage,needsWritePermission,savePermission,scanSelection,insertValues,completionValues). This keeps both branches unit-testable without a device and gives the scanner, downloader, and viewer a single source of truth.Trade-offs (accepted)
WRITE_EXTERNAL_STORAGEdialog on first saveNo functional degradation beyond these was found, so no new KNOWN_ISSUES entry was added.
Test matrix
./gradlew :app:testDebugUnitTest :app:assembleDebug→ 309 tests, 0 failures, 0 skipped.StorageCompatTest25, 28, 29, 35StorageCompatRobolectricTest@Config(sdk=[25, 29])Build.VERSION.SDK_INTwiring +ContentValuesbuildersThe Robolectric suite replays the policy through the real
Build.VERSION.SDK_INT(what the scanner/downloader read on a device), catching a mis-wired source of truth that pure arithmetic would miss.ContentValuesassertions live there becauseputis a framework method and is not mocked on the plain JVM.Lint
./gradlew :app:lintDebug→ 18 errors, all pre-existing and none minSdk-related:UnsafeOptInUsageError+ 7 ×LocalContextGetResourceValueCall+ 1 ×MissingTranslation= ISSUE-119 (viewer PRs, documented).MissingQuantityfrom the people-lane plurals already onmain.Zero
NewApi/InlinedApi/UnusedRequiresPermissionerrors — the actual minSdk-25 check.lintDebugis not a CI gate (workflow runs only:app:testDebugUnitTest+:app:assembleDebug, both green).Version
versionCode 10 → 11,versionName 0.1.9 → 0.2.0, following the changelog-comment convention inapp/build.gradle.kts.Risks
ContentValueslevel, but the actual MediaStore write + permission dialog needs a device smoke test before relying on it.READ_EXTERNAL_STORAGEread path (backup/scanner) still has no runtime permission request anywhere — pre-existing behavior, identical on 25–28 as on 29–32, unchanged by this PR and out of scope here.