/**
 * \brief Convert `HGraphicBufferProducer::FrameEventHistoryDelta` to
 * `::android::FrameEventHistoryDelta`.
 *
 * \param[out] l The destination `::android::FrameEventHistoryDelta`.
 * \param[in] t The source `HGraphicBufferProducer::FrameEventHistoryDelta`.
 *
 * This function will duplicate all file descriptors contained in \p t.
 */
inline bool convertTo(
        ::android::FrameEventHistoryDelta* l,
        HGraphicBufferProducer::FrameEventHistoryDelta const& t) {

    size_t const baseSize = getFlattenedSize(t);
    std::unique_ptr<uint8_t[]> baseBuffer(
            new (std::nothrow) uint8_t[baseSize]);
    if (!baseBuffer) {
        return false;
    }

    size_t const baseNumFds = getFdCount(t);
    std::unique_ptr<int[]> baseFds(
            new (std::nothrow) int[baseNumFds]);
    if (!baseFds) {
        return false;
    }

    void* buffer = static_cast<void*>(baseBuffer.get());
    size_t size = baseSize;
    int* fds = static_cast<int*>(baseFds.get());
    size_t numFds = baseNumFds;
    std::vector<std::vector<native_handle_t*> > nhAA;
    if (flatten(t, &nhAA, buffer, size, fds, numFds) != NO_ERROR) {
        return false;
    }

    void const* constBuffer = static_cast<void const*>(baseBuffer.get());
    size = baseSize;
    int const* constFds = static_cast<int const*>(baseFds.get());
    numFds = baseNumFds;
    if (l->unflatten(constBuffer, size, constFds, numFds) != NO_ERROR) {
        for (auto nhA : nhAA) {
            for (auto nh : nhA) {
                if (nh != nullptr) {
                    native_handle_close(nh);
                    native_handle_delete(nh);
                }
            }
        }
        return false;
    }

    for (auto nhA : nhAA) {
        for (auto nh : nhA) {
            if (nh != nullptr) {
                native_handle_delete(nh);
            }
        }
    }
    return true;
}
Пример #2
0
OverlayRef::~OverlayRef()
{
    if (mOwnHandle) {
        native_handle_close(mOverlayHandle);
        native_handle_delete(const_cast<native_handle*>(mOverlayHandle));
    }
}
static int
data__data_open(struct sensors_data_device_t *dev, native_handle_t* handle)
{
	SensorData*  data = (void*)dev;
	int i;
	D("%s: dev=%p", __FUNCTION__, dev);
	memset(&data->sensors, 0, sizeof(data->sensors));

	for (i=0 ; i<MAX_NUM_SENSORS ; i++) {
		data->sensors[i].vector.status = SENSOR_STATUS_ACCURACY_HIGH;
	}

  
	if (acc_event_fd < 0 || mag_event_fd < 0) {
		acc_event_fd = dup(handle->data[0]);
		mag_event_fd = dup(handle->data[1]);;
		if ((acc_event_fd < 0) || (mag_event_fd < 0)) {
			LOGE("%s fail to open input devices",__FUNCTION__);
			return -1;
		} else {
			int mx, my, mz;
			MEMSAlgLib_eCompass_Init(1000,1000); 

			//if find the last record of calibration data
			if(!read_sensor_calibration_data(&mx, &my, &mz)) //platform related API
				MEMSAlgLib_eCompass_SetCalibration(mx, my, mz);

		}
	}

	data->pendingSensors = 0;
	native_handle_close(handle);
	native_handle_delete(handle);
	return 0;
}
    void recordingFrameHandleCallbackTimestampBatch(
            const std::vector<nsecs_t>& timestamps,
            const std::vector<native_handle_t*>& handles) {
        ALOGV("recordingFrameHandleCallbackTimestampBatch");
        Parcel data, reply;
        data.writeInterfaceToken(ICameraRecordingProxyListener::getInterfaceDescriptor());

        uint32_t n = timestamps.size();
        if (n != handles.size()) {
            ALOGE("%s: size of timestamps(%zu) and handles(%zu) mismatch!",
                    __FUNCTION__, timestamps.size(), handles.size());
            return;
        }
        data.writeUint32(n);
        for (auto ts : timestamps) {
            data.writeInt64(ts);
        }
        for (auto& handle : handles) {
            data.writeNativeHandle(handle);
        }
        remote()->transact(RECORDING_FRAME_HANDLE_CALLBACK_TIMESTAMP_BATCH, data, &reply,
                IBinder::FLAG_ONEWAY);

        // The native handle is dupped in ICameraClient so we need to free it here.
        for (auto& handle : handles) {
            native_handle_close(handle);
            native_handle_delete(handle);
        }
    }
