Package com.facebook.soloader
Class SysUtil
- java.lang.Object
-
- com.facebook.soloader.SysUtil
-
public final class SysUtil extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSysUtil.Api14Utils
-
Constructor Summary
Constructors Constructor Description SysUtil()
-
Method Summary
Modifier and Type Method Description static voiddeleteOrThrow(java.io.File file)static voiddumbDeleteRecursive(java.io.File file)Delete a directory and its contents.static voidfallocateIfSupported(java.io.FileDescriptor fd, long length)Pre-allocate disk space for a file if we can do that on this version of the OS.static intfindAbiScore(java.lang.String[] supportedAbis, java.lang.String abi)Determine how preferred a given ABI is on this system.static voidfsyncRecursive(java.io.File fileName)static longgetApkDepBlockLength(java.io.File apkFile)Retrieve the size of dependency file.static intgetAppVersionCode(android.content.Context context)static java.lang.StringgetBaseName(java.lang.String fileName)Gets the base name, without extension, of given file name.static FileLockergetOrCreateLockOnDir(java.io.File soDirectory, java.io.File lockFileName, boolean blocking)static java.lang.String[]getSupportedAbis()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(java.io.File apkFile, android.content.Context context)N.B.static voidmkdirOrThrow(java.io.File dir)Like File.mkdirs, but throws on error.
-
-
-
Method Detail
-
findAbiScore
public static int findAbiScore(java.lang.String[] supportedAbis, java.lang.String abi)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
public static void deleteOrThrow(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
getSupportedAbis
public static java.lang.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(java.io.FileDescriptor fd, long length) throws java.io.IOExceptionPre-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:
java.io.IOException- IOException
-
dumbDeleteRecursive
public static void dumbDeleteRecursive(java.io.File file) throws java.io.IOExceptionDelete 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:
java.io.IOException- IOException
-
mkdirOrThrow
public static void mkdirOrThrow(java.io.File dir) throws java.io.IOExceptionLike 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:
java.io.IOException- IOException
-
fsyncRecursive
public static void fsyncRecursive(java.io.File fileName) throws java.io.IOException- Throws:
java.io.IOException
-
getApkDepBlockLength
public static long getApkDepBlockLength(java.io.File apkFile) throws java.io.IOExceptionRetrieve the size of dependency file.- Parameters:
apkFile- the apk file- Returns:
- the size of dependency file
- Throws:
java.io.IOException- IOException
-
makeApkDepBlock
public static byte[] makeApkDepBlock(java.io.File apkFile, android.content.Context context) throws java.io.IOExceptionN.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:
java.io.IOException- IOException
-
getAppVersionCode
public static int getAppVersionCode(android.content.Context context)
-
is64Bit
public static boolean is64Bit()
-
isSupportedDirectLoad
public static boolean isSupportedDirectLoad(android.content.Context context, int appType) throws java.io.IOException- Throws:
java.io.IOException
-
isDisabledExtractNativeLibs
public static boolean isDisabledExtractNativeLibs(android.content.Context context)
-
getOrCreateLockOnDir
@Nullable public static FileLocker getOrCreateLockOnDir(java.io.File soDirectory, java.io.File lockFileName, boolean blocking) throws java.io.IOException
- Throws:
java.io.IOException
-
getBaseName
public static java.lang.String getBaseName(java.lang.String fileName)
Gets the base name, without extension, of given file name.- Parameters:
fileName- full file name- Returns:
- base name
-
-