Java 类soot.jimple.infoflow.android.axml.ApkHandler 实例源码

项目:JAADAS    文件:ProcessManifest.java   
/**
 * 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();
    }
}
项目:DroidRA    文件:ProcessManifest.java   
/**
 * 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();
    }
}
项目:DroidForce    文件:UpdateManifestAndCodeForWaitPDP.java   
/**
 * 
 * @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();
}
项目:DroidForce    文件:UpdateManifestAndCodeForWaitPDP.java   
/**
 * 
 * @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();
    }
}
项目:JAADAS    文件:ProcessManifest.java   
/**
 * 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;
}
项目:DroidRA    文件:ProcessManifest.java   
/**
 * 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;
}