Clean up ChooserActivity's per-profile bookkeeping
This is mostly taken from ag/20236439, reimagined for not having
extracted the new `ShortcutLoader` component yet.
The most notable change is the decoupling of ChooserListAdapter from
any AppPredictor instance (or its callback). The previous model gave
us a mechanism for associating each of our user IDs to their
respective AppPredictor/Callback instances, but otherwise wasn't
necessary to support any usage in ChooserListAdapter. OTOH it fell
short of actually assigning any responsibility to ChooserListAdapter
as the "owner" of these instances, since they're created and retained
externally (in ChooserActivity), by the same component that uses them
and is ultimately responsible for requesting their destruction
(according to its own mechanism for getting back to a particular
handle/adapter/AppPredictor/callback "tuple"). Not only is this
unnecessarily complex, it also creates a denormalization hazard since
ChooserListAdapter resetting its own AppPredictor reference to null
after destruction doesn't reset ChooserActivity's reference, which
could still be used (and would throw on the use-after-free).
The CL also includes some minor cleanups that are helpful to set up
for ag/20236439.
Test: atest IntentResolverUnitTests
Bug: 202167050
Change-Id: Ia22c425fcd34627fb67a3ad2543b6d7ac51b5dea
2 files changed