diff options
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/app/ActivityThread.java | 8 | ||||
-rw-r--r-- | core/java/android/app/LoadedApk.java | 2 | ||||
-rw-r--r-- | core/java/android/content/pm/PackageParser.java | 5 | ||||
-rw-r--r-- | core/java/android/content/pm/ServiceInfo.java | 9 | ||||
-rw-r--r-- | core/java/android/os/Process.java | 23 |
5 files changed, 42 insertions, 5 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index e4cfc99..bf632a9 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -134,7 +134,7 @@ public final class ActivityThread { private static final boolean DEBUG_RESULTS = false; private static final boolean DEBUG_BACKUP = true; private static final boolean DEBUG_CONFIGURATION = false; - private static final boolean DEBUG_SERVICE = true; + private static final boolean DEBUG_SERVICE = false; private static final long MIN_TIME_BETWEEN_GCS = 5*1000; private static final Pattern PATTERN_SEMICOLON = Pattern.compile(";"); private static final int SQLITE_MEM_RELEASED_EVENT_LOG_TAG = 75003; @@ -3764,13 +3764,17 @@ public final class ActivityThread { } private void setupGraphicsSupport(LoadedApk info) { + if (Process.isIsolated()) { + // Isolated processes aren't going to do UI. + return; + } try { int uid = Process.myUid(); String[] packages = getPackageManager().getPackagesForUid(uid); // If there are several packages in this application we won't // initialize the graphics disk caches - if (packages.length == 1) { + if (packages != null && packages.length == 1) { ContextImpl appContext = new ContextImpl(); appContext.init(info, null, this); diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index fcbcd81..d9bbb4a 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -119,7 +119,7 @@ public final class LoadedApk { final int myUid = Process.myUid(); mResDir = aInfo.uid == myUid ? aInfo.sourceDir : aInfo.publicSourceDir; - if (!UserId.isSameUser(aInfo.uid, myUid)) { + if (!UserId.isSameUser(aInfo.uid, myUid) && !Process.isIsolated()) { aInfo.dataDir = PackageManager.getDataDirForUser(UserId.getUserId(myUid), mPackageName); } diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index faee873..2023f82 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -2581,6 +2581,11 @@ public class PackageParser { false)) { s.info.flags |= ServiceInfo.FLAG_STOP_WITH_TASK; } + if (sa.getBoolean( + com.android.internal.R.styleable.AndroidManifestService_isolatedProcess, + false)) { + s.info.flags |= ServiceInfo.FLAG_ISOLATED_PROCESS; + } sa.recycle(); diff --git a/core/java/android/content/pm/ServiceInfo.java b/core/java/android/content/pm/ServiceInfo.java index 612e345..7ee84ab 100644 --- a/core/java/android/content/pm/ServiceInfo.java +++ b/core/java/android/content/pm/ServiceInfo.java @@ -42,10 +42,17 @@ public class ServiceInfo extends ComponentInfo public static final int FLAG_STOP_WITH_TASK = 0x0001; /** + * Bit in {@link #flags}: If set, the service will run in its own + * isolated process. Set from the + * {@link android.R.attr#isolatedProcess} attribute. + */ + public static final int FLAG_ISOLATED_PROCESS = 0x0002; + + /** * Options that have been set in the service declaration in the * manifest. * These include: - * {@link #FLAG_STOP_WITH_TASK} + * {@link #FLAG_STOP_WITH_TASK}, {@link #FLAG_ISOLATED_PROCESS}. */ public int flags; diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java index cdf235d..0746af8 100644 --- a/core/java/android/os/Process.java +++ b/core/java/android/os/Process.java @@ -119,7 +119,19 @@ public class Process { * Last of application-specific UIDs starting at * {@link #FIRST_APPLICATION_UID}. */ - public static final int LAST_APPLICATION_UID = 99999; + public static final int LAST_APPLICATION_UID = 89999; + + /** + * First uid used for fully isolated sandboxed processes (with no permissions of their own) + * @hide + */ + public static final int FIRST_ISOLATED_UID = 99000; + + /** + * Last uid used for fully isolated sandboxed processes (with no permissions of their own) + * @hide + */ + public static final int LAST_ISOLATED_UID = 99999; /** * Defines a secondary group id for access to the bluetooth hardware. @@ -576,6 +588,15 @@ public class Process { public static final native int myUid(); /** + * Returns whether the current process is in an isolated sandbox. + * @hide + */ + public static final boolean isIsolated() { + int uid = UserId.getAppId(myUid()); + return uid >= FIRST_ISOLATED_UID && uid <= LAST_ISOLATED_UID; + } + + /** * Returns the UID assigned to a particular user name, or -1 if there is * none. If the given string consists of only numbers, it is converted * directly to a uid. |