/** * Adds the resources from a source folder. * @param sourceFolder the source 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. */ public void addSourceFolder(File sourceFolder) throws ApkCreationException, SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } addSourceFolder(this, sourceFolder); }
/** * Adds the resources from a source folder. * @param sourceFolder the source 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. */ public void addSourceFolder(File sourceFolder) throws ApkCreationException, SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } addSourceFolder(this, sourceFolder); }
public void addNativeLibraries(List<FileEntry> entries) throws SealedApkException, DuplicateFileException, ApkCreationException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } for (FileEntry entry : entries) { try { doAddFile(entry.mFile, entry.mPath); } catch (IOException e) { mBuilder.cleanUp(); throw new ApkCreationException(e, "Failed to add %s", entry.mFile); } } }
throws ApkCreationException, SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed");
throws ApkCreationException, SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed");
public void addNativeLibraries(List<FileEntry> entries) throws SealedApkException, DuplicateFileException, ApkCreationException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } for (FileEntry entry : entries) { try { doAddFile(entry.mFile, entry.mPath); } catch (IOException e) { mBuilder.cleanUp(); throw new ApkCreationException(e, "Failed to add %s", entry.mFile); } } }
/** * Seals the APK, and signs it if necessary. * @throws ApkCreationException * @throws ApkCreationException if an error occurred * @throws SealedApkException if the APK is already sealed. */ public void sealApk() throws ApkCreationException, SealedApkException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } // close and sign the application package. try { mBuilder.close(); mIsSealed = true; } catch (Exception e) { throw new ApkCreationException(e, "Failed to seal APK"); } finally { mBuilder.cleanUp(); } }
/** * Seals the APK, and signs it if necessary. * @throws ApkCreationException * @throws ApkCreationException if an error occurred * @throws SealedApkException if the APK is already sealed. */ public void sealApk() throws ApkCreationException, SealedApkException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } // close and sign the application package. try { mBuilder.close(); mIsSealed = true; } catch (Exception e) { throw new ApkCreationException(e, "Failed to seal APK"); } finally { mBuilder.cleanUp(); } }
/** * Adds the content from a zip file. * All file keep the same path inside the archive. * @param zipFile the zip File. * @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. */ public void addZipFile(File zipFile) throws ApkCreationException, SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } try { verbosePrintln("%s:", zipFile); // reset the filter with this input. mNullFilter.reset(zipFile); // ask the builder to add the content of the file. FileInputStream fis = new FileInputStream(zipFile); mBuilder.writeZip(fis, mNullFilter); fis.close(); } catch (DuplicateFileException e) { mBuilder.cleanUp(); throw e; } catch (Exception e) { mBuilder.cleanUp(); throw new ApkCreationException(e, "Failed to add %s", zipFile); } }
/** * Adds the content from a zip file. * All file keep the same path inside the archive. * @param zipFile the zip File. * @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. */ public void addZipFile(File zipFile) throws ApkCreationException, SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } try { verbosePrintln("%s:", zipFile); // reset the filter with this input. mNullFilter.reset(zipFile); // ask the builder to add the content of the file. FileInputStream fis = new FileInputStream(zipFile); mBuilder.writeZip(fis, mNullFilter); fis.close(); } catch (DuplicateFileException e) { mBuilder.cleanUp(); throw e; } catch (Exception e) { mBuilder.cleanUp(); throw new ApkCreationException(e, "Failed to add %s", zipFile); } }
/** * Adds a file to the APK at a given path * @param file the file to add * @param archivePath the path of the file inside the APK archive. * @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. */ @Override public void addFile(File file, String archivePath) throws ApkCreationException, SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } try { doAddFile(file, archivePath); } catch (DuplicateFileException e) { mBuilder.cleanUp(); throw e; } catch (Exception e) { mBuilder.cleanUp(); throw new ApkCreationException(e, "Failed to add %s", file); } }
/** * Adds a file to the APK at a given path * @param file the file to add * @param archivePath the path of the file inside the APK archive. * @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. */ @Override public void addFile(File file, String archivePath) throws ApkCreationException, SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed"); } try { doAddFile(file, archivePath); } catch (DuplicateFileException e) { mBuilder.cleanUp(); throw e; } catch (Exception e) { mBuilder.cleanUp(); throw new ApkCreationException(e, "Failed to add %s", file); } }
SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed");
SealedApkException, DuplicateFileException { if (mIsSealed) { throw new SealedApkException("APK is already sealed");