From 29d9eba79b82761d0d5019b3f05017fe20f1637b Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 4 May 2018 12:44:38 +0900 Subject: [PATCH] Basedir of a bundled app is added to the permitted paths For bundled apps, add the base directory of the app (e.g., /system/app/Foo/) to the permitted paths so that it can load libraries embedded in module apks under the directory. For now, GmsCore is relying on this, but this isn't specific to the app. Also note that, we don't need to do this for unbundled apps as entire /data is already set to the permitted paths for them. Bug: 79211269 Test: m -j Test: permitted paths of PrebuiltGmsCore contains /system/priv-app/PrebuiltGmsCorePix Change-Id: Id9a874fcec8479e952ab94cf33b2537f9aacd691 --- core/java/android/app/LoadedApk.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index fc7d9a553e317..b24d6e297d6ca 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -64,6 +64,7 @@ import java.lang.ref.WeakReference; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -667,7 +668,17 @@ public final class LoadedApk { makePaths(mActivityThread, isBundledApp, mApplicationInfo, zipPaths, libPaths); String libraryPermittedPath = mDataDir; + if (isBundledApp) { + // For bundled apps, add the base directory of the app (e.g., + // /system/app/Foo/) to the permitted paths so that it can load libraries + // embedded in module apks under the directory. For now, GmsCore is relying + // on this, but this isn't specific to the app. Also note that, we don't + // need to do this for unbundled apps as entire /data is already set to + // the permitted paths for them. + libraryPermittedPath += File.pathSeparator + + Paths.get(getAppDir()).getParent().toString(); + // This is necessary to grant bundled apps access to // libraries located in subdirectories of /system/lib libraryPermittedPath += File.pathSeparator + defaultSearchPaths;