Update targetSdk to 37, Robolectric to 4.17-beta, and fix icon preview - #25
Merged
Conversation
Bump targetSdk 35->37 (app) and 36->37 (baselineProfile) to match the project-wide compileSdk 37, and migrate the deprecation warnings that have clean, behavior-preserving AndroidX-compat replacements. Deprecation migrations: - IntentCompat.getParcelableExtra(..., Class) for typed parcelable extras (ShortcutInfoFactory, ModeDetector, ShortcutEditViewModel) - ServiceCompat.stopForeground(STOP_FOREGROUND_REMOVE) in ModeService - Activity setShowWhenLocked/setTurnScreenOn + requestDismissKeyguard instead of window keyguard flags in AcceptCallActivity - Platform Bundle instead of the deprecated androidx bundleOf in EditWidgetViewModel Robolectric: - Update 4.16.1 -> 4.17-beta-2 for native API 37 support - Add --add-opens=java.base/jdk.internal.access=ALL-UNNAMED to the forked unit-test JVM; JDK 21's module system otherwise blocks Robolectric's FileDescriptor shadow when running at API 37 Advance the lib submodule to the merged PackageInfoCompat version-code change. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: deb19a46-a1a3-40c2-a9b3-a539e068631e
The shortcut edit screen threads an iconVersion token into the Coil
image request to bust the cache when the icon changes, but it stored the
token in the request's generic extras bag. Coil ignores generic extras
when computing the memory cache key, so the content-provider URI stayed
identical and Coil kept serving the cached (stale) bitmap. The preview
never refreshed after picking a custom icon, an icon-pack icon, or
resetting to the default.
Route the version into memoryCacheKeyExtra("version", ...) instead,
which actually participates in the memory cache key. The custom fetcher
returns a stream source, so Coil's disk cache is not involved and the
memory cache was the sole source of staleness.
Add ShortcutImageRequestUnitTest covering that the version lands in
memoryCacheKeyExtras and that different versions yield different keys.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 81097fe6-0ab7-4177-bf55-70ee63e552aa
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the project to target Android API 37 (aligned with compileSdk 37), upgrades Robolectric to a 4.17 beta for API 37 support, and fixes a stale shortcut icon preview by ensuring the icon version participates in Coil’s memory cache key.
Changes:
- Bump
targetSdkto 37 (app + baseline profile) and update Robolectric to4.17-beta-2, adding JPMS--add-opensfor unit tests. - Migrate several deprecated Android APIs to AndroidX/platform replacements (typed parcelable extras, foreground stopping, lockscreen handling, Bundles).
- Fix shortcut preview cache busting by moving the icon version into
memoryCacheKeyExtra, and add a unit test for the request wiring.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gradle/libs.versions.toml | Updates Robolectric version to 4.17-beta-2. |
| build.gradle.kts | Adds --add-opens to unit test JVMs to support Robolectric on newer JDKs/API 37+. |
| app/build.gradle.kts | Updates app targetSdk to 37. |
| baselineProfile/build.gradle.kts | Updates baseline profile module targetSdk to 37. |
| app/src/main/java/com/anod/car/home/incar/ModeService.kt | Replaces deprecated stopForeground(true) with ServiceCompat.stopForeground(...). |
| app/src/main/java/com/anod/car/home/incar/ModeDetector.kt | Uses IntentCompat.getParcelableExtra for typed Bluetooth device extras. |
| app/src/main/java/com/anod/car/home/incar/AcceptCallActivity.kt | Replaces deprecated keyguard window flags with setShowWhenLocked/setTurnScreenOn + requestDismissKeyguard. |
| content/src/androidMain/kotlin/info/anodsplace/carwidget/content/shortcuts/ShortcutInfoFactory.kt | Uses IntentCompat.getParcelableExtra for typed parcelable extras from shortcut intents. |
| content/src/androidMain/kotlin/info/anodsplace/carwidget/content/db/Shortcut.kt | Fixes Coil cache busting by writing iconVersion into memoryCacheKeyExtra. |
| content/src/androidHostTest/kotlin/info/anodsplace/carwidget/content/db/ShortcutImageRequestUnitTest.kt | Adds Robolectric test coverage for the memoryCacheKeyExtras version wiring. |
| compose/src/androidMain/kotlin/info/anodsplace/carwidget/shortcut/ShortcutEditViewModel.kt | Uses IntentCompat.getParcelableExtra for bitmap extra in icon picking flow. |
| compose/src/androidMain/kotlin/info/anodsplace/carwidget/appwidget/EditWidgetViewModel.kt | Replaces deprecated bundleOf usage with platform Bundle. |
- ShortcutEditViewModel: read EXTRA_SHORTCUT_ICON_RESOURCE via typed IntentCompat.getParcelableExtra for correct behavior on API 33+. Keep a narrowly-scoped @Suppress("DEPRECATION") because the platform constant itself is deprecated but is still what icon packs return. - ShortcutImageRequestUnitTest: rename the cache-key test to reflect that it asserts on memoryCacheKeyExtras (Coil does not expose the computed key) and assert on the specific version extra values. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 81097fe6-0ab7-4177-bf55-70ee63e552aa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch bundles two independent changes that were developed together.
Update targetSdk to 37 and Robolectric to 4.17-beta-2
Bumps targetSdk (35 -> 37 for app, 36 -> 37 for baselineProfile) to match the project-wide compileSdk 37, and migrates the deprecation warnings that have clean, behavior-preserving AndroidX-compat replacements:
IntentCompat.getParcelableExtra(..., Class)for typed parcelable extras (ShortcutInfoFactory, ModeDetector, ShortcutEditViewModel)ServiceCompat.stopForeground(STOP_FOREGROUND_REMOVE)in ModeServicesetShowWhenLocked/setTurnScreenOn+requestDismissKeyguardinstead of window keyguard flags in AcceptCallActivityBundleinstead of the deprecated androidxbundleOfin EditWidgetViewModelRobolectric is updated 4.16.1 -> 4.17-beta-2 for native API 37 support. JDK 21's module system otherwise blocks Robolectric's FileDescriptor shadow at API 37, so
--add-opens=java.base/jdk.internal.access=ALL-UNNAMEDis added to the forked unit-test JVM. Also advances thelibsubmodule to the merged PackageInfoCompat version-code change.Fix stale shortcut icon preview
The shortcut edit screen preview did not refresh after picking a custom icon. The screen threads an
iconVersiontoken into the Coil image request to bust the cache when the icon changes, but it stored the token in the request's genericextrasbag. Coil ignores generic extras when computing the memory cache key, so the content-provider URI stayed identical and Coil kept serving the cached (stale) bitmap. This affected custom icons, icon-pack icons, and resetting to the default.The fix routes the version into
memoryCacheKeyExtra("version", ...), which actually participates in the memory cache key. The custom fetcher returns a stream source, so Coil's disk cache is not involved and the memory cache was the sole source of staleness. AddsShortcutImageRequestUnitTestcovering that the version lands inmemoryCacheKeyExtrasand that different versions produce different keys.Testing
./gradlew :content:compileAndroidMainand:compose:compileAndroidMainpass./gradlew :content:testAndroidHostTest --tests ShortcutImageRequestUnitTestpasses