64 lines
2.0 KiB
Java
64 lines
2.0 KiB
Java
|
package com.facebook.soloader;
|
||
|
|
||
|
import android.annotation.TargetApi;
|
||
|
import android.os.Build;
|
||
|
import android.system.ErrnoException;
|
||
|
import android.system.Os;
|
||
|
import android.system.OsConstants;
|
||
|
import android.util.Log;
|
||
|
import c.f.m.d;
|
||
|
import c.f.m.i;
|
||
|
import java.io.FileDescriptor;
|
||
|
import java.io.IOException;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Arrays;
|
||
|
import java.util.TreeSet;
|
||
|
@TargetApi(21)
|
||
|
@d
|
||
|
public final class SysUtil$LollipopSysdeps {
|
||
|
private SysUtil$LollipopSysdeps() {
|
||
|
}
|
||
|
|
||
|
@d
|
||
|
public static void fallocateIfSupported(FileDescriptor fileDescriptor, long j) throws IOException {
|
||
|
int i;
|
||
|
try {
|
||
|
Os.posix_fallocate(fileDescriptor, 0, j);
|
||
|
} catch (ErrnoException e) {
|
||
|
if (e.errno != OsConstants.EOPNOTSUPP && (i = e.errno) != OsConstants.ENOSYS && i != OsConstants.EINVAL) {
|
||
|
throw new IOException(e.toString(), e);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@d
|
||
|
public static String[] getSupportedAbis() {
|
||
|
String[] strArr = Build.SUPPORTED_ABIS;
|
||
|
TreeSet treeSet = new TreeSet();
|
||
|
try {
|
||
|
if (is64Bit()) {
|
||
|
treeSet.add(i.AARCH64.toString());
|
||
|
treeSet.add(i.X86_64.toString());
|
||
|
} else {
|
||
|
treeSet.add(i.ARM.toString());
|
||
|
treeSet.add(i.X86.toString());
|
||
|
}
|
||
|
ArrayList arrayList = new ArrayList();
|
||
|
for (String str : strArr) {
|
||
|
if (treeSet.contains(str)) {
|
||
|
arrayList.add(str);
|
||
|
}
|
||
|
}
|
||
|
return (String[]) arrayList.toArray(new String[arrayList.size()]);
|
||
|
} catch (ErrnoException e) {
|
||
|
Log.e("SysUtil", String.format("Could not read /proc/self/exe. Falling back to default ABI list: %s. errno: %d Err msg: %s", Arrays.toString(strArr), Integer.valueOf(e.errno), e.getMessage()));
|
||
|
return Build.SUPPORTED_ABIS;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@d
|
||
|
public static boolean is64Bit() throws ErrnoException {
|
||
|
return Os.readlink("/proc/self/exe").contains("64");
|
||
|
}
|
||
|
}
|