Remove WebView-package-being-replaced logic from WebViewUpdateService.
The replacing-logic tries to handle packages being uninstalled while
being replaced. This can't be handled through listening to
package-replaced intents since those can be delivered long after the
actual problem occurs.
Bug: 27605997
Change-Id: Iba8e546a5bba1ceb6226d4edb71db088c81ae1a9
diff --git a/api/system-current.txt b/api/system-current.txt
index 7412908..2c164ff 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -48712,9 +48712,8 @@
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
}
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java
index 0751ab0..c280b81 100644
--- a/core/java/android/webkit/WebViewFactory.java
+++ b/core/java/android/webkit/WebViewFactory.java
@@ -103,8 +103,7 @@
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 @@
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";
}
diff --git a/services/core/java/com/android/server/webkit/WebViewUpdateService.java b/services/core/java/com/android/server/webkit/WebViewUpdateService.java
index 2db6b5d..a4bbb51 100644
--- a/services/core/java/com/android/server/webkit/WebViewUpdateService.java
+++ b/services/core/java/com/android/server/webkit/WebViewUpdateService.java
@@ -66,8 +66,6 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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 {