Пример #5
0
// ---------------------------------------------------------------------------
// QCameraStream_record
// ---------------------------------------------------------------------------
void QCameraStream_record::stop()
{
  status_t ret = NO_ERROR;
  ALOGE("%s: BEGIN", __func__);
  mHalCamCtrl->mStartRecording  = false;
  Mutex::Autolock l(&mHalCamCtrl->mRecordLock);
  Mutex::Autolock lock(mStopCallbackLock);
  {
        mHalCamCtrl->mRecordFrameLock.lock();
        mHalCamCtrl->mReleasedRecordingFrame = true;
        mHalCamCtrl->mRecordWait.signal();
        mHalCamCtrl-> mRecordFrameLock.unlock();
  }

  for(int cnt = 0; cnt < mHalCamCtrl->mPreviewMemory.buffer_count; cnt++) {
    if (mHalCamCtrl->mStoreMetaDataInFrame) {
      struct encoder_media_buffer_type * packet =
          (struct encoder_media_buffer_type  *)
          mHalCamCtrl->mRecordingMemory.metadata_memory[cnt]->data;
      native_handle_delete(const_cast<native_handle_t *>(packet->meta_handle));
      mHalCamCtrl->mRecordingMemory.metadata_memory[cnt]->release(
		    mHalCamCtrl->mRecordingMemory.metadata_memory[cnt]);
    }
  }
  ALOGV("%s: END", __func__);

}
void OMXVideoDecoderAVCSecure::MemFreeDataBuffer(OMX_U8 *pBuffer) {

    if (pBuffer == NULL)
    {
        ALOGE("%s: trying to free NULL pointer", __FUNCTION__);
        return;
    }

    if (mNumInportBuffers == 0)
    {
        ALOGE("%s: allocated inport buffer count is already 0, cannot delete buffer %p",
            __FUNCTION__, pBuffer);
        return;
    }
    
    native_handle_t *native_handle = (native_handle_t *) pBuffer;

    ProtectedDataBuffer *dataBuffer = (ProtectedDataBuffer *) native_handle->data[1];
    if (dataBuffer->magic != PROTECTED_DATA_BUFFER_MAGIC)
    {
        ALOGE("%s: attempting to free buffer with a wrong magic 0x%08x", __FUNCTION__, dataBuffer->magic);
        return;
    }

    if (munmap(dataBuffer, sizeof(ProtectedDataBuffer)) != 0) {
        ALOGE("%s: Faild to munmap %p",__FUNCTION__, dataBuffer);
        return;
    }

    native_handle_close(native_handle);
    native_handle_delete(native_handle);
    ALOGV("Free databuffer %p with data = %p", dataBuffer, dataBuffer->data);
    --mNumInportBuffers;
}
status_t H2BGraphicBufferProducer::queueBuffer(
        int slot,
        const QueueBufferInput& input,
        QueueBufferOutput* output) {
    HGraphicBufferProducer::QueueBufferInput tInput;
    native_handle_t* nh;
    if (!wrapAs(&tInput, &nh, input)) {
        ALOGE("H2BGraphicBufferProducer::queueBuffer - "
                "Invalid input");
        return BAD_VALUE;
    }
    status_t fnStatus;
    status_t transStatus = toStatusT(mBase->queueBuffer(slot, tInput,
            [&fnStatus, output] (
                    Status status,
                    HGraphicBufferProducer::QueueBufferOutput const& tOutput) {
                fnStatus = toStatusT(status);
                if (!convertTo(output, tOutput)) {
                    ALOGE("H2BGraphicBufferProducer::queueBuffer - "
                            "Invalid output");
                    fnStatus = fnStatus == NO_ERROR ? BAD_VALUE : fnStatus;
                }
            }));
    native_handle_delete(nh);
    return transStatus == NO_ERROR ? fnStatus : transStatus;
}
Пример #8
0
LayerBuffer::Buffer::~Buffer()
{
    NativeBuffer& src(mNativeBuffer);
    if (src.img.handle) {
        native_handle_delete(src.img.handle);
    }
}
/**
 * \brief Flatten `FrameEventHistoryDelta`.
 *
 * \param[in] t The source `FrameEventHistoryDelta`.
 * \param[out] nh The array of arrays of cloned native handles.
 * \param[in,out] buffer The pointer to the flat non-fd buffer.
 * \param[in,out] size The size of the flat non-fd buffer.
 * \param[in,out] fds The pointer to the flat fd buffer.
 * \param[in,out] numFds The size of the flat fd buffer.
 * \return `NO_ERROR` on success; other value on failure.
 *
 * On success, this function will duplicate file descriptors contained in \p t.
 * The cloned native handles will be stored in \p nh. Before making the call, \p
 * nh should have enough space to store `n` pointers to arrays of native
 * handles, where `n` is the length of `t.deltas`, and each `nh[i]` should have
 * enough space to store `4` native handles.
 */
