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

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

Sensor direct report with HardwareBuffer channel

Implement creation of sensor direct channel in sensor
service for sensor direct report feature.

Bug: 30985702
Test: cts-tradefed run cts --module CtsSensorTestCases
      --test android.hardware.cts.SensorDirectReportTest
Test: cts-tradefed run cts --module CtsSensorTestCases
      --test android.hardware.cts.SensorNativeTest

Change-Id: I52350811df538986cea7f5e1fb336fad53234c86
parent da8385cb
Loading
Loading
Loading
Loading
+17 −20
Original line number Diff line number Diff line
@@ -247,8 +247,12 @@ int SensorManager::createDirectChannel(
        return NO_INIT;
    }

    switch (channelType) {
        case SENSOR_DIRECT_MEM_TYPE_ASHMEM: {
    if (channelType != SENSOR_DIRECT_MEM_TYPE_ASHMEM
            && channelType != SENSOR_DIRECT_MEM_TYPE_GRALLOC) {
        ALOGE("Bad channel shared memory type %d", channelType);
        return BAD_VALUE;
    }

    sp<ISensorEventConnection> conn =
              mSensorServer->createSensorDirectConnection(mOpPackageName,
                  static_cast<uint32_t>(size),
@@ -257,18 +261,11 @@ int SensorManager::createDirectChannel(
    if (conn == nullptr) {
        return NO_MEMORY;
    }

    int nativeHandle = mDirectConnectionHandle++;
    mDirectConnection.emplace(nativeHandle, conn);
    return nativeHandle;
}
        case SENSOR_DIRECT_MEM_TYPE_GRALLOC:
            LOG_FATAL("%s: Finish implementation of ION and GRALLOC or remove", __FUNCTION__);
            return BAD_VALUE;
        default:
            ALOGE("Bad channel shared memory type %d", channelType);
            return BAD_VALUE;
    }
}

void SensorManager::destroyDirectChannel(int channelNativeHandle) {
    Mutex::Autolock _l(mLock);
+1 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ std::string SensorList::dump() const {
                if (s.isDirectChannelTypeSupported(SENSOR_DIRECT_MEM_TYPE_GRALLOC)) {
                    result.append("gralloc, ");
                }
                result.appendFormat("flag =0x%08x", static_cast<int>(s.getFlags()));
                result.append("\n");
            }
            return true;