summaryrefslogtreecommitdiffstats
path: root/tools/aidl
diff options
context:
space:
mode:
authorManuel Roman <manuelroman@google.com>2011-10-06 10:28:35 -0700
committerMike Lockwood <lockwood@android.com>2011-10-28 10:14:51 -0400
commit9e2df9748834aa40bf3e3ba813fe7f433bd2e7d2 (patch)
tree151a5cf1bee35c2e2dc1577f454b385b8049d37b /tools/aidl
parent8f1667ac786538d34bfe94209d0e5942b141d29d (diff)
downloadframeworks_base-9e2df9748834aa40bf3e3ba813fe7f433bd2e7d2.zip
frameworks_base-9e2df9748834aa40bf3e3ba813fe7f433bd2e7d2.tar.gz
frameworks_base-9e2df9748834aa40bf3e3ba813fe7f433bd2e7d2.tar.bz2
Modified AIDL to support authentication
We need to pass an RpcContext with information such as the caller's certificate. I also modified the compiler so it does not use Container anymore and uses Context Change-Id: Ib54b774f9c7b5cb3e0a014ce91548b817efcb72b
Diffstat (limited to 'tools/aidl')
-rwxr-xr-xtools/aidl/Type.h1
-rw-r--r--tools/aidl/generate_java_rpc.cpp35
2 files changed, 28 insertions, 8 deletions
diff --git a/tools/aidl/Type.h b/tools/aidl/Type.h
index c7b2e5d..536dc17 100755
--- a/tools/aidl/Type.h
+++ b/tools/aidl/Type.h
@@ -537,6 +537,7 @@ extern Type* CONTEXT_TYPE;
extern Type* RPC_DATA_TYPE;
extern Type* RPC_ERROR_TYPE;
+extern Type* RPC_CONTEXT_TYPE;
extern Type* EVENT_FAKE_TYPE;
extern Expression* NULL_VALUE;
diff --git a/tools/aidl/generate_java_rpc.cpp b/tools/aidl/generate_java_rpc.cpp
index bcd4b76..8353c45 100644
--- a/tools/aidl/generate_java_rpc.cpp
+++ b/tools/aidl/generate_java_rpc.cpp
@@ -5,8 +5,8 @@
#include <stdlib.h>
#include <string.h>
-Type* SERVICE_CONTAINER_TYPE = new Type("com.android.athome.service",
- "AndroidAtHomeServiceContainer", Type::BUILT_IN, false, false, false);
+Type* SERVICE_CONTEXT_TYPE = new Type("android.content",
+ "Context", Type::BUILT_IN, false, false, false);
Type* PRESENTER_BASE_TYPE = new Type("com.android.athome.service",
"AndroidAtHomePresenter", Type::BUILT_IN, false, false, false);
Type* PRESENTER_LISTENER_BASE_TYPE = new Type("com.android.athome.service",
@@ -21,6 +21,8 @@ Type* RPC_RESULT_HANDLER_TYPE = new ParcelableType("com.android.athome.rpc", "Rp
true, __FILE__, __LINE__);
Type* RPC_ERROR_LISTENER_TYPE = new Type("com.android.athome.rpc", "RpcErrorHandler",
Type::BUILT_IN, false, false, false);
+Type* RPC_CONTEXT_TYPE = new ParcelableType("com.android.athome.rpc", "RpcContext", true,
+ __FILE__, __LINE__);
static void generate_create_from_data(Type* t, StatementBlock* addTo, const string& key,
Variable* v, Variable* data, Variable** cl);
@@ -87,6 +89,7 @@ public:
Method* processMethod;
Variable* actionParam;
Variable* requestParam;
+ Variable* rpcContextParam;
Variable* errorParam;
Variable* requestData;
Variable* resultData;
@@ -112,7 +115,7 @@ DispatcherClass::~DispatcherClass()
void
DispatcherClass::generate_process()
{
- // byte[] process(String action, byte[] params, RpcError status)
+ // byte[] process(String action, byte[] params, RpcContext context, RpcError status)
this->processMethod = new Method;
this->processMethod->modifiers = PUBLIC;
this->processMethod->returnType = BYTE_TYPE;
@@ -126,6 +129,9 @@ DispatcherClass::generate_process()
this->requestParam = new Variable(BYTE_TYPE, "requestParam", 1);
this->processMethod->parameters.push_back(this->requestParam);
+ this->rpcContextParam = new Variable(RPC_CONTEXT_TYPE, "context", 0);
+ this->processMethod->parameters.push_back(this->rpcContextParam);
+
this->errorParam = new Variable(RPC_ERROR_TYPE, "errorParam", 0);
this->processMethod->parameters.push_back(this->errorParam);
@@ -192,6 +198,9 @@ DispatcherClass::AddMethod(const method_type* method)
arg = arg->next;
}
+ // Add a final parameter: RpcContext. Contains data about
+ // incoming request (e.g., certificate)
+ realCall->arguments.push_back(new Variable(RPC_CONTEXT_TYPE, "context", 0));
Type* returnType = NAMES.Search(method->type.type.data);
if (returnType == EVENT_FAKE_TYPE) {
@@ -254,8 +263,10 @@ DispatcherClass::DoneWithMethods()
IfStatement* fallthrough = new IfStatement();
fallthrough->statements = new StatementBlock;
fallthrough->statements->Add(new ReturnStatement(
- new MethodCall(SUPER_VALUE, "process", 3, this->actionParam, this->requestParam,
- this->errorParam)));
+ new MethodCall(SUPER_VALUE, "process", 4,
+ this->actionParam, this->requestParam,
+ this->rpcContextParam,
+ this->errorParam)));
this->dispatchIfStatement->elseif = fallthrough;
IfStatement* s = new IfStatement;
s->statements = new StatementBlock;
@@ -446,7 +457,7 @@ ServiceBaseClass::~ServiceBaseClass()
void
ServiceBaseClass::generate_ctor()
{
- Variable* container = new Variable(SERVICE_CONTAINER_TYPE, "container");
+ Variable* context = new Variable(SERVICE_CONTEXT_TYPE, "context");
Variable* name = new Variable(STRING_TYPE, "name");
Variable* type = new Variable(STRING_TYPE, "type");
Variable* version = new Variable(INT_TYPE, "version");
@@ -454,13 +465,13 @@ ServiceBaseClass::generate_ctor()
ctor->modifiers = PUBLIC;
ctor->name = class_name_leaf(this->type->Name());
ctor->statements = new StatementBlock;
- ctor->parameters.push_back(container);
+ ctor->parameters.push_back(context);
ctor->parameters.push_back(name);
ctor->parameters.push_back(type);
ctor->parameters.push_back(version);
this->elements.push_back(ctor);
- ctor->statements->Add(new MethodCall("super", 4, container, name, type, version));
+ ctor->statements->Add(new MethodCall("super", 4, context, name, type, version));
}
// =================================================
@@ -794,6 +805,10 @@ generate_regular_method(const method_type* method, RpcProxyClass* proxyClass,
arg->type.dimension));
arg = arg->next;
}
+
+ // Add the default RpcContext param to all methods
+ decl->parameters.push_back(new Variable(RPC_CONTEXT_TYPE, "context", 0));
+
serviceBaseClass->elements.push_back(decl);
@@ -858,6 +873,10 @@ generate_event_method(const method_type* method, RpcProxyClass* proxyClass,
arg->type.dimension));
arg = arg->next;
}
+
+ // Add a final parameter: RpcContext. Contains data about
+ // incoming request (e.g., certificate)
+ event->parameters.push_back(new Variable(RPC_CONTEXT_TYPE, "context", 0));
}
static void