本文整理汇总了Java中soot.jimple.infoflow.android.axml.ApkHandler类的典型用法代码示例。如果您正苦于以下问题:Java ApkHandler类的具体用法?Java ApkHandler怎么用?Java ApkHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApkHandler类属于soot.jimple.infoflow.android.axml包,在下文中一共展示了ApkHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ProcessManifest
import soot.jimple.infoflow.android.axml.ApkHandler; //导入依赖的package包/类
/**
* Processes an AppManifest which is within the given {@link File}.
*
* @param apkFile the AppManifest within the given APK will be parsed.
* @throws IOException if an I/O error occurs.
* @throws XmlPullParserException can occur due to a malformed manifest.
* @see {@link ProcessManifest#ProcessManifest(InputStream)}
*/
public ProcessManifest(File apkFile) throws IOException, XmlPullParserException {
this.apk = new ApkHandler(apkFile);
InputStream is = null;
try {
is = this.apk.getInputStream("AndroidManifest.xml");
this.handle(is);
}
finally {
if (is != null)
is.close();
}
}
示例2: replaceManifest
import soot.jimple.infoflow.android.axml.ApkHandler; //导入依赖的package包/类
/**
*
* @param originalApk
*/
public static void replaceManifest(String originalApk) {
File originalApkFile = new File(originalApk);
String newManifest = Settings.sootOutput + File.separatorChar + "AndroidManifest.xml";
String targetApk = Settings.sootOutput + File.separatorChar + originalApkFile.getName();
File newMFile = new File(newManifest);
try {
ApkHandler apkH = new ApkHandler(targetApk);
apkH.addFilesToApk(Collections.singletonList(newMFile));
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("error when writing new manifest: "+ e);
}
newMFile.delete();
}
示例3: addBackgroundFile
import soot.jimple.infoflow.android.axml.ApkHandler; //导入依赖的package包/类
/**
*
* @param originalApk
*/
public static void addBackgroundFile(String originalApk) {
File tempFile = null;
try {
File background_picture = new File("resources", "protect.png");
if (!background_picture.exists()) {
// Load the file from the JAR
URL fileURL = UpdateManifestAndCodeForWaitPDP.class.getResource("protect.png");
// Copy the file local
tempFile = File.createTempFile("droidForce", null);
InputStream is = fileURL.openStream();
try {
Files.copy(is, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
background_picture = tempFile;
}
finally {
is.close();
}
}
// By now, we must have a file
if (background_picture == null ||!background_picture.exists())
throw new RuntimeException("Background image file not found");
File originalApkFile = new File(originalApk);
String targetApk = Settings.sootOutput + File.separatorChar + originalApkFile.getName();
try {
ApkHandler apkH = new ApkHandler(targetApk);
apkH.addFilesToApk(Collections.singletonList(background_picture), Collections.singletonMap(background_picture.getPath(), "assets/protect.png"));
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException("error when adding background image: "+ e);
}
} catch (IOException ex) {
System.err.println("File handling failed: " + ex.getMessage());
ex.printStackTrace();
}
finally {
if (tempFile != null)
tempFile.delete();
}
}
示例4: getApk
import soot.jimple.infoflow.android.axml.ApkHandler; //导入依赖的package包/类
/**
* Returns the handler which opened the APK file. If {@link ProcessManifest} was
* instanciated directly with an {@link InputStream} this will return <code>null</code>.
*
* @return APK Handler
*/
public ApkHandler getApk() {
return this.apk;
}