Class SysUtil

java.lang.Object
com.facebook.soloader.SysUtil

public final class SysUtil extends Object
  • Constructor Details

    • SysUtil

      public SysUtil()
  • Method Details

    • findAbiScore

      public static int findAbiScore(String[] supportedAbis, String abi)
      Determine how preferred a given ABI is on this system.
      Parameters:
      supportedAbis - ABIs on this system
      abi - ABI of a shared library we might want to unpack
      Returns:
      -1 if not supported or an integer, smaller being more preferred
    • deleteOrThrow

      public static void deleteOrThrow(File file) throws IOException
      Throws:
      IOException
    • getSupportedAbis

      public static String[] getSupportedAbis()
      Return an list of ABIs we supported on this device ordered according to preference. Use a separate inner class to isolate the version-dependent call where it won't cause the whole class to fail preverification.
      Returns:
      Ordered array of supported ABIs
    • fallocateIfSupported

      public static void fallocateIfSupported(FileDescriptor fd, long length) throws IOException
      Pre-allocate disk space for a file if we can do that on this version of the OS.
      Parameters:
      fd - File descriptor for file
      length - Number of bytes to allocate.
      Throws:
      IOException - IOException
    • dumbDelete

      public static void dumbDelete(File file) throws IOException
      Delete a directory and its contents.

      WARNING: Java APIs do not let us distinguish directories from symbolic links to directories. Consequently, if the directory contains symbolic links to directories, we will attempt to delete the contents of pointed-to directories.

      Parameters:
      file - File or directory to delete
      Throws:
      IOException - IOException
    • mkdirOrThrow

      public static void mkdirOrThrow(File dir) throws IOException
      Like File.mkdirs, but throws on error. Succeeds even if File.mkdirs "fails", but dir still names a directory.
      Parameters:
      dir - Directory to create. All parents created as well.
      Throws:
      IOException - IOException
    • fsyncAll

      public static void fsyncAll(File fileName) throws IOException
      Throws:
      IOException
    • getApkDepBlockLength

      public static long getApkDepBlockLength(File apkFile) throws IOException
      Retrieve the size of dependency file.
      Parameters:
      apkFile - the apk file
      Returns:
      the size of dependency file
      Throws:
      IOException - IOException
    • makeApkDepBlock

      public static byte[] makeApkDepBlock(File apkFile, android.content.Context context) throws IOException
      N.B. If this method is changed, the above method getApkDepBlockLength(java.io.File) must also be updated to reflect the expected size of the dep block
      Parameters:
      apkFile - apk file
      context - application context
      Returns:
      dependency file in bytes
      Throws:
      IOException - IOException
    • getAppVersionCode

      public static int getAppVersionCode(android.content.Context context)
    • is64Bit

      public static boolean is64Bit()
    • isSupportedDirectLoad

      public static boolean isSupportedDirectLoad(@Nullable android.content.Context context, int appType)
    • isDisabledExtractNativeLibs

      public static boolean isDisabledExtractNativeLibs(android.content.Context context)
    • getOrCreateLockOnDir

      @Nullable public static FileLocker getOrCreateLockOnDir(File soDirectory, File lockFileName) throws IOException
      Throws:
      IOException
    • getFileLocker

      public static FileLocker getFileLocker(File lockFileName) throws IOException
      Throws:
      IOException
    • getBaseName

      public static String getBaseName(String fileName)
      Gets the base name, without extension, of given file name.
      Parameters:
      fileName - full file name
      Returns:
      base name
    • makeNonZipPath

      @Nullable public static String makeNonZipPath(@Nullable String localLdLibraryPath)
    • getClassLoaderLdLoadLibrary

      @Nullable public static String getClassLoaderLdLoadLibrary()
    • getNativeLoadRuntimeMethod

      @Nullable public static Method getNativeLoadRuntimeMethod()