File nativeFolder = new File(jniLibLocation);
if (!nativeFolder.isDirectory()) {
// not a directory? check if it's a file or doesn't exist
if (nativeFolder.exists()) {
throw new PackagerException("%s is not a folder", nativeFolder);
} else {
throw new PackagerException("%s does not exist", nativeFolder);
}
}
File[] abiList = nativeFolder.listFiles();
mLogger.verbose("Native folder: %s", nativeFolder);
if (abiList != null) {
for (File abi : abiList) {
if (abi.isDirectory()) { // ignore files
File[] libs = abi.listFiles();
if (libs != null) {
for (File lib : libs) {
// only consider files that are .so or, if in debug mode, that
// are gdbserver executables
if (lib.isFile() &&
(PATTERN_NATIVELIB_EXT.matcher(lib.getName()).matches() ||
(mJniDebugMode &&
SdkConstants.FN_GDBSERVER.equals(
lib.getName())))) {
String path =
SdkConstants.FD_APK_NATIVE_LIBS + "/" +
abi.getName() + "/" + lib.getName();
try {
doAddFile(lib, path);
} catch (IOException e) {
mBuilder.cleanUp();
throw new PackagerException(e, "Failed to add %s", lib);
}
}
}
}
}