aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeongik Cha <jeongik@google.com>2019-02-16 20:29:46 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-02-16 20:29:46 -0800
commitd9182b546cce26ba50b69544fe4ef079d31a119f (patch)
tree4a7b5f22db63211961666043970d2127fa1bf9ed
parentaf38e1765f3d88747ed53ca002beee3d785e3132 (diff)
parent50b4b395bc22617c0b3abba640eccef0f707f38b (diff)
downloadbuild-d9182b546cce26ba50b69544fe4ef079d31a119f.tar.gz
Merge "Clean up noisy error log in find-shareduid-violation.py"
am: 50b4b395bc Change-Id: I643ffdb62536e48c288ab6cfe902e081908213d1
-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