diff --git a/java/com/facebook/soloader/DirectorySoSource.java b/java/com/facebook/soloader/DirectorySoSource.java index 6b094dc..b5cf093 100644 --- a/java/com/facebook/soloader/DirectorySoSource.java +++ b/java/com/facebook/soloader/DirectorySoSource.java @@ -101,7 +101,9 @@ private void loadDependencies(File soFile, int loadFlags, StrictMode.ThreadPolic } SoLoader.loadLibraryBySoName( - dependency, (loadFlags | LOAD_FLAG_ALLOW_IMPLICIT_PROVISION), threadPolicy); + dependency, + (loadFlags | LOAD_FLAG_ALLOW_IMPLICIT_PROVISION & ~LOAD_FLAG_ALLOW_SOURCE_CHANGE), + threadPolicy); } } diff --git a/java/com/facebook/soloader/SoLoader.java b/java/com/facebook/soloader/SoLoader.java index 2da2af8..c70a769 100644 --- a/java/com/facebook/soloader/SoLoader.java +++ b/java/com/facebook/soloader/SoLoader.java @@ -499,7 +499,11 @@ public static boolean loadLibrary(String shortName, int loadFlags) throws Unsati String soName = mergedLibName != null ? mergedLibName : shortName; return loadLibraryBySoName( - System.mapLibraryName(soName), shortName, mergedLibName, loadFlags, null); + System.mapLibraryName(soName), + shortName, + mergedLibName, + loadFlags | SoSource.LOAD_FLAG_ALLOW_SOURCE_CHANGE, + null); } /* package */ static void loadLibraryBySoName( @@ -658,7 +662,9 @@ private static void doLoadLibraryBySoName( } finally { sSoSourcesLock.readLock().unlock(); } - if (result == SoSource.LOAD_RESULT_NOT_FOUND) { + if ((loadFlags & SoSource.LOAD_FLAG_ALLOW_SOURCE_CHANGE) + == SoSource.LOAD_FLAG_ALLOW_SOURCE_CHANGE + && result == SoSource.LOAD_RESULT_NOT_FOUND) { sSoSourcesLock.writeLock().lock(); try { // TODO(T26270128): check and update sBackupSoSource as well diff --git a/java/com/facebook/soloader/SoSource.java b/java/com/facebook/soloader/SoSource.java index 5439241..98288fb 100644 --- a/java/com/facebook/soloader/SoSource.java +++ b/java/com/facebook/soloader/SoSource.java @@ -47,11 +47,14 @@ abstract public class SoSource { /** Allow loadLibrary to implicitly provide the library instead of actually loading it. */ public static final int LOAD_FLAG_ALLOW_IMPLICIT_PROVISION = 1; + /** Allow loadLibrary to reparse the so sources directories. */ + public static final int LOAD_FLAG_ALLOW_SOURCE_CHANGE = 1 << 1; + /** - * Min flag that can be used in customized {@link SoFileLoader#load(String, int)} - * implementation. The custom flag value has to be greater than this. + * Min flag that can be used in customized {@link SoFileLoader#load(String, int)} implementation. + * The custom flag value has to be greater than this. */ - public static final int LOAD_FLAG_MIN_CUSTOM_FLAG = 1 << 1; + public static final int LOAD_FLAG_MIN_CUSTOM_FLAG = LOAD_FLAG_ALLOW_SOURCE_CHANGE << 1; /** * Allow prepare to spawn threads to do background work.