aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHao Ke <haok@google.com>2021-11-16 18:56:08 +0000
committerHao Ke <haok@google.com>2021-11-18 14:36:29 +0000
commit4bae711bfcf3529bf76a638d48c7e8dc8fa62ab2 (patch)
treecdda284ec9f2fe3cdba3de58e1d7d95f57a346a7
parentca457ce0d9b4666a269b42bb76e06106753ad101 (diff)
downloadaidl-4bae711bfcf3529bf76a638d48c7e8dc8fa62ab2.tar.gz
Introduce @JavaDefault annotation for AIDL interfaces.
Currently the DefaultImpl support is enabled for all AIDL interfaces, detailed at https://source.android.com/devices/architecture/aidl/stable-aidl#dealing-with-older-interfaces. However, this introduces massive code overhead in AIDL generated code; given such methods are often left unused. Hence it became necessary to introduce opt-in annotation letting the AIDL generator to include the DefaultImpl related code. Note the actual annotation behavior is implemented in AOSP CLs: https://android-review.googlesource.com/q/topic:OptInDefaultImpl, and is not planned to cherry-pick/back-port to mainline. Hence this CL only introduced a no-op @JavaDefault to unblock the presubmit process. Using or not using such annotation in mainline makes no change on the AIDL generated Java files. Test: Build Ignore-AOSP-First: Introduced no-op annotation only to unblock https://android-review.googlesource.com/q/topic:OptInDefaultImpl Bug: 206006915 Change-Id: I6c6a0a239a2ef7ca504d535ddb4bf1973142bc19
-rw-r--r--aidl_checkapi.cpp1
-rw-r--r--aidl_language.cpp5
-rw-r--r--aidl_language.h2
3 files changed, 8 insertions, 0 deletions
diff --git a/aidl_checkapi.cpp b/aidl_checkapi.cpp
index 47733c1b..b132494f 100644
--- a/aidl_checkapi.cpp
+++ b/aidl_checkapi.cpp
@@ -86,6 +86,7 @@ static vector<string> get_strict_annotations(const AidlAnnotatable& node) {
AidlAnnotation::Type::NULLABLE,
// @JavaDerive doesn't affect read/write
AidlAnnotation::Type::JAVA_DERIVE,
+ AidlAnnotation::Type::JAVA_DEFAULT,
AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE,
// @Backing for a enum type is checked by the enum checker
AidlAnnotation::Type::BACKING,
diff --git a/aidl_language.cpp b/aidl_language.cpp
index 5bff95e5..22104774 100644
--- a/aidl_language.cpp
+++ b/aidl_language.cpp
@@ -128,6 +128,7 @@ const std::vector<AidlAnnotation::Schema>& AidlAnnotation::AllSchemas() {
"JavaDerive",
CONTEXT_TYPE_STRUCTURED_PARCELABLE | CONTEXT_TYPE_UNION,
{{"toString", kBooleanType}, {"equals", kBooleanType}}},
+ {AidlAnnotation::Type::JAVA_DEFAULT, "JavaDefault", CONTEXT_TYPE_INTERFACE, {}},
{AidlAnnotation::Type::JAVA_ONLY_IMMUTABLE,
"JavaOnlyImmutable",
CONTEXT_TYPE_STRUCTURED_PARCELABLE | CONTEXT_TYPE_UNION |
@@ -403,6 +404,10 @@ bool AidlAnnotatable::JavaDerive(const std::string& method) const {
return false;
}
+bool AidlAnnotatable::IsJavaDefault() const {
+ return GetAnnotation(annotations_, AidlAnnotation::Type::JAVA_DEFAULT);
+}
+
std::string AidlAnnotatable::GetDescriptor() const {
auto annotation = GetAnnotation(annotations_, AidlAnnotation::Type::DESCRIPTOR);
if (annotation != nullptr) {
diff --git a/aidl_language.h b/aidl_language.h
index e0c28a03..4e0f587d 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -209,6 +209,7 @@ class AidlAnnotation : public AidlNode {
SENSITIVE_DATA,
JAVA_PASSTHROUGH,
JAVA_DERIVE,
+ JAVA_DEFAULT,
JAVA_ONLY_IMMUTABLE,
FIXED_SIZE,
DESCRIPTOR,
@@ -325,6 +326,7 @@ class AidlAnnotatable : public AidlCommentable {
bool IsStableApiParcelable(Options::Language lang) const;
bool IsHide() const;
bool JavaDerive(const std::string& method) const;
+ bool IsJavaDefault() const;
std::string GetDescriptor() const;
const AidlAnnotation* UnsupportedAppUsage() const;