Rename & pull `getTargets` up to base `TargetInfo`
This was originally only offered on `MultiDisplayResolveInfo` but
that just resulted in some type-checked conditional logic where the
caller (`ChooserActivity`) took responsibility for implementing the
other cases. Thus this CL is mainly based on the "Replace Conditional
with Polymorphism" item in Fowler's _Refactoring_. (It also separates
one piece of unrelated conditional behavior from the call site in
`ChooserActivity` but leaves any further cleanup of that separate
behavior out of scope.) The method rename is an attempt to call
attention to the use of the legacy `DisplayResolveInfo` type (as
distinguished from other types of "targets" i.e. `ChooserTargetInfo`),
in advance of any cleanup of that design.
This both simplifies the call site (in `ChooserActivity`) and
consolidates `TargetInfo` requirements that were previously diffuse.
It also progresses several of our tactical goals in the ongoing
`TargetInfo` cleanup (go/chooser-targetinfo-cleanup):
* In order to unify the types, all methods offered by any
`TargetInfo` implementation have to be pulled up to the base
interface; this CL prioritizes one method of particular benefit to
callers in its new location, but it was going to have to move
eventually regardless.
* This encapsulates one of the two call sites of
`TargetInfo.getDisplayResolveInfo()`. That API assumes callers have
an understanding of the semantics of the legacy
`DisplayResolveInfo` implementation, along with the semantics of
the (legacy) concrete type of any other `TargetInfo` they might
hold (in order to know whether they can use it as-is vs. descending
through its `getDisplayResolveInfo()`). The new API focuses
(slightly) more on the application requirements that client is
trying to fulfill.
* More broadly, this reduces call sites where clients depend on the
(new-but-deprecated) `TargetInfo` methods that query the legacy
type information. These usages _all_ need to be replaced with new
APIs that are more expressive in the application domain.
Test: atest IntentResolverUnitTests
Bug: 202167050
Change-Id: Ibc6cbfb01f323db4b820053babfeb5f7c8024f26
7 files changed