Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

fix(custom-tabs): `SecurityException` in `bindCustomTabsService` on a Xiaomi device

Open david-allison opened this issue 1 month ago • 1 comments

Purpose / Description

CompatHelper$Companion.resolveActivityCompat was seen to throw an undocumented SecurityException on a Xiaomi Redmi K50 (SDK 34)

Disable custom tabs if this occurs

Fixes

  • Fixes #19711

Approach

As I couldn't reproduce this: multi-pronged approach

  • It's possible that the http protocol was the case
    • change to
    • add it to <queries> anyway, as it may cause other failures and is a valid lookup
  • Catch the SecurityException and continue to see if the code can succeed
  • If the code fails later on with another SecurityException, also catch that one
    • I suspect queryIntentActivitiesCompat

How Has This Been Tested?

⚠️ Not easily testable; app still runs

Checklist

  • [x] You have a descriptive commit message with a short title (first line, max 50 chars).
  • [x] You have commented your code, particularly in hard-to-understand areas
  • [x] You have performed a self-review of your own code
  • [ ] UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • [ ] UI Changes: You have tested your change using the Google Accessibility Scanner

david-allison avatar Dec 07 '25 19:12 david-allison

https://github.com/ankidroid/Anki-Android/labels/Blocked%20by%20dependency

Too close to the 2.23.0 release window, wait for 2.23.1

david-allison avatar Dec 07 '25 19:12 david-allison

@david-allison would love to get this in - the code looks fantastic, just needs a quick commit preening to make sure the import changes I noted are either needed or removed as they appear unrelated now

mikehardy avatar Dec 12 '25 11:12 mikehardy

@mikehardy good to go I feel

david-allison avatar Dec 12 '25 22:12 david-allison

Doing cherry-picks this AM in the slice of time I've got, going to get this in

mikehardy avatar Dec 13 '25 13:12 mikehardy