Class SoSource

java.lang.Object
com.facebook.soloader.SoSource
Direct Known Subclasses:
ApplicationSoSource, DirectApkSoSource, DirectorySoSource, DirectSplitSoSource, NoopSoSource, SystemLoadWrapperSoSource

public abstract class SoSource extends Object
  • Field Details

    • 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:
    • LOAD_RESULT_LOADED

      public static final int LOAD_RESULT_LOADED
      This SoSource loaded the given library.
      See Also:
    • 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:
    • 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:
    • 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:
    • LOAD_FLAG_MIN_CUSTOM_FLAG

      public static final int LOAD_FLAG_MIN_CUSTOM_FLAG
      Min flag that can be used in customized SoFileLoader.load(String, int) implementation. The custom flag value has to be greater than this.
      See Also:
    • 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:
    • PREPARE_FLAG_FORCE_REFRESH

      public static final int PREPARE_FLAG_FORCE_REFRESH
      Force prepare to refresh libs.
      See Also:
    • PREPARE_FLAG_DISABLE_FS_SYNC_JOB

      public static final int PREPARE_FLAG_DISABLE_FS_SYNC_JOB
      Disable so file fsync job.
      See Also:
    • PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE

      public static final int PREPARE_FLAG_SKIP_BACKUP_SO_SOURCE
      Skip preparing backup so source.
      See Also:
  • Constructor Details

    • SoSource

      public SoSource()
  • Method Details

    • loadLibrary

      public abstract int loadLibrary(String soName, int loadFlags, android.os.StrictMode.ThreadPolicy threadPolicy) throws IOException
      Load a shared library library into this process. This routine is independent of loadLibrary(java.lang.String, int, android.os.StrictMode.ThreadPolicy).
      Parameters:
      soName - Name of library to load
      loadFlags - Zero or more of the LOAD_FLAG_XXX constants.
      threadPolicy - Strict Mode policy
      Returns:
      One of the LOAD_RESULT_XXX constants.
      Throws:
      IOException - IOException
    • unpackLibrary

      @Nullable public abstract File unpackLibrary(String soName) throws IOException
      Ensure that a shared library exists on disk somewhere. This routine is independent of loadLibrary(java.lang.String, int, android.os.StrictMode.ThreadPolicy).
      Parameters:
      soName - Name of library to load
      Returns:
      File if library found; null if not.
      Throws:
      IOException - IOException
    • getLibraryPath

      @Nullable public String getLibraryPath(String soFileName) throws IOException
      Gets 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:
      IOException - if there is an error calculating soFileName's canonical path
    • getLibraryDependencies

      @Nullable public String[] getLibraryDependencies(String soName) throws IOException
      Gets 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 soName needs for linking
      Throws:
      IOException - if soName is found but there is an error reading it
    • addToLdLibraryPath

      public void addToLdLibraryPath(Collection<String> paths)
      Add an element to an LD_LIBRARY_PATH under construction.
      Parameters:
      paths - Collection of paths to which to add
    • getSoSourceAbis

      public String[] getSoSourceAbis()
      Return an array of ABIs handled by this SoSource.
      Returns:
      ABIs supported by this SoSource
    • getName

      public abstract String getName()
      Returns:
      the name of this SoSource for logging purposes
    • toString

      public String toString()
      Return the class name of the actual instance. Useful for debugging.
      Overrides:
      toString in class Object
      Returns:
      the instance class name