Package com.facebook.soloader
Class DirectorySoSource
- java.lang.Object
-
- com.facebook.soloader.SoSource
-
- com.facebook.soloader.DirectorySoSource
-
- Direct Known Subclasses:
UnpackingSoSource
public class DirectorySoSource extends SoSource
SoSourcethat finds shared libraries in a given directory.
-
-
Field Summary
Fields Modifier and Type Field Description static intON_LD_LIBRARY_PATHstatic intRESOLVE_DEPENDENCIES-
Fields inherited from class com.facebook.soloader.SoSource
LOAD_FLAG_ALLOW_IMPLICIT_PROVISION, LOAD_FLAG_ALLOW_SOURCE_CHANGE, LOAD_FLAG_MIN_CUSTOM_FLAG, LOAD_RESULT_CORRUPTED_LIB_FILE, LOAD_RESULT_IMPLICITLY_PROVIDED, LOAD_RESULT_LOADED, LOAD_RESULT_NOT_FOUND, PREPARE_FLAG_ALLOW_ASYNC_INIT, PREPARE_FLAG_DISABLE_FS_SYNC_JOB, PREPARE_FLAG_FORCE_REFRESH
-
-
Constructor Summary
Constructors Constructor Description DirectorySoSource(java.io.File soDirectory, int flags)Make a new DirectorySoSource.DirectorySoSource(java.io.File soDirectory, int flags, java.lang.String[] denyList)This method is similar toDirectorySoSource(File, int), with the following differences:
-
Method Summary
Modifier and Type Method Description voidaddToLdLibraryPath(java.util.Collection<java.lang.String> paths)Add an element to an LD_LIBRARY_PATH under construction.java.lang.String[]getLibraryDependencies(java.lang.String soName)Gets the dependencies of a library if it is found on this SoSourcejava.lang.StringgetLibraryPath(java.lang.String soName)Gets the full path of a library if it is found on this SoSource.intloadLibrary(java.lang.String soName, int loadFlags, android.os.StrictMode.ThreadPolicy threadPolicy)Load a shared library library into this process.java.lang.StringtoString()Return the class name of the actual instance.java.io.FileunpackLibrary(java.lang.String soName)Ensure that a shared library exists on disk somewhere.-
Methods inherited from class com.facebook.soloader.SoSource
getSoSourceAbis
-
-
-
-
Field Detail
-
RESOLVE_DEPENDENCIES
public static final int RESOLVE_DEPENDENCIES
- See Also:
- Constant Field Values
-
ON_LD_LIBRARY_PATH
public static final int ON_LD_LIBRARY_PATH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DirectorySoSource
public DirectorySoSource(java.io.File soDirectory, int flags)Make a new DirectorySoSource. IfflagscontainsRESOLVE_DEPENDENCIES, recursively load dependencies for shared objects loaded from this directory. (We shouldn't need to resolve dependencies for libraries loaded from system directories: the dynamic linker is smart enough to do it on its own there.)- Parameters:
soDirectory- the dir that contains the so filesflags- load flags
-
DirectorySoSource
public DirectorySoSource(java.io.File soDirectory, int flags, java.lang.String[] denyList)This method is similar toDirectorySoSource(File, int), with the following differences:- Parameters:
soDirectory- the dir that contains the so filesflags- load flagsdenyList- the soname list that we won't try to load from this source
-
-
Method Detail
-
loadLibrary
public int loadLibrary(java.lang.String soName, int loadFlags, android.os.StrictMode.ThreadPolicy threadPolicy) throws java.io.IOExceptionDescription copied from class:SoSourceLoad a shared library library into this process. This routine is independent ofSoSource.loadLibrary(java.lang.String, int, android.os.StrictMode.ThreadPolicy).- Specified by:
loadLibraryin classSoSource- Parameters:
soName- Name of library to loadloadFlags- Zero or more of the LOAD_FLAG_XXX constants.threadPolicy- Strict Mode policy- Returns:
- One of the LOAD_RESULT_XXX constants.
- Throws:
java.io.IOException- IOException
-
getLibraryPath
@Nullable public java.lang.String getLibraryPath(java.lang.String soName) throws java.io.IOExceptionDescription copied from class:SoSourceGets the full path of a library if it is found on this SoSource.- Overrides:
getLibraryPathin classSoSource- Parameters:
soName- the full file name of the library- Returns:
- the full path of a library if it is found on this SoSource, null otherwise.
- Throws:
java.io.IOException- if there is an error calculatingsoFileName's canonical path
-
getLibraryDependencies
@Nullable public java.lang.String[] getLibraryDependencies(java.lang.String soName) throws java.io.IOExceptionDescription copied from class:SoSourceGets the dependencies of a library if it is found on this SoSource- Overrides:
getLibraryDependenciesin classSoSource- Parameters:
soName- Name of library to inspect- Returns:
- An array of library names upon which
soNameneeds for linking - Throws:
java.io.IOException- ifsoNameis found but there is an error reading it
-
unpackLibrary
@Nullable public java.io.File unpackLibrary(java.lang.String soName) throws java.io.IOExceptionDescription copied from class:SoSourceEnsure that a shared library exists on disk somewhere. This routine is independent ofSoSource.loadLibrary(java.lang.String, int, android.os.StrictMode.ThreadPolicy).- Specified by:
unpackLibraryin classSoSource- Parameters:
soName- Name of library to load- Returns:
- File if library found;
nullif not. - Throws:
java.io.IOException- IOException
-
addToLdLibraryPath
public void addToLdLibraryPath(java.util.Collection<java.lang.String> paths)
Description copied from class:SoSourceAdd an element to an LD_LIBRARY_PATH under construction.- Overrides:
addToLdLibraryPathin classSoSource- Parameters:
paths- Collection of paths to which to add
-
-