Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eedcdb04 authored by Gustav Sennton's avatar Gustav Sennton Committed by Android (Google) Code Review
Browse files

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

parents b898ce95 26c82fff
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -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_LOAD_LIBRARY = 6; // 0x6
    field public static final int LIBLOAD_FAILED_TO_OPEN_RELRO_FILE = 5; // 0x5
    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_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_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
    field public static final int LIBLOAD_WRONG_PACKAGE_NAME = 1; // 0x1
  }
  }
+1 −4
Original line number Original line Diff line number Diff line
@@ -103,8 +103,7 @@ public final class WebViewFactory {
    public static final int LIBLOAD_FAILED_JNI_CALL = 7;
    public static final int LIBLOAD_FAILED_JNI_CALL = 7;


    // more error codes for waiting for WebView preparation
    // 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 = 8;
    public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 9;


    // error for namespace lookup
    // error for namespace lookup
    public static final int LIBLOAD_FAILED_TO_FIND_NAMESPACE = 10;
    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";
                return "Time out waiting for Relro files being created";
            case LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES:
            case LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES:
                return "No WebView installed";
                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:
            case LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN:
                return "Crashed for unknown reason";
                return "Crashed for unknown reason";
        }
        }
+4 −29
Original line number Original line Diff line number Diff line
@@ -66,8 +66,6 @@ public class WebViewUpdateService extends SystemService {
    private int mNumRelroCreationsFinished = 0;
    private int mNumRelroCreationsFinished = 0;
    // Implies that we need to rerun relro creation because we are using an out-of-date package
    // Implies that we need to rerun relro creation because we are using an out-of-date package
    private boolean mWebViewPackageDirty = false;
    private boolean mWebViewPackageDirty = false;
    // Set to true when the current provider is being replaced
    private boolean mCurrentProviderBeingReplaced = false;
    private boolean mAnyWebViewInstalled = false;
    private boolean mAnyWebViewInstalled = false;


    private int NUMBER_OF_RELROS_UNKNOWN = Integer.MAX_VALUE;
    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
                    // the removal of the old package and one representing the addition of the
                    // new package.
                    // new package.
                    // In the case where we receive an intent to remove the old version of the
                    // 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
                    // package that is being replaced we early-out here so that we don't run the
                    // don't change provider while replacing the current package (we will instead
                    // update-logic twice.
                    // change provider when the new version of the package is being installed).
                    if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)
                    if (intent.getAction().equals(Intent.ACTION_PACKAGE_REMOVED)
                        && intent.getExtras().getBoolean(Intent.EXTRA_REPLACING)) {
                        && 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;
                        return;
                    }
                    }


@@ -406,9 +395,6 @@ public class WebViewUpdateService extends SystemService {
    private void onWebViewProviderChanged(PackageInfo newPackage) {
    private void onWebViewProviderChanged(PackageInfo newPackage) {
        synchronized(this) {
        synchronized(this) {
            mAnyWebViewInstalled = true;
            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) {
            if (mNumRelroCreationsStarted == mNumRelroCreationsFinished) {
                mCurrentWebViewPackage = newPackage;
                mCurrentWebViewPackage = newPackage;
                updateUserSetting(newPackage.packageName);
                updateUserSetting(newPackage.packageName);
@@ -504,7 +490,6 @@ public class WebViewUpdateService extends SystemService {
    private boolean webViewIsReadyLocked() {
    private boolean webViewIsReadyLocked() {
        return !mWebViewPackageDirty
        return !mWebViewPackageDirty
            && (mNumRelroCreationsStarted == mNumRelroCreationsFinished)
            && (mNumRelroCreationsStarted == mNumRelroCreationsFinished)
            && !mCurrentProviderBeingReplaced
            // The current package might be replaced though we haven't received an intent declaring
            // 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.
            // this yet, the following flag makes anyone loading WebView to wait in this case.
            && mAnyWebViewInstalled;
            && mAnyWebViewInstalled;
@@ -516,13 +501,8 @@ public class WebViewUpdateService extends SystemService {
                mWebViewPackageDirty = false;
                mWebViewPackageDirty = false;
                // If we have changed provider since we started the relro creation we need to
                // If we have changed provider since we started the relro creation we need to
                // redo the whole process using the new package instead.
                // 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();
                PackageInfo newPackage = findPreferredWebViewPackage();
                onWebViewProviderChanged(newPackage);
                onWebViewProviderChanged(newPackage);
                }
            } else {
            } else {
                this.notifyAll();
                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
                // Make sure we return the provider that was used to create the relro file
                webViewPackage = WebViewUpdateService.this.mCurrentWebViewPackage;
                webViewPackage = WebViewUpdateService.this.mCurrentWebViewPackage;
                if (webViewReady) {
                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) {
                } else if (!mAnyWebViewInstalled) {
                    webViewStatus = WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES;
                    webViewStatus = WebViewFactory.LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES;
                } else {
                } else {