Exemple #1
0
def align_and_sign_output_apk(
    unaligned_apk_path,
    output_apk_path,
    reset_timestamps,
    sign,
    keystore,
    key_alias,
    key_password,
    ignore_zipalign,
    page_align,
):
    if isfile(output_apk_path):
        os.remove(output_apk_path)

    try:
        os.makedirs(dirname(output_apk_path))
    except OSError as e:
        if e.errno != errno.EEXIST:
            raise

    zipalign(unaligned_apk_path, output_apk_path, ignore_zipalign, page_align)

    if reset_timestamps:
        ZipReset.reset_file(output_apk_path)

    # Add new signature
    if sign:
        sign_apk(keystore, key_password, key_alias, output_apk_path)
Exemple #2
0
def create_dex_jar(
    jarpath, dexpath, compression=zipfile.ZIP_STORED, reset_timestamps=True
):
    with zipfile.ZipFile(jarpath, mode="w") as zf:
        zf.write(dexpath, "classes.dex", compress_type=compression)
        zf.writestr(
            "/META-INF/MANIFEST.MF",
            b"Manifest-Version: 1.0\n"
            b"Dex-Location: classes.dex\n"
            b"Created-By: redex\n\n",
        )
    if reset_timestamps:
        ZipReset.reset_file(jarpath)