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() {
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())) {
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);
}
}
- 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.
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.webkit.IWebViewUpdateService;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
enabled = false;
}
+ try {
+ IWebViewUpdateService webviewUpdateService =
+ IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
+ if (webviewUpdateService.isFallbackPackage(mAppEntry.info.packageName)) {
+ enabled = false;
+ }
+ } catch (RemoteException e) {
+ throw new RuntimeException(e);
+ }
+
mUninstallButton.setEnabled(enabled);
if (enabled) {
// Register listener
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
+import android.webkit.IWebViewUpdateService;
import com.android.settings.R;
private final PackageManager mPm;
private final IPackageManager mIPm;
private final INotificationManager mNm;
+ private final IWebViewUpdateService mWvus;
private final NetworkPolicyManager mNpm;
private final AppOpsManager mAom;
private final Context mContext;
mIPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
mNm = INotificationManager.Stub.asInterface(
ServiceManager.getService(Context.NOTIFICATION_SERVICE));
+ mWvus = IWebViewUpdateService.Stub.asInterface(ServiceManager.getService("webviewupdate"));
mNpm = NetworkPolicyManager.from(context);
mAom = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
}
}
if (!app.enabled) {
if (mPm.getApplicationEnabledSetting(app.packageName)
- == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) {
+ == PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER
+ && !isNonEnableableFallback(app.packageName)) {
mPm.setApplicationEnabledSetting(app.packageName,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT,
PackageManager.DONT_KILL_APP);
}
});
}
+
+ private boolean isNonEnableableFallback(String packageName) {
+ try {
+ return mWvus.isFallbackPackage(packageName);
+ } catch (RemoteException e) {
+ throw new RuntimeException(e);
+ }
+ }
}