Update WebViewUpdateService to receive PACKAGE_REPLACED broadcast.

This allows the WebViewUpdateService to receive notifications that
an update has been installed and we need to trigger recreation of
the relro file.

bug: 16329377
Change-Id: I088e61487416add997995db304beca0cde71390c
This commit is contained in:
Ben Murdoch
2014-07-17 14:55:00 +01:00
parent 6ccb5f894e
commit dc00a84af1
3 changed files with 37 additions and 2 deletions

View File

@@ -63,6 +63,11 @@ public final class WebViewFactory {
private static final Object sProviderLock = new Object();
private static boolean sAddressSpaceReserved = false;
public static String getWebViewPackageName() {
// TODO: Make this dynamic based on resource configuration.
return "com.android.webview";
}
static WebViewFactoryProvider getProvider() {
synchronized (sProviderLock) {
// For now the main purpose of this function (and the factory abstraction) is to keep

View File

@@ -16,10 +16,15 @@
package com.android.server.webkit;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Binder;
import android.os.Process;
import android.util.Log;
import android.webkit.IWebViewUpdateService;
import android.webkit.WebViewFactory;
/**
* Private service to wait for the updatable WebView to be ready for use.
@@ -32,7 +37,22 @@ public class WebViewUpdateService extends IWebViewUpdateService.Stub {
private boolean mRelroReady32Bit = false;
private boolean mRelroReady64Bit = false;
public WebViewUpdateService() {
private BroadcastReceiver mWebViewUpdatedReceiver;
public WebViewUpdateService(Context context) {
mWebViewUpdatedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String webviewPackage = "package:" + WebViewFactory.getWebViewPackageName();
if (webviewPackage.equals(intent.getDataString())) {
onWebViewUpdateInstalled();
}
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
filter.addDataScheme("package");
context.registerReceiver(mWebViewUpdatedReceiver, filter);
}
/**
@@ -75,4 +95,14 @@ public class WebViewUpdateService extends IWebViewUpdateService.Stub {
}
}
}
private void onWebViewUpdateInstalled() {
Log.d(TAG, "WebView Package updated!");
synchronized (this) {
mRelroReady32Bit = false;
mRelroReady64Bit = false;
}
WebViewFactory.prepareWebViewInSystemServer();
}
}

View File

@@ -411,7 +411,7 @@ public final class SystemServer {
SystemConfig.getInstance();
Slog.i(TAG, "WebView Update Service");
ServiceManager.addService("webviewupdate", new WebViewUpdateService());
ServiceManager.addService("webviewupdate", new WebViewUpdateService(context));
Slog.i(TAG, "WebViewFactory preparation");
WebViewFactory.prepareWebViewInSystemServer();