Display browsable layout for http/s scheme intents
Displays Settings button instead of always button for all intents that have http or https scheme, as opposed to only intents that have BROWSABLE as category. This fixes an inconsistent and confusing behaviour that users were experiencing, as sometimes they saw the Always button and sometime the Settings button. Fixes: 126499502 Test: open a mail.google.com from Facebook Messenger - used to display Always button and now displays Settings button Test: use shell command to send https intent without BROWSABLE category - used to display Always button and now displays Settings button Change-Id: I1084fd716ba8e584c2b17d8fe1500dbc641cab46
This commit is contained in:
@@ -194,7 +194,7 @@ public class ResolverActivity extends Activity {
|
||||
com.android.internal.R.string.whichHomeApplicationNamed,
|
||||
com.android.internal.R.string.whichHomeApplicationLabel);
|
||||
|
||||
// SpR.id.buttonecial titles for BROWSABLE components
|
||||
// titles for layout that deals with http(s) intents
|
||||
public static final int BROWSABLE_TITLE_RES =
|
||||
com.android.internal.R.string.whichGiveAccessToApplication;
|
||||
public static final int BROWSABLE_NAMED_TITLE_RES =
|
||||
@@ -302,7 +302,7 @@ public class ResolverActivity extends Activity {
|
||||
|
||||
mUseLayoutForBrowsables = getTargetIntent() == null
|
||||
? false
|
||||
: getTargetIntent().hasCategory(Intent.CATEGORY_BROWSABLE);
|
||||
: isHttpSchemeAndViewAction(getTargetIntent());
|
||||
|
||||
// We don't want to support Always Use if browsable layout is being used,
|
||||
// as to mitigate Intent Capturing vulnerability
|
||||
@@ -473,8 +473,8 @@ public class ResolverActivity extends Activity {
|
||||
final boolean named = mAdapter.getFilteredPosition() >= 0;
|
||||
if (title == ActionTitle.DEFAULT && defaultTitleRes != 0) {
|
||||
return getString(defaultTitleRes);
|
||||
} else if (intent.hasCategory(Intent.CATEGORY_BROWSABLE)) {
|
||||
// If the Intent is BROWSABLE then we need to warn the user that
|
||||
} 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
|
||||
return named
|
||||
? getString(ActionTitle.BROWSABLE_NAMED_TITLE_RES, intent.getData().getHost(),
|
||||
@@ -583,6 +583,12 @@ public class ResolverActivity extends Activity {
|
||||
resetButtonBar();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user