Skip to content

fix(chat): guard MediaStore.getPickImagesMaxLimit on older pickers - #1741

Merged
bmc08gt merged 2 commits into
code/cashfrom
fix/chat-photo-picker-max-limit
Oct 9, 2026
Merged

bmc08gt merged 2 commits into
code/cashfrom
fix/chat-photo-picker-max-limit

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Opening any chat crashes on Android 11–12 devices that lack the MediaProvider update with SDK extension R 2. rememberChatPhotoPicker calls MediaStore.getPickImagesMaxLimit() during composition, and that method only exists on API 33+ or API 30–32 with extension R ≥ 2. Bugsnag 6ac91865991833fd09984195 has 8 NoSuchMethodError events from one Samsung SM-N976V on Android 12, all on 2026.10.2. The call came in with #1683.

The fix calls it only when the SDK version or extension check passes. Otherwise the picker is capped at the open slots, and the result callback still trims the selection with uris.take(currentRemaining) for fallback pickers that ignore the cap.

I used an explicit SDK_INT / SdkExtensions check instead of PickVisualMedia.isPhotoPickerAvailable(context) because lint's NewApi check doesn't treat the androidx helper as a guard. :apps:flipcash:shared:chat-ui:lintDebug flagged the original call and passes with this change.

A hotfix PR against the 2026.10.2 release follows separately.

rememberChatPhotoPicker called getPickImagesMaxLimit() during composition
with no version check. The method exists only on API 33+, or on API 30-32
with SDK extension R 2+, so an Android 12 device without the MediaProvider
update threw NoSuchMethodError every time a chat opened (Bugsnag
6ac91865991833fd09984195, Samsung SM-N976V).

Only call it where the system picker provides it. Elsewhere androidx falls
back to a picker with no cap of its own, and the result callback already
trims the selection to the remaining slots.
@bmc08gt bmc08gt self-assigned this Oct 9, 2026
@github-actions github-actions Bot added the type: fix Bug fix label Oct 9, 2026
Int.MAX_VALUE never reached the picker, since the clamp came out to
remaining anyway, but it read as no cap. Fall back to remaining directly.
@bmc08gt
bmc08gt merged commit 59fc672 into code/cash Oct 9, 2026
2 of 3 checks passed
bmc08gt added a commit that referenced this pull request Oct 9, 2026
* fix(chat): guard MediaStore.getPickImagesMaxLimit on older pickers

rememberChatPhotoPicker called getPickImagesMaxLimit() during composition
with no version check. The method exists only on API 33+, or on API 30-32
with SDK extension R 2+, so an Android 12 device without the MediaProvider
update threw NoSuchMethodError every time a chat opened (Bugsnag
6ac91865991833fd09984195, Samsung SM-N976V).

Only call it where the system picker provides it. Elsewhere androidx falls
back to a picker with no cap of its own, and the result callback already
trims the selection to the remaining slots.

* fix(chat): cap the fallback photo picker at the open slots

Int.MAX_VALUE never reached the picker, since the clamp came out to
remaining anyway, but it read as no cap. Fall back to remaining directly.

* ci(lint): lint library modules from the app's lintDebug

CI runs :apps:flipcash:app:lintDebug, but checkDependencies defaults to
false, so lint only looked at the app module. The unguarded
MediaStore.getPickImagesMaxLimit() call in chat-ui (#1741) shipped
because no lint run ever saw it; with checkDependencies on, lint fails on
it with NewApi.

Turning it on surfaces three other existing errors, which go in the
baseline so the check gates new issues only: WrongConstant in
AppSettingsMapper, UnspecifiedRegisterReceiverFlag in SmsOtpAutofill (the
pre-34 branch, where the flag isn't available), and
UnrememberedMutableState in Flippable.
bmc08gt added a commit that referenced this pull request Oct 9, 2026
* fix(chat): guard MediaStore.getPickImagesMaxLimit on older pickers

rememberChatPhotoPicker called getPickImagesMaxLimit() during composition
with no version check. The method exists only on API 33+, or on API 30-32
with SDK extension R 2+, so an Android 12 device without the MediaProvider
update threw NoSuchMethodError every time a chat opened (Bugsnag
6ac91865991833fd09984195, Samsung SM-N976V).

Only call it where the system picker provides it. Elsewhere androidx falls
back to a picker with no cap of its own, and the result callback already
trims the selection to the remaining slots.

* fix(chat): cap the fallback photo picker at the open slots

Int.MAX_VALUE never reached the picker, since the clamp came out to
remaining anyway, but it read as no cap. Fall back to remaining directly.

* ci(lint): lint library modules from the app's lintDebug

CI runs :apps:flipcash:app:lintDebug, but checkDependencies defaults to
false, so lint only looked at the app module. The unguarded
MediaStore.getPickImagesMaxLimit() call in chat-ui (#1741) shipped
because no lint run ever saw it; with checkDependencies on, lint fails on
it with NewApi.

Turning it on surfaces three other existing errors, which go in the
baseline so the check gates new issues only: WrongConstant in
AppSettingsMapper, UnspecifiedRegisterReceiverFlag in SmsOtpAutofill (the
pre-34 branch, where the flag isn't available), and
UnrememberedMutableState in Flippable.

* fix(lint): clear the three errors baselined in #1743

- WrongConstant: AppSettingMapper passed Biometrics.TEST_AUTH across a
  module boundary, where lint can't see it is a valid authenticator flag.
  The check now goes through Biometrics.authenticationState(), and
  TEST_AUTH is private.
- UnspecifiedRegisterReceiverFlag: SmsOtpAutofill only passed
  RECEIVER_EXPORTED on API 34+. ContextCompat.registerReceiver takes the
  flag on every version; the receiver stays exported, as SMS_RETRIEVED
  comes from Play services and SEND_PERMISSION still guards it.
- UnrememberedMutableState: FlippableCard built a new State object on
  each composition when animateFlip is false. It now uses
  rememberUpdatedState.

The three entries come out of the app's lint baseline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant