Merge "Revert ResolverActivity changes associated with browseables." into rvc-dev

This commit is contained in:
Narayan Kamath
2020-05-28 10:35:09 +00:00
committed by Android (Google) Code Review
10 changed files with 21 additions and 149 deletions

View File

@@ -54,8 +54,6 @@ public abstract class AbstractResolverComparator implements Comparator<ResolvedC
// True if the current share is a link.
private final boolean mHttp;
// can be null if mHttp == false or current user has no default browser package
private final String mDefaultBrowserPackageName;
// message types
static final int RANKER_SERVICE_RESULT = 0;
@@ -102,9 +100,6 @@ public abstract class AbstractResolverComparator implements Comparator<ResolvedC
getContentAnnotations(intent);
mPm = context.getPackageManager();
mUsm = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
mDefaultBrowserPackageName = mHttp
? mPm.getDefaultBrowserPackageNameAsUser(UserHandle.myUserId())
: null;
mAzComparator = new AzInfoComparator(context);
}
@@ -157,17 +152,6 @@ public abstract class AbstractResolverComparator implements Comparator<ResolvedC
}
if (mHttp) {
// Special case: we want filters that match URI paths/schemes to be
// ordered before others. This is for the case when opening URIs,
// to make native apps go above browsers - except for 1 even more special case
// which is the default browser, as we want that to go above them all.
if (isDefaultBrowser(lhs)) {
return -1;
}
if (isDefaultBrowser(rhs)) {
return 1;
}
final boolean lhsSpecific = ResolverActivity.isSpecificUriMatch(lhs.match);
final boolean rhsSpecific = ResolverActivity.isSpecificUriMatch(rhs.match);
if (lhsSpecific != rhsSpecific) {
@@ -272,21 +256,6 @@ public abstract class AbstractResolverComparator implements Comparator<ResolvedC
mAfterCompute = null;
}
private boolean isDefaultBrowser(ResolveInfo ri) {
// It makes sense to prefer the default browser
// only if the targeted user is the current user
if (ri.targetUserId != UserHandle.USER_CURRENT) {
return false;
}
if (ri.activityInfo.packageName != null
&& ri.activityInfo.packageName.equals(mDefaultBrowserPackageName)) {
return true;
}
return false;
}
/**
* Sort intents alphabetically based on package name.
*/

View File

@@ -875,7 +875,6 @@ public class ChooserActivity extends ResolverActivity implements
initialIntents,
rList,
filterLastUsed,
mUseLayoutForBrowsables,
/* userHandle */ UserHandle.of(UserHandle.myUserId()));
return new ChooserMultiProfilePagerAdapter(
/* context */ this,
@@ -896,7 +895,6 @@ public class ChooserActivity extends ResolverActivity implements
selectedProfile == PROFILE_PERSONAL ? initialIntents : null,
rList,
filterLastUsed,
mUseLayoutForBrowsables,
/* userHandle */ getPersonalProfileUserHandle());
ChooserGridAdapter workAdapter = createChooserGridAdapter(
/* context */ this,
@@ -904,7 +902,6 @@ public class ChooserActivity extends ResolverActivity implements
selectedProfile == PROFILE_WORK ? initialIntents : null,
rList,
filterLastUsed,
mUseLayoutForBrowsables,
/* userHandle */ getWorkProfileUserHandle());
return new ChooserMultiProfilePagerAdapter(
/* context */ this,
@@ -2486,10 +2483,10 @@ public class ChooserActivity extends ResolverActivity implements
@VisibleForTesting
public ChooserGridAdapter createChooserGridAdapter(Context context,
List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList,
boolean filterLastUsed, boolean useLayoutForBrowsables, UserHandle userHandle) {
boolean filterLastUsed, UserHandle userHandle) {
ChooserListAdapter chooserListAdapter = createChooserListAdapter(context, payloadIntents,
initialIntents, rList, filterLastUsed,
useLayoutForBrowsables, createListController(userHandle));
createListController(userHandle));
AppPredictor.Callback appPredictorCallback = createAppPredictorCallback(chooserListAdapter);
AppPredictor appPredictor = setupAppPredictorForUser(userHandle, appPredictorCallback);
chooserListAdapter.setAppPredictor(appPredictor);
@@ -2500,11 +2497,10 @@ public class ChooserActivity extends ResolverActivity implements
@VisibleForTesting
public ChooserListAdapter createChooserListAdapter(Context context,
List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList,
boolean filterLastUsed, boolean useLayoutForBrowsables,
ResolverListController resolverListController) {
boolean filterLastUsed, ResolverListController resolverListController) {
return new ChooserListAdapter(context, payloadIntents, initialIntents, rList,
filterLastUsed, resolverListController, useLayoutForBrowsables,
this, this, context.getPackageManager());
filterLastUsed, resolverListController, this,
this, context.getPackageManager());
}
@VisibleForTesting

