Java Code Examples for com.android.SdkConstants#FD_APK_NATIVE_LIBS

The following examples show how to use com.android.SdkConstants#FD_APK_NATIVE_LIBS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApkBuilder.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
/**
 * Adds the native libraries from the top native folder.
 * The content of this folder must be the various ABI folders.
 *
 * This may or may not copy gdbserver into the apk based on whether the debug mode is set.
 *
 * @param nativeFolder the native folder.
 *
 * @throws ApkCreationException if an error occurred
 * @throws SealedApkException if the APK is already sealed.
 * @throws DuplicateFileException if a file conflicts with another already added to the APK
 *                                   at the same location inside the APK archive.
 *
 * @see #setDebugMode(boolean)
 */
public void addNativeLibraries(File nativeFolder)
        throws ApkCreationException, SealedApkException, DuplicateFileException {
    if (mIsSealed) {
        throw new SealedApkException("APK is already sealed");
    }

    if (!nativeFolder.isDirectory()) {
        // not a directory? check if it's a file or doesn't exist
        if (nativeFolder.exists()) {
            throw new ApkCreationException("%s is not a folder", nativeFolder);
        } else {
            throw new ApkCreationException("%s does not exist", nativeFolder);
        }
    }

    File[] abiList = nativeFolder.listFiles();

    verbosePrintln("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() ||
                                PATTERN_BITCODELIB_EXT.matcher(lib.getName()).matches() ||
                                        (mDebugMode &&
                                                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 ApkCreationException(e, "Failed to add %s", lib);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 2
Source File: ApkBuilder.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
public static List<FileEntry> getNativeFiles(File nativeFolder, boolean debugMode)
        throws ApkCreationException  {

    if (!nativeFolder.isDirectory()) {
        // not a directory? check if it's a file or doesn't exist
        if (nativeFolder.exists()) {
            throw new ApkCreationException("%s is not a folder", nativeFolder);
        } else {
            throw new ApkCreationException("%s does not exist", nativeFolder);
        }
    }

    List<FileEntry> files = new ArrayList<FileEntry>();

    File[] abiList = nativeFolder.listFiles();

    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() ||
                                PATTERN_BITCODELIB_EXT.matcher(lib.getName()).matches() ||
                                        (debugMode &&
                                                SdkConstants.FN_GDBSERVER.equals(
                                                        lib.getName())))) {
                            String path =
                                SdkConstants.FD_APK_NATIVE_LIBS + "/" +
                                abi.getName() + "/" + lib.getName();

                            files.add(new FileEntry(lib, path));
                        }
                    }
                }
            }
        }
    }

    return files;
}
 
Example 3
Source File: ApkBuilder.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Adds the native libraries from the top native folder.
 * The content of this folder must be the various ABI folders.
 *
 * This may or may not copy gdbserver into the apk based on whether the debug mode is set.
 *
 * @param nativeFolder the native folder.
 *
 * @throws ApkCreationException if an error occurred
 * @throws SealedApkException if the APK is already sealed.
 * @throws DuplicateFileException if a file conflicts with another already added to the APK
 *                                   at the same location inside the APK archive.
 *
 * @see #setDebugMode(boolean)
 */
public void addNativeLibraries(File nativeFolder)
        throws ApkCreationException, SealedApkException, DuplicateFileException {
    if (mIsSealed) {
        throw new SealedApkException("APK is already sealed");
    }

    if (!nativeFolder.isDirectory()) {
        // not a directory? check if it's a file or doesn't exist
        if (nativeFolder.exists()) {
            throw new ApkCreationException("%s is not a folder", nativeFolder);
        } else {
            throw new ApkCreationException("%s does not exist", nativeFolder);
        }
    }

    File[] abiList = nativeFolder.listFiles();

    verbosePrintln("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() ||
                                PATTERN_BITCODELIB_EXT.matcher(lib.getName()).matches() ||
                                        (mDebugMode &&
                                                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 ApkCreationException(e, "Failed to add %s", lib);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 4
Source File: ApkBuilder.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static List<FileEntry> getNativeFiles(File nativeFolder, boolean debugMode)
        throws ApkCreationException  {

    if (!nativeFolder.isDirectory()) {
        // not a directory? check if it's a file or doesn't exist
        if (nativeFolder.exists()) {
            throw new ApkCreationException("%s is not a folder", nativeFolder);
        } else {
            throw new ApkCreationException("%s does not exist", nativeFolder);
        }
    }

    List<FileEntry> files = new ArrayList<FileEntry>();

    File[] abiList = nativeFolder.listFiles();

    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() ||
                                PATTERN_BITCODELIB_EXT.matcher(lib.getName()).matches() ||
                                        (debugMode &&
                                                SdkConstants.FN_GDBSERVER.equals(
                                                        lib.getName())))) {
                            String path =
                                SdkConstants.FD_APK_NATIVE_LIBS + "/" +
                                abi.getName() + "/" + lib.getName();

                            files.add(new FileEntry(lib, path));
                        }
                    }
                }
            }
        }
    }

    return files;
}
 
