aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongik Cha <jeongik@google.com>2019-02-15 15:21:00 +0900
committerJeongik Cha <jeongik@google.com>2019-02-16 10:50:56 +0900
commitb806c44326fe256b23afcb2a4693189202e6e5ff (patch)
tree98d4d3c0ce0589238e51b22b584341aff1a94d0c
parent8f4e0f2939ff02fe42f9db3b828143fe31b18e72 (diff)
downloadbuild-b806c44326fe256b23afcb2a4693189202e6e5ff.tar.gz
Clean up noisy error log in find-shareduid-violation.py
The script makes noisy error although fallback cmd succeed. So make the script writes error log only if both of commands fail. Bug: 124470143 Bug: 123664116 Test: m -j out/target/product/$(get_build_var TARGET_DEVICE)/shareduid_violation_modules.json Test: And there is no error log in stderr Change-Id: I3d4756066ee6904826c18754969fd4190bd02e1e
-rwxr-xr-xcore/tasks/find-shareduid-violation.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/core/tasks/find-shareduid-violation.py b/core/tasks/find-shareduid-violation.py
index 0fe6ffadd5..1f8e4df5e0 100755
--- a/core/tasks/find-shareduid-violation.py
+++ b/core/tasks/find-shareduid-violation.py
@@ -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