Package com.facebook.soloader
Class SysUtil
java.lang.Object
com.facebook.soloader.SysUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddeleteOrThrow(File file) static voiddumbDelete(File file) Delete a directory and its contents.static voidfallocateIfSupported(FileDescriptor fd, long length) Pre-allocate disk space for a file if we can do that on this version of the OS.static intfindAbiScore(String[] supportedAbis, String abi) Determine how preferred a given ABI is on this system.static voidstatic longgetApkDepBlockLength(File apkFile) Retrieve the size of dependency file.static intgetAppVersionCode(android.content.Context context) static StringgetBaseName(String fileName) Gets the base name, without extension, of given file name.static Stringstatic FileLockergetFileLocker(File lockFileName) static Methodstatic FileLockergetOrCreateLockOnDir(File soDirectory, File lockFileName) static String[]Return an list of ABIs we supported on this device ordered according to preference.static booleanis64Bit()static booleanisDisabledExtractNativeLibs(android.content.Context context) static booleanisSupportedDirectLoad(android.content.Context context, int appType) static byte[]makeApkDepBlock(File apkFile, android.content.Context context) N.B.static StringmakeNonZipPath(String localLdLibraryPath) static voidmkdirOrThrow(File dir) Like File.mkdirs, but throws on error.
-
Constructor Details
-
SysUtil
public SysUtil()
-
-
Method Details
-
findAbiScore
Determine how preferred a given ABI is on this system.- Parameters:
supportedAbis- ABIs on this systemabi- ABI of a shared library we might want to unpack- Returns:
- -1 if not supported or an integer, smaller being more preferred
-
deleteOrThrow
- Throws:
IOException
-
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
Pre-allocate disk space for a file if we can do that on this version of the OS.- Parameters:
fd- File descriptor for filelength- Number of bytes to allocate.- Throws:
IOException- IOException
-
dumbDelete
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
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
- Throws:
IOException
-
getApkDepBlockLength
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 methodgetApkDepBlockLength(java.io.File)must also be updated to reflect the expected size of the dep block- Parameters:
apkFile- apk filecontext- 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
- Throws:
IOException
-
getBaseName
Gets the base name, without extension, of given file name.- Parameters:
fileName- full file name- Returns:
- base name
-
makeNonZipPath
-
getClassLoaderLdLoadLibrary
-
getNativeLoadRuntimeMethod
-