diff --git a/Android.mk b/Android.mk index 6639d7d1cf12c..bf17fba69f4b9 100644 --- a/Android.mk +++ b/Android.mk @@ -658,10 +658,23 @@ $(LOCAL_LIGHT_GREYLIST): $(LOCAL_SRC_ALL) $(call assert-has-no-duplicates,$@) $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API)) -# Generate an empty dark greylist. +# Generate dark greylist as remaining members of classes on the light greylist, +# as well as the members of their inner classes. +# The algorithm is as follows: +# (1) extract the class descriptor from each entry in LOCAL_LIGHT_GREYLIST +# (2) strip the final semicolon and anything after (and including) a dollar sign, +# e.g. 'Lpackage/class$inner;' turns into 'Lpackage/class' +# (3) insert all entries from LOCAL_SRC_PRIVATE_API which begin with the stripped +# descriptor followed by a semi-colon or a dollar sign, e.g. matching a regex +# '^Lpackage/class[;$]' +# (4) subtract entries shared with LOCAL_LIGHT_GREYLIST $(LOCAL_DARK_GREYLIST): $(LOCAL_SRC_ALL) $(LOCAL_LIGHT_GREYLIST) - rm -f $@ - touch $@ + comm -13 $(LOCAL_LIGHT_GREYLIST) \ + <(sed 's/;\->.*//' $(LOCAL_LIGHT_GREYLIST) | sed 's/$$.*//' | sort | uniq | \ + while read CLASS_DESC; do \ + grep -E "^$${CLASS_DESC}[;$$]" $(LOCAL_SRC_PRIVATE_API); \ + done | sort | uniq) \ + > $@ $(call assert-is-subset,$@,$(LOCAL_SRC_PRIVATE_API)) $(call assert-has-no-duplicates,$@) $(call assert-has-no-overlap,$@,$(LOCAL_LIGHT_GREYLIST))