summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Peng Xu <pengxu@google.com> 2017-04-14 20:29:47 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-04-14 20:29:47 +0000
commit1742ede041fa9f72f4b2072f1000c72c5d65e81b (patch)
tree69366ef4cddcc5ba493f887e8466159b91143113
parent5d6d98a1dff7a6de2ea89f5098af0b77e1d5c36a (diff)
parentf88e2b95b2cd6238f6758ef6a180fbd277f06ff2 (diff)
Merge "Fix gralloc direct channel bug and polish log messages" into oc-dev
-rw-r--r--services/sensorservice/SensorDirectConnection.cpp7
-rw-r--r--services/sensorservice/SensorService.cpp8
2 files changed, 9 insertions, 6 deletions
diff --git a/services/sensorservice/SensorDirectConnection.cpp b/services/sensorservice/SensorDirectConnection.cpp
index b096e1cf98..91923b36a0 100644
--- a/services/sensorservice/SensorDirectConnection.cpp
+++ b/services/sensorservice/SensorDirectConnection.cpp
@@ -185,17 +185,18 @@ bool SensorService::SensorDirectConnection::isEquivalent(const sensors_direct_me
struct stat s1, s2;
int fd1, fd2;
fd1 = mMem.handle->data[0];
- fd2 = mem->handle->data[1];
+ fd2 = mem->handle->data[0];
if (fstat(fd1, &s1) < 0 || fstat(fd2, &s2) < 0 || s1.st_ino == s2.st_ino) {
ret = true;
}
break;
}
case SENSOR_DIRECT_MEM_TYPE_GRALLOC:
- LOG_FATAL("%s: Implement GRALLOC or remove", __FUNCTION__);
- ret = true;
+ // there is no known method to test if two gralloc handle are equivalent
+ ret = false;
break;
default:
+ // should never happen
ALOGE("Unexpected mem type %d", mMem.type);
ret = true;
break;
diff --git a/services/sensorservice/SensorService.cpp b/services/sensorservice/SensorService.cpp
index 4d76272146..26f9143530 100644
--- a/services/sensorservice/SensorService.cpp
+++ b/services/sensorservice/SensorService.cpp
@@ -978,6 +978,7 @@ sp<ISensorEventConnection> SensorService::createSensorDirectConnection(
for (auto &i : mDirectConnections) {
sp<SensorDirectConnection> connection(i.promote());
if (connection != nullptr && connection->isEquivalent(&mem)) {
+ ALOGE("Duplicate create channel request for the same share memory");
return nullptr;
}
}
@@ -988,14 +989,15 @@ sp<ISensorEventConnection> SensorService::createSensorDirectConnection(
int fd = resource->data[0];
int size2 = ashmem_get_size_region(fd);
// check size consistency
- if (size2 != static_cast<int>(size)) {
- ALOGE("Ashmem direct channel size mismatch, %" PRIu32 " vs %d", size, size2);
+ if (size2 < static_cast<int>(size)) {
+ ALOGE("Ashmem direct channel size %" PRIu32 " greater than shared memory size %d",
+ size, size2);
return nullptr;
}
break;
}
case SENSOR_DIRECT_MEM_TYPE_GRALLOC:
- LOG_FATAL("%s: Finish implementation of ION and GRALLOC or remove", __FUNCTION__);
+ // no specific checks for gralloc
break;
default:
ALOGE("Unknown direct connection memory type %d", type);