Class ApkHandler

java.lang.Object
soot.jimple.infoflow.android.axml.ApkHandler
All Implemented Interfaces:
AutoCloseable

public class ApkHandler extends Object implements AutoCloseable
Provides access to the files within an APK and can add and replace files.
Author:
Stefan Haas, Mario Schlipf
  • Field Details

    • apk

      protected File apk
      The handled APK file.
    • zip

      protected ZipFile zip
      Pointer to the ZipFile. If an InputStream for a file within the ZipFile is returned by getInputStream(String) the ZipFile object has to remain available in order to read the InputStream.
  • Constructor Details

  • Method Details

    • getAbsolutePath

      public String getAbsolutePath()
      Returns the absolute path of the APK which is held by the ApkHandler.
      See Also:
    • getPath

      public String getPath()
      Returns the path of the APK which is held by the ApkHandler.
      See Also:
    • getFilename

      public String getFilename()
      Returns the filename of the APK which is held by the ApkHandler.
      See Also:
    • getInputStream

      public InputStream getInputStream(String filename) throws IOException
      Returns an InputStream for a file within the APK.
      The given filename has to be the relative path within the APK, e.g. res/menu/main.xml
      Parameters:
      filename - the file's path
      Returns:
      InputStream for the searched file, if not found null
      Throws:
      IOException - if an I/O error occurs.
    • addFilesToApk

      public void addFilesToApk(List<File> files) throws IOException
      Parameters:
      files - array with File objects to be added to the APK.
      Throws:
      IOException - if an I/O error occurs.
      See Also:
    • addFilesToApk

      public void addFilesToApk(List<File> files, Map<String,String> paths) throws IOException
      Adds the files to the APK which is handled by this ApkHandler.
      Parameters:
      files - Array with File objects to be added to the APK.
      paths - Map containing paths where to put the files. The Map's keys are the file's paths: paths.get(file.getPath())
      Throws:
      IOException - if an I/O error occurs.
    • close

      public void close()
      Closes this apk file
      Specified by:
      close in interface AutoCloseable