Merge "Remove WebView-package-being-replaced logic from WebViewUpdateService." into nyc-dev

This commit is contained in:
Gustav Sennton
2016-03-18 10:52:32 +00:00
committed by Android (Google) Code Review
3 changed files with 6 additions and 35 deletions

View File

@@ -48673,9 +48673,8 @@ package android.webkit {
field public static final int LIBLOAD_FAILED_TO_LOAD_LIBRARY = 6; // 0x6
field public static final int LIBLOAD_FAILED_TO_OPEN_RELRO_FILE = 5; // 0x5
field public static final int LIBLOAD_FAILED_WAITING_FOR_RELRO = 3; // 0x3
field public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 9; // 0x9
field public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 8; // 0x8
field public static final int LIBLOAD_SUCCESS = 0; // 0x0
field public static final int LIBLOAD_WEBVIEW_BEING_REPLACED = 8; // 0x8
field public static final int LIBLOAD_WRONG_PACKAGE_NAME = 1; // 0x1
}

View File

@@ -103,8 +103,7 @@ public final class WebViewFactory {
public static final int LIBLOAD_FAILED_JNI_CALL = 7;
// more error codes for waiting for WebView preparation
public static final int LIBLOAD_WEBVIEW_BEING_REPLACED = 8;
public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 9;
public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 8;
// error for namespace lookup
public static final int LIBLOAD_FAILED_TO_FIND_NAMESPACE = 10;
@@ -115,8 +114,6 @@ public final class WebViewFactory {
return "Time out waiting for Relro files being created";
case LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES:
return "No WebView installed";
case LIBLOAD_WEBVIEW_BEING_REPLACED:
return "Time out waiting for WebView to be replaced";
case LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN:
return "Crashed for unknown reason";
}

View File

@@ -66,8 +66,6 @@ public class WebViewUpdateService extends SystemService {
private int mNumRelroCreationsFinished = 0;
// Implies that we need to rerun relro creation because we are using an out-of-date package
private boolean mWebViewPackageDirty = false;
// Set to true when the current provider is being replaced
private boolean mCurrentProviderBeingReplaced = false;
private boolean mAnyWebViewInstalled = false;
private int NUMBER_OF_RELROS_UNKNOWN = Integer.MAX_VALUE;
@@ -92,19 +90,10 @@ public class WebViewUpdateService extends SystemService {
// the removal of the old package and one representing the addition of the
// new package.
// In the case where we receive an intent to remove the old version of the
// package that is being replaced we set a flag here and early-out so that we
// don't change provider while replacing the current package (we will instead
// change provider when the new version of the package is being installed).
// package that is being replaced we early-out here so that we don't run the
// update-logic twice.
if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)
&& intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)) {
synchronized(WebViewUpdateService.this) {
if (mCurrentWebViewPackage == null) return;
String webViewPackage = "package:" + mCurrentWebViewPackage.packageName;
if (webViewPackage.equals(intent.getDataString()))
mCurrentProviderBeingReplaced = true;
}
return;
}
@@ -406,9 +395,6 @@ public class WebViewUpdateService extends SystemService {
private void onWebViewProviderChanged(PackageInfo newPackage) {
synchronized(this) {
mAnyWebViewInstalled = true;
// If we have changed provider then the replacement of the old provider is
// irrelevant - we can only have chosen a new provider if its package is available.
mCurrentProviderBeingReplaced = false;
if (mNumRelroCreationsStarted == mNumRelroCreationsFinished) {
mCurrentWebViewPackage = newPackage;
updateUserSetting(newPackage.packageName);
@@ -504,7 +490,6 @@ public class WebViewUpdateService extends SystemService {
private boolean webViewIsReadyLocked() {
return !mWebViewPackageDirty
&& (mNumRelroCreationsStarted == mNumRelroCreationsFinished)
&& !mCurrentProviderBeingReplaced
// The current package might be replaced though we haven't received an intent declaring
// this yet, the following flag makes anyone loading WebView to wait in this case.
&& mAnyWebViewInstalled;
@@ -516,13 +501,8 @@ public class WebViewUpdateService extends SystemService {
mWebViewPackageDirty = false;
// If we have changed provider since we started the relro creation we need to
// redo the whole process using the new package instead.
// Though, if the current provider package is being replaced we don't want to change
// provider here since we will perform the change either when the package is added
// again or when we switch to another provider (whichever comes first).
if (!mCurrentProviderBeingReplaced) {
PackageInfo newPackage = findPreferredWebViewPackage();
onWebViewProviderChanged(newPackage);
}
PackageInfo newPackage = findPreferredWebViewPackage();
onWebViewProviderChanged(newPackage);
} else {
this.notifyAll();
}
@@ -597,11 +577,6 @@ public class WebViewUpdateService extends SystemService {
// Make sure we return the provider that was used to create the relro file
webViewPackage = WebViewUpdateService.this.mCurrentWebViewPackage;
if (webViewReady) {
} else if (mCurrentProviderBeingReplaced) {
// It is important that we check this flag before the one representing WebView
// being installed, otherwise we might think there is no WebView though the
// current one is just being replaced.
webViewStatus = WebViewFactory.LIBLOAD_WEBVIEW_BEING_REPLACED;
} else if (!mAnyWebViewInstalled) {
webViewStatus = WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES;
} else {