Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9182b54 authored by Jeongik Cha's avatar Jeongik Cha Committed by android-build-merger
Browse files

Merge "Clean up noisy error log in find-shareduid-violation.py"

am: 50b4b395

Change-Id: I643ffdb62536e48c288ab6cfe902e081908213d1
parents af38e176 50b4b395
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -28,14 +28,26 @@ else:
    product_out = sys.argv[1]
    aapt = sys.argv[2]

def make_aapt_cmd(file):
    cmds = [aapt + ' dump ' + file + ' --file AndroidManifest.xml',
def execute(cmd):
    p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    out, err = map(lambda b: b.decode('utf-8'), p.communicate())
    return p.returncode == 0, out, err

def make_aapt_cmds(file):
    return [aapt + ' dump ' + file + ' --file AndroidManifest.xml',
            aapt + ' dump xmltree ' + file + ' --file AndroidManifest.xml']
    return " || ".join(cmds)

def extract_shared_uid(file):
    manifest = subprocess.check_output(make_aapt_cmd(file), shell=True).decode().split('\n')
    for l in manifest:
    for cmd in make_aapt_cmds(file):
        success, manifest, error_msg = execute(cmd)
        if success:
            break
    else:
        print(error_msg, file=sys.stderr)
        sys.exit()
        return None

    for l in manifest.split('\n'):
        if "sharedUserId" in l:
            return l.split('"')[-2]
    return None