summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2023-07-06 20:25:41 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-07-06 20:25:41 +0000
commit64e2cf277790571bed1fa0bae75f617c709c2dcf (patch)
tree4418adde426ec75035f108a381364b9f0282b57b /java
parent6f5a52d7cfced7302c9d7e796a0ab53a433b128d (diff)
parent7cbff193529acbfbccce1d270127cd889c65b68c (diff)
Merge "Move two params to ResolverActivity.onCreate()" into udc-qpr-dev
Diffstat (limited to 'java')
-rw-r--r--java/src/com/android/intentresolver/ChooserActivity.java12
-rw-r--r--java/src/com/android/intentresolver/ResolverActivity.java98
2 files changed, 57 insertions, 53 deletions
diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java
index c615d388..2c1b8d2a 100644
--- a/java/src/com/android/intentresolver/ChooserActivity.java
+++ b/java/src/com/android/intentresolver/ChooserActivity.java
@@ -286,10 +286,6 @@ public class ChooserActivity extends ResolverActivity implements
mEnterTransitionAnimationDelegate,
new HeadlineGeneratorImpl(this));
- setAdditionalTargets(mChooserRequest.getAdditionalTargets());
-
- setSafeForwardingMode(true);
-
mPinnedSharedPrefs = getPinnedSharedPrefs(this);
mMaxTargetsPerRow = getResources().getInteger(R.integer.config_chooser_max_targets_per_row);
@@ -307,12 +303,14 @@ public class ChooserActivity extends ResolverActivity implements
super.onCreate(
savedInstanceState,
mChooserRequest.getTargetIntent(),
+ mChooserRequest.getAdditionalTargets(),
mChooserRequest.getTitle(),
mChooserRequest.getDefaultTitleResource(),
mChooserRequest.getInitialIntents(),
- /* rList: List<ResolveInfo> = */ null,
- /* supportsAlwaysUseOption = */ false,
- new DefaultTargetDataLoader(this, getLifecycle(), false));
+ /* resolutionList= */ null,
+ /* supportsAlwaysUseOption= */ false,
+ new DefaultTargetDataLoader(this, getLifecycle(), false),
+ /* safeForwardingMode= */ true);
mChooserShownTime = System.currentTimeMillis();
final long systemCost = mChooserShownTime - intentReceivedTime;
diff --git a/java/src/com/android/intentresolver/ResolverActivity.java b/java/src/com/android/intentresolver/ResolverActivity.java
index dfc5a021..d0d8aa66 100644
--- a/java/src/com/android/intentresolver/ResolverActivity.java
+++ b/java/src/com/android/intentresolver/ResolverActivity.java
@@ -119,6 +119,7 @@ import com.android.internal.util.LatencyTracker;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
@@ -146,7 +147,14 @@ public class ResolverActivity extends FragmentActivity implements
mIsIntentPicker = isIntentPicker;
}
+ /**
+ * Whether to enable a launch mode that is safe to use when forwarding intents received from
+ * applications and running in system processes. This mode uses Activity.startActivityAsCaller
+ * instead of the normal Activity.startActivity for launching the activity selected
+ * by the user.
+ */
private boolean mSafeForwardingMode;
+
private Button mAlwaysButton;
private Button mOnceButton;
protected View mProfileView;
@@ -335,38 +343,55 @@ public class ResolverActivity extends FragmentActivity implements
mResolvingHome = true;
}
- setSafeForwardingMode(true);
-
- onCreate(savedInstanceState, intent, null, 0, null, null, true, createIconLoader());
+ onCreate(
+ savedInstanceState,
+ intent,
+ /* additionalTargets= */ null,
+ /* title= */ null,
+ /* defaultTitleRes= */ 0,
+ /* initialIntents= */ null,
+ /* resolutionList= */ null,
+ /* supportsAlwaysUseOption= */ true,
+ createIconLoader(),
+ /* safeForwardingMode= */ true);
}
/**
* Compatibility version for other bundled services that use this overload without
* a default title resource
*/
- protected void onCreate(Bundle savedInstanceState, Intent intent,
- CharSequence title, Intent[] initialIntents,
- List<ResolveInfo> rList, boolean supportsAlwaysUseOption) {
+ protected void onCreate(
+ Bundle savedInstanceState,
+ Intent intent,
+ CharSequence title,
+ Intent[] initialIntents,
+ List<ResolveInfo> resolutionList,
+ boolean supportsAlwaysUseOption,
+ boolean safeForwardingMode) {
onCreate(
savedInstanceState,
intent,
+ null,
title,
0,
initialIntents,
- rList,
+ resolutionList,
supportsAlwaysUseOption,
- createIconLoader());
+ createIconLoader(),
+ safeForwardingMode);
}
protected void onCreate(
Bundle savedInstanceState,
Intent intent,
+ Intent[] additionalTargets,
CharSequence title,
int defaultTitleRes,
Intent[] initialIntents,
- List<ResolveInfo> rList,
+ List<ResolveInfo> resolutionList,
boolean supportsAlwaysUseOption,
- TargetDataLoader targetDataLoader) {
+ TargetDataLoader targetDataLoader,
+ boolean safeForwardingMode) {
setTheme(appliedThemeResId());
super.onCreate(savedInstanceState);
@@ -384,12 +409,17 @@ public class ResolverActivity extends FragmentActivity implements
mReferrerPackage = getReferrerPackageName();
- // Add our initial intent as the first item, regardless of what else has already been added.
+ // The initial intent must come before any other targets that are to be added.
mIntents.add(0, new Intent(intent));
+ if (additionalTargets != null) {
+ Collections.addAll(mIntents, additionalTargets);
+ }
+
mTitle = title;
mDefaultTitleResId = defaultTitleRes;
mSupportsAlwaysUseOption = supportsAlwaysUseOption;
+ mSafeForwardingMode = safeForwardingMode;
// The last argument of createResolverListAdapter is whether to do special handling
// of the last used choice to highlight it in the list. We need to always
@@ -402,7 +432,7 @@ public class ResolverActivity extends FragmentActivity implements
boolean filterLastUsed = mSupportsAlwaysUseOption && !isVoiceInteraction()
&& !shouldShowTabs() && !hasCloneProfile();
mMultiProfilePagerAdapter = createMultiProfilePagerAdapter(
- initialIntents, rList, filterLastUsed, targetDataLoader);
+ initialIntents, resolutionList, filterLastUsed, targetDataLoader);
if (configureContentView(targetDataLoader)) {
return;
}
@@ -458,17 +488,17 @@ public class ResolverActivity extends FragmentActivity implements
protected AbstractMultiProfilePagerAdapter createMultiProfilePagerAdapter(
Intent[] initialIntents,
- List<ResolveInfo> rList,
+ List<ResolveInfo> resolutionList,
boolean filterLastUsed,
TargetDataLoader targetDataLoader) {
AbstractMultiProfilePagerAdapter resolverMultiProfilePagerAdapter = null;
if (shouldShowTabs()) {
resolverMultiProfilePagerAdapter =
createResolverMultiProfilePagerAdapterForTwoProfiles(
- initialIntents, rList, filterLastUsed, targetDataLoader);
+ initialIntents, resolutionList, filterLastUsed, targetDataLoader);
} else {
resolverMultiProfilePagerAdapter = createResolverMultiProfilePagerAdapterForOneProfile(
- initialIntents, rList, filterLastUsed, targetDataLoader);
+ initialIntents, resolutionList, filterLastUsed, targetDataLoader);
}
return resolverMultiProfilePagerAdapter;
}
@@ -1046,7 +1076,7 @@ public class ResolverActivity extends FragmentActivity implements
Context context,
List<Intent> payloadIntents,
Intent[] initialIntents,
- List<ResolveInfo> rList,
+ List<ResolveInfo> resolutionList,
boolean filterLastUsed,
UserHandle userHandle,
TargetDataLoader targetDataLoader) {
@@ -1057,7 +1087,7 @@ public class ResolverActivity extends FragmentActivity implements
context,
payloadIntents,
initialIntents,
- rList,
+ resolutionList,
filterLastUsed,
createListController(userHandle),
userHandle,
@@ -1145,14 +1175,14 @@ public class ResolverActivity extends FragmentActivity implements
private ResolverMultiProfilePagerAdapter
createResolverMultiProfilePagerAdapterForOneProfile(
Intent[] initialIntents,
- List<ResolveInfo> rList,
+ List<ResolveInfo> resolutionList,
boolean filterLastUsed,
TargetDataLoader targetDataLoader) {
ResolverListAdapter adapter = createResolverListAdapter(
/* context */ this,
/* payloadIntents */ mIntents,
initialIntents,
- rList,
+ resolutionList,
filterLastUsed,
/* userHandle */ getPersonalProfileUserHandle(),
targetDataLoader);
@@ -1173,7 +1203,7 @@ public class ResolverActivity extends FragmentActivity implements
private ResolverMultiProfilePagerAdapter createResolverMultiProfilePagerAdapterForTwoProfiles(
Intent[] initialIntents,
- List<ResolveInfo> rList,
+ List<ResolveInfo> resolutionList,
boolean filterLastUsed,
TargetDataLoader targetDataLoader) {
// In the edge case when we have 0 apps in the current profile and >1 apps in the other,
@@ -1200,7 +1230,7 @@ public class ResolverActivity extends FragmentActivity implements
/* context */ this,
/* payloadIntents */ mIntents,
selectedProfile == PROFILE_PERSONAL ? initialIntents : null,
- rList,
+ resolutionList,
(filterLastUsed && UserHandle.myUserId()
== getPersonalProfileUserHandle().getIdentifier()),
/* userHandle */ getPersonalProfileUserHandle(),
@@ -1210,7 +1240,7 @@ public class ResolverActivity extends FragmentActivity implements
/* context */ this,
/* payloadIntents */ mIntents,
selectedProfile == PROFILE_WORK ? initialIntents : null,
- rList,
+ resolutionList,
(filterLastUsed && UserHandle.myUserId()
== workProfileUserHandle.getIdentifier()),
/* userHandle */ workProfileUserHandle,
@@ -1368,14 +1398,6 @@ public class ResolverActivity extends FragmentActivity implements
return new Option(target.getDisplayLabel(), index);
}
- protected final void setAdditionalTargets(Intent[] intents) {
- if (intents != null) {
- for (Intent intent : intents) {
- mIntents.add(intent);
- }
- }
- }
-
public final Intent getTargetIntent() {
return mIntents.isEmpty() ? null : mIntents.get(0);
}
@@ -1436,22 +1458,6 @@ public class ResolverActivity extends FragmentActivity implements
() -> getString(R.string.forward_intent_to_work));
}
- /**
- * Turn on launch mode that is safe to use when forwarding intents received from
- * applications and running in system processes. This mode uses Activity.startActivityAsCaller
- * instead of the normal Activity.startActivity for launching the activity selected
- * by the user.
- *
- * <p>This mode is set to true by default if the activity is initialized through
- * {@link #onCreate(android.os.Bundle)}. If a subclass calls one of the other onCreate
- * methods, it is set to false by default. You must set it before calling one of the
- * more detailed onCreate methods, so that it will be set correctly in the case where
- * there is only one intent to resolve and it is thus started immediately.</p>
- */
- public final void setSafeForwardingMode(boolean safeForwarding) {
- mSafeForwardingMode = safeForwarding;
- }
-
protected final CharSequence getTitleForAction(Intent intent, int defaultTitleRes) {
final ActionTitle title = mResolvingHome
? ActionTitle.HOME