diff options
| author | 2020-11-17 18:04:35 +0900 | |
|---|---|---|
| committer | 2020-11-27 19:53:04 +0900 | |
| commit | 8e74eb6b435c9a9838a8cd498f71bd13edf1ee47 (patch) | |
| tree | ac93885947798a3f5d04a4213a0468a6aae2c827 | |
| parent | 540826860636597c634fc8c991d22b97d893bdbc (diff) | |
Create linker namespace in startServiceFromJar
Previously the classloader would have no initialized linker namespace,
so JNI libraries associated with a JAR in an APEX would not be found.
Use ClassLoaderFactory to ensure that the linker namespace is
initialized.
Bug: 172541385
Test: manual: boot device with system server JAR using JNI in APEX
Merged-In: Icc94c70b3e3817aa637c32f1190faa41364e1604
Change-Id: Icc94c70b3e3817aa637c32f1190faa41364e1604
| -rw-r--r-- | services/core/java/com/android/server/SystemServiceManager.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/SystemServiceManager.java b/services/core/java/com/android/server/SystemServiceManager.java index 74bb7d7e90f1..9205737a550a 100644 --- a/services/core/java/com/android/server/SystemServiceManager.java +++ b/services/core/java/com/android/server/SystemServiceManager.java @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.UserIdInt; import android.content.Context; import android.content.pm.UserInfo; +import android.os.Build; import android.os.Environment; import android.os.SystemClock; import android.os.Trace; @@ -28,6 +29,7 @@ import android.os.UserManagerInternal; import android.util.ArrayMap; import android.util.Slog; +import com.android.internal.os.ClassLoaderFactory; import com.android.server.SystemService.TargetUser; import com.android.server.utils.TimingsTraceAndSlog; @@ -99,7 +101,10 @@ public class SystemServiceManager { if (pathClassLoader == null) { // NB: the parent class loader should always be the system server class loader. // Changing it has implications that require discussion with the mainline team. - pathClassLoader = new PathClassLoader(path, this.getClass().getClassLoader()); + pathClassLoader = (PathClassLoader) ClassLoaderFactory.createClassLoader( + path, null /* librarySearchPath */, null /* libraryPermittedPath */, + this.getClass().getClassLoader(), Build.VERSION.SDK_INT, + true /* isNamespaceShared */, null /* classLoaderName */); mLoadedPaths.put(path, pathClassLoader); } final Class<SystemService> serviceClass = loadClassFromLoader(className, pathClassLoader); |