diff options
author | Mathias Agopian <mathias@google.com> | 2010-07-21 16:07:15 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-07-21 16:07:15 -0700 |
commit | 865991b075de1df8144426b5c2b2f341e4e33d33 (patch) | |
tree | 8281e3fa3f81b4e6e4aa9596c1847b76467b4a22 /services | |
parent | e4764521353e898554931a557460fc49209fb0a9 (diff) | |
parent | 6f8b4d28d41508e3a563c12f5841918bb3869819 (diff) | |
download | frameworks_base-865991b075de1df8144426b5c2b2f341e4e33d33.zip frameworks_base-865991b075de1df8144426b5c2b2f341e4e33d33.tar.gz frameworks_base-865991b075de1df8144426b5c2b2f341e4e33d33.tar.bz2 |
Merge "Added partial support for repporting sensor activity to IBatteryStats" into gingerbread
Diffstat (limited to 'services')
-rw-r--r-- | services/sensorservice/SensorService.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp index 5410cbc..0ab4a20 100644 --- a/services/sensorservice/SensorService.cpp +++ b/services/sensorservice/SensorService.cpp @@ -23,8 +23,10 @@ #include <utils/Atomic.h> #include <utils/Errors.h> #include <utils/RefBase.h> +#include <utils/Singleton.h> #include <binder/BinderService.h> +#include <binder/IServiceManager.h> #include <gui/ISensorServer.h> #include <gui/ISensorEventConnection.h> @@ -44,8 +46,37 @@ namespace android { * send something to application when they enable a sensor that is already * active (the issue here is that it can take time before a value is * produced by the h/w if the rate is low or if it's a one-shot sensor). + * - send sensor info to battery service */ +// --------------------------------------------------------------------------- + +class BatteryService : public Singleton<BatteryService> { + friend class Singleton<BatteryService>; + sp<IBinder> mBatteryStatService; + BatteryService() { + const String16 name("batteryinfo"); + //getService(name, &mBatteryStatService); + } +public: + void enableSensor(int handle) { + if (mBatteryStatService != 0) { + int uid = IPCThreadState::self()->getCallingUid(); + //mBatteryStatService->noteStartSensor(uid, handle); + } + } + void disableSensor(int handle) { + if (mBatteryStatService != 0) { + int uid = IPCThreadState::self()->getCallingUid(); + //mBatteryStatService->noteStopSensor(uid, handle); + } + } +}; + +ANDROID_SINGLETON_STATIC_INSTANCE(BatteryService) + +// --------------------------------------------------------------------------- + SensorService::SensorService() : Thread(false), mDump("android.permission.DUMP") @@ -201,6 +232,9 @@ status_t SensorService::enable(const sp<SensorEventConnection>& connection, mActiveSensors.add(handle, rec); err = mSensorDevice->activate(mSensorDevice, handle, 1); LOGE_IF(err, "Error activating sensor %d (%s)", handle, strerror(-err)); + if (err == 0) { + BatteryService::getInstance().enableSensor(handle); + } } else { err = rec->addConnection(connection); } @@ -232,6 +266,9 @@ status_t SensorService::disable(const sp<SensorEventConnection>& connection, mActiveSensors.removeItem(handle); delete rec; err = mSensorDevice->activate(mSensorDevice, handle, 0); + if (err == 0) { + BatteryService::getInstance().disableSensor(handle); + } } } return err; |