diff options
| author | 2022-11-11 15:27:08 -0500 | |
|---|---|---|
| committer | 2022-11-28 18:52:31 +0000 | |
| commit | 2a6323fd89e50d655c061b6dda2d2f7ff11493b5 (patch) | |
| tree | ec5a145f53a9fa375d5e48c0d8a5224c47c57b96 /java/tests/src | |
| parent | 0919a83ee94b469eba0a72ee6e79fddb1e7dc7f7 (diff) | |
Extact Chooser intent processing; remove delegate
This CL makes two small cleanups with no observable behavior changes:
1. Extract a helper (in a new component) to handle the intent
processing that was previously inline in ChooserActivity's
onCreate(), storing the validated request data immutably. There's
a lot of boilerplate in the processing that was too verbose
inline in such an important lifecycle hook, and this refactoring
clarifies the lifecycle -- many of the extracted parameters had
been individual ivars on ChooserActivity, and it wasn't obvious
that they were all assigned in a batch and then never modified.
2. In previous code reviews, ayepin@ and I have discussed the
opportunity to remove the ChooserListCommunicator interface now
that it's clearly only responsible for providing values that we
can precompute and inject upfront; that precomputation mostly
involves the parameters extracted in this CL, so I've gone ahead
and made that change here. (It's not as straightforward to
replace the base ResolverListCommunicator, so for now we're still
passing through the same "communicator object" as before, but
without the enhanced "chooser-specific" API.
Test: atest IntentResolverUnitTests
Bug: 202167050
Change-Id: I7c3d47d282591f86ab1fae5e04c3d7d83f2fea0d
Diffstat (limited to 'java/tests/src')
| -rw-r--r-- | java/tests/src/com/android/intentresolver/ChooserListAdapterTest.kt | 8 | ||||
| -rw-r--r-- | java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java | 16 |
2 files changed, 15 insertions, 9 deletions
diff --git a/java/tests/src/com/android/intentresolver/ChooserListAdapterTest.kt b/java/tests/src/com/android/intentresolver/ChooserListAdapterTest.kt index bcb6c240..d054e7fa 100644 --- a/java/tests/src/com/android/intentresolver/ChooserListAdapterTest.kt +++ b/java/tests/src/com/android/intentresolver/ChooserListAdapterTest.kt @@ -45,10 +45,6 @@ class ChooserListAdapterTest { } private val context = InstrumentationRegistry.getInstrumentation().getContext() private val resolverListController = mock<ResolverListController>() - private val chooserListCommunicator = mock<ChooserListAdapter.ChooserListCommunicator> { - whenever(maxRankedTargets).thenReturn(0) - whenever(targetIntent).thenReturn(mock()) - } private val chooserActivityLogger = mock<ChooserActivityLogger>() private fun createChooserListAdapter( @@ -60,9 +56,11 @@ class ChooserListAdapterTest { emptyList(), false, resolverListController, - chooserListCommunicator, + mock(), packageManager, chooserActivityLogger, + mock(), + 0 ) { override fun createLoadDirectShareIconTask( info: SelectableTargetInfo diff --git a/java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java b/java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java index 56e583bb..fe448d63 100644 --- a/java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java +++ b/java/tests/src/com/android/intentresolver/ChooserWrapperActivity.java @@ -66,9 +66,15 @@ public class ChooserWrapperActivity } @Override - public ChooserListAdapter createChooserListAdapter(Context context, List<Intent> payloadIntents, - Intent[] initialIntents, List<ResolveInfo> rList, boolean filterLastUsed, - ResolverListController resolverListController) { + public ChooserListAdapter createChooserListAdapter( + Context context, + List<Intent> payloadIntents, + Intent[] initialIntents, + List<ResolveInfo> rList, + boolean filterLastUsed, + ResolverListController resolverListController, + ChooserRequestParameters chooserRequest, + int maxTargetsPerRow) { PackageManager packageManager = sOverrides.packageManager == null ? context.getPackageManager() : sOverrides.packageManager; @@ -81,7 +87,9 @@ public class ChooserWrapperActivity resolverListController, this, packageManager, - getChooserActivityLogger()); + getChooserActivityLogger(), + chooserRequest, + maxTargetsPerRow); } @Override |