Merge non-SDK @removed API and light greylist
@removed APIs are not part of the public SDK but we do not want
to block access to them. Use the recently added removed-dex.txt
list of @removed API signatures and merge it into the hidden API
light greylist programmatically.
Note that due to Doclava's rule precedence, @removed APIs which
override a public SDK method are considered public and are
whitelisted. We have to intersect removed-dex.txt with private-dex.txt
to satisfy the rule that light greylist is a subset of private-dex.txt.
Bug: 78182899
Test: make out/target/common/obj/PACKAGING/removed-dex.txt
Change-Id: I44e54c405fc667d54a990b9ded1de8456802545e
diff --git a/Android.mk b/Android.mk
index 6a827b0..bb37fa2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -873,9 +873,16 @@
# rules for building them. Other rules in the build system should depend on the
# files in the build folder.
-# Automatically add all methods which match the following signatures.
-# These need to be greylisted in order to allow applications to write their
-# own serializers.
+# Merge light greylist from multiple files:
+# (1) manual light greylist
+# (2) list of usages from vendor apps
+# (3) list of removed APIs
+# @removed does not imply private in Doclava. We must take the subset also
+# in PRIVATE_API.
+# (4) list of serialization APIs
+# Automatically adds all methods which match the signatures in
+# REGEX_SERIALIZATION. These are greylisted in order to allow applications
+# to write their own serializers.
$(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST): REGEX_SERIALIZATION := \
"readObject\(Ljava/io/ObjectInputStream;\)V" \
"readObjectNoData\(\)V" \
@@ -885,14 +892,15 @@
"writeObject\(Ljava/io/ObjectOutputStream;\)V" \
"writeReplace\(\)Ljava/lang/Object;"
$(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST): PRIVATE_API := $(INTERNAL_PLATFORM_PRIVATE_DEX_API_FILE)
-# Temporarily merge light greylist from two files. Vendor list will become dark
-# grey once we remove the UI toast.
+$(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST): REMOVED_API := $(INTERNAL_PLATFORM_REMOVED_DEX_API_FILE)
$(INTERNAL_PLATFORM_HIDDENAPI_LIGHT_GREYLIST): frameworks/base/config/hiddenapi-light-greylist.txt \
frameworks/base/config/hiddenapi-vendor-list.txt \
- $(INTERNAL_PLATFORM_PRIVATE_DEX_API_FILE)
+ $(INTERNAL_PLATFORM_PRIVATE_DEX_API_FILE) \
+ $(INTERNAL_PLATFORM_REMOVED_DEX_API_FILE)
sort frameworks/base/config/hiddenapi-light-greylist.txt \
frameworks/base/config/hiddenapi-vendor-list.txt \
<(grep -E "\->("$(subst $(space),"|",$(REGEX_SERIALIZATION))")$$" $(PRIVATE_API)) \
+ <(comm -12 <(sort $(REMOVED_API)) <(sort $(PRIVATE_API))) \
> $@
$(eval $(call copy-one-file,frameworks/base/config/hiddenapi-dark-greylist.txt,\