From 2aa7e5e861123bab22bd2af676bcab662bcd37da Mon Sep 17 00:00:00 2001 From: Suprabh Shukla Date: Wed, 12 Oct 2016 19:01:11 -0700 Subject: [PATCH] DO NOT MERGE Isolated processes don't get precached system service binders More specifically, they get a PackageManager binder -- necessary for Android process startup and configuration -- but none of the other usual preloaded service binders. (backported from commit 2c61c57ac53cbb270b4e76b9d04465f8a3f6eadc) Bug: 30202228 Change-Id: I3810649f504cd631665ece338a83d2e54d41ad05 --- .../com/android/server/am/ActivityManagerService.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index c85dc98a3335..d3871ec2b9c1 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -788,6 +788,7 @@ public final class ActivityManagerService extends ActivityManagerNative * For example, references to the commonly used services. */ HashMap mAppBindArgs; + HashMap mIsolatedAppBindArgs; /** * Temporary to avoid allocations. Protected by main lock. @@ -2210,7 +2211,17 @@ public final class ActivityManagerService extends ActivityManagerNative * process when the bindApplication() IPC is sent to the process. They're * lazily setup to make sure the services are running when they're asked for. */ - private HashMap getCommonServicesLocked() { + private HashMap getCommonServicesLocked(boolean isolated) { + // Isolated processes won't get this optimization, so that we don't + // violate the rules about which services they have access to. + if (isolated) { + if (mIsolatedAppBindArgs == null) { + mIsolatedAppBindArgs = new HashMap(); + mIsolatedAppBindArgs.put("package", ServiceManager.getService("package")); + } + return mIsolatedAppBindArgs; + } + if (mAppBindArgs == null) { mAppBindArgs = new HashMap(); @@ -4990,7 +5001,8 @@ public final class ActivityManagerService extends ActivityManagerNative app.instrumentationArguments, app.instrumentationWatcher, app.instrumentationUiAutomationConnection, testMode, enableOpenGlTrace, isRestrictedBackupMode || !normalMode, app.persistent, - new Configuration(mConfiguration), app.compat, getCommonServicesLocked(), + new Configuration(mConfiguration), app.compat, + getCommonServicesLocked(app.isolated), mCoreSettingsObserver.getCoreSettingsLocked()); updateLruProcessLocked(app, false, null); app.lastRequestedGc = app.lastLowMemory = SystemClock.uptimeMillis(); -- 2.11.0