Class DirectorySoSource

java.lang.Object
com.facebook.soloader.SoSource
com.facebook.soloader.DirectorySoSource
Direct Known Subclasses:
UnpackingSoSource

public class DirectorySoSource extends SoSource
SoSource that finds shared libraries in a given directory.
  • Field Details

  • Constructor Details

    • DirectorySoSource

      public DirectorySoSource(File soDirectory, int flags)
      Make a new DirectorySoSource. If flags contains RESOLVE_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 files
      flags - load flags
    • DirectorySoSource

      public DirectorySoSource(File soDirectory, int flags, String[] denyList)
      This method is similar to DirectorySoSource(File, int), with the following differences:
      Parameters:
      soDirectory - the dir that contains the so files
      flags - load flags
      denyList - the soname list that we won't try to load from this source
  • Method Details

    • setExplicitDependencyResolution

      public void setExplicitDependencyResolution()
    • loadLibrary

      public int loadLibrary(String soName, int loadFlags, android.os.StrictMode.ThreadPolicy threadPolicy) throws IOException
      Description copied from class: SoSource
      Load a shared library library into this process. This routine is independent of SoSource.loadLibrary(java.lang.String, int, android.os.StrictMode.ThreadPolicy).
      Specified by:
      loadLibrary in class SoSource
      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
    • getSoFileByName

      @Nullable public File getSoFileByName(String soName) throws IOException
      Throws:
      IOException
    • getLibraryPath

      @Nullable public String getLibraryPath(String soName) throws IOException
      Description copied from class: SoSource
      Gets the full path of a library if it is found on this SoSource.
      Overrides:
      getLibraryPath in class SoSource
      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:
      IOException - if there is an error calculating soFileName's canonical path
    • getLibraryDependencies

      @Nullable public String[] getLibraryDependencies(String soName) throws IOException
      Description copied from class: SoSource
      Gets the dependencies of a library if it is found on this SoSource
      Overrides:
      getLibraryDependencies in class 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
    • unpackLibrary

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

      public void addToLdLibraryPath(Collection<String> paths)
      Description copied from class: SoSource
      Add an element to an LD_LIBRARY_PATH under construction.
      Overrides:
      addToLdLibraryPath in class SoSource
      Parameters:
      paths - Collection of paths to which to add
    • getName

      public String getName()
      Specified by:
      getName in class SoSource
      Returns:
      the name of this SoSource for logging purposes
    • toString

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