Ejemplo n.º 1
0
  public void decodeUnknownFiles(ExtFile apkFile, File outDir, ResTable resTable)
      throws AndrolibException {
    LOGGER.info("Copying unknown files...");
    File unknownOut = new File(outDir, UNK_DIRNAME);
    ZipEntry invZipFile;

    // have to use container of ZipFile to help identify compression type
    // with regular looping of apkFile for easy copy
    try {
      Directory unk = apkFile.getDirectory();
      ZipFile apkZipFile = new ZipFile(apkFile.getAbsolutePath());

      // loop all items in container recursively, ignoring any that are pre-defined by aapt
      Set<String> files = unk.getFiles(true);
      for (String file : files) {
        if (!isAPKFileNames(file) && !file.endsWith(".dex")) {

          // copy file out of archive into special "unknown" folder
          unk.copyToDir(unknownOut, file);
          try {
            invZipFile = apkZipFile.getEntry(file);

            // lets record the name of the file, and its compression type
            // so that we may re-include it the same way
            if (invZipFile != null) {
              mResUnknownFiles.addUnknownFileInfo(
                  invZipFile.getName(), String.valueOf(invZipFile.getMethod()));
            }
          } catch (NullPointerException ignored) {
          }
        }
      }
      apkZipFile.close();
    } catch (DirectoryException | IOException ex) {
      throw new AndrolibException(ex);
    }
  }