inline status_t flatten(
        HGraphicBufferProducer::FrameEventHistoryDelta const& t,
        std::vector<std::vector<native_handle_t*> >* nh,
        void*& buffer, size_t& size, int*& fds, size_t& numFds) {
    if (t.deltas.size() > ::android::FrameEventHistory::MAX_FRAME_HISTORY) {
        return BAD_VALUE;
    }
    if (size < getFlattenedSize(t)) {
        return NO_MEMORY;
    }

    FlattenableUtils::write(buffer, size, t.compositorTiming);

    FlattenableUtils::write(buffer, size, static_cast<uint32_t>(t.deltas.size()));
    nh->resize(t.deltas.size());
    for (size_t deltaIndex = 0; deltaIndex < t.deltas.size(); ++deltaIndex) {
        status_t status = flatten(
                t.deltas[deltaIndex], &((*nh)[deltaIndex]),
                buffer, size, fds, numFds);
        if (status != NO_ERROR) {
            while (deltaIndex > 0) {
                --deltaIndex;
                for (size_t snapshotIndex = 0;
                        snapshotIndex < 4; ++snapshotIndex) {
                    native_handle_close((*nh)[deltaIndex][snapshotIndex]);
                    native_handle_delete((*nh)[deltaIndex][snapshotIndex]);
                    (*nh)[deltaIndex][snapshotIndex] = nullptr;
                }
            }
            return status;
        }
    }
    return NO_ERROR;
}
Пример #10
0
status_t StreamHalHidl::dump(int fd) {
    if (!mStream) return NO_INIT;
    native_handle_t* hidlHandle = native_handle_create(1, 0);
    hidlHandle->data[0] = fd;
    Return<void> ret = mStream->debugDump(hidlHandle);
    native_handle_delete(hidlHandle);
    return processReturn("dump", ret);
}
Пример #11
0
void GraphicBuffer::free_handle()
{
    if (mOwner == ownHandle) {
        native_handle_close(handle);
        native_handle_delete(const_cast<native_handle*>(handle));
    } else if (mOwner == ownData) {
        GraphicBufferAllocator& allocator(GraphicBufferAllocator::get());
        allocator.free(handle);
    }
}
Пример #12
0
ServerWaylandBuffer::~ServerWaylandBuffer()
{
    if (m_buf)
        wl_buffer_destroy(m_buf);

    m_gralloc->unregisterBuffer(m_gralloc, handle);
    native_handle_close(handle);
    native_handle_delete(const_cast<native_handle_t *>(handle));
    wl_array_release(&ints);
    wl_array_release(&fds);
}
void GraphicBuffer::free_handle()
{
    if (mOwner == ownHandle) {
        mBufferMapper.unregisterBuffer(handle);
        native_handle_close(handle);
        native_handle_delete(const_cast<native_handle*>(handle));
    } else if (mOwner == ownData) {
        GraphicBufferAllocator& allocator(GraphicBufferAllocator::get());
        allocator.free(handle);
    }
    mWrappedBuffer = 0;
}
    void releaseRecordingFrameHandle(native_handle_t *handle) {
        ALOGV("releaseRecordingFrameHandle");
        Parcel data, reply;
        data.writeInterfaceToken(ICameraRecordingProxy::getInterfaceDescriptor());
        data.writeNativeHandle(handle);

        remote()->transact(RELEASE_RECORDING_FRAME_HANDLE, data, &reply);

        // Close the native handle because camera received a dup copy.
        native_handle_close(handle);
        native_handle_delete(handle);
    }
    void recordingFrameHandleCallbackTimestamp(nsecs_t timestamp, native_handle_t* handle) {
        ALOGV("recordingFrameHandleCallbackTimestamp");
        Parcel data, reply;
        data.writeInterfaceToken(ICameraRecordingProxyListener::getInterfaceDescriptor());
        data.writeInt64(timestamp);
        data.writeNativeHandle(handle);
        remote()->transact(RECORDING_FRAME_HANDLE_CALLBACK_TIMESTAMP, data, &reply,
                IBinder::FLAG_ONEWAY);

        // The native handle is dupped in ICameraClient so we need to free it here.
        native_handle_close(handle);
        native_handle_delete(handle);
    }
