Fix AID routing precedence to prioritize default wallet services
A logic flaw in NFC'RegisteredAidCache conflict resolution allows a sideloaded application to squat on a shared role priority package name. This grants the attacker's app wallet-tier precedence, enabling it to intercept payment APDUs intended for the legitimate wallet application.
This commit resolves the issue in `RegisteredAidCache` by fixing two areas where AID routing precedence was incorrectly resolved:
1. When sorting multiple wallet services with the same AID type, the sort logic is updated to first prioritize the default wallet holder's own services over associated services, before falling back to alphabetical sorting by component name. This prevents an associated service from gaining priority merely by having an alphabetically earlier name.
2. When resolving prefix conflicts against exact-match child AIDs, the logic now explicitly checks if any of the conflicting services are owned by the default wallet holder itself (`conflictingHasWallet`). If so, it returns an empty resolve info to correctly allow the exact child AID rule to govern, rather than ignoring it in favor of the prefix.
Bug: 522373825
Test: atest NfcNciUnitTests:RegisteredAidCacheTest
Flag: EXEMPT BUGFIX
(cherry picked from commit a810afd69488a55248e17e1ef94c9dc9d9c11608)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:5727f605d44162b09f0e2fe92e273818637146cc
Merged-In: I6d0580c1df7514c878fe398f6a9fd0549756b3b9
Change-Id: I6d0580c1df7514c878fe398f6a9fd0549756b3b9
2 files changed