summaryrefslogtreecommitdiffstats
path: root/healthd/BatteryPropertiesRegistrar.cpp
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2013-09-18 20:09:33 -0700
committerTodd Poynor <toddpoynor@google.com>2013-10-22 16:32:54 -0700
commit020369d8724eff2b87350e54e157a609846166e4 (patch)
tree57eed3999a23125cfc1666b4c1c6305b36f10bb3 /healthd/BatteryPropertiesRegistrar.cpp
parent6dcc45ed6dd455d82ecfb3addf247125846f3019 (diff)
downloadcore-020369d8724eff2b87350e54e157a609846166e4.tar.gz
core-020369d8724eff2b87350e54e157a609846166e4.tar.bz2
core-020369d8724eff2b87350e54e157a609846166e4.zip
healthd: BatteryService dumpstate support
Change-Id: Ia6938b7126751801310632c995af0f96e41f5f64
Diffstat (limited to 'healthd/BatteryPropertiesRegistrar.cpp')
-rw-r--r--healthd/BatteryPropertiesRegistrar.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/healthd/BatteryPropertiesRegistrar.cpp b/healthd/BatteryPropertiesRegistrar.cpp
index f2edee434..7add9bc17 100644
--- a/healthd/BatteryPropertiesRegistrar.cpp
+++ b/healthd/BatteryPropertiesRegistrar.cpp
@@ -18,7 +18,10 @@
#include <batteryservice/BatteryService.h>
#include <batteryservice/IBatteryPropertiesListener.h>
#include <batteryservice/IBatteryPropertiesRegistrar.h>
+#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
+#include <binder/PermissionCache.h>
+#include <private/android_filesystem_config.h>
#include <utils/Errors.h>
#include <utils/Mutex.h>
#include <utils/String16.h>
@@ -69,6 +72,19 @@ status_t BatteryPropertiesRegistrar::getProperty(int id, struct BatteryProperty
return healthd_get_property(id, val);
}
+status_t BatteryPropertiesRegistrar::dump(int fd, const Vector<String16>& args) {
+ IPCThreadState* self = IPCThreadState::self();
+ const int pid = self->getCallingPid();
+ const int uid = self->getCallingUid();
+ if ((uid != AID_SHELL) &&
+ !PermissionCache::checkPermission(
+ String16("android.permission.DUMP"), pid, uid))
+ return PERMISSION_DENIED;
+
+ healthd_dump_battery_state(fd);
+ return OK;
+}
+
void BatteryPropertiesRegistrar::binderDied(const wp<IBinder>& who) {
Mutex::Autolock _l(mRegistrationLock);