Skip to content

Commit

Permalink
disambiguate loadLibraryBySoName overloads
Browse files Browse the repository at this point in the history
Summary: The purpose of one of the overloads is to serve as a fast path to load dependencies. Let's name it accordingly to clearly state the purpose and (in the following diffs) lets add appropriate instrumentation.

Reviewed By: adicatana, danjin250

Differential Revision: D48040738

fbshipit-source-id: e286800a14861587094d4ced8412edfa7827d4c3
  • Loading branch information
michalgr authored and facebook-github-bot committed Aug 17, 2023
1 parent 6ee9ea6 commit 7d791d0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 1 addition & 2 deletions java/com/facebook/soloader/DirectApkSoSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ private void loadDependencies(

if (dependencies != null) {
for (String dependency : dependencies) {
SoLoader.loadLibraryBySoName(
dependency, loadFlags | LOAD_FLAG_ALLOW_IMPLICIT_PROVISION, threadPolicy);
SoLoader.loadDependency(dependency, loadFlags, threadPolicy);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions java/com/facebook/soloader/NativeDeps.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public static void loadDependencies(
continue;
}

SoLoader.loadLibraryBySoName(
dependency, loadFlags | SoSource.LOAD_FLAG_ALLOW_IMPLICIT_PROVISION, threadPolicy);
SoLoader.loadDependency(dependency, loadFlags, threadPolicy);
}
}

Expand Down
14 changes: 12 additions & 2 deletions java/com/facebook/soloader/SoLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,19 @@ public static boolean loadLibrary(String shortName, int loadFlags) throws Unsati
return null;
}

/* package */ static void loadLibraryBySoName(
/**
* Load a library that is a dependency of another library by name. A dedicated entry point allows
* SoLoader to optimise recursive calls by assuming that the current platform is Android and merge
* map does not need to be consulted.
*
* @param soName Name of the library to load, as extracted from dynamic section.
* @param loadFlags
* @param oldPolicy
*/
/* package */ static void loadDependency(
String soName, int loadFlags, StrictMode.ThreadPolicy oldPolicy) {
loadLibraryBySoNameImpl(soName, null, null, loadFlags, oldPolicy);
loadLibraryBySoNameImpl(
soName, null, null, loadFlags | SoSource.LOAD_FLAG_ALLOW_IMPLICIT_PROVISION, oldPolicy);
}

private static boolean loadLibraryBySoName(
Expand Down

0 comments on commit 7d791d0

Please sign in to comment.