From 907b70ae3d82133cd2b78e22edb89c096ca3c21f Mon Sep 17 00:00:00 2001 From: Will Coster Date: Tue, 14 Jan 2020 14:08:05 -0800 Subject: [PATCH] Add build target for permissions text file This CL adds a genrule that generates a text file that contains all of the normal / non-signature permissions formatted with one permission per line. This can be used by tools that require a list of permissions known as part of their build. Without this support, it would be difficult to write the build rules for such tools as it is not possible to access the frameworks/base/core/res/AndroidManifest.xml from Android.bp files in other directories. Test: Built locally and manually verified the file Change-Id: I01046e5faa1f0a81c3d2ee82643094d4cf82f221 --- core/res/Android.bp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/core/res/Android.bp b/core/res/Android.bp index 3dc74f827be4b..b365de4f4630d 100644 --- a/core/res/Android.bp +++ b/core/res/Android.bp @@ -54,3 +54,22 @@ filegroup { "res/**/*", ], } + +// Generate a text file containing a list of permissions that non-system apps +// are allowed to obtain. +genrule { + name: "permission-list-normal", + out: ["permission-list-normal.txt"], + srcs: ["AndroidManifest.xml"], + cmd: "cat $(in) " + + // xmllint has trouble accessing attributes under the android namespace. + // Strip these prefixes prior to processing with xmllint. + " | sed -r 's/android:(name|protectionLevel)/\\1/g' " + + " | $(location xmllint) /dev/stdin --xpath " + + " '//permission[not(contains(@protectionLevel, \"signature\"))]/@name'" + + // The result of xmllint is name="value" pairs. Format these to just the + // permission name, one per-line. + " | sed -r 's/\\s*name=\\s*//g' | tr -d '\"'" + + " > $(out)", + tools: ["xmllint"] +}