From eab9e7f8014fa67164fb9a14ccd9dd624c802c51 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Mon, 22 Jun 2020 10:17:02 -0700 Subject: Don't add API annotations in the internal R.java I'm trying to enable a check for the following structure: ``` /** @hide */ public class Class1 { /** @hide */ @SystemApi // Invalid because the class is hidden. public void method1() { } } ``` The internal R.java file violates this, which this change is going to fix. Bug: 159162473 Test: build (treehugger) Test: atest aapt2_tests Merged-in: I613e8611ddaf5f8e4761d351d4cd0142d59c7cc9 Change-Id: I613e8611ddaf5f8e4761d351d4cd0142d59c7cc9 --- tools/aapt2/java/AnnotationProcessor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tools/aapt2/java/AnnotationProcessor.cpp') diff --git a/tools/aapt2/java/AnnotationProcessor.cpp b/tools/aapt2/java/AnnotationProcessor.cpp index a4610b2575b9..bb667d6fa539 100644 --- a/tools/aapt2/java/AnnotationProcessor.cpp +++ b/tools/aapt2/java/AnnotationProcessor.cpp @@ -110,7 +110,7 @@ void AnnotationProcessor::AppendNewLine() { } } -void AnnotationProcessor::Print(Printer* printer) const { +void AnnotationProcessor::Print(Printer* printer, bool strip_api_annotations) const { if (has_comments_) { std::string result = comment_.str(); for (const StringPiece& line : util::Tokenize(result, '\n')) { @@ -123,6 +123,9 @@ void AnnotationProcessor::Print(Printer* printer) const { printer->Println("@Deprecated"); } + if (strip_api_annotations) { + return; + } for (const AnnotationRule& rule : sAnnotationRules) { if (annotation_bit_mask_ & rule.bit_mask) { printer->Println(rule.annotation); -- cgit v1.2.3