diff options
| author | 2024-02-13 13:55:54 -0500 | |
|---|---|---|
| committer | 2024-02-13 14:06:33 -0500 | |
| commit | df71f480dee389192a080fba6fe417f83506b33b (patch) | |
| tree | c44df4cedaafc2c51ebc768daa19e401693aaac6 /java/src | |
| parent | 249753fec137c15b09f80712001fa9d78dc10ce7 (diff) | |
Remove direct reference to Activity getIntent()
ActivityLaunch provides activity-scoped values from launch time. This
abstraction is important for testability, allowing us to consistently
test startup conditions in isolation without involving actually
starting an activity, or depending on the state of the system in
any way.
Test: atest IntentResolver-tests-activity
Test: atest IntentResolver-tests-unit
Change-Id: Iec8b6b7067c6535f723ab47d712e1a937000e1c4
Diffstat (limited to 'java/src')
| -rw-r--r-- | java/src/com/android/intentresolver/v2/ChooserActivity.java | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/java/src/com/android/intentresolver/v2/ChooserActivity.java b/java/src/com/android/intentresolver/v2/ChooserActivity.java index cdc05b95..072c56de 100644 --- a/java/src/com/android/intentresolver/v2/ChooserActivity.java +++ b/java/src/com/android/intentresolver/v2/ChooserActivity.java @@ -485,7 +485,7 @@ public class ChooserActivity extends Hilt_ChooserActivity implements .get(BasePreviewViewModel.class); previewViewModel.init( chooserRequest.getTargetIntent(), - getIntent(), + mActivityLaunch.getIntent(), chooserRequest.getAdditionalContentUri(), chooserRequest.getFocusedItemPosition(), mChooserServiceFeatureFlags.chooserPayloadToggling()); @@ -807,10 +807,6 @@ public class ChooserActivity extends Hilt_ChooserActivity implements mChooserMultiProfilePagerAdapter.getActiveListAdapter().handlePackagesChanged(); } - public boolean super_shouldAutoLaunchSingleChoice(TargetInfo target) { - return !target.isSuspended(); - } - /** Start the activity specified by the {@link TargetInfo}.*/ public final void safelyStartActivity(TargetInfo cti) { // In case cloned apps are present, we would want to start those apps in cloned user @@ -1652,14 +1648,12 @@ public class ChooserActivity extends Hilt_ChooserActivity implements } public boolean shouldAutoLaunchSingleChoice(TargetInfo target) { - // Note that this is only safe because the Intent handled by the ChooserActivity is - // guaranteed to contain no extras unknown to the local ClassLoader. That is why this - // method can not be replaced in the ResolverActivity whole hog. - if (!super_shouldAutoLaunchSingleChoice(target)) { + if (target.isSuspended()) { return false; } - return getIntent().getBooleanExtra(Intent.EXTRA_AUTO_LAUNCH_SINGLE_CHOICE, true); + return mActivityLaunch.getIntent().getBooleanExtra(Intent.EXTRA_AUTO_LAUNCH_SINGLE_CHOICE, + true); } private void showTargetDetails(TargetInfo targetInfo) { |