summaryrefslogtreecommitdiffstats
path: root/libbinderwrapper
diff options
context:
space:
mode:
authorDaniel Erat <derat@google.com>2015-10-16 09:04:33 -0600
committerDaniel Erat <derat@google.com>2015-10-16 09:04:33 -0600
commit7cba9db9cdcdafe221d0481c52316a8653f577a1 (patch)
treeeb2764ba9c209794b2a3a5876af0b889205744cc /libbinderwrapper
parentb8cc70a94bcbf7b920465d92da6889f0db6d6fa5 (diff)
downloadsystem_core-7cba9db9cdcdafe221d0481c52316a8653f577a1.tar.gz
system_core-7cba9db9cdcdafe221d0481c52316a8653f577a1.tar.bz2
system_core-7cba9db9cdcdafe221d0481c52316a8653f577a1.zip
libbinderwrapper: Add GetCallingUid() and GetCallingPid().
Add methods to BinderWrapper for getting the caller's UID and PID while in a transaction. Bug: 24988639 Change-Id: Ibd711fc6b3d83623d4bb1060838c65aaef30d76e
Diffstat (limited to 'libbinderwrapper')
-rw-r--r--libbinderwrapper/real_binder_wrapper.cc9
-rw-r--r--libbinderwrapper/real_binder_wrapper.h2
-rw-r--r--libbinderwrapper/stub_binder_wrapper.cc12
3 files changed, 22 insertions, 1 deletions
diff --git a/libbinderwrapper/real_binder_wrapper.cc b/libbinderwrapper/real_binder_wrapper.cc
index adff19bed..1c518226d 100644
--- a/libbinderwrapper/real_binder_wrapper.cc
+++ b/libbinderwrapper/real_binder_wrapper.cc
@@ -19,6 +19,7 @@
#include <base/logging.h>
#include <binder/Binder.h>
#include <binder/IBinder.h>
+#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
namespace android {
@@ -111,4 +112,12 @@ bool RealBinderWrapper::UnregisterForDeathNotifications(
return true;
}
+uid_t RealBinderWrapper::GetCallingUid() {
+ return IPCThreadState::self()->getCallingUid();
+}
+
+pid_t RealBinderWrapper::GetCallingPid() {
+ return IPCThreadState::self()->getCallingPid();
+}
+
} // namespace android
diff --git a/libbinderwrapper/real_binder_wrapper.h b/libbinderwrapper/real_binder_wrapper.h
index 8e281f2f8..ea0837171 100644
--- a/libbinderwrapper/real_binder_wrapper.h
+++ b/libbinderwrapper/real_binder_wrapper.h
@@ -38,6 +38,8 @@ class RealBinderWrapper : public BinderWrapper {
bool RegisterForDeathNotifications(const sp<IBinder>& binder,
const base::Closure& callback) override;
bool UnregisterForDeathNotifications(const sp<IBinder>& binder) override;
+ uid_t GetCallingUid() override;
+ pid_t GetCallingPid() override;
private:
class DeathRecipient;
diff --git a/libbinderwrapper/stub_binder_wrapper.cc b/libbinderwrapper/stub_binder_wrapper.cc
index 1d2468101..87c6ab793 100644
--- a/libbinderwrapper/stub_binder_wrapper.cc
+++ b/libbinderwrapper/stub_binder_wrapper.cc
@@ -22,7 +22,9 @@
namespace android {
-StubBinderWrapper::StubBinderWrapper() = default;
+StubBinderWrapper::StubBinderWrapper()
+ : calling_uid_(-1),
+ calling_pid_(-1) {}
StubBinderWrapper::~StubBinderWrapper() = default;
@@ -73,4 +75,12 @@ bool StubBinderWrapper::UnregisterForDeathNotifications(
return true;
}
+uid_t StubBinderWrapper::GetCallingUid() {
+ return calling_uid_;
+}
+
+pid_t StubBinderWrapper::GetCallingPid() {
+ return calling_pid_;
+}
+
} // namespace android