Example 5
Source File: ApkBuilder.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
public static List<FileEntry> getNativeFiles(File nativeFolder, boolean debugMode)
        throws ApkCreationException {

    if (!nativeFolder.isDirectory()) {
        // not a directory? check if it's a file or doesn't exist
        if (nativeFolder.exists()) {
            throw new ApkCreationException("%s is not a folder", nativeFolder);
        } else {
            throw new ApkCreationException("%s does not exist", nativeFolder);
        }
    }

    List<FileEntry> files = new ArrayList<FileEntry>();

    File[] abiList = nativeFolder.listFiles();

    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() ||
                                        PATTERN_BITCODELIB_EXT.matcher(lib.getName()).matches())) {
                            String path =
                                    SdkConstants.FD_APK_NATIVE_LIBS + "/" +
                                            abi.getName() + "/" + lib.getName();

                            files.add(new FileEntry(lib, path));
                        }
                    }
                }
            }
        }
    }

    return files;
}
 
Example 6
Source File: ApkBuilder.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Adds the native libraries from the top native folder.
 * The content of this folder must be the various ABI folders.
 * <p>
 * This may or may not copy gdbserver into the apk based on whether the debug mode is set.
 *
 * @param nativeFolder the native folder.
 * @throws ApkCreationException   if an error occurred
 * @throws SealedApkException     if the APK is already sealed.
 * @throws DuplicateFileException if a file conflicts with another already added to the APK
 *                                at the same location inside the APK archive.
 * @see #setDebugMode(boolean)
 */
public void addNativeLibraries(File nativeFolder)
        throws ApkCreationException, SealedApkException, DuplicateFileException {
    if (mIsSealed) {
        throw new SealedApkException("APK is already sealed");
    }

    if (!nativeFolder.isDirectory()) {
        // not a directory? check if it's a file or doesn't exist
        if (nativeFolder.exists()) {
            throw new ApkCreationException("%s is not a folder", nativeFolder);
        } else {
            throw new ApkCreationException("%s does not exist", nativeFolder);
        }
    }

    File[] abiList = nativeFolder.listFiles();

    verbosePrintln("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() ||
                                        PATTERN_BITCODELIB_EXT.matcher(lib.getName()).matches())) {
                            String path =
                                    SdkConstants.FD_APK_NATIVE_LIBS + "/" +
                                            abi.getName() + "/" + lib.getName();

                            try {
                                doAddFile(lib, path);
                            } catch (IOException e) {
                                mBuilder.cleanUp();
                                throw new ApkCreationException(e, "Failed to add %s", lib);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
Example 7
Source File: Packager.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Adds the native libraries from the top native folder.
 * The content of this folder must be the various ABI folders.
 *
 * This may or may not copy gdbserver into the apk based on whether the debug mode is set.
 *
 * @param nativeFolder the root folder containing the abi folders which contain the .so
 * @param abiFilters a list of abi filters to include. If null or empty, all abis are included.
 *
 * @throws PackagerException if an error occurred
 * @throws SealedPackageException if the APK is already sealed.
 * @throws DuplicateFileException if a file conflicts with another already added to the APK
 *                                   at the same location inside the APK archive.
 *
 * @see #setJniDebugMode(boolean)
 */
public void addNativeLibraries(@NonNull File nativeFolder, @Nullable Set<String> abiFilters)
        throws PackagerException, SealedPackageException, DuplicateFileException {
    if (mIsSealed) {
        throw new SealedPackageException("APK is already sealed");
    }

    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 (abiFilters != null && !abiFilters.isEmpty() && !abiFilters.contains(abi.getName())) {
                continue;
            }

            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
                        String libName = lib.getName();
                        if (lib.isFile() &&
                                (PATTERN_NATIVELIB_EXT.matcher(lib.getName()).matches())) {

                            String path =
                                SdkConstants.FD_APK_NATIVE_LIBS + "/" +
                                abi.getName() + "/" + libName;

                            try {

                                if (mPackagingOptionsFilter == null
                                        || mPackagingOptionsFilter.checkEntry(path)) {
                                    doAddFile(lib, path);
                                }
                            } catch (Exception e) {
                                mBuilder.cleanUp();
                                throw new PackagerException(e, "Failed to add %s", lib);
                            }
                        }
                    }
                }
            }
        }
    }
}