View File

@@ -120,15 +120,13 @@ public class ChooserListAdapter extends ResolverListAdapter {
public ChooserListAdapter(Context context, List<Intent> payloadIntents,
Intent[] initialIntents, List<ResolveInfo> rList,
boolean filterLastUsed, ResolverListController resolverListController,
boolean useLayoutForBrowsables,
ChooserListCommunicator chooserListCommunicator,
SelectableTargetInfo.SelectableTargetInfoCommunicator selectableTargetInfoCommunicator,
PackageManager packageManager) {
// Don't send the initial intents through the shared ResolverActivity path,
// we want to separate them into a different section.
super(context, payloadIntents, null, rList, filterLastUsed,
resolverListController, useLayoutForBrowsables,
chooserListCommunicator, false);
resolverListController, chooserListCommunicator, false);
createPlaceHolders();
mMaxShortcutTargetsPerApp =

View File

@@ -133,9 +133,6 @@ public class ResolverActivity extends Activity implements
private CharSequence mTitle;
private int mDefaultTitleResId;
@VisibleForTesting
protected boolean mUseLayoutForBrowsables;
// Whether or not this activity supports choosing a default handler for the intent.
@VisibleForTesting
protected boolean mSupportsAlwaysUseOption;
@@ -364,10 +361,6 @@ public class ResolverActivity extends Activity implements
mTitle = title;
mDefaultTitleResId = defaultTitleRes;
mUseLayoutForBrowsables = getTargetIntent() == null
? false
: isHttpSchemeAndViewAction(getTargetIntent());
mSupportsAlwaysUseOption = supportsAlwaysUseOption;
mWorkProfileUserHandle = fetchWorkProfileUserProfile();
@@ -461,7 +454,6 @@ public class ResolverActivity extends Activity implements
initialIntents,
rList,
filterLastUsed,
mUseLayoutForBrowsables,
/* userHandle */ UserHandle.of(UserHandle.myUserId()));
return new ResolverMultiProfilePagerAdapter(
/* context */ this,
@@ -500,7 +492,6 @@ public class ResolverActivity extends Activity implements
rList,
(filterLastUsed && UserHandle.myUserId()
== getPersonalProfileUserHandle().getIdentifier()),
mUseLayoutForBrowsables,
/* userHandle */ getPersonalProfileUserHandle());
UserHandle workProfileUserHandle = getWorkProfileUserHandle();
ResolverListAdapter workAdapter = createResolverListAdapter(
@@ -510,7 +501,6 @@ public class ResolverActivity extends Activity implements
rList,
(filterLastUsed && UserHandle.myUserId()
== workProfileUserHandle.getIdentifier()),
mUseLayoutForBrowsables,
/* userHandle */ workProfileUserHandle);
return new ResolverMultiProfilePagerAdapter(
/* context */ this,
@@ -775,26 +765,6 @@ public class ResolverActivity extends Activity implements
mMultiProfilePagerAdapter.getActiveListAdapter().getFilteredPosition() >= 0;
if (title == ActionTitle.DEFAULT && defaultTitleRes != 0) {
return getString(defaultTitleRes);
} else if (isHttpSchemeAndViewAction(intent)) {
// If the Intent's scheme is http(s) then we need to warn the user that
// they're giving access for the activity to open URLs from this specific host
String dialogTitle = null;
if (named && !mUseLayoutForBrowsables) {
dialogTitle = getString(ActionTitle.BROWSABLE_APP_TITLE_RES,
mMultiProfilePagerAdapter.getActiveListAdapter().getFilteredItem()
.getDisplayLabel());
} else if (named && mUseLayoutForBrowsables) {
dialogTitle = getString(ActionTitle.BROWSABLE_HOST_APP_TITLE_RES,
intent.getData().getHost(),
mMultiProfilePagerAdapter.getActiveListAdapter().getFilteredItem()
.getDisplayLabel());
} else if (mMultiProfilePagerAdapter.getActiveListAdapter().areAllTargetsBrowsers()) {
dialogTitle = getString(ActionTitle.BROWSABLE_TITLE_RES);
} else {
dialogTitle = getString(ActionTitle.BROWSABLE_HOST_TITLE_RES,
intent.getData().getHost());
}
return dialogTitle;
} else {
return named
? getString(title.namedTitleRes, mMultiProfilePagerAdapter
@@ -907,12 +877,6 @@ public class ResolverActivity extends Activity implements
mMultiProfilePagerAdapter.clearInactiveProfileCache();
}
private boolean isHttpSchemeAndViewAction(Intent intent) {
return (IntentFilter.SCHEME_HTTP.equals(intent.getScheme())
|| IntentFilter.SCHEME_HTTPS.equals(intent.getScheme()))
&& Intent.ACTION_VIEW.equals(intent.getAction());
}
private boolean hasManagedProfile() {
UserManager userManager = (UserManager) getSystemService(Context.USER_SERVICE);
if (userManager == null) {
@@ -963,13 +927,9 @@ public class ResolverActivity extends Activity implements
} else {
enabled = true;
}
if (mUseLayoutForBrowsables && !ri.handleAllWebDataURI) {
mAlwaysButton.setText(getResources()
.getString(R.string.activity_resolver_set_always));
} else {
mAlwaysButton.setText(getResources()
.getString(R.string.activity_resolver_use_always));
}
mAlwaysButton.setText(getResources()
.getString(R.string.activity_resolver_use_always));
}
if (ri != null) {
@@ -999,31 +959,7 @@ public class ResolverActivity extends Activity implements
? currentListAdapter.getFilteredPosition()
: listView.getCheckedItemPosition();
boolean hasIndexBeenFiltered = !currentListAdapter.hasFilteredItem();
ResolveInfo ri = currentListAdapter.resolveInfoForPosition(which, hasIndexBeenFiltered);
if (mUseLayoutForBrowsables
&& !ri.handleAllWebDataURI && id == R.id.button_always) {
showSettingsForSelected(ri);
} else {
startSelected(which, id == R.id.button_always, hasIndexBeenFiltered);
}
}
private void showSettingsForSelected(ResolveInfo ri) {
Intent intent = new Intent();
final String packageName = ri.activityInfo.packageName;
Bundle showFragmentArgs = new Bundle();
showFragmentArgs.putString(EXTRA_FRAGMENT_ARG_KEY, OPEN_LINKS_COMPONENT_KEY);
showFragmentArgs.putString("package", packageName);
// For regular apps, we open the Open by Default page
intent.setAction(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS)
.setData(Uri.fromParts("package", packageName, null))
.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT)
.putExtra(EXTRA_FRAGMENT_ARG_KEY, OPEN_LINKS_COMPONENT_KEY)
.putExtra(EXTRA_SHOW_FRAGMENT_ARGS, showFragmentArgs);
startActivity(intent);
startSelected(which, id == R.id.button_always, hasIndexBeenFiltered);
}
public void startSelected(int which, boolean always, boolean hasIndexBeenFiltered) {
@@ -1415,12 +1351,12 @@ public class ResolverActivity extends Activity implements
@VisibleForTesting
protected ResolverListAdapter createResolverListAdapter(Context context,
List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList,
boolean filterLastUsed, boolean useLayoutForBrowsables, UserHandle userHandle) {
boolean filterLastUsed, UserHandle userHandle) {
Intent startIntent = getIntent();
boolean isAudioCaptureDevice =
startIntent.getBooleanExtra(EXTRA_IS_AUDIO_CAPTURE_DEVICE, false);
return new ResolverListAdapter(context, payloadIntents, initialIntents, rList,
filterLastUsed, createListController(userHandle), useLayoutForBrowsables, this,
filterLastUsed, createListController(userHandle), this,
isAudioCaptureDevice);
}
@@ -1794,7 +1730,7 @@ public class ResolverActivity extends Activity implements
listView.setOnItemClickListener(listener);
listView.setOnItemLongClickListener(listener);
if (mSupportsAlwaysUseOption || mUseLayoutForBrowsables) {
if (mSupportsAlwaysUseOption) {
listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
}
}
@@ -1835,7 +1771,7 @@ public class ResolverActivity extends Activity implements
}
protected void resetButtonBar() {
if (!mSupportsAlwaysUseOption && !mUseLayoutForBrowsables) {
if (!mSupportsAlwaysUseOption) {
return;
}
final ViewGroup buttonLayout = findViewById(R.id.button_bar);

View File

@@ -69,13 +69,11 @@ public class ResolverListAdapter extends BaseAdapter {
private final PackageManager mPm;
protected final Context mContext;
private final ColorMatrixColorFilter mSuspendedMatrixColorFilter;
private final boolean mUseLayoutForBrowsables;
private final int mIconDpi;
protected ResolveInfo mLastChosen;
private DisplayResolveInfo mOtherProfile;
ResolverListController mResolverListController;
private int mPlaceholderCount;
private boolean mAllTargetsAreBrowsers = false;
protected final LayoutInflater mInflater;
@@ -94,7 +92,6 @@ public class ResolverListAdapter extends BaseAdapter {
Intent[] initialIntents, List<ResolveInfo> rList,
boolean filterLastUsed,
ResolverListController resolverListController,
boolean useLayoutForBrowsables,
ResolverListCommunicator resolverListCommunicator,
boolean isAudioCaptureDevice) {
mContext = context;
@@ -107,7 +104,6 @@ public class ResolverListAdapter extends BaseAdapter {
mFilterLastUsed = filterLastUsed;
mResolverListController = resolverListController;
mSuspendedMatrixColorFilter = createSuspendedColorMatrix();
mUseLayoutForBrowsables = useLayoutForBrowsables;
mResolverListCommunicator = resolverListCommunicator;
mIsAudioCaptureDevice = isAudioCaptureDevice;
final ActivityManager am = (ActivityManager) mContext.getSystemService(ACTIVITY_SERVICE);
@@ -182,14 +178,6 @@ public class ResolverListAdapter extends BaseAdapter {
return mUnfilteredResolveList;
}
/**
* @return true if all items in the display list are defined as browsers by
* ResolveInfo.handleAllWebDataURI
*/
public boolean areAllTargetsBrowsers() {
return mAllTargetsAreBrowsers;
}
/**
* Rebuild the list of resolvers. In some cases some parts will need some asynchronous work
* to complete.
@@ -207,7 +195,6 @@ public class ResolverListAdapter extends BaseAdapter {
mOtherProfile = null;
mLastChosen = null;
mLastChosenPosition = -1;
mAllTargetsAreBrowsers = false;
mDisplayList.clear();
mIsTabLoaded = false;
@@ -322,8 +309,6 @@ public class ResolverListAdapter extends BaseAdapter {
boolean doPostProcessing) {
int n;
if (sortedComponents != null && (n = sortedComponents.size()) != 0) {
mAllTargetsAreBrowsers = mUseLayoutForBrowsables;
// First put the initial items at the top.
if (mInitialIntents != null) {
for (int i = 0; i < mInitialIntents.length; i++) {
@@ -353,7 +338,6 @@ public class ResolverListAdapter extends BaseAdapter {
ri.noResourceId = true;
ri.icon = 0;
}
mAllTargetsAreBrowsers &= ri.handleAllWebDataURI;
addResolveInfo(new DisplayResolveInfo(ii, ri,
ri.loadLabel(mPm), null, ii, makePresentationGetter(ri)));
@@ -364,7 +348,6 @@ public class ResolverListAdapter extends BaseAdapter {
for (ResolvedComponentInfo rci : sortedComponents) {
final ResolveInfo ri = rci.getResolveInfoAt(0);
if (ri != null) {
mAllTargetsAreBrowsers &= ri.handleAllWebDataURI;
addResolveInfoWithAlternates(rci);
}
}

View File

@@ -4137,18 +4137,10 @@
as the default in the activity resolver. [CHAR LIMIT=25] -->
<string name="activity_resolver_use_always">Always</string>
<!-- Title for a button to choose the currently selected activity
as the default in the activity resolver. [CHAR LIMIT=50] -->
<string name="activity_resolver_set_always">Set to always open</string>
<!-- Title for a button to choose the currently selected activity
from the activity resolver to use just this once. [CHAR LIMIT=25] -->
<string name="activity_resolver_use_once">Just once</string>
<!-- Title for a button to choose to go to
'Open by Default' app settings. [CHAR LIMIT=25] -->
<string name="activity_resolver_app_settings">Settings</string>
<!-- Text for the toast that is shown when the user clicks on a launcher that
doesn't support the work profile. [CHAR LIMIT=100] -->
<string name="activity_resolver_work_profiles_support">%1$s doesn\'t support work profile</string>

View File

@@ -2552,7 +2552,6 @@
<java-symbol type="bool" name="config_allow_ussd_over_ims" />
<java-symbol type="attr" name="touchscreenBlocksFocus" />
<java-symbol type="layout" name="resolver_list_with_default" />
<java-symbol type="string" name="activity_resolver_set_always" />
<java-symbol type="string" name="activity_resolver_use_always" />
<java-symbol type="string" name="whichApplicationNamed" />
<java-symbol type="string" name="whichApplicationLabel" />

View File

@@ -61,12 +61,12 @@ public class ChooserWrapperActivity extends ChooserActivity {
@Override
public ChooserListAdapter createChooserListAdapter(Context context, List<Intent> payloadIntents,
Intent[] initialIntents, List<ResolveInfo> rList, boolean filterLastUsed,
boolean useLayoutForBrowsables, ResolverListController resolverListController) {
ResolverListController resolverListController) {
PackageManager packageManager =
sOverrides.packageManager == null ? context.getPackageManager()
: sOverrides.packageManager;
return new ChooserListAdapter(context, payloadIntents, initialIntents, rList,
filterLastUsed, resolverListController, useLayoutForBrowsables,
filterLastUsed, resolverListController,
this, this, packageManager);
}

View File

@@ -42,9 +42,9 @@ public class ResolverWrapperActivity extends ResolverActivity {
@Override
public ResolverListAdapter createResolverListAdapter(Context context,
List<Intent> payloadIntents, Intent[] initialIntents, List<ResolveInfo> rList,
boolean filterLastUsed, boolean useLayoutForBrowsables, UserHandle userHandle) {
boolean filterLastUsed, UserHandle userHandle) {
return new ResolverWrapperAdapter(context, payloadIntents, initialIntents, rList,
filterLastUsed, createListController(userHandle), useLayoutForBrowsables, this);
filterLastUsed, createListController(userHandle), this);
}
@Override
@@ -166,4 +166,4 @@ public class ResolverWrapperActivity extends ResolverActivity {
};
}
}
}
}

View File

@@ -35,11 +35,10 @@ public class ResolverWrapperAdapter extends ResolverListAdapter {
List<Intent> payloadIntents,
Intent[] initialIntents,
List<ResolveInfo> rList, boolean filterLastUsed,
ResolverListController resolverListController, boolean useLayoutForBrowsables,
ResolverListController resolverListController,
ResolverListCommunicator resolverListCommunicator) {
super(context, payloadIntents, initialIntents, rList, filterLastUsed,
resolverListController,
useLayoutForBrowsables, resolverListCommunicator, false);
resolverListController, resolverListCommunicator, false);
}
public CountingIdlingResource getLabelIdlingResource() {