1c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong/* 2c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * Copyright (C) 2017 The Android Open Source Project 3c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * 4c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * Licensed under the Apache License, Version 2.0 (the "License"); 5c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * you may not use this file except in compliance with the License. 6c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * You may obtain a copy of the License at 7c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * 8c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * http://www.apache.org/licenses/LICENSE-2.0 9c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * 10c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * Unless required by applicable law or agreed to in writing, software 11c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * distributed under the License is distributed on an "AS IS" BASIS, 12c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * See the License for the specific language governing permissions and 14c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong * limitations under the License. 15c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong */ 16c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong 17c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong#include "DirectReportChannel.h" 18c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong#include "utils.h" 19c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong 20c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hongnamespace android { 21c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hongnamespace frameworks { 22c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hongnamespace sensorservice { 23c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hongnamespace V1_0 { 24c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hongnamespace implementation { 25c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong 26c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan HongDirectReportChannel::DirectReportChannel(::android::SensorManager& manager, int channelId) 27c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong : mManager(manager), mId(channelId) {} 28c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong 29c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan HongDirectReportChannel::~DirectReportChannel() { 30c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong mManager.destroyDirectChannel(mId); 31c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong} 32c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong 33c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong// Methods from ::android::frameworks::sensorservice::V1_0::IDirectReportChannel follow. 34c7cbda64bea65f1675b7c681f07b438fdf88e6b5Yifan HongReturn<void> DirectReportChannel::configure(int32_t sensorHandle, RateLevel rate, 35c7cbda64bea65f1675b7c681f07b438fdf88e6b5Yifan Hong configure_cb _hidl_cb) { 3605fc8afc081722606aa815f5a6cb8f8f640d3e28Yifan Hong int token = mManager.configureDirectChannel(mId, 3705fc8afc081722606aa815f5a6cb8f8f640d3e28Yifan Hong static_cast<int>(sensorHandle), static_cast<int>(rate)); 38c7cbda64bea65f1675b7c681f07b438fdf88e6b5Yifan Hong _hidl_cb(token <= 0 ? 0 : token, 39c7cbda64bea65f1675b7c681f07b438fdf88e6b5Yifan Hong token <= 0 ? convertResult(token) : Result::OK); 40c7cbda64bea65f1675b7c681f07b438fdf88e6b5Yifan Hong return Void(); 41c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong} 42c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong 43c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong 44c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong} // namespace implementation 45c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong} // namespace V1_0 46c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong} // namespace sensorservice 47c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong} // namespace frameworks 48c34f57fed0ad09c6d7361a39580da20b466d46d1Yifan Hong} // namespace android 49