Block the user from enabling or disabling webview fallback packages.
Now that we support webview fallback packages - packages that should be enabled if and only if no other webview packages are available - we need to ensure that the Settings UI consistently shows that these packages cannot be enabled or disabled (e.g. the 'Enable' and 'Disable' buttons for enabling/disabling them are greyed out). Also, remove the Dialog that lets a user enable a disabled webview package from the webview implementation Dev Setting. Instead show a Toast if the user has chosen an invalid package. Bug: 26375524, 26375860 Change-Id: I949083d3f7c83cd2e049dd2c5c15ec5ab880fe07
This commit is contained in:
@@ -821,13 +821,15 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
mBtHciSnoopLog.isChecked() ? 1 : 0);
|
||||
}
|
||||
|
||||
private void writeWebViewProviderOptions(Object newValue) {
|
||||
private boolean writeWebViewProviderOptions(Object newValue) {
|
||||
try {
|
||||
mWebViewUpdateService.changeProviderAndSetting(
|
||||
String updatedProvider = mWebViewUpdateService.changeProviderAndSetting(
|
||||
newValue == null ? "" : newValue.toString());
|
||||
updateWebViewProviderOptions();
|
||||
return newValue != null && newValue.equals(updatedProvider);
|
||||
} catch(RemoteException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void writeDebuggerOptions() {
|
||||
@@ -1933,18 +1935,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
return false;
|
||||
}
|
||||
|
||||
private void enableAndSetWebViewPackage(String packageName) {
|
||||
getActivity().getPackageManager().setApplicationEnabledSetting(packageName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0);
|
||||
mWebViewProvider.setValue(packageName);
|
||||
writeWebViewProviderOptions(packageName);
|
||||
}
|
||||
|
||||
private void showEnableWebViewProviderAlert(final String packageName) {
|
||||
EnableWebViewProviderDialogFragment.newInstance(packageName).show(
|
||||
getChildFragmentManager(), EnableWebViewProviderDialogFragment.TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
|
||||
@@ -1957,19 +1947,15 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
Log.e(TAG, "Tried to set a null WebView provider");
|
||||
return false;
|
||||
}
|
||||
String newWebViewPackageName = (String) newValue;
|
||||
if (isPackageEnabled(newWebViewPackageName)) {
|
||||
writeWebViewProviderOptions(newValue);
|
||||
if (writeWebViewProviderOptions(newValue)) {
|
||||
return true;
|
||||
} else {
|
||||
// The user chose a package that became invalid since the list was last updated,
|
||||
// show a Toast to explain the situation.
|
||||
Toast toast = Toast.makeText(getActivity(),
|
||||
R.string.select_webview_provider_toast_text, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
// Package is disabled or uninstalled, if it is simply disabled, check if the user wants
|
||||
// to enable it
|
||||
if (isPackageInstalled(getActivity(), newWebViewPackageName)) {
|
||||
showEnableWebViewProviderAlert(newWebViewPackageName);
|
||||
return false;
|
||||
}
|
||||
// Package has been uninstalled (could happen if the package was uninstalled between
|
||||
// opening and closing the setting).
|
||||
return false;
|
||||
} else if (preference == mLogdSize) {
|
||||
writeLogdSizeOption(newValue);
|
||||
@@ -2128,36 +2114,6 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
}
|
||||
}
|
||||
|
||||
public static class EnableWebViewProviderDialogFragment extends DialogFragment {
|
||||
public static final String TAG = "EnableWebViewProviderDialogFragment";
|
||||
private static final String PACKAGE_NAME_TAG = "packageName";
|
||||
|
||||
public static EnableWebViewProviderDialogFragment newInstance(String packageName) {
|
||||
EnableWebViewProviderDialogFragment fragment
|
||||
= new EnableWebViewProviderDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PACKAGE_NAME_TAG, packageName);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final String packageName = getArguments().getString(PACKAGE_NAME_TAG);
|
||||
|
||||
return new AlertDialog.Builder(getActivity())
|
||||
.setMessage(R.string.select_webview_provider_confirmation_text)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
((DevelopmentSettings)getParentFragment()).enableAndSetWebViewPackage(
|
||||
packageName);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For Search.
|
||||
|
Reference in New Issue
Block a user