Skip to content

Update targetSdk to 37, Robolectric to 4.17-beta, and fix icon preview - #25

Merged
anod merged 3 commits into
mainfrom
update-target-sdk-37-robolectric-beta
Jul 26, 2026
Merged

Update targetSdk to 37, Robolectric to 4.17-beta, and fix icon preview#25
anod merged 3 commits into
mainfrom
update-target-sdk-37-robolectric-beta

Conversation

@anod

@anod anod commented Jul 26, 2026

Copy link
Copy Markdown
Owner

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 ModeService
  • Activity setShowWhenLocked / setTurnScreenOn + requestDismissKeyguard instead of window keyguard flags in AcceptCallActivity
  • Platform Bundle instead of the deprecated androidx bundleOf in EditWidgetViewModel

Robolectric 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-UNNAMED is added to the forked unit-test JVM. Also advances the lib submodule 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 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. 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. Adds ShortcutImageRequestUnitTest covering that the version lands in memoryCacheKeyExtras and that different versions produce different keys.

Testing

  • ./gradlew :content:compileAndroidMain and :compose:compileAndroidMain pass
  • ./gradlew :content:testAndroidHostTest --tests ShortcutImageRequestUnitTest passes

anod and others added 2 commits July 23, 2026 14:52
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
Copilot AI review requested due to automatic review settings July 26, 2026 05:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 targetSdk to 37 (app + baseline profile) and update Robolectric to 4.17-beta-2, adding JPMS --add-opens for 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
Copilot AI review requested due to automatic review settings July 26, 2026 06:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated no new comments.

@anod
anod merged commit ca7aa13 into main Jul 26, 2026
1 check passed
@anod
anod deleted the update-target-sdk-37-robolectric-beta branch August 1, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants