summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorAravind Akella <aakella@google.com>2015-07-01 17:40:07 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-01 17:40:08 +0000
commit8719e3b6310f97a736620395024c858ca8ec7e0c (patch)
treee67388ced8b26443ce4b3456dc3c2c364a79b886 /libs
parente59cb43edad0eff28a81b18c3c4484442ff680dd (diff)
parent841a5926fc9b3f9f0e654ba3aab8e43bea7de7f1 (diff)
downloadframeworks_native-8719e3b6310f97a736620395024c858ca8ec7e0c.zip
frameworks_native-8719e3b6310f97a736620395024c858ca8ec7e0c.tar.gz
frameworks_native-8719e3b6310f97a736620395024c858ca8ec7e0c.tar.bz2
Merge "Enable sensor data injection mode through adb." into mnc-dev
Diffstat (limited to 'libs')
-rw-r--r--libs/gui/ISensorServer.cpp6
-rw-r--r--libs/gui/SensorEventQueue.cpp22
-rw-r--r--libs/gui/SensorManager.cpp6
3 files changed, 20 insertions, 14 deletions
diff --git a/libs/gui/ISensorServer.cpp b/libs/gui/ISensorServer.cpp
index 5dde9f9..f581b5c 100644
--- a/libs/gui/ISensorServer.cpp
+++ b/libs/gui/ISensorServer.cpp
@@ -77,10 +77,9 @@ public:
return interface_cast<ISensorEventConnection>(reply.readStrongBinder());
}
- virtual status_t enableDataInjection(int enable) {
+ virtual int isDataInjectionEnabled() {
Parcel data, reply;
data.writeInterfaceToken(ISensorServer::getInterfaceDescriptor());
- data.writeInt32(enable);
remote()->transact(ENABLE_DATA_INJECTION, data, &reply);
return reply.readInt32();
}
@@ -121,8 +120,7 @@ status_t BnSensorServer::onTransact(
}
case ENABLE_DATA_INJECTION: {
CHECK_INTERFACE(ISensorServer, data, reply);
- int32_t enable = data.readInt32();
- status_t ret = enableDataInjection(enable);
+ int32_t ret = isDataInjectionEnabled();
reply->writeInt32(static_cast<int32_t>(ret));
return NO_ERROR;
}
diff --git a/libs/gui/SensorEventQueue.cpp b/libs/gui/SensorEventQueue.cpp
index 8b2018f..4b7986e 100644
--- a/libs/gui/SensorEventQueue.cpp
+++ b/libs/gui/SensorEventQueue.cpp
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <linux/errno.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
@@ -150,13 +151,20 @@ status_t SensorEventQueue::setEventRate(Sensor const* sensor, nsecs_t ns) const
}
status_t SensorEventQueue::injectSensorEvent(const ASensorEvent& event) {
- // Blocking call.
- ssize_t size = ::send(mSensorChannel->getFd(), &event, sizeof(event), MSG_NOSIGNAL);
- if (size < 0) {
- ALOGE("injectSensorEvent failure %zd %d", size, mSensorChannel->getFd());
- return INVALID_OPERATION;
- }
- return NO_ERROR;
+ do {
+ // Blocking call.
+ ssize_t size = ::send(mSensorChannel->getFd(), &event, sizeof(event), MSG_NOSIGNAL);
+ if (size >= 0) {
+ return NO_ERROR;
+ } else if (size < 0 && errno == EAGAIN) {
+ // If send is returning a "Try again" error, sleep for 100ms and try again. In all
+ // other cases log a failure and exit.
+ usleep(100000);
+ } else {
+ ALOGE("injectSensorEvent failure %s %zd", strerror(errno), size);
+ return INVALID_OPERATION;
+ }
+ } while (true);
}
void SensorEventQueue::sendAck(const ASensorEvent* events, int count) {
diff --git a/libs/gui/SensorManager.cpp b/libs/gui/SensorManager.cpp
index 8c9f95b..dd37781 100644
--- a/libs/gui/SensorManager.cpp
+++ b/libs/gui/SensorManager.cpp
@@ -153,12 +153,12 @@ sp<SensorEventQueue> SensorManager::createEventQueue(String8 packageName, int mo
return queue;
}
-status_t SensorManager::enableDataInjection(bool enable) {
+bool SensorManager::isDataInjectionEnabled() {
Mutex::Autolock _l(mLock);
if (assertStateLocked() == NO_ERROR) {
- return mSensorServer->enableDataInjection(enable);
+ return mSensorServer->isDataInjectionEnabled();
}
- return INVALID_OPERATION;
+ return false;
}
// ----------------------------------------------------------------------------