Merge "Move current WebView provider from Settings.Secure to Settings.Global" into nyc-dev
am: 7a002a215d
* commit '7a002a215db498d232100c0b227d145244a03412':
Move current WebView provider from Settings.Secure to Settings.Global
This commit is contained in:
@@ -5906,13 +5906,6 @@ public final class Settings {
|
||||
public static final String CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED =
|
||||
"camera_double_tap_power_gesture_disabled";
|
||||
|
||||
/**
|
||||
* Name of the package used as WebView provider (if unset the provider is instead determined
|
||||
* by the system).
|
||||
* @hide
|
||||
*/
|
||||
public static final String WEBVIEW_PROVIDER = "webview_provider";
|
||||
|
||||
/**
|
||||
* This are the settings to be backed up.
|
||||
*
|
||||
@@ -6940,6 +6933,13 @@ public final class Settings {
|
||||
public static final String WEBVIEW_DATA_REDUCTION_PROXY_KEY =
|
||||
"webview_data_reduction_proxy_key";
|
||||
|
||||
/**
|
||||
* Name of the package used as WebView provider (if unset the provider is instead determined
|
||||
* by the system).
|
||||
* @hide
|
||||
*/
|
||||
public static final String WEBVIEW_PROVIDER = "webview_provider";
|
||||
|
||||
/**
|
||||
* Whether Wifi display is enabled/disabled
|
||||
* 0=disabled. 1=enabled.
|
||||
|
||||
@@ -97,22 +97,12 @@ public class WebViewProviderInfo implements Parcelable {
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
try {
|
||||
PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
|
||||
int enabled_state = pm.getApplicationEnabledSetting(packageName);
|
||||
switch (enabled_state) {
|
||||
case PackageManager.COMPONENT_ENABLED_STATE_ENABLED:
|
||||
return true;
|
||||
case PackageManager.COMPONENT_ENABLED_STATE_DEFAULT:
|
||||
ApplicationInfo applicationInfo = getPackageInfo().applicationInfo;
|
||||
return applicationInfo.enabled;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
// Explicitly fetch up-to-date package info here since the enabled-state of the package
|
||||
// might have changed since we last fetched its package info.
|
||||
updatePackageInfo();
|
||||
return getPackageInfo().applicationInfo.enabled;
|
||||
} catch (WebViewPackageNotFoundException e) {
|
||||
return false;
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Thrown by PackageManager.getApplicationEnabledSetting if the package does not exist
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,14 +114,18 @@ public class WebViewProviderInfo implements Parcelable {
|
||||
return availableByDefault;
|
||||
}
|
||||
|
||||
private void updatePackageInfo() {
|
||||
try {
|
||||
PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
|
||||
packageInfo = pm.getPackageInfo(packageName, PACKAGE_FLAGS);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
throw new WebViewPackageNotFoundException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public PackageInfo getPackageInfo() {
|
||||
if (packageInfo == null) {
|
||||
try {
|
||||
PackageManager pm = AppGlobals.getInitialApplication().getPackageManager();
|
||||
packageInfo = pm.getPackageInfo(packageName, PACKAGE_FLAGS);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
throw new WebViewPackageNotFoundException(e);
|
||||
}
|
||||
updatePackageInfo();
|
||||
}
|
||||
return packageInfo;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.provider.Settings.Global;
|
||||
import android.util.AndroidRuntimeException;
|
||||
import android.util.Slog;
|
||||
import android.webkit.IWebViewUpdateService;
|
||||
@@ -91,7 +91,7 @@ public class WebViewUpdateService extends SystemService {
|
||||
// change provider when the new version of the package is being installed).
|
||||
if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)
|
||||
&& intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)) {
|
||||
synchronized(this) {
|
||||
synchronized(WebViewUpdateService.this) {
|
||||
if (mCurrentWebViewPackage == null) return;
|
||||
|
||||
String webViewPackage = "package:" + mCurrentWebViewPackage.packageName;
|
||||
@@ -268,13 +268,13 @@ public class WebViewUpdateService extends SystemService {
|
||||
}
|
||||
|
||||
private static String getUserChosenWebViewProvider() {
|
||||
return Settings.Secure.getString(AppGlobals.getInitialApplication().getContentResolver(),
|
||||
Settings.Secure.WEBVIEW_PROVIDER);
|
||||
return Settings.Global.getString(AppGlobals.getInitialApplication().getContentResolver(),
|
||||
Settings.Global.WEBVIEW_PROVIDER);
|
||||
}
|
||||
|
||||
private void updateUserSetting(String newProviderName) {
|
||||
Settings.Secure.putString(getContext().getContentResolver(),
|
||||
Settings.Secure.WEBVIEW_PROVIDER,
|
||||
Settings.Global.putString(getContext().getContentResolver(),
|
||||
Settings.Global.WEBVIEW_PROVIDER,
|
||||
newProviderName == null ? "" : newProviderName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user