Class SoSource

    • Constructor Summary

      Constructors 
      Constructor Description
      SoSource()  
    • Method Summary

      Modifier and Type Method Description
      void addToLdLibraryPath​(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 SoSource
      java.lang.String getLibraryPath​(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 int loadLibrary​(java.lang.String soName, int loadFlags, android.os.StrictMode.ThreadPolicy threadPolicy)
      Load a shared library library into this process.
      java.lang.String toString()
      Return the class name of the actual instance.
      abstract java.io.File unpackLibrary​(java.lang.String soName)
      Ensure that a shared library exists on disk somewhere.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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
      • 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
    • Constructor Detail

      • SoSource

        public SoSource()
    • Method Detail

      • loadLibrary

        public abstract int loadLibrary​(java.lang.String soName,
                                        int loadFlags,
                                        android.os.StrictMode.ThreadPolicy threadPolicy)
                                 throws java.io.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:
        java.io.IOException - IOException
      • unpackLibrary

        @Nullable
        public abstract java.io.File unpackLibrary​(java.lang.String soName)
                                            throws java.io.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:
        java.io.IOException - IOException
      • getLibraryPath

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

        @Nullable
        public java.lang.String[] getLibraryDependencies​(java.lang.String soName)
                                                  throws java.io.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:
        java.io.IOException - if soName is 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:
        toString in class java.lang.Object
        Returns:
        the instance class name