Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f88e2b95 authored by Peng Xu's avatar Peng Xu
Browse files

Fix gralloc direct channel bug and polish log messages

1) Remove obsoleted stub code so that second gralloc direct channel
   can be successfully registered.

2) Remove obsoleted misleading log messages.
3) Add missing log messages at failure to help debugging.

Bug: 36900495
Test: SensorDirectReportTest
Change-Id: I1d6941c4179338f6db8f84079844dce515b80516
parent 99dfb8a6
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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;
+5 −3
Original line number Diff line number Diff line
@@ -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);