summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit
diff options
context:
space:
mode:
authorPrimiano Tucci <primiano@google.com>2014-07-25 18:03:16 +0100
committerBen Murdoch <benm@google.com>2014-08-01 14:24:09 +0100
commit810c052d9b117217152c2a609ccec056a2a61d1e (patch)
treefbc663c7cf06cba6a8eda4accbe7d718023c646f /core/java/android/webkit
parent6c778cebc73e7eb76510f6e2183d804b8c07082b (diff)
downloadframeworks_base-810c052d9b117217152c2a609ccec056a2a61d1e.zip
frameworks_base-810c052d9b117217152c2a609ccec056a2a61d1e.tar.gz
frameworks_base-810c052d9b117217152c2a609ccec056a2a61d1e.tar.bz2
Cherry pick Introduce startIsolatedProcess private API in ActivityManager DO NOT MERGE
The new API spawns a isolated process, using a custom uid, entrypoint and abi. Such API is used by the WebViewFactory to spawn its unpriviledged but trusted process (hence the fixed uid) which rewrites the rerlo file on boot / when an update occurs. Since both the ActivityManager service and the WebViewUpdate service live in the SystemServer their calls be dispatched locally and no binder interface needs to be exposed for the new startIsolatedProcess API. Original BUG:16403706 Original Change-Id: I327b59735c12698595e0dbcc4da5d759c9103b0a Bug: 16723226 Change-Id: Iecb49888e11eec9d302d9712953fd498db5821af
Diffstat (limited to 'core/java/android/webkit')
-rw-r--r--core/java/android/webkit/WebViewFactory.java46
1 files changed, 28 insertions, 18 deletions
diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java
index 0401fb7..ef3ab4a 100644
--- a/core/java/android/webkit/WebViewFactory.java
+++ b/core/java/android/webkit/WebViewFactory.java
@@ -16,6 +16,7 @@
package android.webkit;
+import android.app.ActivityManagerInternal;
import android.app.AppGlobals;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -26,6 +27,7 @@ import android.os.ServiceManager;
import android.os.StrictMode;
import android.util.AndroidRuntimeException;
import android.util.Log;
+import com.android.server.LocalServices;
import dalvik.system.VMRuntime;
import java.io.File;
@@ -129,9 +131,9 @@ public final class WebViewFactory {
} else {
Log.e(LOGTAG, "reserving address space failed");
}
- } catch (Throwable e) {
+ } catch (Throwable t) {
// Log and discard errors at this stage as we must not crash the zygote.
- Log.e(LOGTAG, "error preparing native loader", e);
+ Log.e(LOGTAG, "error preparing native loader", t);
}
}
@@ -144,29 +146,37 @@ public final class WebViewFactory {
public static void prepareWebViewInSystemServer() {
if (DEBUG) Log.v(LOGTAG, "creating relro files");
if (new File(CHROMIUM_WEBVIEW_NATIVE_LIB_64).exists()) {
- createRelroFile(Build.SUPPORTED_64_BIT_ABIS[0]);
+ createRelroFile(true /* is64Bit */);
}
if (new File(CHROMIUM_WEBVIEW_NATIVE_LIB_32).exists()) {
- createRelroFile(Build.SUPPORTED_32_BIT_ABIS[0]);
+ createRelroFile(false /* is64Bit */);
}
}
- private static void createRelroFile(String abi) {
+ private static void createRelroFile(final boolean is64Bit) {
+ String abi = is64Bit ? Build.SUPPORTED_64_BIT_ABIS[0] : Build.SUPPORTED_32_BIT_ABIS[0];
+
+ // crashHandler is invoked by the ActivityManagerService when the isolated process crashes.
+ Runnable crashHandler = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ getUpdateService().notifyRelroCreationCompleted(is64Bit, false);
+ } catch (RemoteException e) {
+ Log.e(LOGTAG, "Cannot reach WebViewUpdateService. " + e.getMessage());
+ }
+ }
+ };
+
try {
- Process.start("android.webkit.WebViewFactory$RelroFileCreator",
- "WebViewLoader-" + abi,
- Process.SHARED_RELRO_UID,
- Process.SHARED_RELRO_UID,
- null,
- 0, // TODO(torne): do we need to set debug flags?
- Zygote.MOUNT_EXTERNAL_NONE,
- Build.VERSION.SDK_INT,
- null,
- abi,
- null);
- } catch (Throwable e) {
+ String[] args = null; // TODO: plumb native library paths via args.
+ LocalServices.getService(ActivityManagerInternal.class).startIsolatedProcess(
+ RelroFileCreator.class.getName(), args, "WebViewLoader-" + abi, abi,
+ Process.SHARED_RELRO_UID, crashHandler);
+ } catch (Throwable t) {
// Log and discard errors as we must not crash the system server.
- Log.e(LOGTAG, "error starting relro file creator for abi " + abi, e);
+ Log.e(LOGTAG, "error starting relro file creator for abi " + abi, t);
+ crashHandler.run();
}
}