Пример #16
0
void QCameraStream_record::releaseEncodeBuffer() {
  for(int cnt = 0; cnt < mHalCamCtrl->mPreviewMemory.buffer_count; cnt++) {
    if (mHalCamCtrl->mStoreMetaDataInFrame) {
      struct encoder_media_buffer_type * packet =
          (struct encoder_media_buffer_type  *)
          mHalCamCtrl->mRecordingMemory.metadata_memory[cnt]->data;
      native_handle_delete(const_cast<native_handle_t *>(packet->meta_handle));
      mHalCamCtrl->mRecordingMemory.metadata_memory[cnt]->release(
        mHalCamCtrl->mRecordingMemory.metadata_memory[cnt]);

    }
  }
}
Пример #17
0
int hybris_gralloc_release(buffer_handle_t handle, int was_allocated)
{
    int ret = -ENOSYS;

    if GRALLOC1(
        ret = gralloc1_release(gralloc1_device, handle);

        // this needs to happen if the last reference is gone, this function is
        // only called in such cases.
        if (!gralloc1_release_implies_delete) {
            native_handle_close((native_handle_t*)handle);
            native_handle_delete((native_handle_t*)handle);
        }
    ) else if GRALLOC0(
status_t H2BGraphicBufferProducer::cancelBuffer(int slot, const sp<Fence>& fence) {
    hidl_handle tFence;
    native_handle_t* nh = nullptr;
    if ((fence == nullptr) || !wrapAs(&tFence, &nh, *fence)) {
        ALOGE("H2BGraphicBufferProducer::cancelBuffer - "
                "Invalid input fence");
        return BAD_VALUE;
    }

    status_t status = toStatusT(mBase->cancelBuffer(
            static_cast<int32_t>(slot), tFence));
    native_handle_delete(nh);
    return status;
}
Пример #19
0
static int sensors_open(struct sensors_data_device_t *dev, native_handle_t* hd)
{
    event_fd = open(SYSFS_PATH "coord", O_RDONLY | O_NONBLOCK);
    if (event_fd < 0) {
        LOGE("coord open failed in %s: %s", __FUNCTION__, strerror(errno));
        return -1;
    }

    sensors.vector.status = SENSOR_STATUS_ACCURACY_HIGH;
    LOGD("%s\n", __func__);
    write_int("ths", DEFAULT_THRESHOLD);
    native_handle_close(hd);
    native_handle_delete(hd);

    return 0;
}
native_handle_t* sensors_proxy_open_all_dev(SensorsProxy* proxy)
{
    int i=0;
    native_handle_t* handle =  native_handle_create(2, 0);;

    for(i=0;i<numSensorDrivers;i++)
    {
        handle->data[i]= sensor_open_dev(proxy->mSensors[i]);
        if(handle->data[i]<0)
        {
            native_handle_close(handle);
            native_handle_delete(handle);
            handle = NULL;
            break;
        }
    }
    return handle;
}
static int
data__data_open(struct sensors_poll_device_t *dev, native_handle_t* handle)
{
    SensorPoll*  data = (void*)dev;
    int i;
    D("%s: dev=%p fd=%d", __FUNCTION__, dev, handle->data[0]);
    memset(&data->sensors, 0, sizeof(data->sensors));

    data->pendingSensors = 0;
    data->timeStart      = 0;
    data->timeOffset     = 0;

    data->events_fd = dup(handle->data[0]);
    D("%s: dev=%p fd=%d (was %d)", __FUNCTION__, dev, data->events_fd, handle->data[0]);
    native_handle_close(handle);
    native_handle_delete(handle);
    return 0;
}
static jobject
android_open(JNIEnv *env, jclass clazz)
{
    native_handle_t* handle = sSensorDevice->open_data_source(sSensorDevice);
    if (!handle) {
        return NULL;
    }

    // new Bundle()
    jobject bundle = env->NewObject(
            gBundleOffsets.mClass,
            gBundleOffsets.mConstructor);

    if (handle->numFds > 0) {
        jobjectArray fdArray = env->NewObjectArray(handle->numFds,
                gParcelFileDescriptorOffsets.mClass, NULL);
        for (int i = 0; i < handle->numFds; i++) {
            // new FileDescriptor()
            jobject fd = env->NewObject(gFileDescriptorOffsets.mClass,
                    gFileDescriptorOffsets.mConstructor);
            env->SetIntField(fd, gFileDescriptorOffsets.mDescriptor, handle->data[i]);
            // new ParcelFileDescriptor()
            jobject pfd = env->NewObject(gParcelFileDescriptorOffsets.mClass,
                    gParcelFileDescriptorOffsets.mConstructor, fd);
            env->SetObjectArrayElement(fdArray, i, pfd);
        }
        // bundle.putParcelableArray("fds", fdArray);
        env->CallVoidMethod(bundle, gBundleOffsets.mPutParcelableArray,
                env->NewStringUTF("fds"), fdArray);
    }

    if (handle->numInts > 0) {
        jintArray intArray = env->NewIntArray(handle->numInts);
        env->SetIntArrayRegion(intArray, 0, handle->numInts, &handle->data[handle->numInts]);
        // bundle.putIntArray("ints", intArray);
        env->CallVoidMethod(bundle, gBundleOffsets.mPutIntArray,
                env->NewStringUTF("ints"), intArray);
    }

    // delete the file handle, but don't close any file descriptors
    native_handle_delete(handle);
    return bundle;
}
Пример #23
0
native_handle_t* native_handle_clone(const native_handle_t* handle) {
    native_handle_t* clone = native_handle_create(handle->numFds, handle->numInts);
    if (clone == NULL) return NULL;

    for (int i = 0; i < handle->numFds; i++) {
        clone->data[i] = dup(handle->data[i]);
        if (clone->data[i] == -1) {
            clone->numFds = i;
            native_handle_close(clone);
            native_handle_delete(clone);
            return NULL;
        }
    }

    memcpy(&clone->data[handle->numFds], &handle->data[handle->numFds],
           sizeof(int) * handle->numInts);

    return clone;
}
Пример #24
0
static void
server_wlegl_create_buffer(struct wl_client *client,
			   struct wl_resource *resource,
			   uint32_t id,
			   int32_t width,
			   int32_t height,
			   int32_t stride,
			   int32_t format,
			   int32_t usage,
			   struct wl_resource *hnd)
{
	server_wlegl *wlegl = server_wlegl_from(resource);
	server_wlegl_handle *handle = server_wlegl_handle_from(hnd);
	server_wlegl_buffer *buffer;
	buffer_handle_t native;

	if (width < 1 || height < 1) {
		wl_resource_post_error(resource,
				       ANDROID_WLEGL_ERROR_BAD_VALUE,
				       "bad width (%d) or height (%d)",
				       width, height);
		return;
	}

	native = server_wlegl_handle_to_native(handle);
	if (!native) {
		wl_resource_post_error(resource,
				       ANDROID_WLEGL_ERROR_BAD_HANDLE,
				       "fd count mismatch");
		return;
	}

	buffer = server_wlegl_buffer_create(client, id, width, height, stride,
					    format, usage, native, wlegl);
	if (!buffer) {
		native_handle_close((native_handle_t *)native);
		native_handle_delete((native_handle_t *)native);
		wl_resource_post_error(resource,
				       ANDROID_WLEGL_ERROR_BAD_HANDLE,
				       "invalid native handle");
		return;
	}
}
Пример #25
0
static int data__data_open(struct sensors_data_context_t *dev, native_handle_t* handle)
{
    int i;
    struct input_absinfo absinfo;
    memset(&dev->sensors, 0, sizeof(dev->sensors));

    for (i = 0; i < MAX_NUM_SENSORS; i++) {
        // by default all sensors have high accuracy
        // (we do this because we don't get an update if the value doesn't
        // change).
        dev->sensors[i].vector.status = SENSOR_STATUS_ACCURACY_HIGH;
    }

    dev->sensors[ID_A].sensor = SENSOR_TYPE_ACCELEROMETER;
    dev->sensors[ID_M].sensor = SENSOR_TYPE_MAGNETIC_FIELD;
    dev->sensors[ID_O].sensor = SENSOR_TYPE_ORIENTATION;
    dev->sensors[ID_T].sensor = SENSOR_TYPE_TEMPERATURE;
    dev->sensors[ID_P].sensor = SENSOR_TYPE_PROXIMITY;
    dev->sensors[ID_L].sensor = SENSOR_TYPE_LIGHT;

    dev->events_fd[0] = dup(handle->data[0]);
    dev->events_fd[1] = dup(handle->data[1]);
    //dev->events_fd[2] = dup(handle->data[2]);
    LOGV("data__data_open: accelerometer fd = %d, dup=%d", handle->data[0], dev->events_fd[0] );
    LOGV("data__data_open: compass fd = %d, dup=%d", handle->data[1], dev->events_fd[1] );
    //LOGV("data__data_open: light fd = %d, dup=%d", handle->data[2], dev->events_fd[2] );
    // Framework will close the handle
    native_handle_delete(handle);

    dev->pendingSensors = 0;
    /* if (!ioctl(dev->events_fd[1], EVIOCGABS(ABS_DISTANCE), &absinfo)) { */
    /*     LOGV("proximity sensor initial value %d\n", absinfo.value); */
    /*     dev->pendingSensors |= SENSORS_CM_PROXIMITY; */
    /*     // FIXME: we should save here absinfo.{minimum, maximum, etc} */
    /*     //        and use them to scale the return value according to */
    /*     //        the sensor description. */
    /*     dev->sensors[ID_P].distance = (float)absinfo.value; */
    /* } */
    /* else LOGE("Cannot get proximity sensor initial value: %s\n", */
              /* strerror(errno)); */

    return 0;
}
void GraphicBuffer::free_handle()
{
    if (mOwner == ownHandle) {
#ifndef MTK_DEFAULT_AOSP
        ALOGD("close handle(%p) (w:%d h:%d f:%d)",
            handle, stride, height, format);
#endif
        mBufferMapper.unregisterBuffer(handle);
        native_handle_close(handle);
        native_handle_delete(const_cast<native_handle*>(handle));
    } else if (mOwner == ownData) {
#ifndef MTK_DEFAULT_AOSP
        ALOGI("free buffer (w:%d h:%d f:%d) handle(%p)",
            stride, height, format, handle);
#endif
        GraphicBufferAllocator& allocator(GraphicBufferAllocator::get());
        allocator.free(handle);
    }
    mWrappedBuffer = 0;
}
static int data__data_open(struct sensors_data_context_t *dev, native_handle_t* handle)
{
    int i;
    struct input_absinfo absinfo;
    memset(&dev->sensors, 0, sizeof(dev->sensors));

    for (i = 0; i < MAX_NUM_SENSORS; i++) {
        // by default all sensors have high accuracy
        // (we do this because we don't get an update if the value doesn't
        // change).
        dev->sensors[i].vector.status = SENSOR_STATUS_ACCURACY_HIGH;
    }

    dev->sensors[ID_A].sensor = SENSOR_TYPE_ACCELEROMETER;
    dev->sensors[ID_M].sensor = SENSOR_TYPE_MAGNETIC_FIELD;
    dev->sensors[ID_O].sensor = SENSOR_TYPE_ORIENTATION;
    dev->sensors[ID_T].sensor = SENSOR_TYPE_TEMPERATURE;
    dev->sensors[ID_P].sensor = SENSOR_TYPE_PROXIMITY;
    dev->sensors[ID_L].sensor = SENSOR_TYPE_LIGHT;

    dev->events_fd[0] = dup(handle->data[0]);
    dev->events_fd[1] = dup(handle->data[1]);
    dev->events_fd[2] = dup(handle->data[2]);
    LOGV("data__data_open: compass fd = %d", handle->data[0]);
    LOGV("data__data_open: proximity fd = %d", handle->data[1]);
    LOGV("data__data_open: light fd = %d", handle->data[2]);
    // Framework will close the handle
    native_handle_delete(handle);

    dev->pendingSensors = 0;
    if (!ioctl(dev->events_fd[1], EVIOCGABS(ABS_DISTANCE), &absinfo)) {
        LOGV("proximity sensor initial value %d\n", absinfo.value);
        dev->pendingSensors |= SENSORS_GP_PROXIMITY;
	dev->sensors[ID_P].distance = (absinfo.value == 1.0f ? 0.0f : 1.0f);
    }
    else LOGE("Cannot get proximity sensor initial value: %s\n",
              strerror(errno));

    return 0;
}
Пример #28
0
arxstatus_t ImageBuffer::free()
{
    if (mRemote) {
        if (mImage.memType == DVP_MTYPE_GRALLOC_2DTILED ||
            mImage.memType == DVP_MTYPE_DISPLAY_2DTILED) {
            native_handle_t  *handle = reinterpret_cast<native_handle_t *>(mImage.reserved);
            if (!mUsingTexture) {
                GraphicBufferMapper &mapper = GraphicBufferMapper::get();
                mapper.unlock(handle);
                mapper.unregisterBuffer(handle);
            }
            native_handle_close(handle);
            native_handle_delete(handle);
        } else {
            DVP_Image_Free_Import(mDvp, &mImage, mImportHdls);
            if (mImage.memType != DVP_MTYPE_MPUCACHED_VIRTUAL_SHARED) {
                for (uint32_t i = 0; i < mImage.planes; i++) {
                    close(mSharedFds[i]);
                }
            }
        }
        return NOERROR;
    }

    if (mAnw) {
        anativewindow_release(mAnw, &(mImage.reserved));
    } else {
        DVP_Image_Free(mDvp, &mImage);
        if (mImage.memType != DVP_MTYPE_MPUCACHED_VIRTUAL_SHARED) {
            for (uint32_t i = 0; i < mImage.planes; i++) {
                close(mSharedFds[i]);
            }
        }
    }
    return NOERROR;
}
Пример #29
0
RemoteWindowBuffer::~RemoteWindowBuffer()
{
	this->m_gralloc->unregisterBuffer(this->m_gralloc, this->handle);
	native_handle_close(this->handle);
	native_handle_delete(const_cast<native_handle_t*>(this->handle)); 
}