summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/binder/Parcel.cpp25
-rw-r--r--libs/gui/SensorEventQueue.cpp22
2 files changed, 38 insertions, 9 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index ba5688c..f61eaca 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -26,6 +26,7 @@
#include <binder/TextOutput.h>
#include <errno.h>
+#include <utils/CallStack.h>
#include <utils/Debug.h>
#include <utils/Log.h>
#include <utils/String8.h>
@@ -767,6 +768,29 @@ status_t Parcel::writeFileDescriptor(int fd, bool takeOwnership)
status_t Parcel::writeDupFileDescriptor(int fd)
{
int dupFd = dup(fd);
+
+ { // Temporary extra debug validation for b/17477219: a Parcel recipient is
+ // getting a positive but invalid fd unexpectedly. Trying to track down
+ // where it's coming from.
+ int dupErrno = dupFd < 0 ? errno : 0;
+ int fdFlags = fcntl(fd, F_GETFD);
+ int fdFlagsErrno = fdFlags == -1 ? errno : 0;
+ int dupFlags = fcntl(dupFd, F_GETFD);
+ int dupFlagsErrno = dupFlags == -1 ? errno : 0;
+ if (dupFd < 0 || fdFlags == -1 || dupFlags == -1) {
+ ALOGE("Parcel::writeDupFileDescriptor failed:\n"
+ " fd=%d flags=%d err=%d(%s)\n"
+ " dupFd=%d dupErr=%d(%s) flags=%d err=%d(%s)",
+ fd, fdFlags, fdFlagsErrno, strerror(fdFlagsErrno),
+ dupFd, dupErrno, strerror(dupErrno),
+ dupFlags, dupFlagsErrno, strerror(dupFlagsErrno));
+ if (fd < 0 || fdFlags == -1) {
+ CallStack(LOG_TAG);
+ }
+ return -errno;
+ }
+ }
+
if (dupFd < 0) {
return -errno;
}
@@ -1297,6 +1321,7 @@ status_t Parcel::read(FlattenableHelperInterface& val) const
oldfd, fds[i], dupErrno, strerror(dupErrno),
oldfd, flags, fcntlErrno, strerror(fcntlErrno),
flat, flat ? flat->type : 0);
+ CallStack(LOG_TAG);
}
}
diff --git a/libs/gui/SensorEventQueue.cpp b/libs/gui/SensorEventQueue.cpp
index 842502d..1305e9f 100644
--- a/libs/gui/SensorEventQueue.cpp
+++ b/libs/gui/SensorEventQueue.cpp
@@ -36,7 +36,8 @@ namespace android {
// ----------------------------------------------------------------------------
SensorEventQueue::SensorEventQueue(const sp<ISensorEventConnection>& connection)
- : mSensorEventConnection(connection), mRecBuffer(NULL), mAvailable(0), mConsumed(0) {
+ : mSensorEventConnection(connection), mRecBuffer(NULL), mAvailable(0), mConsumed(0),
+ mNumAcksToSend(0) {
mRecBuffer = new ASensorEvent[MAX_RECEIVE_BUFFER_EVENT_COUNT];
}
@@ -148,14 +149,17 @@ status_t SensorEventQueue::setEventRate(Sensor const* sensor, nsecs_t ns) const
void SensorEventQueue::sendAck(const ASensorEvent* events, int count) {
for (int i = 0; i < count; ++i) {
if (events[i].flags & WAKE_UP_SENSOR_EVENT_NEEDS_ACK) {
- // Send just a byte of data to acknowledge for the wake up sensor events
- // received
- char buf = '1';
- ssize_t size = ::send(mSensorChannel->getFd(), &buf, sizeof(buf),
- MSG_DONTWAIT | MSG_NOSIGNAL);
- if (size < 0) {
- ALOGE("sendAck failure %d", size);
- }
+ ++mNumAcksToSend;
+ }
+ }
+ // Send mNumAcksToSend to acknowledge for the wake up sensor events received.
+ if (mNumAcksToSend > 0) {
+ ssize_t size = ::send(mSensorChannel->getFd(), &mNumAcksToSend, sizeof(mNumAcksToSend),
+ MSG_DONTWAIT | MSG_NOSIGNAL);
+ if (size < 0) {
+ ALOGE("sendAck failure %d %d", size, mNumAcksToSend);
+ } else {
+ mNumAcksToSend = 0;
}
}
return;