Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e42ae2d4 authored by Steve Kondik's avatar Steve Kondik
Browse files

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
parent dd69c3cb
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -567,6 +567,12 @@ check_types(const char* filename, document_item_type* items)
                    // prevent duplicate methods
                    if (methodNames.find(m->name.data) == methodNames.end()) {
                        methodNames[m->name.data] = m;
                    } else {
                        if (m->hasId) {
                            fprintf(stderr, "%s:%d redefining method %s\n",
                                filename, m->name.lineno, m->name.data);
                            m->deduplicate = true;
                            methodNames[m->name.data] = m;
                        } else {
                            fprintf(stderr,"%s:%d attempt to redefine method %s,\n",
                                    filename, m->name.lineno, m->name.data);
@@ -576,6 +582,7 @@ check_types(const char* filename, document_item_type* items)
                            err = 1;
                        }
                    }
                }
                member = member->next;
            }
        }
@@ -1013,9 +1020,6 @@ compile_aidl(Options& options)
    NAMES.Dump();
#endif

    // check the referenced types in mainDoc to make sure we've imported them
    err |= check_types(options.inputFileName.c_str(), mainDoc);

    // finally, there really only needs to be one thing in mainDoc, and it
    // needs to be an interface.
    bool onlyParcelable = false;
@@ -1027,6 +1031,9 @@ compile_aidl(Options& options)
                ((interface_type*)mainDoc)->interface_items);
    }

    // check the referenced types in mainDoc to make sure we've imported them
    err |= check_types(options.inputFileName.c_str(), mainDoc);

    // after this, there shouldn't be any more errors because of the
    // input.
    if (err != 0 || mainDoc == NULL) {
+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ typedef struct method_type {
    buffer_type semicolon_token;
    buffer_type* comments_token; // points into this structure, DO NOT DELETE
    int assigned_id;
    bool deduplicate;
} method_type;

enum {
+6 −0
Original line number Diff line number Diff line
@@ -260,6 +260,12 @@ generate_method(const method_type* method, Class* interface,
    string transactCodeName = "TRANSACTION_";
    transactCodeName += method->name.data;

    if (method->deduplicate) {
        char tmp[16];
        sprintf(tmp, "_%d", index);
        transactCodeName += tmp;
    }

    char transactCodeValue[60];
    sprintf(transactCodeValue, "(android.os.IBinder.FIRST_CALL_TRANSACTION + %d)", index);