summaryrefslogtreecommitdiffstats
path: root/services/sensorservice
diff options
context:
space:
mode:
Diffstat (limited to 'services/sensorservice')
-rw-r--r--services/sensorservice/BatteryService.cpp32
-rw-r--r--services/sensorservice/BatteryService.h8
-rw-r--r--services/sensorservice/SensorService.cpp5
3 files changed, 9 insertions, 36 deletions
diff --git a/services/sensorservice/BatteryService.cpp b/services/sensorservice/BatteryService.cpp
index 38dc749..cb962a6 100644
--- a/services/sensorservice/BatteryService.cpp
+++ b/services/sensorservice/BatteryService.cpp
@@ -34,32 +34,10 @@ BatteryService::BatteryService() {
const sp<IServiceManager> sm(defaultServiceManager());
if (sm != NULL) {
const String16 name("batterystats");
- mBatteryStatService = sm->getService(name);
+ mBatteryStatService = interface_cast<IBatteryStats>(sm->getService(name));
}
}
-status_t BatteryService::noteStartSensor(int uid, int handle) {
- Parcel data, reply;
- data.writeInterfaceToken(DESCRIPTOR);
- data.writeInt32(uid);
- data.writeInt32(handle);
- status_t err = mBatteryStatService->transact(
- TRANSACTION_noteStartSensor, data, &reply, 0);
- err = reply.readExceptionCode();
- return err;
-}
-
-status_t BatteryService::noteStopSensor(int uid, int handle) {
- Parcel data, reply;
- data.writeInterfaceToken(DESCRIPTOR);
- data.writeInt32(uid);
- data.writeInt32(handle);
- status_t err = mBatteryStatService->transact(
- TRANSACTION_noteStopSensor, data, &reply, 0);
- err = reply.readExceptionCode();
- return err;
-}
-
bool BatteryService::addSensor(uid_t uid, int handle) {
Mutex::Autolock _l(mActivationsLock);
Info key(uid, handle);
@@ -86,7 +64,7 @@ void BatteryService::enableSensorImpl(uid_t uid, int handle) {
if (mBatteryStatService != 0) {
if (addSensor(uid, handle)) {
int64_t identity = IPCThreadState::self()->clearCallingIdentity();
- noteStartSensor(uid, handle);
+ mBatteryStatService->noteStartSensor(uid, handle);
IPCThreadState::self()->restoreCallingIdentity(identity);
}
}
@@ -95,7 +73,7 @@ void BatteryService::disableSensorImpl(uid_t uid, int handle) {
if (mBatteryStatService != 0) {
if (removeSensor(uid, handle)) {
int64_t identity = IPCThreadState::self()->clearCallingIdentity();
- noteStopSensor(uid, handle);
+ mBatteryStatService->noteStopSensor(uid, handle);
IPCThreadState::self()->restoreCallingIdentity(identity);
}
}
@@ -108,7 +86,7 @@ void BatteryService::cleanupImpl(uid_t uid) {
for (ssize_t i=0 ; i<mActivations.size() ; i++) {
const Info& info(mActivations[i]);
if (info.uid == uid) {
- noteStopSensor(info.uid, info.handle);
+ mBatteryStatService->noteStopSensor(info.uid, info.handle);
mActivations.removeAt(i);
i--;
}
@@ -117,8 +95,6 @@ void BatteryService::cleanupImpl(uid_t uid) {
}
}
-const String16 BatteryService::DESCRIPTOR("com.android.internal.app.IBatteryStats");
-
ANDROID_SINGLETON_STATIC_INSTANCE(BatteryService)
// ---------------------------------------------------------------------------
diff --git a/services/sensorservice/BatteryService.h b/services/sensorservice/BatteryService.h
index 86cc884..08ba857 100644
--- a/services/sensorservice/BatteryService.h
+++ b/services/sensorservice/BatteryService.h
@@ -17,22 +17,18 @@
#include <stdint.h>
#include <sys/types.h>
+#include <binder/IBatteryStats.h>
#include <utils/Singleton.h>
namespace android {
// ---------------------------------------------------------------------------
class BatteryService : public Singleton<BatteryService> {
- static const int TRANSACTION_noteStartSensor = IBinder::FIRST_CALL_TRANSACTION + 3;
- static const int TRANSACTION_noteStopSensor = IBinder::FIRST_CALL_TRANSACTION + 4;
- static const String16 DESCRIPTOR;
friend class Singleton<BatteryService>;
- sp<IBinder> mBatteryStatService;
+ sp<IBatteryStats> mBatteryStatService;
BatteryService();
- status_t noteStartSensor(int uid, int handle);
- status_t noteStopSensor(int uid, int handle);
void enableSensorImpl(uid_t uid, int handle);
void disableSensorImpl(uid_t uid, int handle);
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 148f404..8837a4d 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -808,11 +808,12 @@ void SensorService::SensorEventConnection::dump(String8& result) {
Mutex::Autolock _l(mConnectionLock);
for (size_t i = 0; i < mSensorInfo.size(); ++i) {
const FlushInfo& flushInfo = mSensorInfo.valueAt(i);
- result.appendFormat("\t %s | status: %s | pending flush events %d\n",
+ result.appendFormat("\t %s | status: %s | pending flush events %d | uid %d\n",
mService->getSensorName(mSensorInfo.keyAt(i)).string(),
flushInfo.mFirstFlushPending ? "First flush pending" :
"active",
- flushInfo.mPendingFlushEventsToSend);
+ flushInfo.mPendingFlushEventsToSend,
+ mUid);
}
}