From 3b0867ec3a5606e900d7a5bbc9506f9375b4f9db Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 2 Jan 2018 19:02:07 +0900 Subject: [PATCH] Make SystemApi retained at runtime SystemApi annotation is now retained at runtime in order for the CtsSignatureTest to extract the list of System APIs from the device and compare it with the known list of the APIs. Until now, the test only ensured that the known list of the APIs exist in the device, but didn't ensured the opposite. In order words, it was possible for device manufacturers to revive the APIs that were once deleted. This will become a problem when SystemAPIs will be allowed to non-system partitions such as vendor. An apk in the vendor partition which is using the revived-but-officially-deleted System API will break when the system partition is replaced with the Generic System Image (GSI) built from AOSP, which doesn't have the deleted API. (Running CTS on GSI is part of the Treble compliance tests) The overhead of retaining this annotation at runtime is small, because the relationship from an entity (a class, a field, a member, etc) to the annotation is recorded as a 4 byte offset field [1]. [1] https://source.android.com/devices/tech/dalvik/dex-format#annotations-directory Bug: 70832217 Bug: 67891551 Test: measure the size increment before and after. framework.jar was increased by 2964 byte. Change-Id: I679b19ac5ce57d33ce59e32b3b1753f8a1962e11 --- core/java/android/annotation/SystemApi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/annotation/SystemApi.java b/core/java/android/annotation/SystemApi.java index 55028ebfa8fd0..e96ff01d0850f 100644 --- a/core/java/android/annotation/SystemApi.java +++ b/core/java/android/annotation/SystemApi.java @@ -39,6 +39,6 @@ import java.lang.annotation.Target; * @hide */ @Target({TYPE, FIELD, METHOD, CONSTRUCTOR, ANNOTATION_TYPE, PACKAGE}) -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.RUNTIME) public @interface SystemApi { }