diff options
| author | Patrick Baumann <patb@google.com> | 2018-03-13 14:26:58 -0700 |
|---|---|---|
| committer | Patrick Baumann <patb@google.com> | 2018-04-30 20:33:36 +0000 |
| commit | 1bea237aa296a35c263f0c4965ba0f5a140cd848 (patch) | |
| tree | 1b11564543ab86124636262772e39f6c5be4d1bb /core/java/android | |
| parent | 331a22e39a95e335da6f401aa4caee8efb3781de (diff) | |
In place split install native support
This change makes it possible for apps installed with the DONT_KILL flag
set to obtain access to newly installed native libraries while avoiding
double load of existing native libraries prior to the install when
loaded using System.loadLibrary.
Bug: 72047376
Test: manual - used sample app to verify availability of native libs
Change-Id: I331eaa48da1f8dee424584911317ec3fba92f873
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/ApplicationLoaders.java | 13 | ||||
| -rw-r--r-- | core/java/android/app/LoadedApk.java | 5 |
2 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/app/ApplicationLoaders.java b/core/java/android/app/ApplicationLoaders.java index 725704422290..0ed50f2bea97 100644 --- a/core/java/android/app/ApplicationLoaders.java +++ b/core/java/android/app/ApplicationLoaders.java @@ -25,6 +25,8 @@ import com.android.internal.os.ClassLoaderFactory; import dalvik.system.PathClassLoader; +import java.util.Collection; + /** @hide */ public class ApplicationLoaders { public static ApplicationLoaders getDefault() { @@ -121,6 +123,17 @@ public class ApplicationLoaders { baseDexClassLoader.addDexPath(dexPath); } + /** + * @hide + */ + void addNative(ClassLoader classLoader, Collection<String> libPaths) { + if (!(classLoader instanceof PathClassLoader)) { + throw new IllegalStateException("class loader is not a PathClassLoader"); + } + final PathClassLoader baseDexClassLoader = (PathClassLoader) classLoader; + baseDexClassLoader.addNativePath(libPaths); + } + private final ArrayMap<String, ClassLoader> mLoaders = new ArrayMap<>(); private static final ApplicationLoaders gApplicationLoaders = new ApplicationLoaders(); diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index fc7d9a553e31..8c0cd23e5fbd 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -90,6 +90,7 @@ final class ServiceConnectionLeaked extends AndroidRuntimeException { public final class LoadedApk { static final String TAG = "LoadedApk"; static final boolean DEBUG = false; + private static final String PROPERTY_NAME_APPEND_NATIVE = "pi.append_native_lib_paths"; private final ActivityThread mActivityThread; final String mPackageName; @@ -723,6 +724,10 @@ public final class LoadedApk { needToSetupJitProfiles = true; } + if (!libPaths.isEmpty() && SystemProperties.getBoolean(PROPERTY_NAME_APPEND_NATIVE, true)) { + ApplicationLoaders.getDefault().addNative(mClassLoader, libPaths); + } + if (addedPaths != null && addedPaths.size() > 0) { final String add = TextUtils.join(File.pathSeparator, addedPaths); ApplicationLoaders.getDefault().addPath(mClassLoader, add); |
