Package com.facebook.soloader
Class SoSource
- java.lang.Object
-
- com.facebook.soloader.SoSource
-
- Direct Known Subclasses:
ApplicationSoSource,DirectApkSoSource,DirectorySoSource,NoopSoSource
public abstract class SoSource extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static intLOAD_FLAG_ALLOW_IMPLICIT_PROVISIONAllow loadLibrary to implicitly provide the library instead of actually loading it.static intLOAD_FLAG_ALLOW_SOURCE_CHANGEDeprecated.static intLOAD_FLAG_MIN_CUSTOM_FLAGMin flag that can be used in customizedSoFileLoader.load(String, int)implementation.static intLOAD_RESULT_CORRUPTED_LIB_FILEThis SoSource tried to load the library but it seems that the file is corrupted.static intLOAD_RESULT_IMPLICITLY_PROVIDEDThis SoSource did not load the library, but verified that the system loader will load it if some other library depends on it.static intLOAD_RESULT_LOADEDThis SoSource loaded the given library.static intLOAD_RESULT_NOT_FOUNDThis SoSource doesn't know how to provide the given library.static intPREPARE_FLAG_ALLOW_ASYNC_INITAllow prepare to spawn threads to do background work.static intPREPARE_FLAG_DISABLE_FS_SYNC_JOBDisable so file fsync job.static intPREPARE_FLAG_FORCE_REFRESHForce prepare to refresh libs.
-
Constructor Summary
Constructors Constructor Description SoSource()
-
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 soFileName)Gets the full path of a library if it is found on this SoSource.java.lang.String[]getSoSourceAbis()Return an array of ABIs handled by this SoSource.abstract 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.abstract java.io.FileunpackLibrary(java.lang.String soName)Ensure that a shared library exists on disk somewhere.
-
-
-
Field Detail
-
LOAD_RESULT_NOT_FOUND
public static final int LOAD_RESULT_NOT_FOUND
This SoSource doesn't know how to provide the given library.- See Also:
- Constant Field Values
-
LOAD_RESULT_LOADED
public static final int LOAD_RESULT_LOADED
This SoSource loaded the given library.- See Also:
- Constant Field Values
-
LOAD_RESULT_IMPLICITLY_PROVIDED
public static final int LOAD_RESULT_IMPLICITLY_PROVIDED
This SoSource did not load the library, but verified that the system loader will load it if some other library depends on it. Returned only if LOAD_FLAG_ALLOW_IMPLICIT_PROVISION is provided to loadLibrary.- See Also:
- Constant Field Values
-
LOAD_RESULT_CORRUPTED_LIB_FILE
public static final int LOAD_RESULT_CORRUPTED_LIB_FILE
This SoSource tried to load the library but it seems that the file is corrupted.- See Also:
- Constant Field Values
-
LOAD_FLAG_ALLOW_IMPLICIT_PROVISION
public static final int LOAD_FLAG_ALLOW_IMPLICIT_PROVISION
Allow loadLibrary to implicitly provide the library instead of actually loading it.- See Also:
- Constant Field Values
-
LOAD_FLAG_ALLOW_SOURCE_CHANGE
@Deprecated public static final int LOAD_FLAG_ALLOW_SOURCE_CHANGE
Deprecated.Allow loadLibrary to reparse the so sources directories.- See Also:
- Constant Field Values
-
LOAD_FLAG_MIN_CUSTOM_FLAG
public static final int LOAD_FLAG_MIN_CUSTOM_FLAG
Min flag that can be used in customizedSoFileLoader.load(String, int)implementation. The custom flag value has to be greater than this.- See Also:
- Constant Field Values
-
PREPARE_FLAG_ALLOW_ASYNC_INIT
public static final int PREPARE_FLAG_ALLOW_ASYNC_INIT
Allow prepare to spawn threads to do background work.- See Also:
- Constant Field Values
-
PREPARE_FLAG_FORCE_REFRESH
public static final int PREPARE_FLAG_FORCE_REFRESH
Force prepare to refresh libs.- See Also:
- Constant Field Values
-
PREPARE_FLAG_DISABLE_FS_SYNC_JOB
public static final int PREPARE_FLAG_DISABLE_FS_SYNC_JOB
Disable so file fsync job.- See Also:
- Constant Field Values
-
-
Method Detail
-
loadLibrary
public abstract int loadLibrary(java.lang.String soName, int loadFlags, android.os.StrictMode.ThreadPolicy threadPolicy) throws java.io.IOExceptionLoad a shared library library into this process. This routine is independent ofloadLibrary(java.lang.String, int, android.os.StrictMode.ThreadPolicy).- 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
-
unpackLibrary
@Nullable public abstract java.io.File unpackLibrary(java.lang.String soName) throws java.io.IOExceptionEnsure that a shared library exists on disk somewhere. This routine is independent ofloadLibrary(java.lang.String, int, android.os.StrictMode.ThreadPolicy).- Parameters:
soName- Name of library to load- Returns:
- File if library found;
nullif not. - Throws:
java.io.IOException- IOException
-
getLibraryPath
@Nullable public java.lang.String getLibraryPath(java.lang.String soFileName) throws java.io.IOExceptionGets the full path of a library if it is found on this SoSource.- Parameters:
soFileName- 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.IOExceptionGets the dependencies of a library if it is found on this SoSource- 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
-
addToLdLibraryPath
public void addToLdLibraryPath(java.util.Collection<java.lang.String> paths)
Add an element to an LD_LIBRARY_PATH under construction.- Parameters:
paths- Collection of paths to which to add
-
getSoSourceAbis
public java.lang.String[] getSoSourceAbis()
Return an array of ABIs handled by this SoSource.- Returns:
- ABIs supported by this SoSource
-
toString
public java.lang.String toString()
Return the class name of the actual instance. Useful for debugging.- Overrides:
toStringin classjava.lang.Object- Returns:
- the instance class name
-
-