mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-23 12:35:33 -04:00
universal7885: Move folders to subfolders
Change-Id: I109b02201607d12209180c7cf3356b4e2e3d7ce6 Signed-off-by: roynatech2544 <whiteshell2544@naver.com>
This commit is contained in:
parent
abd58dad16
commit
8cc7aca046
89 changed files with 0 additions and 0 deletions
|
|
@ -1,3 +0,0 @@
|
|||
LOCAL_PATH := $(call my-dir)
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
//
|
||||
// Copyright (C) 2021 The LineageOS Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.camera.provider@2.5-service.exynos7885",
|
||||
defaults: [
|
||||
"hidl_defaults",
|
||||
],
|
||||
compile_multilib: "32",
|
||||
proprietary: true,
|
||||
relative_install_path: "hw",
|
||||
srcs: [
|
||||
"SamsungCameraProvider.cpp",
|
||||
"service.cpp"
|
||||
],
|
||||
init_rc: ["android.hardware.camera.provider@2.5-service.exynos7885.rc"],
|
||||
shared_libs: [
|
||||
"android.hardware.camera.provider@2.4",
|
||||
"android.hardware.camera.provider@2.4-legacy",
|
||||
"android.hardware.camera.provider@2.5",
|
||||
"android.hardware.camera.provider@2.5-legacy",
|
||||
"libbinder",
|
||||
"libcamera_metadata",
|
||||
"libcutils",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"liblog",
|
||||
"libutils",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.camera.common@1.0-helper",
|
||||
],
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2021 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "SamsungCameraProvider@2.5"
|
||||
|
||||
#include "SamsungCameraProvider.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using ::android::NO_ERROR;
|
||||
using ::android::OK;
|
||||
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
|
||||
const int kMaxCameraIdLen = 16;
|
||||
|
||||
SamsungCameraProvider::SamsungCameraProvider() : LegacyCameraProviderImpl_2_5() {
|
||||
mExtraIDs.push_back(50);
|
||||
mDisabledIDs.push_back(2);
|
||||
if (!mInitFailed) {
|
||||
for (int i : mExtraIDs) {
|
||||
struct camera_info info;
|
||||
auto rc = mModule->getCameraInfo(i, &info);
|
||||
|
||||
if (rc != NO_ERROR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (checkCameraVersion(i, info) != OK) {
|
||||
ALOGE("Camera version check failed!");
|
||||
mModule.clear();
|
||||
mInitFailed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SAMSUNG_CAMERA_DEBUG
|
||||
ALOGI("ID=%d is at index %d", i, mNumberOfLegacyCameras);
|
||||
#endif
|
||||
|
||||
char cameraId[kMaxCameraIdLen];
|
||||
snprintf(cameraId, sizeof(cameraId), "%d", i);
|
||||
std::string cameraIdStr(cameraId);
|
||||
mCameraStatusMap[cameraIdStr] = CAMERA_DEVICE_STATUS_PRESENT;
|
||||
|
||||
addDeviceNames(i);
|
||||
mNumberOfLegacyCameras++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Return<void> SamsungCameraProvider::getCameraIdList(
|
||||
ICameraProvider::getCameraIdList_cb _hidl_cb) {
|
||||
std::vector<hidl_string> deviceNameList;
|
||||
for (auto const& deviceNamePair : mCameraDeviceNames) {
|
||||
int id = std::stoi(deviceNamePair.first);
|
||||
if (id >= mNumberOfLegacyCameras || std::find(mDisabledIDs.begin(), mDisabledIDs.end(), id) != mDisabledIDs.end()) {
|
||||
// External camera devices must be reported through the device status change callback,
|
||||
// not in this list.
|
||||
// Linux4: Also skip disabled camera IDs.
|
||||
continue;
|
||||
}
|
||||
if (mCameraStatusMap[deviceNamePair.first] == CAMERA_DEVICE_STATUS_PRESENT) {
|
||||
deviceNameList.push_back(deviceNamePair.second);
|
||||
}
|
||||
}
|
||||
hidl_vec<hidl_string> hidlDeviceNameList(deviceNameList);
|
||||
_hidl_cb(::android::hardware::camera::common::V1_0::Status::OK, hidlDeviceNameList);
|
||||
return Void();
|
||||
}
|
||||
|
||||
SamsungCameraProvider::~SamsungCameraProvider() {}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2021 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SAMSUNG_CAMERA_PROVIDER_H
|
||||
|
||||
#include "LegacyCameraProviderImpl_2_5.h"
|
||||
|
||||
#define SAMSUNG_CAMERA_DEBUG
|
||||
|
||||
using ::android::hardware::camera::provider::V2_5::ICameraProvider;
|
||||
using ::android::hardware::camera::provider::V2_5::implementation::LegacyCameraProviderImpl_2_5;
|
||||
using ::android::hardware::Return;
|
||||
|
||||
class SamsungCameraProvider : public LegacyCameraProviderImpl_2_5 {
|
||||
public:
|
||||
SamsungCameraProvider();
|
||||
~SamsungCameraProvider();
|
||||
|
||||
Return<void> getCameraIdList(ICameraProvider::getCameraIdList_cb _hidl_cb);
|
||||
private:
|
||||
std::vector<int> mExtraIDs;
|
||||
std::vector<int> mDisabledIDs;
|
||||
};
|
||||
|
||||
#endif // SAMSUNG_CAMERA_PROVIDER_H
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
service vendor.camera-provider-2-5 /vendor/bin/hw/android.hardware.camera.provider@2.5-service.exynos7885
|
||||
interface android.hardware.camera.provider@2.5::ICameraProvider legacy/0
|
||||
interface android.hardware.camera.provider@2.4::ICameraProvider legacy/0
|
||||
class hal
|
||||
user cameraserver
|
||||
group audio camera input drmrpc
|
||||
ioprio rt 4
|
||||
capabilities SYS_NICE
|
||||
task_profiles CameraServiceCapacity MaxPerformance
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright 2019 The Android Open Source Project
|
||||
* Copyright 2021 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.camera.provider@2.5-service.samsung"
|
||||
|
||||
#include <android/hardware/camera/provider/2.5/ICameraProvider.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <hidl/HidlLazyUtils.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
#include "CameraProvider_2_5.h"
|
||||
#include "SamsungCameraProvider.h"
|
||||
|
||||
using android::status_t;
|
||||
using android::hardware::camera::provider::V2_5::ICameraProvider;
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace android::hardware::camera::provider::V2_5::implementation;
|
||||
|
||||
ALOGI("CameraProvider@2.5 legacy service is starting.");
|
||||
|
||||
::android::hardware::configureRpcThreadpool(/*threads*/ HWBINDER_THREAD_COUNT, /*willJoin*/ true);
|
||||
|
||||
::android::sp<ICameraProvider> provider = new CameraProvider<SamsungCameraProvider>();
|
||||
|
||||
status_t status = provider->registerAsService("legacy/0");
|
||||
LOG_ALWAYS_FATAL_IF(status != android::OK, "Error while registering provider service: %d",
|
||||
status);
|
||||
|
||||
::android::hardware::joinRpcThreadpool();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
cc_binary {
|
||||
name: "android.hardware.biometrics.fingerprint@2.3-service.samsung",
|
||||
defaults: ["hidl_defaults"],
|
||||
proprietary: true,
|
||||
init_rc: ["android.hardware.biometrics.fingerprint@2.3-service.samsung.rc"],
|
||||
vintf_fragments: ["android.hardware.biometrics.fingerprint@2.3-service.samsung.xml"],
|
||||
relative_install_path: "hw",
|
||||
cflags: ["-DHAS_FINGERPRINT_GESTURES"],
|
||||
srcs: [
|
||||
"BiometricsFingerprint.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libcutils",
|
||||
"libhardware",
|
||||
"libbase",
|
||||
"libutils",
|
||||
"libhidlbase",
|
||||
"android.hardware.biometrics.fingerprint@2.1",
|
||||
"android.hardware.biometrics.fingerprint@2.2",
|
||||
"android.hardware.biometrics.fingerprint@2.3",
|
||||
],
|
||||
}
|
||||
|
|
@ -1,519 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2019 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.3-service.samsung"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <hardware/hw_auth_token.h>
|
||||
|
||||
#include <hardware/fingerprint.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include "BiometricsFingerprint.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include <fstream>
|
||||
|
||||
#ifdef HAS_FINGERPRINT_GESTURES
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace biometrics {
|
||||
namespace fingerprint {
|
||||
namespace V2_3 {
|
||||
namespace implementation {
|
||||
|
||||
using RequestStatus = android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
||||
|
||||
BiometricsFingerprint* BiometricsFingerprint::sInstance = nullptr;
|
||||
|
||||
BiometricsFingerprint::BiometricsFingerprint() : mClientCallback(nullptr) {
|
||||
sInstance = this; // keep track of the most recent instance
|
||||
if (!openHal()) {
|
||||
LOG(ERROR) << "Can't open HAL module";
|
||||
}
|
||||
|
||||
#ifdef HAS_FINGERPRINT_GESTURES
|
||||
request(FINGERPRINT_REQUEST_NAVIGATION_MODE_START, 1);
|
||||
|
||||
uinputFd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
|
||||
if (uinputFd < 0) {
|
||||
LOG(ERROR) << "Unable to open uinput node";
|
||||
return;
|
||||
}
|
||||
|
||||
int err = ioctl(uinputFd, UI_SET_EVBIT, EV_KEY) | ioctl(uinputFd, UI_SET_KEYBIT, KEY_UP) |
|
||||
ioctl(uinputFd, UI_SET_KEYBIT, KEY_DOWN);
|
||||
if (err != 0) {
|
||||
LOG(ERROR) << "Unable to enable key events";
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(uidev.name, "uinput-sec-fp");
|
||||
uidev.id.bustype = BUS_VIRTUAL;
|
||||
|
||||
err = write(uinputFd, &uidev, sizeof(uidev));
|
||||
if (err < 0) {
|
||||
LOG(ERROR) << "Write user device to uinput node failed";
|
||||
return;
|
||||
}
|
||||
|
||||
err = ioctl(uinputFd, UI_DEV_CREATE);
|
||||
if (err < 0) {
|
||||
LOG(ERROR) << "Unable to create uinput device";
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(INFO) << "Successfully registered uinput-sec-fp for fingerprint gestures";
|
||||
#endif
|
||||
}
|
||||
|
||||
BiometricsFingerprint::~BiometricsFingerprint() {
|
||||
if (ss_fingerprint_close() != 0) {
|
||||
LOG(ERROR) << "Can't close HAL module";
|
||||
}
|
||||
}
|
||||
|
||||
Return<bool> BiometricsFingerprint::isUdfps(uint32_t) {
|
||||
std::ifstream in("/sys/devices/virtual/fingerprint/fingerprint/position");
|
||||
if (in) {
|
||||
in.close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Return<void> BiometricsFingerprint::onFingerDown(uint32_t, uint32_t, float, float) {
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> BiometricsFingerprint::onFingerUp() {
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::ErrorFilter(int32_t error) {
|
||||
switch (error) {
|
||||
case 0:
|
||||
return RequestStatus::SYS_OK;
|
||||
case -2:
|
||||
return RequestStatus::SYS_ENOENT;
|
||||
case -4:
|
||||
return RequestStatus::SYS_EINTR;
|
||||
case -5:
|
||||
return RequestStatus::SYS_EIO;
|
||||
case -11:
|
||||
return RequestStatus::SYS_EAGAIN;
|
||||
case -12:
|
||||
return RequestStatus::SYS_ENOMEM;
|
||||
case -13:
|
||||
return RequestStatus::SYS_EACCES;
|
||||
case -14:
|
||||
return RequestStatus::SYS_EFAULT;
|
||||
case -16:
|
||||
return RequestStatus::SYS_EBUSY;
|
||||
case -22:
|
||||
return RequestStatus::SYS_EINVAL;
|
||||
case -28:
|
||||
return RequestStatus::SYS_ENOSPC;
|
||||
case -110:
|
||||
return RequestStatus::SYS_ETIMEDOUT;
|
||||
default:
|
||||
LOG(ERROR) << "An unknown error returned from fingerprint vendor library: " << error;
|
||||
return RequestStatus::SYS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
// Translate from errors returned by traditional HAL (see fingerprint.h) to
|
||||
// HIDL-compliant FingerprintError.
|
||||
FingerprintError BiometricsFingerprint::VendorErrorFilter(int32_t error, int32_t* vendorCode) {
|
||||
*vendorCode = 0;
|
||||
switch (error) {
|
||||
case FINGERPRINT_ERROR_HW_UNAVAILABLE:
|
||||
return FingerprintError::ERROR_HW_UNAVAILABLE;
|
||||
case FINGERPRINT_ERROR_UNABLE_TO_PROCESS:
|
||||
return FingerprintError::ERROR_UNABLE_TO_PROCESS;
|
||||
case FINGERPRINT_ERROR_TIMEOUT:
|
||||
return FingerprintError::ERROR_TIMEOUT;
|
||||
case FINGERPRINT_ERROR_NO_SPACE:
|
||||
return FingerprintError::ERROR_NO_SPACE;
|
||||
case FINGERPRINT_ERROR_CANCELED:
|
||||
return FingerprintError::ERROR_CANCELED;
|
||||
case FINGERPRINT_ERROR_UNABLE_TO_REMOVE:
|
||||
return FingerprintError::ERROR_UNABLE_TO_REMOVE;
|
||||
case FINGERPRINT_ERROR_LOCKOUT:
|
||||
return FingerprintError::ERROR_LOCKOUT;
|
||||
default:
|
||||
if (error >= FINGERPRINT_ERROR_VENDOR_BASE) {
|
||||
// vendor specific code.
|
||||
*vendorCode = error - FINGERPRINT_ERROR_VENDOR_BASE;
|
||||
return FingerprintError::ERROR_VENDOR;
|
||||
}
|
||||
}
|
||||
LOG(ERROR) << "Unknown error from fingerprint vendor library: " << error;
|
||||
return FingerprintError::ERROR_UNABLE_TO_PROCESS;
|
||||
}
|
||||
|
||||
// Translate acquired messages returned by traditional HAL (see fingerprint.h)
|
||||
// to HIDL-compliant FingerprintAcquiredInfo.
|
||||
FingerprintAcquiredInfo BiometricsFingerprint::VendorAcquiredFilter(int32_t info,
|
||||
int32_t* vendorCode) {
|
||||
*vendorCode = 0;
|
||||
switch (info) {
|
||||
case FINGERPRINT_ACQUIRED_GOOD:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_GOOD;
|
||||
case FINGERPRINT_ACQUIRED_PARTIAL:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_PARTIAL;
|
||||
case FINGERPRINT_ACQUIRED_INSUFFICIENT:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
|
||||
case FINGERPRINT_ACQUIRED_IMAGER_DIRTY:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_IMAGER_DIRTY;
|
||||
case FINGERPRINT_ACQUIRED_TOO_SLOW:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_TOO_SLOW;
|
||||
case FINGERPRINT_ACQUIRED_TOO_FAST:
|
||||
return FingerprintAcquiredInfo::ACQUIRED_TOO_FAST;
|
||||
default:
|
||||
if (info >= FINGERPRINT_ACQUIRED_VENDOR_BASE) {
|
||||
// vendor specific code.
|
||||
*vendorCode = info - FINGERPRINT_ACQUIRED_VENDOR_BASE;
|
||||
return FingerprintAcquiredInfo::ACQUIRED_VENDOR;
|
||||
}
|
||||
}
|
||||
LOG(ERROR) << "Unknown acquiredmsg from fingerprint vendor library: " << info;
|
||||
return FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
|
||||
}
|
||||
|
||||
Return<uint64_t> BiometricsFingerprint::setNotify(
|
||||
const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
|
||||
std::lock_guard<std::mutex> lock(mClientCallbackMutex);
|
||||
mClientCallback = clientCallback;
|
||||
// This is here because HAL 2.3 doesn't have a way to propagate a
|
||||
// unique token for its driver. Subsequent versions should send a unique
|
||||
// token for each call to setNotify(). This is fine as long as there's only
|
||||
// one fingerprint device on the platform.
|
||||
return reinterpret_cast<uint64_t>(this);
|
||||
}
|
||||
|
||||
Return<uint64_t> BiometricsFingerprint::preEnroll() {
|
||||
return ss_fingerprint_pre_enroll();
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69>& hat,
|
||||
uint32_t gid, uint32_t timeoutSec) {
|
||||
const hw_auth_token_t* authToken = reinterpret_cast<const hw_auth_token_t*>(hat.data());
|
||||
|
||||
return ErrorFilter(ss_fingerprint_enroll(authToken, gid, timeoutSec));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::postEnroll() {
|
||||
return ErrorFilter(ss_fingerprint_post_enroll());
|
||||
}
|
||||
|
||||
Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
|
||||
return ss_fingerprint_get_auth_id();
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::cancel() {
|
||||
int32_t ret = ss_fingerprint_cancel();
|
||||
|
||||
#ifdef CALL_NOTIFY_ON_CANCEL
|
||||
if (ret == 0) {
|
||||
fingerprint_msg_t msg{};
|
||||
msg.type = FINGERPRINT_ERROR;
|
||||
msg.data.error = FINGERPRINT_ERROR_CANCELED;
|
||||
notify(&msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ErrorFilter(ret);
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::enumerate() {
|
||||
if (ss_fingerprint_enumerate != nullptr) {
|
||||
return ErrorFilter(ss_fingerprint_enumerate());
|
||||
}
|
||||
|
||||
return RequestStatus::SYS_UNKNOWN;
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) {
|
||||
return ErrorFilter(ss_fingerprint_remove(gid, fid));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
|
||||
const hidl_string& storePath) {
|
||||
if (storePath.size() >= PATH_MAX || storePath.size() <= 0) {
|
||||
LOG(ERROR) << "Bad path length: " << storePath.size();
|
||||
return RequestStatus::SYS_EINVAL;
|
||||
}
|
||||
|
||||
if (access(storePath.c_str(), W_OK)) {
|
||||
return RequestStatus::SYS_EINVAL;
|
||||
}
|
||||
|
||||
return ErrorFilter(ss_fingerprint_set_active_group(gid, storePath.c_str()));
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid) {
|
||||
return ErrorFilter(ss_fingerprint_authenticate(operationId, gid));
|
||||
}
|
||||
|
||||
IBiometricsFingerprint* BiometricsFingerprint::getInstance() {
|
||||
if (!sInstance) {
|
||||
sInstance = new BiometricsFingerprint();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
bool BiometricsFingerprint::openHal() {
|
||||
void* handle = dlopen("libbauthserver.so", RTLD_NOW);
|
||||
if (handle) {
|
||||
int err;
|
||||
|
||||
ss_fingerprint_close = reinterpret_cast<typeof(ss_fingerprint_close)>(
|
||||
dlsym(handle, "ss_fingerprint_close"));
|
||||
ss_fingerprint_open =
|
||||
reinterpret_cast<typeof(ss_fingerprint_open)>(dlsym(handle, "ss_fingerprint_open"));
|
||||
|
||||
ss_set_notify_callback = reinterpret_cast<typeof(ss_set_notify_callback)>(
|
||||
dlsym(handle, "ss_set_notify_callback"));
|
||||
ss_fingerprint_pre_enroll = reinterpret_cast<typeof(ss_fingerprint_pre_enroll)>(
|
||||
dlsym(handle, "ss_fingerprint_pre_enroll"));
|
||||
ss_fingerprint_enroll = reinterpret_cast<typeof(ss_fingerprint_enroll)>(
|
||||
dlsym(handle, "ss_fingerprint_enroll"));
|
||||
ss_fingerprint_post_enroll = reinterpret_cast<typeof(ss_fingerprint_post_enroll)>(
|
||||
dlsym(handle, "ss_fingerprint_post_enroll"));
|
||||
ss_fingerprint_get_auth_id = reinterpret_cast<typeof(ss_fingerprint_get_auth_id)>(
|
||||
dlsym(handle, "ss_fingerprint_get_auth_id"));
|
||||
ss_fingerprint_cancel = reinterpret_cast<typeof(ss_fingerprint_cancel)>(
|
||||
dlsym(handle, "ss_fingerprint_cancel"));
|
||||
ss_fingerprint_enumerate = reinterpret_cast<typeof(ss_fingerprint_enumerate)>(
|
||||
dlsym(handle, "ss_fingerprint_enumerate"));
|
||||
ss_fingerprint_remove = reinterpret_cast<typeof(ss_fingerprint_remove)>(
|
||||
dlsym(handle, "ss_fingerprint_remove"));
|
||||
ss_fingerprint_set_active_group = reinterpret_cast<typeof(ss_fingerprint_set_active_group)>(
|
||||
dlsym(handle, "ss_fingerprint_set_active_group"));
|
||||
ss_fingerprint_authenticate = reinterpret_cast<typeof(ss_fingerprint_authenticate)>(
|
||||
dlsym(handle, "ss_fingerprint_authenticate"));
|
||||
ss_fingerprint_request = reinterpret_cast<typeof(ss_fingerprint_request)>(
|
||||
dlsym(handle, "ss_fingerprint_request"));
|
||||
|
||||
if ((err = ss_fingerprint_open(nullptr)) != 0) {
|
||||
LOG(ERROR) << "Can't open fingerprint, error: " << err;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((err = ss_set_notify_callback(BiometricsFingerprint::notify)) != 0) {
|
||||
LOG(ERROR) << "Can't register fingerprint module callback, error: " << err;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void BiometricsFingerprint::notify(const fingerprint_msg_t* msg) {
|
||||
BiometricsFingerprint* thisPtr =
|
||||
static_cast<BiometricsFingerprint*>(BiometricsFingerprint::getInstance());
|
||||
std::lock_guard<std::mutex> lock(thisPtr->mClientCallbackMutex);
|
||||
if (thisPtr == nullptr || thisPtr->mClientCallback == nullptr) {
|
||||
LOG(ERROR) << "Receiving callbacks before the client callback is registered.";
|
||||
return;
|
||||
}
|
||||
const uint64_t devId = 1;
|
||||
switch (msg->type) {
|
||||
case FINGERPRINT_ERROR: {
|
||||
int32_t vendorCode = 0;
|
||||
FingerprintError result = VendorErrorFilter(msg->data.error, &vendorCode);
|
||||
LOG(DEBUG) << "onError(" << static_cast<int>(result) << ")";
|
||||
if (!thisPtr->mClientCallback->onError(devId, result, vendorCode).isOk()) {
|
||||
LOG(ERROR) << "failed to invoke fingerprint onError callback";
|
||||
}
|
||||
} break;
|
||||
case FINGERPRINT_ACQUIRED: {
|
||||
if (msg->data.acquired.acquired_info > SEM_FINGERPRINT_EVENT_BASE) {
|
||||
thisPtr->handleEvent(msg->data.acquired.acquired_info);
|
||||
return;
|
||||
}
|
||||
int32_t vendorCode = 0;
|
||||
FingerprintAcquiredInfo result =
|
||||
VendorAcquiredFilter(msg->data.acquired.acquired_info, &vendorCode);
|
||||
LOG(DEBUG) << "onAcquired(" << static_cast<int>(result) << ")";
|
||||
if (!thisPtr->mClientCallback->onAcquired(devId, result, vendorCode).isOk()) {
|
||||
LOG(ERROR) << "failed to invoke fingerprint onAcquired callback";
|
||||
}
|
||||
} break;
|
||||
case FINGERPRINT_TEMPLATE_ENROLLING:
|
||||
#ifdef USES_PERCENTAGE_SAMPLES
|
||||
const_cast<fingerprint_msg_t*>(msg)->data.enroll.samples_remaining =
|
||||
100 - msg->data.enroll.samples_remaining;
|
||||
#endif
|
||||
#ifdef CALL_CANCEL_ON_ENROLL_COMPLETION
|
||||
if (msg->data.enroll.samples_remaining == 0) {
|
||||
thisPtr->ss_fingerprint_cancel();
|
||||
}
|
||||
#endif
|
||||
LOG(DEBUG) << "onEnrollResult(fid=" << msg->data.enroll.finger.fid
|
||||
<< ", gid=" << msg->data.enroll.finger.gid
|
||||
<< ", rem=" << msg->data.enroll.samples_remaining << ")";
|
||||
if (!thisPtr->mClientCallback
|
||||
->onEnrollResult(devId, msg->data.enroll.finger.fid,
|
||||
msg->data.enroll.finger.gid,
|
||||
msg->data.enroll.samples_remaining)
|
||||
.isOk()) {
|
||||
LOG(ERROR) << "failed to invoke fingerprint onEnrollResult callback";
|
||||
}
|
||||
break;
|
||||
case FINGERPRINT_TEMPLATE_REMOVED:
|
||||
LOG(DEBUG) << "onRemove(fid=" << msg->data.removed.finger.fid
|
||||
<< ", gid=" << msg->data.removed.finger.gid
|
||||
<< ", rem=" << msg->data.removed.remaining_templates << ")";
|
||||
if (!thisPtr->mClientCallback
|
||||
->onRemoved(devId, msg->data.removed.finger.fid,
|
||||
msg->data.removed.finger.gid,
|
||||
msg->data.removed.remaining_templates)
|
||||
.isOk()) {
|
||||
LOG(ERROR) << "failed to invoke fingerprint onRemoved callback";
|
||||
}
|
||||
break;
|
||||
case FINGERPRINT_AUTHENTICATED:
|
||||
LOG(DEBUG) << "onAuthenticated(fid=" << msg->data.authenticated.finger.fid
|
||||
<< ", gid=" << msg->data.authenticated.finger.gid << ")";
|
||||
if (msg->data.authenticated.finger.fid != 0) {
|
||||
const uint8_t* hat = reinterpret_cast<const uint8_t*>(&msg->data.authenticated.hat);
|
||||
const hidl_vec<uint8_t> token(
|
||||
std::vector<uint8_t>(hat, hat + sizeof(msg->data.authenticated.hat)));
|
||||
if (!thisPtr->mClientCallback
|
||||
->onAuthenticated(devId, msg->data.authenticated.finger.fid,
|
||||
msg->data.authenticated.finger.gid, token)
|
||||
.isOk()) {
|
||||
LOG(ERROR) << "failed to invoke fingerprint onAuthenticated callback";
|
||||
}
|
||||
} else {
|
||||
// Not a recognized fingerprint
|
||||
if (!thisPtr->mClientCallback
|
||||
->onAuthenticated(devId, msg->data.authenticated.finger.fid,
|
||||
msg->data.authenticated.finger.gid,
|
||||
hidl_vec<uint8_t>())
|
||||
.isOk()) {
|
||||
LOG(ERROR) << "failed to invoke fingerprint onAuthenticated callback";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FINGERPRINT_TEMPLATE_ENUMERATING:
|
||||
LOG(DEBUG) << "onEnumerate(fid=" << msg->data.enumerated.finger.fid
|
||||
<< ", gid=" << msg->data.enumerated.finger.gid
|
||||
<< ", rem=" << msg->data.enumerated.remaining_templates << ")";
|
||||
if (!thisPtr->mClientCallback
|
||||
->onEnumerate(devId, msg->data.enumerated.finger.fid,
|
||||
msg->data.enumerated.finger.gid,
|
||||
msg->data.enumerated.remaining_templates)
|
||||
.isOk()) {
|
||||
LOG(ERROR) << "failed to invoke fingerprint onEnumerate callback";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BiometricsFingerprint::handleEvent(int eventCode) {
|
||||
switch (eventCode) {
|
||||
#ifdef HAS_FINGERPRINT_GESTURES
|
||||
case SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_DOWN:
|
||||
case SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP:
|
||||
struct input_event event {};
|
||||
int keycode = eventCode == SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP ? KEY_UP : KEY_DOWN;
|
||||
int err;
|
||||
|
||||
// Report the key
|
||||
event.type = EV_KEY;
|
||||
event.code = keycode;
|
||||
event.value = 1;
|
||||
err = write(uinputFd, &event, sizeof(event));
|
||||
if (err < 0) {
|
||||
LOG(ERROR) << "Write EV_KEY to uinput node failed";
|
||||
return;
|
||||
}
|
||||
|
||||
// Force a flush with an EV_SYN
|
||||
event.type = EV_SYN;
|
||||
event.code = SYN_REPORT;
|
||||
event.value = 0;
|
||||
err = write(uinputFd, &event, sizeof(event));
|
||||
if (err < 0) {
|
||||
LOG(ERROR) << "Write EV_SYN to uinput node failed";
|
||||
return;
|
||||
}
|
||||
|
||||
// Report the key
|
||||
event.type = EV_KEY;
|
||||
event.code = keycode;
|
||||
event.value = 0;
|
||||
err = write(uinputFd, &event, sizeof(event));
|
||||
if (err < 0) {
|
||||
LOG(ERROR) << "Write EV_KEY to uinput node failed";
|
||||
return;
|
||||
}
|
||||
|
||||
// Force a flush with an EV_SYN
|
||||
event.type = EV_SYN;
|
||||
event.code = SYN_REPORT;
|
||||
event.value = 0;
|
||||
err = write(uinputFd, &event, sizeof(event));
|
||||
if (err < 0) {
|
||||
LOG(ERROR) << "Write EV_SYN to uinput node failed";
|
||||
return;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
int BiometricsFingerprint::request(int cmd, int param) {
|
||||
// TO-DO: input, output handling not implemented
|
||||
int result = ss_fingerprint_request(cmd, nullptr, 0, nullptr, 0, param);
|
||||
LOG(INFO) << "request(cmd=" << cmd << ", param=" << param << ", result=" << result << ")";
|
||||
return result;
|
||||
}
|
||||
|
||||
int BiometricsFingerprint::waitForSensor(std::chrono::milliseconds pollWait,
|
||||
std::chrono::milliseconds timeOut) {
|
||||
int sensorStatus = SEM_SENSOR_STATUS_WORKING;
|
||||
std::chrono::milliseconds timeWaited = 0ms;
|
||||
while (sensorStatus != SEM_SENSOR_STATUS_OK) {
|
||||
if (sensorStatus == SEM_SENSOR_STATUS_CALIBRATION_ERROR ||
|
||||
sensorStatus == SEM_SENSOR_STATUS_ERROR) {
|
||||
return -1;
|
||||
}
|
||||
if (timeWaited >= timeOut) {
|
||||
return -2;
|
||||
}
|
||||
sensorStatus = request(FINGERPRINT_REQUEST_GET_SENSOR_STATUS, 0);
|
||||
std::this_thread::sleep_for(pollWait);
|
||||
timeWaited += pollWait;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_3
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2019 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
|
||||
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#ifdef HAS_FINGERPRINT_GESTURES
|
||||
#include <linux/uinput.h>
|
||||
#endif
|
||||
|
||||
#include <android/hardware/biometrics/fingerprint/2.1/types.h>
|
||||
#include <android/hardware/biometrics/fingerprint/2.3/IBiometricsFingerprint.h>
|
||||
#include <hardware/fingerprint.h>
|
||||
#include <hardware/hardware.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include "VendorConstants.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace biometrics {
|
||||
namespace fingerprint {
|
||||
namespace V2_3 {
|
||||
namespace implementation {
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::FingerprintError;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
|
||||
using ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
|
||||
|
||||
struct BiometricsFingerprint : public IBiometricsFingerprint {
|
||||
BiometricsFingerprint();
|
||||
~BiometricsFingerprint();
|
||||
|
||||
// Method to wrap legacy HAL with BiometricsFingerprint class
|
||||
static IBiometricsFingerprint* getInstance();
|
||||
|
||||
// Methods from ::android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint
|
||||
// follow.
|
||||
Return<uint64_t> setNotify(
|
||||
const sp<IBiometricsFingerprintClientCallback>& clientCallback) override;
|
||||
Return<uint64_t> preEnroll() override;
|
||||
Return<RequestStatus> enroll(const hidl_array<uint8_t, 69>& hat, uint32_t gid,
|
||||
uint32_t timeoutSec) override;
|
||||
Return<RequestStatus> postEnroll() override;
|
||||
Return<uint64_t> getAuthenticatorId() override;
|
||||
Return<RequestStatus> cancel() override;
|
||||
Return<RequestStatus> enumerate() override;
|
||||
Return<RequestStatus> remove(uint32_t gid, uint32_t fid) override;
|
||||
Return<RequestStatus> setActiveGroup(uint32_t gid, const hidl_string& storePath) override;
|
||||
Return<RequestStatus> authenticate(uint64_t operationId, uint32_t gid) override;
|
||||
Return<bool> isUdfps(uint32_t sensorID) override;
|
||||
Return<void> onFingerDown(uint32_t x, uint32_t y, float minor, float major) override;
|
||||
Return<void> onFingerUp() override;
|
||||
Return<void> onShowUdfpsOverlay() { return Void(); }
|
||||
Return<void> onHideUdfpsOverlay() { return Void(); }
|
||||
|
||||
private:
|
||||
bool openHal();
|
||||
int request(int cmd, int param);
|
||||
int waitForSensor(std::chrono::milliseconds pollWait, std::chrono::milliseconds timeOut);
|
||||
static void notify(
|
||||
const fingerprint_msg_t* msg); /* Static callback for legacy HAL implementation */
|
||||
void handleEvent(int eventCode);
|
||||
static Return<RequestStatus> ErrorFilter(int32_t error);
|
||||
static FingerprintError VendorErrorFilter(int32_t error, int32_t* vendorCode);
|
||||
static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode);
|
||||
static BiometricsFingerprint* sInstance;
|
||||
|
||||
std::mutex mClientCallbackMutex;
|
||||
sp<IBiometricsFingerprintClientCallback> mClientCallback;
|
||||
#ifdef HAS_FINGERPRINT_GESTURES
|
||||
int uinputFd;
|
||||
struct uinput_user_dev uidev {};
|
||||
#endif
|
||||
|
||||
int (*ss_fingerprint_close)();
|
||||
int (*ss_fingerprint_open)(const char* id);
|
||||
|
||||
int (*ss_set_notify_callback)(fingerprint_notify_t notify);
|
||||
uint64_t (*ss_fingerprint_pre_enroll)();
|
||||
int (*ss_fingerprint_enroll)(const hw_auth_token_t* hat, uint32_t gid, uint32_t timeout_sec);
|
||||
int (*ss_fingerprint_post_enroll)();
|
||||
uint64_t (*ss_fingerprint_get_auth_id)();
|
||||
int (*ss_fingerprint_cancel)();
|
||||
int (*ss_fingerprint_enumerate)();
|
||||
int (*ss_fingerprint_remove)(uint32_t gid, uint32_t fid);
|
||||
int (*ss_fingerprint_set_active_group)(uint32_t gid, const char* store_path);
|
||||
int (*ss_fingerprint_authenticate)(uint64_t operation_id, uint32_t gid);
|
||||
int (*ss_fingerprint_request)(uint32_t cmd, char* inBuf, uint32_t inBuf_length, char* outBuf,
|
||||
uint32_t outBuf_length, uint32_t param);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_3
|
||||
} // namespace fingerprint
|
||||
} // namespace biometrics
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_3_BIOMETRICSFINGERPRINT_H
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright (C) 2020 The LineageOS Project
|
||||
|
||||
#ifndef SAMSUNG_FINGERPRINT_CONSTANTS_H
|
||||
#define SAMSUNG_FINGERPRINT_CONSTANTS_H
|
||||
|
||||
// Fingerprint requests
|
||||
#define FINGERPRINT_REQUEST_ENROLL_SESSION 1002
|
||||
#define FINGERPRINT_REQUEST_ENROLL_TYPE 18
|
||||
#define FINGERPRINT_REQUEST_ENUMERATE 11
|
||||
#define FINGERPRINT_REQUEST_GET_FP_IDS 1003
|
||||
#define FINGERPRINT_REQUEST_GET_MAX_TEMPLATE_NUMBER 1004
|
||||
#define FINGERPRINT_REQUEST_GET_SENSOR_INFO 5
|
||||
#define FINGERPRINT_REQUEST_GET_SENSOR_STATUS 6
|
||||
#define FINGERPRINT_REQUEST_GET_TOUCH_CNT 1007
|
||||
#define FINGERPRINT_REQUEST_GET_UNIQUE_ID 7
|
||||
#define FINGERPRINT_REQUEST_GET_USERIDS 12
|
||||
#define FINGERPRINT_REQUEST_GET_VERSION 4
|
||||
#define FINGERPRINT_REQUEST_HAS_FEATURE 1006
|
||||
#define FINGERPRINT_REQUEST_LOCKOUT 1001
|
||||
#define FINGERPRINT_REQUEST_NAVIGATION_LCD_ONOFF 17
|
||||
#define FINGERPRINT_REQUEST_NAVIGATION_MODE_END 16
|
||||
#define FINGERPRINT_REQUEST_NAVIGATION_MODE_START 15
|
||||
#define FINGERPRINT_REQUEST_PAUSE 0
|
||||
#define FINGERPRINT_REQUEST_PROCESS_FIDO 9
|
||||
#define FINGERPRINT_REQUEST_REMOVE_FINGER 1000
|
||||
#define FINGERPRINT_REQUEST_RESUME 1
|
||||
#define FINGERPRINT_REQUEST_SENSOR_TEST_NORMALSCAN 3
|
||||
#define FINGERPRINT_REQUEST_SESSION_OPEN 2
|
||||
#define FINGERPRINT_REQUEST_SET_ACTIVE_GROUP 8
|
||||
#define FINGERPRINT_REQUEST_UPDATE_SID 10
|
||||
|
||||
#define SEM_REQUEST_FORCE_CBGE 21
|
||||
#define SEM_REQUEST_GET_FINGER_ICON_REMAIN_TIME 1010
|
||||
#define SEM_REQUEST_GET_SECURITY_LEVEL 30
|
||||
#define SEM_REQUEST_GET_SENSOR_TEST_RESULT 19
|
||||
#define SEM_REQUEST_GET_TA_VERSION 10000
|
||||
#define SEM_REQUEST_GET_TSP_BLOCK_STATUS 0x3F9
|
||||
#define SEM_REQUEST_HIDE_INDISPLAY_AUTH_ANIMATION 0x3F4
|
||||
#define SEM_REQUEST_INSTALL_TA 10001
|
||||
#define SEM_REQUEST_IS_NEW_MATCHER 27
|
||||
#define SEM_REQUEST_IS_TEMPLATE_CHANGED 25
|
||||
#define SEM_REQUEST_MASK_CTL 0x3F5
|
||||
#define SEM_REQUEST_MOVE_INDISPLAY_ICON 0x3F3
|
||||
#define SEM_REQUEST_OPTICAL_CALIBRATION 0x3F8
|
||||
#define SEM_REQUEST_REMOVE_ALL_USER 0x3F6
|
||||
#define SEM_REQUEST_SET_ASP_LEVEL 20
|
||||
#define SEM_REQUEST_SET_BOUNCER_SCREEN_STATUS 0x3FA
|
||||
#define SEM_REQUEST_SET_SCREEN_STATUS 0x3F0
|
||||
#define SEM_REQUEST_SHOW_INDISPLAY_AUTH_ANIMATION 1009
|
||||
#define SEM_REQUEST_TOUCH_EVENT 22
|
||||
#define SEM_REQUEST_TOUCH_SENSITIVE_CHANGE 0x3F7
|
||||
#define SEM_REQUEST_UPDATE_MATCHER 28
|
||||
#define SEM_REQUEST_VENDOR_EGIS_CALIBRATION 23
|
||||
#define SEM_REQUEST_VENDOR_QCOM_REMOVE_CBGE 24
|
||||
#define SEM_REQUEST_WIRELESS_CHARGER_STATUS 29
|
||||
|
||||
// Fingerprint aquired codes
|
||||
#define SEM_FINGERPRINT_ACQUIRED_DUPLICATED_IMAGE 1002
|
||||
#define SEM_FINGERPRINT_ACQUIRED_LIGHT_TOUCH 1003
|
||||
#define SEM_FINGERPRINT_ACQUIRED_TSP_BLOCK 1004
|
||||
#define SEM_FINGERPRINT_ACQUIRED_TSP_UNBLOCK 1005
|
||||
#define SEM_FINGERPRINT_ACQUIRED_WET_FINGER 1001
|
||||
|
||||
// Fingerprint errors
|
||||
#define SEM_FINGERPRINT_ERROR_CALIBRATION 1001
|
||||
#define SEM_FINGERPRINT_ERROR_DISABLED_BIOMETRICS 5002
|
||||
#define SEM_FINGERPRINT_ERROR_INVALID_HW 1005
|
||||
#define SEM_FINGERPRINT_ERROR_NEED_TO_RETRY 5000
|
||||
#define SEM_FINGERPRINT_ERROR_ONE_HAND_MODE 5001
|
||||
#define SEM_FINGERPRINT_ERROR_PATTERN_DETECTED 1007
|
||||
#define SEM_FINGERPRINT_ERROR_SERVICE_FAILURE 1003
|
||||
#define SEM_FINGERPRINT_ERROR_SMART_VIEW 5003
|
||||
#define SEM_FINGERPRINT_ERROR_SYSTEM_FAILURE 1002
|
||||
#define SEM_FINGERPRINT_ERROR_TA_UPDATE -100
|
||||
#define SEM_FINGERPRINT_ERROR_TEMPLATE_CORRUPTED 1004
|
||||
#define SEM_FINGERPRINT_ERROR_TEMPLATE_FORMAT_CHANGED 1006
|
||||
#define SEM_FINGERPRINT_ERROR_WIRELESS_CHARGING 5004
|
||||
|
||||
// Fingerprint events
|
||||
#define SEM_FINGERPRINT_EVENT_BASE 10000
|
||||
#define SEM_FINGERPRINT_EVENT_CAPTURE_COMPLETED 10003
|
||||
#define SEM_FINGERPRINT_EVENT_CAPTURE_FAILED 10006
|
||||
#define SEM_FINGERPRINT_EVENT_CAPTURE_READY 10001
|
||||
#define SEM_FINGERPRINT_EVENT_CAPTURE_STARTED 10002
|
||||
#define SEM_FINGERPRINT_EVENT_CAPTURE_SUCCESS 10005
|
||||
#define SEM_FINGERPRINT_EVENT_FACTORY_SNSR_SCRIPT_END 10009
|
||||
#define SEM_FINGERPRINT_EVENT_FACTORY_SNSR_SCRIPT_START 10008
|
||||
#define SEM_FINGERPRINT_EVENT_FINGER_LEAVE 10004
|
||||
#define SEM_FINGERPRINT_EVENT_FINGER_LEAVE_TIMEOUT 10007
|
||||
#define SEM_FINGERPRINT_EVENT_GESTURE_DTAP 20003
|
||||
#define SEM_FINGERPRINT_EVENT_GESTURE_LPRESS 20004
|
||||
#define SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_DOWN 20002
|
||||
#define SEM_FINGERPRINT_EVENT_GESTURE_SWIPE_UP 20001
|
||||
#define SEM_FINGERPRINT_EVENT_SPEN_CONTROL_OFF 30002
|
||||
#define SEM_FINGERPRINT_EVENT_SPEN_CONTROL_ON 30001
|
||||
|
||||
// Fingerprint sensor status codes
|
||||
#define SEM_SENSOR_STATUS_CALIBRATION_ERROR 100045
|
||||
#define SEM_SENSOR_STATUS_ERROR 100042
|
||||
#define SEM_SENSOR_STATUS_OK 100040
|
||||
#define SEM_SENSOR_STATUS_WORKING 100041
|
||||
|
||||
#endif // SAMSUNG_FINGERPRINT_CONSTANTS_H
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.3-service.samsung
|
||||
# "class hal" causes a race condition on some devices due to files created
|
||||
# in /data. As a workaround, postpone startup until later in boot once
|
||||
# /data is mounted.
|
||||
class late_start
|
||||
user system
|
||||
group system input uhid
|
||||
writepid /dev/cpuset/system-background/tasks
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<manifest version="1.0" type="device">
|
||||
<hal format="hidl" override="true">
|
||||
<name>android.hardware.biometrics.fingerprint</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>2.3</version>
|
||||
<interface>
|
||||
<name>IBiometricsFingerprint</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2019 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.3-service.samsung"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
#include "BiometricsFingerprint.h"
|
||||
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
using android::hardware::biometrics::fingerprint::V2_3::IBiometricsFingerprint;
|
||||
using android::hardware::biometrics::fingerprint::V2_3::implementation::BiometricsFingerprint;
|
||||
|
||||
using android::OK;
|
||||
using android::sp;
|
||||
|
||||
int main() {
|
||||
android::sp<IBiometricsFingerprint> bio = BiometricsFingerprint::getInstance();
|
||||
|
||||
configureRpcThreadpool(1, true);
|
||||
|
||||
if (bio == nullptr || bio->registerAsService() != OK) {
|
||||
LOG(ERROR) << "Could not register service for Fingerprint HAL";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
LOG(INFO) << "Fingerprint HAL service is Ready.";
|
||||
joinRpcThreadpool();
|
||||
|
||||
shutdown:
|
||||
// In normal operation, we don't expect the thread pool to shutdown
|
||||
LOG(ERROR) << "Fingerprint HAL failed to join thread pool.";
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2019 The LineageOS Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
service.cpp
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
android.hardware.keymaster@4.0 \
|
||||
libbase \
|
||||
libcutils \
|
||||
libhardware \
|
||||
libhidlbase \
|
||||
libkeymaster4 \
|
||||
liblog \
|
||||
libskeymaster4device \
|
||||
libutils
|
||||
|
||||
LOCAL_MODULE := android.hardware.keymaster@4.0-service.samsung
|
||||
LOCAL_INIT_RC := android.hardware.keymaster@4.0-service.samsung.rc
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_OWNER := samsung
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
service vendor.keymaster-4-0 /vendor/bin/hw/android.hardware.keymaster@4.0-service.samsung
|
||||
class early_hal
|
||||
user system
|
||||
group system drmrpc
|
||||
|
||||
on post-fs-data
|
||||
mkdir /mnt/vendor/efs/DAK 0775 system system
|
||||
restorecon -R /mnt/vendor/efs/DAK
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright 2019 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.keymaster@4.0-service.samsung"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/keymaster/4.0/IKeymasterDevice.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
#include <AndroidKeymaster4Device.h>
|
||||
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
using android::hardware::keymaster::V4_0::IKeymasterDevice;
|
||||
using android::hardware::keymaster::V4_0::SecurityLevel;
|
||||
|
||||
using android::OK;
|
||||
using android::status_t;
|
||||
|
||||
namespace skeymaster {
|
||||
IKeymasterDevice* CreateSKeymasterDevice(SecurityLevel securityLevel);
|
||||
} // namespace skeymaster
|
||||
|
||||
int main() {
|
||||
IKeymasterDevice* keymaster =
|
||||
skeymaster::CreateSKeymasterDevice(SecurityLevel::TRUSTED_ENVIRONMENT);
|
||||
|
||||
configureRpcThreadpool(1, true);
|
||||
|
||||
status_t status = keymaster->registerAsService();
|
||||
|
||||
if (status != OK) {
|
||||
LOG(ERROR) << "Could not register service for Keymaster HAL";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
LOG(INFO) << "Keymaster HAL service is Ready.";
|
||||
joinRpcThreadpool();
|
||||
|
||||
shutdown:
|
||||
// In normal operation, we don't expect the thread pool to shutdown
|
||||
LOG(ERROR) << "Keymaster HAL failed to join thread pool.";
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
cc_library_shared {
|
||||
name: "android.hardware.sensors@1.0-impl.samsung",
|
||||
defaults: ["hidl_defaults"],
|
||||
proprietary: true,
|
||||
relative_install_path: "hw",
|
||||
srcs: ["Sensors.cpp"],
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libcutils",
|
||||
"libhardware",
|
||||
"libbase",
|
||||
"libutils",
|
||||
"libhidlbase",
|
||||
"android.hardware.sensors@1.0",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.sensors@1.0-convert",
|
||||
"multihal",
|
||||
],
|
||||
}
|
||||
|
|
@ -1,354 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
//#define VERBOSE
|
||||
|
||||
#include "Sensors.h"
|
||||
#include <sensors/convert.h>
|
||||
#include "multihal.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace sensors {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
/*
|
||||
* If a multi-hal configuration file exists in the proper location,
|
||||
* return true indicating we need to use multi-hal functionality.
|
||||
*/
|
||||
static bool UseMultiHal() {
|
||||
const std::string& name = MULTI_HAL_CONFIG_FILE_PATH;
|
||||
struct stat buffer;
|
||||
return (stat(name.c_str(), &buffer) == 0);
|
||||
}
|
||||
|
||||
static Result ResultFromStatus(status_t err) {
|
||||
switch (err) {
|
||||
case OK:
|
||||
return Result::OK;
|
||||
case PERMISSION_DENIED:
|
||||
return Result::PERMISSION_DENIED;
|
||||
case NO_MEMORY:
|
||||
return Result::NO_MEMORY;
|
||||
case BAD_VALUE:
|
||||
return Result::BAD_VALUE;
|
||||
default:
|
||||
return Result::INVALID_OPERATION;
|
||||
}
|
||||
}
|
||||
|
||||
Sensors::Sensors() : mInitCheck(NO_INIT), mSensorModule(nullptr), mSensorDevice(nullptr) {
|
||||
status_t err = OK;
|
||||
if (UseMultiHal()) {
|
||||
mSensorModule = ::get_multi_hal_module_info();
|
||||
} else {
|
||||
err = hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&mSensorModule);
|
||||
}
|
||||
if (mSensorModule == NULL) {
|
||||
err = UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
if (err != OK) {
|
||||
LOG(ERROR) << "Couldn't load " << SENSORS_HARDWARE_MODULE_ID << " module ("
|
||||
<< strerror(-err) << ")";
|
||||
|
||||
mInitCheck = err;
|
||||
return;
|
||||
}
|
||||
|
||||
err = sensors_open_1(&mSensorModule->common, &mSensorDevice);
|
||||
|
||||
if (err != OK) {
|
||||
LOG(ERROR) << "Couldn't open device for module " << SENSORS_HARDWARE_MODULE_ID << " ("
|
||||
<< strerror(-err) << ")";
|
||||
|
||||
mInitCheck = err;
|
||||
return;
|
||||
}
|
||||
|
||||
// Require all the old HAL APIs to be present except for injection, which
|
||||
// is considered optional.
|
||||
CHECK_GE(getHalDeviceVersion(), SENSORS_DEVICE_API_VERSION_1_3);
|
||||
|
||||
if (getHalDeviceVersion() == SENSORS_DEVICE_API_VERSION_1_4) {
|
||||
if (mSensorDevice->inject_sensor_data == nullptr) {
|
||||
LOG(ERROR) << "HAL specifies version 1.4, but does not implement inject_sensor_data()";
|
||||
}
|
||||
if (mSensorModule->set_operation_mode == nullptr) {
|
||||
LOG(ERROR) << "HAL specifies version 1.4, but does not implement set_operation_mode()";
|
||||
}
|
||||
}
|
||||
|
||||
/* Get us all sensors */
|
||||
setOperationMode(static_cast<hardware::sensors::V1_0::OperationMode>(5555));
|
||||
|
||||
mInitCheck = OK;
|
||||
}
|
||||
|
||||
status_t Sensors::initCheck() const {
|
||||
return mInitCheck;
|
||||
}
|
||||
|
||||
Return<void> Sensors::getSensorsList(getSensorsList_cb _hidl_cb) {
|
||||
sensor_t const* list;
|
||||
size_t count = mSensorModule->get_sensors_list(mSensorModule, &list);
|
||||
|
||||
hidl_vec<SensorInfo> out;
|
||||
out.resize(count);
|
||||
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
const sensor_t* src = &list[i];
|
||||
SensorInfo* dst = &out[i];
|
||||
|
||||
convertFromSensor(*src, dst);
|
||||
|
||||
if (dst->requiredPermission == "com.samsung.permission.SSENSOR") {
|
||||
dst->requiredPermission = "";
|
||||
}
|
||||
|
||||
if (dst->typeAsString == "com.samsung.sensor.physical_proximity") {
|
||||
LOG(INFO) << "Fixing com.samsung.sensor.physical_proximity";
|
||||
dst->type = SensorType::PROXIMITY;
|
||||
dst->typeAsString = SENSOR_STRING_TYPE_PROXIMITY;
|
||||
dst->maxRange = 1;
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
LOG(INFO) << "SENSOR NAME: " << dst->name;
|
||||
LOG(INFO) << " VENDOR: " << dst->name;
|
||||
LOG(INFO) << " TYPE: " << (uint32_t)dst->type;
|
||||
LOG(INFO) << " TYPE_AS_STRING: " << dst->typeAsString;
|
||||
LOG(INFO) << " FLAGS: " << std::hex << dst->flags;
|
||||
LOG(INFO) << "";
|
||||
#endif
|
||||
}
|
||||
|
||||
_hidl_cb(out);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
int Sensors::getHalDeviceVersion() const {
|
||||
if (!mSensorDevice) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return mSensorDevice->common.version;
|
||||
}
|
||||
|
||||
Return<Result> Sensors::setOperationMode(OperationMode mode) {
|
||||
if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_4 ||
|
||||
mSensorModule->set_operation_mode == nullptr) {
|
||||
return Result::INVALID_OPERATION;
|
||||
}
|
||||
return ResultFromStatus(mSensorModule->set_operation_mode((uint32_t)mode));
|
||||
}
|
||||
|
||||
Return<Result> Sensors::activate(int32_t sensor_handle, bool enabled) {
|
||||
return ResultFromStatus(mSensorDevice->activate(
|
||||
reinterpret_cast<sensors_poll_device_t*>(mSensorDevice), sensor_handle, enabled));
|
||||
}
|
||||
|
||||
Return<void> Sensors::poll(int32_t maxCount, poll_cb _hidl_cb) {
|
||||
hidl_vec<Event> out;
|
||||
hidl_vec<SensorInfo> dynamicSensorsAdded;
|
||||
|
||||
std::unique_ptr<sensors_event_t[]> data;
|
||||
int err = android::NO_ERROR;
|
||||
|
||||
{ // scope of reentry lock
|
||||
|
||||
// This enforces a single client, meaning that a maximum of one client can call poll().
|
||||
// If this function is re-entred, it means that we are stuck in a state that may prevent
|
||||
// the system from proceeding normally.
|
||||
//
|
||||
// Exit and let the system restart the sensor-hal-implementation hidl service.
|
||||
//
|
||||
// This function must not call _hidl_cb(...) or return until there is no risk of blocking.
|
||||
std::unique_lock<std::mutex> lock(mPollLock, std::try_to_lock);
|
||||
if (!lock.owns_lock()) {
|
||||
// cannot get the lock, hidl service will go into deadlock if it is not restarted.
|
||||
// This is guaranteed to not trigger in passthrough mode.
|
||||
LOG(ERROR)
|
||||
<< "ISensors::poll() re-entry. I do not know what to do except killing myself.";
|
||||
::exit(-1);
|
||||
}
|
||||
|
||||
if (maxCount <= 0) {
|
||||
err = android::BAD_VALUE;
|
||||
} else {
|
||||
int bufferSize = maxCount <= kPollMaxBufferSize ? maxCount : kPollMaxBufferSize;
|
||||
data.reset(new sensors_event_t[bufferSize]);
|
||||
err = mSensorDevice->poll(reinterpret_cast<sensors_poll_device_t*>(mSensorDevice),
|
||||
data.get(), bufferSize);
|
||||
}
|
||||
}
|
||||
|
||||
if (err < 0) {
|
||||
_hidl_cb(ResultFromStatus(err), out, dynamicSensorsAdded);
|
||||
return Void();
|
||||
}
|
||||
|
||||
const size_t count = (size_t)err;
|
||||
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
if (data[i].type != SENSOR_TYPE_DYNAMIC_SENSOR_META) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const dynamic_sensor_meta_event_t* dyn = &data[i].dynamic_sensor_meta;
|
||||
|
||||
if (!dyn->connected) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CHECK(dyn->sensor != nullptr);
|
||||
CHECK_EQ(dyn->sensor->handle, dyn->handle);
|
||||
|
||||
SensorInfo info;
|
||||
convertFromSensor(*dyn->sensor, &info);
|
||||
|
||||
size_t numDynamicSensors = dynamicSensorsAdded.size();
|
||||
dynamicSensorsAdded.resize(numDynamicSensors + 1);
|
||||
dynamicSensorsAdded[numDynamicSensors] = info;
|
||||
}
|
||||
|
||||
out.resize(count);
|
||||
convertFromSensorEvents(err, data.get(), &out);
|
||||
|
||||
_hidl_cb(Result::OK, out, dynamicSensorsAdded);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Result> Sensors::batch(int32_t sensor_handle, int64_t sampling_period_ns,
|
||||
int64_t max_report_latency_ns) {
|
||||
return ResultFromStatus(mSensorDevice->batch(mSensorDevice, sensor_handle, 0, /*flags*/
|
||||
sampling_period_ns, max_report_latency_ns));
|
||||
}
|
||||
|
||||
Return<Result> Sensors::flush(int32_t sensor_handle) {
|
||||
return ResultFromStatus(mSensorDevice->flush(mSensorDevice, sensor_handle));
|
||||
}
|
||||
|
||||
Return<Result> Sensors::injectSensorData(const Event& event) {
|
||||
if (getHalDeviceVersion() < SENSORS_DEVICE_API_VERSION_1_4 ||
|
||||
mSensorDevice->inject_sensor_data == nullptr) {
|
||||
return Result::INVALID_OPERATION;
|
||||
}
|
||||
|
||||
sensors_event_t out;
|
||||
convertToSensorEvent(event, &out);
|
||||
|
||||
return ResultFromStatus(mSensorDevice->inject_sensor_data(mSensorDevice, &out));
|
||||
}
|
||||
|
||||
Return<void> Sensors::registerDirectChannel(const SharedMemInfo& mem,
|
||||
registerDirectChannel_cb _hidl_cb) {
|
||||
if (mSensorDevice->register_direct_channel == nullptr ||
|
||||
mSensorDevice->config_direct_report == nullptr) {
|
||||
// HAL does not support
|
||||
_hidl_cb(Result::INVALID_OPERATION, -1);
|
||||
return Void();
|
||||
}
|
||||
|
||||
sensors_direct_mem_t m;
|
||||
if (!convertFromSharedMemInfo(mem, &m)) {
|
||||
_hidl_cb(Result::BAD_VALUE, -1);
|
||||
return Void();
|
||||
}
|
||||
|
||||
int err = mSensorDevice->register_direct_channel(mSensorDevice, &m, -1);
|
||||
|
||||
if (err < 0) {
|
||||
_hidl_cb(ResultFromStatus(err), -1);
|
||||
} else {
|
||||
int32_t channelHandle = static_cast<int32_t>(err);
|
||||
_hidl_cb(Result::OK, channelHandle);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<Result> Sensors::unregisterDirectChannel(int32_t channelHandle) {
|
||||
if (mSensorDevice->register_direct_channel == nullptr ||
|
||||
mSensorDevice->config_direct_report == nullptr) {
|
||||
// HAL does not support
|
||||
return Result::INVALID_OPERATION;
|
||||
}
|
||||
|
||||
mSensorDevice->register_direct_channel(mSensorDevice, nullptr, channelHandle);
|
||||
|
||||
return Result::OK;
|
||||
}
|
||||
|
||||
Return<void> Sensors::configDirectReport(int32_t sensorHandle, int32_t channelHandle,
|
||||
RateLevel rate, configDirectReport_cb _hidl_cb) {
|
||||
if (mSensorDevice->register_direct_channel == nullptr ||
|
||||
mSensorDevice->config_direct_report == nullptr) {
|
||||
// HAL does not support
|
||||
_hidl_cb(Result::INVALID_OPERATION, -1);
|
||||
return Void();
|
||||
}
|
||||
|
||||
sensors_direct_cfg_t cfg = {.rate_level = convertFromRateLevel(rate)};
|
||||
if (cfg.rate_level < 0) {
|
||||
_hidl_cb(Result::BAD_VALUE, -1);
|
||||
return Void();
|
||||
}
|
||||
|
||||
int err = mSensorDevice->config_direct_report(mSensorDevice, sensorHandle, channelHandle, &cfg);
|
||||
|
||||
if (rate == RateLevel::STOP) {
|
||||
_hidl_cb(ResultFromStatus(err), -1);
|
||||
} else {
|
||||
_hidl_cb(err > 0 ? Result::OK : ResultFromStatus(err), err);
|
||||
}
|
||||
return Void();
|
||||
}
|
||||
|
||||
// static
|
||||
void Sensors::convertFromSensorEvents(size_t count, const sensors_event_t* srcArray,
|
||||
hidl_vec<Event>* dstVec) {
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
const sensors_event_t& src = srcArray[i];
|
||||
Event* dst = &(*dstVec)[i];
|
||||
|
||||
convertFromSensorEvent(src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
ISensors* HIDL_FETCH_ISensors(const char* /* hal */) {
|
||||
Sensors* sensors = new Sensors;
|
||||
if (sensors->initCheck() != OK) {
|
||||
delete sensors;
|
||||
sensors = nullptr;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return sensors;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace sensors
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef HARDWARE_INTERFACES_SENSORS_V1_0_SAMSUNG_SENSORS_H_
|
||||
|
||||
#define HARDWARE_INTERFACES_SENSORS_V1_0_SAMSUNG_SENSORS_H_
|
||||
|
||||
#include <android-base/macros.h>
|
||||
#include <android/hardware/sensors/1.0/ISensors.h>
|
||||
#include <hardware/sensors.h>
|
||||
#include <mutex>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace sensors {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
struct Sensors : public ::android::hardware::sensors::V1_0::ISensors {
|
||||
Sensors();
|
||||
|
||||
status_t initCheck() const;
|
||||
|
||||
Return<void> getSensorsList(getSensorsList_cb _hidl_cb) override;
|
||||
|
||||
Return<Result> setOperationMode(OperationMode mode) override;
|
||||
|
||||
Return<Result> activate(int32_t sensor_handle, bool enabled) override;
|
||||
|
||||
Return<void> poll(int32_t maxCount, poll_cb _hidl_cb) override;
|
||||
|
||||
Return<Result> batch(int32_t sensor_handle, int64_t sampling_period_ns,
|
||||
int64_t max_report_latency_ns) override;
|
||||
|
||||
Return<Result> flush(int32_t sensor_handle) override;
|
||||
|
||||
Return<Result> injectSensorData(const Event& event) override;
|
||||
|
||||
Return<void> registerDirectChannel(const SharedMemInfo& mem,
|
||||
registerDirectChannel_cb _hidl_cb) override;
|
||||
|
||||
Return<Result> unregisterDirectChannel(int32_t channelHandle) override;
|
||||
|
||||
Return<void> configDirectReport(int32_t sensorHandle, int32_t channelHandle, RateLevel rate,
|
||||
configDirectReport_cb _hidl_cb) override;
|
||||
|
||||
private:
|
||||
static constexpr int32_t kPollMaxBufferSize = 128;
|
||||
status_t mInitCheck;
|
||||
sensors_module_t* mSensorModule;
|
||||
sensors_poll_device_1_t* mSensorDevice;
|
||||
std::mutex mPollLock;
|
||||
|
||||
int getHalDeviceVersion() const;
|
||||
|
||||
static void convertFromSensorEvents(size_t count, const sensors_event_t* src,
|
||||
hidl_vec<Event>* dst);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Sensors);
|
||||
};
|
||||
|
||||
extern "C" ISensors* HIDL_FETCH_ISensors(const char* name);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace sensors
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // HARDWARE_INTERFACES_SENSORS_V1_0_SAMSUNG_SENSORS_H_
|
||||
Loading…
Reference in a new issue