summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2015-03-27 16:44:29 -0700
committerSteve Kondik <steve@cyngn.com>2016-10-08 11:32:32 -0700
commit6d7e0fa88c583651af8ee0915370fbb0c733e30b (patch)
treeab08fc5b479dd7b7420586d743cf3eddf17c0793
parent3f3924909f21c64ff397511b57169dcebeec7686 (diff)
downloadandroid_system_tools_aidl-6d7e0fa88c583651af8ee0915370fbb0c733e30b.tar.gz
android_system_tools_aidl-6d7e0fa88c583651af8ee0915370fbb0c733e30b.tar.bz2
android_system_tools_aidl-6d7e0fa88c583651af8ee0915370fbb0c733e30b.zip
aidl: Support for duplicate methods having different arguments
* Add support for duplicate methods in AIDL when they have different ids, only when ids have been manually assigned to all methods. * This is useful for backwards compatibility. Change-Id: I9612d1633c48e31fe65b966777366a9a6b3ebf5c
-rw-r--r--aidl.cpp26
-rw-r--r--aidl_language.h3
-rw-r--r--generate_java_binder.cpp6
3 files changed, 26 insertions, 9 deletions
diff --git a/aidl.cpp b/aidl.cpp
index 10a90e4..1815e56 100644
--- a/aidl.cpp
+++ b/aidl.cpp
@@ -229,11 +229,18 @@ int check_types(const string& filename,
if (it == method_names.end()) {
method_names[m->GetName()] = m.get();
} else {
- cerr << filename << ":" << m->GetLine()
- << " attempt to redefine method " << m->GetName() << "," << endl
- << filename << ":" << it->second->GetLine()
- << " previously defined here." << endl;
- err = 1;
+ if (m->HasId()) {
+ cerr << filename << ":" << m->GetLine()
+ << " redefining method " << m->GetName() << endl;
+ m->SetDeduplicate(true);
+ method_names[m->GetName()] = m.get();
+ } else {
+ cerr << filename << ":" << m->GetLine()
+ << " attempt to redefine method " << m->GetName() << "," << endl
+ << filename << ":" << it->second->GetLine()
+ << " previously defined here." << endl;
+ err = 1;
+ }
}
}
return err;
@@ -603,10 +610,6 @@ AidlError load_and_validate_aidl(
}
}
- // check the referenced types in parsed_doc to make sure we've imported them
- if (check_types(input_file_name, interface.get(), types) != 0) {
- err = AidlError::BAD_TYPE;
- }
if (err != AidlError::OK) {
return err;
}
@@ -618,6 +621,11 @@ AidlError load_and_validate_aidl(
return AidlError::BAD_METHOD_ID;
}
+ // check the referenced types in parsed_doc to make sure we've imported them
+ if (check_types(input_file_name, interface.get(), types) != 0) {
+ return AidlError::BAD_TYPE;
+ }
+
if (returned_interface)
*returned_interface = std::move(interface);
diff --git a/aidl_language.h b/aidl_language.h
index a23f4dc..bf4c70f 100644
--- a/aidl_language.h
+++ b/aidl_language.h
@@ -178,6 +178,8 @@ class AidlMethod : public AidlMember {
bool HasId() const { return has_id_; }
int GetId() { return id_; }
void SetId(unsigned id) { id_ = id; }
+ bool IsDeduplicate() const { return deduplicate_; }
+ void SetDeduplicate(bool deduplicate) { deduplicate_ = deduplicate; }
const std::vector<std::unique_ptr<AidlArgument>>& GetArguments() const {
return arguments_;
@@ -203,6 +205,7 @@ class AidlMethod : public AidlMember {
std::vector<const AidlArgument*> out_arguments_;
bool has_id_;
int id_;
+ bool deduplicate_;
DISALLOW_COPY_AND_ASSIGN(AidlMethod);
};
diff --git a/generate_java_binder.cpp b/generate_java_binder.cpp
index b692637..87d8d0c 100644
--- a/generate_java_binder.cpp
+++ b/generate_java_binder.cpp
@@ -271,6 +271,12 @@ static void generate_method(const AidlMethod& method, Class* interface,
string transactCodeName = "TRANSACTION_";
transactCodeName += method.GetName();
+ if (method.IsDeduplicate()) {
+ char tmp[16];
+ sprintf(tmp, "_%d", index);
+ transactCodeName += tmp;
+ }
+
char transactCodeValue[60];
sprintf(transactCodeValue, "(android.os.IBinder.FIRST_CALL_TRANSACTION + %d)",
index);