Class ApkHandler
java.lang.Object
soot.jimple.infoflow.android.axml.ApkHandler
- All Implemented Interfaces:
AutoCloseable
Provides access to the files within an APK and can add and replace files.
- Author:
- Stefan Haas, Mario Schlipf
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionApkHandler(File apk) Creates a newApkHandlerwhich handles the given APK file.ApkHandler(String path) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFilesToApk(List<File> files) voidAdds the files to the APK which is handled by thisApkHandler.voidclose()Closes this apk fileReturns the absolute path of the APK which is held by theApkHandler.Returns the filename of the APK which is held by theApkHandler.getInputStream(String filename) Returns anInputStreamfor a file within the APK.
The given filename has to be the relative path within the APK, e.g.getPath()Returns the path of the APK which is held by theApkHandler.
-
Field Details
-
apk
The handled APK file. -
zip
Pointer to the ZipFile. If an InputStream for a file within the ZipFile is returned bygetInputStream(String)the ZipFile object has to remain available in order to read the InputStream.
-
-
Constructor Details
-
ApkHandler
- Parameters:
path- the APK's path- Throws:
ZipException- occurs if the APK is no a valid zip file.IOException- if an I/O error occurs.- See Also:
-
ApkHandler
Creates a newApkHandlerwhich handles the given APK file.- Parameters:
apk- the APK's path- Throws:
ZipException- occurs if the APK is no a valid zip file.IOException- if an I/O error occurs.
-
-
Method Details
-
getAbsolutePath
Returns the absolute path of the APK which is held by theApkHandler.- See Also:
-
getPath
Returns the path of the APK which is held by theApkHandler.- See Also:
-
getFilename
Returns the filename of the APK which is held by theApkHandler.- See Also:
-
getInputStream
Returns anInputStreamfor 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:
InputStreamfor the searched file, if not found null- Throws:
IOException- if an I/O error occurs.
-
addFilesToApk
- Parameters:
files- array with File objects to be added to the APK.- Throws:
IOException- if an I/O error occurs.- See Also:
-
addFilesToApk
Adds the files to the APK which is handled by thisApkHandler.- 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:
closein interfaceAutoCloseable
-