kunlun2: Remove all useless stuffs

Signed-off-by: SamarV-121 <samarvispute121@gmail.com>
This commit is contained in:
SamarV-121 2020-04-10 22:21:48 +05:30
parent bfe26e1492
commit d5cc7b6ce3
38 changed files with 1 additions and 2810 deletions

View file

@ -1,32 +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.
cc_binary {
relative_install_path: "hw",
defaults: ["hidl_defaults"],
name: "vendor.lineage.camera.motor@1.0-service.realme_sdm710",
init_rc: ["vendor.lineage.camera.motor@1.0-service.realme_sdm710.rc"],
srcs: ["service.cpp", "CameraMotor.cpp"],
shared_libs: [
"libbase",
"libhardware",
"libhidlbase",
"libhidltransport",
"liblog",
"libhwbinder",
"libutils",
"vendor.lineage.camera.motor@1.0",
],
}

View file

@ -1,123 +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 "CameraMotorService"
#include "CameraMotor.h"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include <chrono>
#include <fstream>
#include <thread>
#define CAMERA_MOTOR_ENABLE "/sys/devices/platform/vendor/vendor:motor_pl/enable"
#define CAMERA_MOTOR_DIRECTION "/sys/devices/platform/vendor/vendor:motor_pl/direction"
#define CAMERA_MOTOR_POSITION "/sys/devices/platform/vendor/vendor:motor_pl/position"
#define DIRECTION_DOWN "0"
#define DIRECTION_UP "1"
#define POSITION_MID "2"
#define POSITION_DOWN "1"
#define POSITION_UP "0"
#define ENABLED "1"
#define CAMERA_ID_FRONT "1"
namespace vendor {
namespace lineage {
namespace camera {
namespace motor {
namespace V1_0 {
namespace implementation {
using namespace std::chrono_literals;
/*
* Write value to path and close file.
*/
template <typename T>
static void set(const std::string& path, const T& value) {
std::ofstream file(path);
file << value;
}
template <typename T>
static T get(const std::string& path, const T& def) {
std::ifstream file(path);
T result;
file >> result;
return file.fail() ? def : result;
}
static void waitUntilFileChange(const std::string& path, const std::string &val,
const std::chrono::milliseconds relativeTimeout) {
auto startTime = std::chrono::steady_clock::now();
while (true) {
if (get<std::string>(path, "") == val) {
return;
}
std::this_thread::sleep_for(50ms);
auto now = std::chrono::steady_clock::now();
auto timeElapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - startTime);
if (timeElapsed > relativeTimeout) {
return;
}
}
}
Return<void> CameraMotor::onConnect(const hidl_string& cameraId) {
auto motorPosition = get<std::string>(CAMERA_MOTOR_POSITION, "");
if (cameraId == CAMERA_ID_FRONT && (motorPosition == POSITION_DOWN || motorPosition == POSITION_MID)) {
LOG(INFO) << "Popping out front camera";
set(CAMERA_MOTOR_DIRECTION, DIRECTION_UP);
set(CAMERA_MOTOR_ENABLE, ENABLED);
waitUntilFileChange(CAMERA_MOTOR_POSITION, POSITION_UP, 5s);
} else if (cameraId != CAMERA_ID_FRONT && motorPosition == POSITION_UP) {
LOG(INFO) << "Retracting front camera";
set(CAMERA_MOTOR_DIRECTION, DIRECTION_DOWN);
set(CAMERA_MOTOR_ENABLE, ENABLED);
waitUntilFileChange(CAMERA_MOTOR_POSITION, POSITION_DOWN, 5s);
}
return Void();
}
Return<void> CameraMotor::onDisconnect(const hidl_string& cameraId) {
auto motorPosition = get<std::string>(CAMERA_MOTOR_POSITION, "");
if (cameraId == CAMERA_ID_FRONT && motorPosition == POSITION_UP) {
LOG(INFO) << "Retracting front camera";
set(CAMERA_MOTOR_DIRECTION, DIRECTION_DOWN);
set(CAMERA_MOTOR_ENABLE, ENABLED);
waitUntilFileChange(CAMERA_MOTOR_POSITION, POSITION_DOWN, 5s);
}
return Void();
}
} // namespace implementation
} // namespace V1_0
} // namespace motor
} // namespace camera
} // namespace lineage
} // namespace vendor

View file

@ -1,45 +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 VENDOR_LINEAGE_CAMERA_MOTOR_V1_0_FINGERPRINTINSCREEN_H
#define VENDOR_LINEAGE_CAMERA_MOTOR_V1_0_FINGERPRINTINSCREEN_H
#include <vendor/lineage/camera/motor/1.0/ICameraMotor.h>
namespace vendor {
namespace lineage {
namespace camera {
namespace motor {
namespace V1_0 {
namespace implementation {
using ::android::hardware::hidl_string;
using ::android::hardware::Return;
using ::android::hardware::Void;
class CameraMotor : public ICameraMotor {
public:
Return<void> onConnect(const hidl_string& cameraId) override;
Return<void> onDisconnect(const hidl_string& cameraId) override;
};
} // namespace implementation
} // namespace V1_0
} // namespace motor
} // namespace camera
} // namespace lineage
} // namespace vendor
#endif // VENDOR_LINEAGE_CAMERA_MOTOR_V1_0_FINGERPRINTINSCREEN_H

View file

@ -1,50 +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 "vendor.lineage.camera.motor@1.0-service.realme_sdm710"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include "CameraMotor.h"
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using vendor::lineage::camera::motor::V1_0::ICameraMotor;
using vendor::lineage::camera::motor::V1_0::implementation::CameraMotor;
using android::OK;
using android::status_t;
int main() {
android::sp<ICameraMotor> service = new CameraMotor();
configureRpcThreadpool(1, true);
status_t status = service->registerAsService();
if (status != OK) {
LOG(ERROR) << "Cannot register Camera Motor HAL service.";
return 1;
}
LOG(INFO) << "Camera Motor HAL service ready.";
joinRpcThreadpool();
LOG(ERROR) << "FOD HAL service failed to join thread pool.";
return 1;
}

View file

@ -1,6 +0,0 @@
service vendor.camera-motor-1-0 /system/bin/hw/vendor.lineage.camera.motor@1.0-service.realme_sdm710
interface vendor.lineage.camera.motor@1.0::ICameraMotor default
class hal
user system
group system
shutdown critical

View file

@ -55,9 +55,6 @@ PRODUCT_PACKAGES += \
vendor.display.config@1.0 vendor.display.config@1.0
# Fingerprint # Fingerprint
PRODUCT_PACKAGES += \
android.hardware.biometrics.fingerprint@2.1-service.realme_sdm710
PRODUCT_COPY_FILES += \ PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.fingerprint.xml:system/etc/permissions/android.hardware.fingerprint.xml frameworks/native/data/etc/android.hardware.fingerprint.xml:system/etc/permissions/android.hardware.fingerprint.xml

View file

@ -1,24 +0,0 @@
cc_binary {
name: "android.hardware.biometrics.fingerprint@2.1-service.realme_sdm710",
defaults: ["hidl_defaults"],
init_rc: ["android.hardware.biometrics.fingerprint@2.1-service.realme_sdm710.rc"],
relative_install_path: "hw",
srcs: [
"BiometricsFingerprint.cpp",
"service.cpp",
],
cflags: [
"-Wno-unused-parameter",
],
shared_libs: [
"libcutils",
"liblog",
"libhidlbase",
"libhidltransport",
"libhardware",
"libutils",
"libbase",
"android.hardware.biometrics.fingerprint@2.1",
"vendor.oppo.hardware.biometrics.fingerprint@2.1",
],
}

View file

@ -1,220 +0,0 @@
/*
* Copyright (C) 2017 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 LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.realme_sdm710"
#define LOG_VERBOSE "android.hardware.biometrics.fingerprint@2.1-service.realme_sdm710"
#include <hardware/hardware.h>
#include <hardware/fingerprint.h>
#include "BiometricsFingerprint.h"
#include <inttypes.h>
#include <unistd.h>
namespace android {
namespace hardware {
namespace biometrics {
namespace fingerprint {
namespace V2_1 {
namespace implementation {
BiometricsFingerprint::BiometricsFingerprint() {
mOppoBiometricsFingerprint = vendor::oppo::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint::getService();
}
class OppoClientCallback : public vendor::oppo::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback {
public:
OppoClientCallback(sp<android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback> clientCallback) : mClientCallback(clientCallback) {}
Return<void> onEnrollResult(uint64_t deviceId, uint32_t fingerId,
uint32_t groupId, uint32_t remaining) {
return mClientCallback->onEnrollResult(deviceId, fingerId, groupId, remaining);
}
Return<void> onAcquired(uint64_t deviceId, vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo acquiredInfo,
int32_t vendorCode) {
return mClientCallback->onAcquired(deviceId, OppoToAOSPFingerprintAcquiredInfo(acquiredInfo), vendorCode);
}
Return<void> onAuthenticated(uint64_t deviceId, uint32_t fingerId, uint32_t groupId,
const hidl_vec<uint8_t>& token) {
return mClientCallback->onAuthenticated(deviceId, fingerId, groupId, token);
}
Return<void> onError(uint64_t deviceId, vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError error, int32_t vendorCode) {
return mClientCallback->onError(deviceId, OppoToAOSPFingerprintError(error), vendorCode);
}
Return<void> onRemoved(uint64_t deviceId, uint32_t fingerId, uint32_t groupId,
uint32_t remaining) {
return mClientCallback->onRemoved(deviceId, fingerId, groupId, remaining);
}
Return<void> onEnumerate(uint64_t deviceId, uint32_t fingerId, uint32_t groupId,
uint32_t remaining) {
return mClientCallback->onEnumerate(deviceId, fingerId, groupId, remaining);
}
Return<void> onTouchUp(uint64_t deviceId) { return Void(); }
Return<void> onTouchDown(uint64_t deviceId) { return Void(); }
Return<void> onSyncTemplates(uint64_t deviceId, const hidl_vec<uint32_t>& fingerId, uint32_t remaining) { return Void(); }
Return<void> onFingerprintCmd(int32_t deviceId, const hidl_vec<uint32_t>& groupId, uint32_t remaining) { return Void(); }
Return<void> onImageInfoAcquired(uint32_t type, uint32_t quality, uint32_t match_score) { return Void(); }
Return<void> onMonitorEventTriggered(uint32_t type, const hidl_string& data) { return Void(); }
Return<void> onEngineeringInfoUpdated(uint32_t length, const hidl_vec<uint32_t>& keys, const hidl_vec<hidl_string>& values) { return Void(); }
private:
sp<android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback> mClientCallback;
Return<android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo> OppoToAOSPFingerprintAcquiredInfo(vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo info) {
switch(info) {
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_GOOD: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_GOOD;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_PARTIAL: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_PARTIAL;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_INSUFFICIENT;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_IMAGER_DIRTY: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_IMAGER_DIRTY;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_TOO_SLOW: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_TOO_SLOW;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_TOO_FAST: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_TOO_FAST;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_VENDOR: return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_VENDOR;
default:
return android::hardware::biometrics::fingerprint::V2_1::FingerprintAcquiredInfo::ACQUIRED_GOOD;
}
}
Return<android::hardware::biometrics::fingerprint::V2_1::FingerprintError> OppoToAOSPFingerprintError(vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError error) {
switch(error) {
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_ERROR: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_ERROR;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_HW_UNAVAILABLE: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_HW_UNAVAILABLE;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_UNABLE_TO_PROCESS: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_UNABLE_TO_PROCESS;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_TIMEOUT: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_TIMEOUT;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_SPACE: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_SPACE;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_CANCELED: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_CANCELED;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_UNABLE_TO_REMOVE: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_UNABLE_TO_REMOVE;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_LOCKOUT: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_LOCKOUT;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_VENDOR: return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_VENDOR;
default:
return android::hardware::biometrics::fingerprint::V2_1::FingerprintError::ERROR_NO_ERROR;
}
}
};
Return<uint64_t> BiometricsFingerprint::setNotify(
const sp<IBiometricsFingerprintClientCallback>& clientCallback) {
mOppoClientCallback = new OppoClientCallback(clientCallback);
return mOppoBiometricsFingerprint->setNotify(mOppoClientCallback);
}
Return<RequestStatus> BiometricsFingerprint::OppoToAOSPRequestStatus(vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus req) {
switch(req) {
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_UNKNOWN: return RequestStatus::SYS_UNKNOWN;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_OK: return RequestStatus::SYS_OK;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_ENOENT: return RequestStatus::SYS_ENOENT;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EINTR: return RequestStatus::SYS_EINTR;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EIO: return RequestStatus::SYS_EIO;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EAGAIN: return RequestStatus::SYS_EAGAIN;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_ENOMEM: return RequestStatus::SYS_ENOMEM;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EACCES: return RequestStatus::SYS_EACCES;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EFAULT: return RequestStatus::SYS_EFAULT;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EBUSY: return RequestStatus::SYS_EBUSY;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_EINVAL: return RequestStatus::SYS_EINVAL;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_ENOSPC: return RequestStatus::SYS_ENOSPC;
case vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus::SYS_ETIMEDOUT: return RequestStatus::SYS_ETIMEDOUT;
default:
return RequestStatus::SYS_UNKNOWN;
}
}
Return<uint64_t> BiometricsFingerprint::preEnroll() {
return mOppoBiometricsFingerprint->preEnroll();
}
Return<RequestStatus> BiometricsFingerprint::enroll(const hidl_array<uint8_t, 69>& hat,
uint32_t gid, uint32_t timeoutSec) {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->enroll(hat, gid, timeoutSec));
}
Return<RequestStatus> BiometricsFingerprint::postEnroll() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->postEnroll());
}
Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
return mOppoBiometricsFingerprint->getAuthenticatorId();
}
Return<RequestStatus> BiometricsFingerprint::cancel() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->cancel());
}
Return<RequestStatus> BiometricsFingerprint::enumerate() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->enumerate());
}
Return<RequestStatus> BiometricsFingerprint::remove(uint32_t gid, uint32_t fid) {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->remove(gid, fid));
}
Return<RequestStatus> BiometricsFingerprint::setActiveGroup(uint32_t gid,
const hidl_string& storePath) {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->setActiveGroup(gid, storePath));
}
Return<RequestStatus> BiometricsFingerprint::authenticate(uint64_t operationId, uint32_t gid) {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->authenticate(operationId, gid));
}
Return<RequestStatus> BiometricsFingerprint::cleanUp() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->cleanUp());
}
Return<RequestStatus> BiometricsFingerprint::pauseEnroll() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->pauseEnroll());
}
Return<RequestStatus> BiometricsFingerprint::continueEnroll() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->continueEnroll());
}
Return<RequestStatus> BiometricsFingerprint::setTouchEventListener() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->setTouchEventListener());
}
Return<RequestStatus> BiometricsFingerprint::dynamicallyConfigLog(uint32_t on) {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->dynamicallyConfigLog(on));
}
Return<RequestStatus> BiometricsFingerprint::pauseIdentify() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->pauseIdentify());
}
Return<RequestStatus> BiometricsFingerprint::continueIdentify() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->continueIdentify());
}
Return<RequestStatus> BiometricsFingerprint::getAlikeyStatus() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->getAlikeyStatus());
}
Return<RequestStatus> BiometricsFingerprint::getEnrollmentTotalTimes() {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->getEnrollmentTotalTimes());
}
Return<RequestStatus> BiometricsFingerprint::getEngineeringInfo(uint32_t type) {
return OppoToAOSPRequestStatus(mOppoBiometricsFingerprint->getEngineeringInfo(type));
}
} // namespace implementation
} // namespace V2_1
} // namespace fingerprint
} // namespace biometrics
} // namespace hardware
} // namespace android

View file

@ -1,87 +0,0 @@
/*
* Copyright (C) 2017 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 ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
#define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H
#include <log/log.h>
#include <android/log.h>
#include <hardware/hardware.h>
#include <hardware/fingerprint.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <android/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
#include <android/hardware/biometrics/fingerprint/2.1/types.h>
#include <vendor/oppo/hardware/biometrics/fingerprint/2.1/IBiometricsFingerprint.h>
namespace android {
namespace hardware {
namespace biometrics {
namespace fingerprint {
namespace V2_1 {
namespace implementation {
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback;
using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::OK;
using ::android::sp;
using ::android::status_t;
struct BiometricsFingerprint : public IBiometricsFingerprint {
public:
BiometricsFingerprint();
// Methods from ::android::hardware::biometrics::fingerprint::V2_1::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<RequestStatus> cleanUp();
Return<RequestStatus> pauseEnroll();
Return<RequestStatus> continueEnroll();
Return<RequestStatus> setTouchEventListener();
Return<RequestStatus> dynamicallyConfigLog(uint32_t on);
Return<RequestStatus> pauseIdentify();
Return<RequestStatus> continueIdentify();
Return<RequestStatus> getAlikeyStatus();
Return<RequestStatus> getEnrollmentTotalTimes();
Return<RequestStatus> getEngineeringInfo(uint32_t type);
private:
sp<vendor::oppo::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint> mOppoBiometricsFingerprint;
sp<vendor::oppo::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback> mOppoClientCallback;
static Return<RequestStatus> OppoToAOSPRequestStatus(vendor::oppo::hardware::biometrics::fingerprint::V2_1::RequestStatus req);
};
} // namespace implementation
} // namespace V2_1
} // namespace fingerprint
} // namespace biometrics
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H

View file

@ -1,7 +0,0 @@
service fps_hal.realme_sdm710 /system/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.realme_sdm710
# "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

View file

@ -1,61 +0,0 @@
/*
* Copyright (C) 2017 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 LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service.realme_sdm710"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include "BiometricsFingerprint.h"
using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint;
using android::hardware::biometrics::fingerprint::V2_1::implementation::BiometricsFingerprint;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::OK;
using android::sp;
using android::status_t;
int main() {
sp<BiometricsFingerprint> biometricsFingerprint;
status_t status;
LOG(INFO) << "Fingerprint HAL Adapter service is starting.";
biometricsFingerprint = new BiometricsFingerprint();
if (biometricsFingerprint == nullptr) {
LOG(ERROR) << "Can not create an instance of Fingerprint HAL Adapter BiometricsFingerprint Iface, exiting.";
goto shutdown;
}
configureRpcThreadpool(1, true /*callerWillJoin*/);
status = biometricsFingerprint->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for Fingerprint HAL Adapter BiometricsFingerprint Iface ("
<< status << ")";
goto shutdown;
}
LOG(INFO) << "Fingerprint HAL Adapter service is ready.";
joinRpcThreadpool();
// Should not pass this line
shutdown:
// In normal operation, we don't expect the thread pool to shutdown
LOG(ERROR) << "Fingerprint HAL Adapter service is shutting down.";
return 1;
}

View file

@ -1,35 +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.
cc_binary {
relative_install_path: "hw",
defaults: ["hidl_defaults"],
name: "lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710",
init_rc: ["lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710.rc"],
srcs: [
"service.cpp",
"FingerprintInscreen.cpp",
],
shared_libs: [
"libbase",
"libhardware",
"libhidlbase",
"libhidltransport",
"liblog",
"libhwbinder",
"libutils",
"vendor.lineage.biometrics.fingerprint.inscreen@1.0",
],
}

View file

@ -1,142 +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 "FingerprintInscreenService"
#include "FingerprintInscreen.h"
#include <hidl/HidlTransportSupport.h>
#include <android-base/logging.h>
#include <fstream>
#include <cmath>
#define FP_PRESS_PATH "/sys/kernel/oppo_display/notify_fppress"
#define HBM_PATH "/sys/kernel/oppo_display/hbm"
#define DIM_AMOUNT_PATH "/sys/kernel/oppo_display/dim_alpha"
namespace {
template <typename T>
static void set(const std::string& path, const T& value) {
std::ofstream file(path);
file << value;
LOG(INFO) << "wrote path: " << path << ", value: " << value << "\n";
}
template <typename T>
static T get(const std::string& path, const T& def) {
std::ifstream file(path);
T result;
file >> result;
return file.fail() ? def : result;
}
} // anonymous namespace
namespace vendor {
namespace lineage {
namespace biometrics {
namespace fingerprint {
namespace inscreen {
namespace V1_0 {
namespace implementation {
FingerprintInscreen::FingerprintInscreen() {
}
Return<int32_t> FingerprintInscreen::getPositionX() {
return 442;
}
Return<int32_t> FingerprintInscreen::getPositionY() {
return 1986;
}
Return<int32_t> FingerprintInscreen::getSize() {
return 196;
}
Return<void> FingerprintInscreen::onStartEnroll() {
return Void();
}
Return<void> FingerprintInscreen::onFinishEnroll() {
return Void();
}
Return<void> FingerprintInscreen::onPress() {
set(HBM_PATH, 1);
set(FP_PRESS_PATH, 1);
return Void();
}
Return<void> FingerprintInscreen::onRelease() {
set(HBM_PATH, 0);
set(FP_PRESS_PATH, 0);
return Void();
}
Return<void> FingerprintInscreen::onShowFODView() {
return Void();
}
Return<void> FingerprintInscreen::onHideFODView() {
set(HBM_PATH, 0);
set(FP_PRESS_PATH, 0);
return Void();
}
Return<bool> FingerprintInscreen::handleAcquired(int32_t acquiredInfo, int32_t vendorCode) {
LOG(ERROR) << "acquiredInfo: " << acquiredInfo << ", vendorCode: " << vendorCode << "\n";
return false;
}
Return<bool> FingerprintInscreen::handleError(int32_t error, int32_t vendorCode) {
LOG(ERROR) << "error: " << error << ", vendorCode: " << vendorCode << "\n";
return false;
}
Return<void> FingerprintInscreen::setLongPressEnabled(bool) {
return Void();
}
Return<int32_t> FingerprintInscreen::getDimAmount(int32_t) {
int dimAmount = get(DIM_AMOUNT_PATH, 0);
LOG(INFO) << "dimAmount = " << dimAmount;
return dimAmount;
}
Return<bool> FingerprintInscreen::shouldBoostBrightness() {
return false;
}
Return<void> FingerprintInscreen::setCallback(const sp<::vendor::lineage::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreenCallback>& callback) {
{
std::lock_guard<std::mutex> _lock(mCallbackLock);
mCallback = callback;
}
return Void();
}
} // namespace implementation
} // namespace V1_0
} // namespace inscreen
} // namespace fingerprint
} // namespace biometrics
} // namespace lineage
} // namespace vendor

View file

@ -1,66 +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 VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
#define VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H
#include <vendor/lineage/biometrics/fingerprint/inscreen/1.0/IFingerprintInscreen.h>
namespace vendor {
namespace lineage {
namespace biometrics {
namespace fingerprint {
namespace inscreen {
namespace V1_0 {
namespace implementation {
using ::android::sp;
using ::android::hardware::Return;
using ::android::hardware::Void;
class FingerprintInscreen : public IFingerprintInscreen {
public:
FingerprintInscreen();
Return<int32_t> getPositionX() override;
Return<int32_t> getPositionY() override;
Return<int32_t> getSize() override;
Return<void> onStartEnroll() override;
Return<void> onFinishEnroll() override;
Return<void> onPress() override;
Return<void> onRelease() override;
Return<void> onShowFODView() override;
Return<void> onHideFODView() override;
Return<bool> handleAcquired(int32_t acquiredInfo, int32_t vendorCode) override;
Return<bool> handleError(int32_t error, int32_t vendorCode) override;
Return<void> setLongPressEnabled(bool enabled) override;
Return<int32_t> getDimAmount(int32_t brightness) override;
Return<bool> shouldBoostBrightness() override;
Return<void> setCallback(const sp<::vendor::lineage::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreenCallback>& callback) override;
private:
std::mutex mCallbackLock;
sp<IFingerprintInscreenCallback> mCallback;
};
} // namespace implementation
} // namespace V1_0
} // namespace inscreen
} // namespace fingerprint
} // namespace biometrics
} // namespace lineage
} // namespace vendor
#endif // VENDOR_LINEAGE_BIOMETRICS_FINGERPRINT_INSCREEN_V1_0_FINGERPRINTINSCREEN_H

View file

@ -1,6 +0,0 @@
service fingerprint-inscreen-1-0 /system/bin/hw/lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710
interface vendor.lineage.biometrics.fingerprint.inscreen@1.0::IFingerprintInscreen default
class hal
user system
group system
shutdown critical

View file

@ -1,50 +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 "lineage.biometrics.fingerprint.inscreen@1.0-service.realme_sdm710"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include "FingerprintInscreen.h"
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using vendor::lineage::biometrics::fingerprint::inscreen::V1_0::IFingerprintInscreen;
using vendor::lineage::biometrics::fingerprint::inscreen::V1_0::implementation::FingerprintInscreen;
using android::OK;
using android::status_t;
int main() {
android::sp<IFingerprintInscreen> service = new FingerprintInscreen();
configureRpcThreadpool(1, true);
status_t status = service->registerAsService();
if (status != OK) {
LOG(ERROR) << "Cannot register FOD HAL service.";
return 1;
}
LOG(INFO) << "FOD HAL service ready.";
joinRpcThreadpool();
LOG(ERROR) << "FOD HAL service failed to join thread pool.";
return 1;
}

View file

@ -17,13 +17,4 @@
<instance>default</instance> <instance>default</instance>
</interface> </interface>
</hal> </hal>
<hal format="hidl">
<name>android.hardware.biometrics.fingerprint</name>
<transport>hwbinder</transport>
<version>2.1</version>
<interface>
<name>IBiometricsFingerprint</name>
<instance>default</instance>
</interface>
</hal>
</manifest> </manifest>

View file

@ -1,4 +1,4 @@
hidl_package_root { hidl_package_root {
name: "vendor.lineage", name: "vendor.lineage",
path: "device/realme/sdm710-common/interfaces/", path: "device/lenovo/kunlun2/interfaces/",
} }

View file

@ -1,4 +0,0 @@
hidl_package_root {
name: "vendor.oppo",
path: "device/realme/sdm710-common/interfaces/vendor",
}

View file

@ -1,16 +0,0 @@
// This file is autogenerated by hidl-gen -Landroidbp.
hidl_interface {
name: "vendor.oppo.hardware.biometrics.fingerprint@2.1",
root: "vendor.oppo",
srcs: [
"IBiometricsFingerprint.hal",
"IBiometricsFingerprintClientCallback.hal",
"types.hal",
],
interfaces: [
"android.hidl.base@1.0",
],
gen_java: true,
}

View file

@ -1,73 +0,0 @@
/*
* Copyright (C) 2017 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.
*/
package vendor.oppo.hardware.biometrics.fingerprint@2.1;
import IBiometricsFingerprintClientCallback;
interface IBiometricsFingerprint {
setNotify(IBiometricsFingerprintClientCallback clientCallback) generates (uint64_t deviceId);
preEnroll() generates (uint64_t authChallenge);
enroll(uint8_t[69] hat, uint32_t gid, uint32_t timeoutSec) generates (RequestStatus debugErrno);
postEnroll() generates (RequestStatus debugErrno);
getAuthenticatorId() generates (uint64_t AuthenticatorId);
cancel() generates (RequestStatus debugErrno);
enumerate() generates (RequestStatus debugErrno);
remove(uint32_t gid, uint32_t fid) generates (RequestStatus debugErrno);
setActiveGroup(uint32_t gid, string storePath) generates (RequestStatus debugErrno);
authenticate(uint64_t operationId, uint32_t gid) generates (RequestStatus debugErrno);
pauseEnroll() generates (RequestStatus debugErrno);
pauseIdentify() generates (RequestStatus debugErrno);
continueEnroll() generates (RequestStatus debugErrno);
setScreenState(FingerprintScreenState ScreenState);
getAlikeyStatus() generates (RequestStatus debugErrno);
continueIdentify() generates (RequestStatus debugErrno);
authenticateAsType(uint64_t auth, uint32_t type, FingerprintAuthType AuthType) generates (RequestStatus debugErrno);
getEngineeringInfo(uint32_t info) generates (RequestStatus debugErrno);
sendFingerprintCmd(int32_t cmd, vec<int8_t> CmdId) generates (RequestStatus debugErrno);
dynamicallyConfigLog(uint32_t log) generates (RequestStatus debugErrno);
setTouchEventListener() generates (RequestStatus debugErrno);
getEnrollmentTotalTimes() generates (RequestStatus debugErrno);
cleanUp() generates (RequestStatus debugErrno);
touchUp() generates (RequestStatus debugErrno);
touchDown() generates (RequestStatus debugErrno);
};

View file

@ -1,44 +0,0 @@
/*
* Copyright (C) 2017 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.
*/
package vendor.oppo.hardware.biometrics.fingerprint@2.1;
/* This HAL interface communicates asynchronous results from the
fingerprint driver in response to user actions on the fingerprint sensor
*/
interface IBiometricsFingerprintClientCallback {
oneway onEnrollResult(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, uint32_t remaining);
oneway onAcquired(uint64_t deviceId, FingerprintAcquiredInfo acquiredInfo, int32_t vendorCode);
oneway onAuthenticated(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, vec<uint8_t> token);
oneway onError(uint64_t deviceId, FingerprintError error, int32_t vendorCode);
oneway onRemoved(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, uint32_t remaining);
oneway onEnumerate(uint64_t deviceId, uint32_t fingerId, uint32_t groupId, uint32_t remaining);
oneway onTouchUp(uint64_t deviceId);
oneway onTouchDown(uint64_t deviceId);
oneway onSyncTemplates(uint64_t deviceId, vec<uint32_t> fingerId, uint32_t remaining);
oneway onFingerprintCmd(int32_t deviceId, vec<uint32_t> groupId, uint32_t remaining);
oneway onImageInfoAcquired(uint32_t type, uint32_t quality, uint32_t match_score);
oneway onMonitorEventTriggered(uint32_t type, string data);
oneway onEngineeringInfoUpdated(uint32_t length, vec<uint32_t> keys, vec<string> values);
};

View file

@ -1,103 +0,0 @@
/*
* Copyright (C) 2017 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.
*/
package vendor.oppo.hardware.biometrics.fingerprint@2.1;
enum RequestStatus : int32_t {
SYS_UNKNOWN = 1,
SYS_OK = 0,
SYS_ENOENT = -2,
SYS_EINTR = -4,
SYS_EIO = -5,
SYS_EAGAIN = -11,
SYS_ENOMEM = -12,
SYS_EACCES = -13,
SYS_EFAULT = -14,
SYS_EBUSY = -16,
SYS_EINVAL = -22,
SYS_ENOSPC = -28,
SYS_ETIMEDOUT = -110,
};
enum FingerprintError : int32_t {
ERROR_NO_ERROR = 0,
ERROR_HW_UNAVAILABLE = 1,
ERROR_UNABLE_TO_PROCESS = 2,
ERROR_TIMEOUT = 3,
ERROR_NO_SPACE = 4,
ERROR_CANCELED = 5,
ERROR_UNABLE_TO_REMOVE = 6,
ERROR_LOCKOUT = 7,
ERROR_VENDOR = 8
};
enum FingerprintAcquiredInfo : int32_t {
ACQUIRED_GOOD = 0,
ACQUIRED_PARTIAL = 1,
ACQUIRED_INSUFFICIENT = 2,
ACQUIRED_IMAGER_DIRTY = 3,
ACQUIRED_TOO_SLOW = 4,
ACQUIRED_TOO_FAST = 5,
ACQUIRED_VENDOR = 6
};
struct FingerprintFingerId {
uint32_t gid;
uint32_t fid;
};
struct FingerprintEnroll {
FingerprintFingerId finger;
uint32_t samplesRemaining; uint64_t msg;
};
struct FingerprintIterator {
FingerprintFingerId finger;
uint32_t remainingTemplates;
};
typedef FingerprintIterator FingerprintEnumerated;
typedef FingerprintIterator FingerprintRemoved;
struct FingerprintAcquired {
FingerprintAcquiredInfo acquiredInfo;
};
struct FingerprintAuthenticated {
FingerprintFingerId finger;
uint8_t[69] hat;
};
enum FingerprintMsgType : int32_t {
ERROR = -1,
ACQUIRED = 1,
TEMPLATE_ENROLLING = 3,
TEMPLATE_REMOVED = 4,
AUTHENTICATED = 5,
TEMPLATE_ENUMERATING = 6,
};
enum FingerprintScreenState : int32_t {
FINGERPRINT_SCREEN_OFF = 0,
FINGERPRINT_SCREEN_ON = 1,
};
enum FingerprintAuthType : int32_t {
TYPE_KEYGUARD = 1,
TYPE_PAY = 2,
TYPE_OTHER = 3,
};

View file

@ -1,6 +0,0 @@
#!/bin/bash
source $ANDROID_BUILD_TOP/system/tools/hidl/update-makefiles-helper.sh
do_makefiles_update \
"vendor.oppo:device/realme/sdm710-common/interfaces/vendor"

View file

@ -23,58 +23,6 @@ on boot
chown system system /proc/touchpanel/double_tap_enable chown system system /proc/touchpanel/double_tap_enable
chown 0660 /proc/touchpanel/double_tap_enable chown 0660 /proc/touchpanel/double_tap_enable
# Disable edge limit control interface
write /proc/touchpanel/oppo_tp_limit_enable 0
# Enable oppo touchpanel direction
write /proc/touchpanel/oppo_tp_direction 1
# Update touchscreen firmware
write /proc/touchpanel/tp_fw_update 1
# OTG
write /sys/class/power_supply/usb/otg_switch 1
# FP
chown system system /dev/goodix_fp
chown system system /dev/esfp0
service oppo_fingerprints_sh /vendor/bin/sh /vendor/bin/init.oppo.fingerprints.sh
class main
user root
oneshot
service fps_hal /vendor/bin/hw/vendor.oppo.hardware.biometrics.fingerprint@2.1-service
class late_start
user system
group system input uhid
on post-fs-data
mkdir /data/gf_data 0700 system system
mkdir /data/system/gf_data 0700 system system
mkdir /data/images 0700 system system
mkdir /data/system/silead 0770 system system
mkdir /persist/silead 0770 system system
chown system system /sys/bus/platform/devices/fpc_interrupt/clk_enable
chown system system /sys/bus/platform/devices/fpc_interrupt/wakelock_enable
chown system system /sys/bus/platform/devices/fpc_interrupt/irq
chown system system /sys/bus/platform/devices/fpc_interrupt/irq_enable
chown system system /sys/bus/platform/devices/fpc_interrupt/irq_unexpected
chmod 0200 /sys/bus/platform/devices/fpc_interrupt/irq_enable
chmod 0200 /sys/bus/platform/devices/fpc_interrupt/clk_enable
chmod 0200 /sys/bus/platform/devices/fpc_interrupt/wakelock_enable
chmod 0600 /sys/bus/platform/devices/fpc_interrupt/irq
chmod 0660 /sys/bus/platform/devices/fpc_interrupt/irq_unexpected
mkdir /data/vendor/fingerprint 0770 system system
mkdir /mnt/vendor/persist/fingerprint 0770 system system
chown system system /sys/kernel/oppo_display/hbm
mkdir /data/vendor/silead 0770 system system
mkdir /mnt/vendor/persist/fingerprint/silead 0770 system system
mkdir /data/vendor/egis 0770 system system
service face_hal /system/bin/true
disabled
service cvphalservice /system/bin/true service cvphalservice /system/bin/true
disabled disabled

View file

@ -1,43 +0,0 @@
cc_library_shared {
name: "android.hardware.sensors@1.0-impl.realme_sdm710",
defaults: ["hidl_defaults"],
relative_install_path: "hw",
srcs: ["Sensors.cpp"],
shared_libs: [
"liblog",
"libcutils",
"libhardware",
"libbase",
"libutils",
"libhidlbase",
"libhidltransport",
"android.hardware.sensors@1.0",
],
static_libs: [
"android.hardware.sensors@1.0-convert",
"multihal.realme_sdm710",
],
}
cc_library_static {
name: "multihal.realme_sdm710",
srcs: [
"multihal.cpp",
"SensorEventQueue.cpp",
],
header_libs: [
"libhardware_headers",
],
shared_libs: [
"liblog",
"libcutils",
"libutils",
"libdl",
],
export_include_dirs: ["."],
cflags: [
"-Wall",
"-Werror",
],
}

View file

@ -1,93 +0,0 @@
/*
* Copyright (C) 2013 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.
*/
#include <pthread.h>
#include <algorithm>
#include <log/log.h>
#include <hardware/sensors.h>
#include "SensorEventQueue.h"
SensorEventQueue::SensorEventQueue(int capacity) {
mCapacity = capacity;
mStart = 0;
mSize = 0;
mData = new sensors_event_t[mCapacity];
pthread_cond_init(&mSpaceAvailableCondition, NULL);
}
SensorEventQueue::~SensorEventQueue() {
delete[] mData;
mData = NULL;
pthread_cond_destroy(&mSpaceAvailableCondition);
}
int SensorEventQueue::getWritableRegion(int requestedLength, sensors_event_t** out) {
if (mSize == mCapacity || requestedLength <= 0) {
*out = NULL;
return 0;
}
// Start writing after the last readable record.
int firstWritable = (mStart + mSize) % mCapacity;
int lastWritable = firstWritable + requestedLength - 1;
// Don't go past the end of the data array.
if (lastWritable > mCapacity - 1) {
lastWritable = mCapacity - 1;
}
// Don't go into the readable region.
if (firstWritable < mStart && lastWritable >= mStart) {
lastWritable = mStart - 1;
}
*out = &mData[firstWritable];
return lastWritable - firstWritable + 1;
}
void SensorEventQueue::markAsWritten(int count) {
mSize += count;
}
int SensorEventQueue::getSize() {
return mSize;
}
sensors_event_t* SensorEventQueue::peek() {
if (mSize == 0) return NULL;
return &mData[mStart];
}
void SensorEventQueue::dequeue() {
if (mSize == 0) return;
if (mSize == mCapacity) {
pthread_cond_broadcast(&mSpaceAvailableCondition);
}
mSize--;
mStart = (mStart + 1) % mCapacity;
}
// returns true if it waited, or false if it was a no-op.
bool SensorEventQueue::waitForSpace(pthread_mutex_t* mutex) {
bool waited = false;
while (mSize == mCapacity) {
waited = true;
pthread_cond_wait(&mSpaceAvailableCondition, mutex);
}
return waited;
}

View file

@ -1,76 +0,0 @@
/*
* Copyright (C) 2013 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 SENSOREVENTQUEUE_H_
#define SENSOREVENTQUEUE_H_
#include <hardware/sensors.h>
#include <pthread.h>
/*
* Fixed-size circular queue, with an API developed around the sensor HAL poll() method.
* Poll() takes a pointer to a buffer, which is written by poll() before it returns.
* This class can provide a pointer to a spot in its internal buffer for poll() to
* write to, instead of using an intermediate buffer and a memcpy.
*
* Thread safety:
* Reading can be done safely after grabbing the mutex lock, while poll() writing in a separate
* thread without a mutex lock. But there can only be one writer at a time.
*/
class SensorEventQueue {
int mCapacity;
int mStart; // start of readable region
int mSize; // number of readable items
sensors_event_t* mData;
pthread_cond_t mSpaceAvailableCondition;
public:
explicit SensorEventQueue(int capacity);
~SensorEventQueue();
// Returns length of region, between zero and min(capacity, requestedLength). If there is any
// writable space, it will return a region of at least one. Because it must return
// a pointer to a contiguous region, it may return smaller regions as we approach the end of
// the data array.
// Only call while holding the lock.
// The region is not marked internally in any way. Subsequent calls may return overlapping
// regions. This class expects there to be exactly one writer at a time.
int getWritableRegion(int requestedLength, sensors_event_t** out);
// After writing to the region returned by getWritableRegion(), call this to indicate how
// many records were actually written.
// This increases size() by count.
// Only call while holding the lock.
void markAsWritten(int count);
// Gets the number of readable records.
// Only call while holding the lock.
int getSize();
// Returns pointer to the first readable record, or NULL if size() is zero.
// Only call this while holding the lock.
sensors_event_t* peek();
// This will decrease the size by one, freeing up the oldest readable event's slot for writing.
// Only call while holding the lock.
void dequeue();
// Blocks until space is available. No-op if there is already space.
// Returns true if it had to wait.
bool waitForSpace(pthread_mutex_t* mutex);
};
#endif // SENSOREVENTQUEUE_H_

View file

@ -1,370 +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.
*/
#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()";
}
}
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->typeAsString == "qti.sensor.wise_light") {
dst->type = SensorType::LIGHT;
dst->typeAsString = "";
}
if (dst->typeAsString == "qti.sensor.proximity_fake") {
dst->type = SensorType::PROXIMITY;
dst->typeAsString = "";
}
}
_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

View file

@ -1,88 +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_DEFAULT_SENSORS_H_
#define HARDWARE_INTERFACES_SENSORS_V1_0_DEFAULT_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_DEFAULT_SENSORS_H_

View file

@ -1,832 +0,0 @@
/*
* Copyright (C) 2013 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.
*/
#include "SensorEventQueue.h"
#include "multihal.h"
#define LOG_NDEBUG 1
#include <cutils/log.h>
#include <cutils/atomic.h>
#include <hardware/sensors.h>
#include <vector>
#include <string>
#include <fstream>
#include <map>
#include <dirent.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <math.h>
#include <poll.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
static pthread_mutex_t init_modules_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t init_sensors_mutex = PTHREAD_MUTEX_INITIALIZER;
// This mutex is shared by all queues
static pthread_mutex_t queue_mutex = PTHREAD_MUTEX_INITIALIZER;
// Used to pause the multihal poll(). Broadcasted by sub-polling tasks if waiting_for_data.
static pthread_cond_t data_available_cond = PTHREAD_COND_INITIALIZER;
bool waiting_for_data = false;
// Vector of sub modules, whose indexes are referred to in this file as module_index.
static std::vector<hw_module_t *> *sub_hw_modules = nullptr;
// Vector of sub modules shared object handles
static std::vector<void *> *so_handles = nullptr;
/*
* Comparable class that globally identifies a sensor, by module index and local handle.
* A module index is the module's index in sub_hw_modules.
* A local handle is the handle the sub-module assigns to a sensor.
*/
struct FullHandle {
int moduleIndex;
int localHandle;
bool operator<(const FullHandle &that) const {
if (moduleIndex < that.moduleIndex) {
return true;
}
if (moduleIndex > that.moduleIndex) {
return false;
}
return localHandle < that.localHandle;
}
bool operator==(const FullHandle &that) const {
return moduleIndex == that.moduleIndex && localHandle == that.localHandle;
}
};
std::map<int, FullHandle> global_to_full;
std::map<FullHandle, int> full_to_global;
int next_global_handle = 1;
static int assign_global_handle(int module_index, int local_handle) {
int global_handle = next_global_handle++;
FullHandle full_handle;
full_handle.moduleIndex = module_index;
full_handle.localHandle = local_handle;
full_to_global[full_handle] = global_handle;
global_to_full[global_handle] = full_handle;
return global_handle;
}
// Returns the local handle, or -1 if it does not exist.
static int get_local_handle(int global_handle) {
if (global_to_full.count(global_handle) == 0) {
ALOGW("Unknown global_handle %d", global_handle);
return -1;
}
return global_to_full[global_handle].localHandle;
}
// Returns the sub_hw_modules index of the module that contains the sensor associates with this
// global_handle, or -1 if that global_handle does not exist.
static int get_module_index(int global_handle) {
if (global_to_full.count(global_handle) == 0) {
ALOGW("Unknown global_handle %d", global_handle);
return -1;
}
FullHandle f = global_to_full[global_handle];
ALOGV("FullHandle for global_handle %d: moduleIndex %d, localHandle %d",
global_handle, f.moduleIndex, f.localHandle);
return f.moduleIndex;
}
// Returns the global handle for this full_handle, or -1 if the full_handle is unknown.
static int get_global_handle(FullHandle* full_handle) {
int global_handle = -1;
if (full_to_global.count(*full_handle)) {
global_handle = full_to_global[*full_handle];
} else {
ALOGW("Unknown FullHandle: moduleIndex %d, localHandle %d",
full_handle->moduleIndex, full_handle->localHandle);
}
return global_handle;
}
static const int SENSOR_EVENT_QUEUE_CAPACITY = 36;
struct TaskContext {
sensors_poll_device_t* device;
SensorEventQueue* queue;
};
void *writerTask(void* ptr) {
ALOGV("writerTask STARTS");
TaskContext* ctx = (TaskContext*)ptr;
sensors_poll_device_t* device = ctx->device;
SensorEventQueue* queue = ctx->queue;
sensors_event_t* buffer;
int eventsPolled;
while (1) {
pthread_mutex_lock(&queue_mutex);
if (queue->waitForSpace(&queue_mutex)) {
ALOGV("writerTask waited for space");
}
int bufferSize = queue->getWritableRegion(SENSOR_EVENT_QUEUE_CAPACITY, &buffer);
// Do blocking poll outside of lock
pthread_mutex_unlock(&queue_mutex);
ALOGV("writerTask before poll() - bufferSize = %d", bufferSize);
eventsPolled = device->poll(device, buffer, bufferSize);
ALOGV("writerTask poll() got %d events.", eventsPolled);
if (eventsPolled <= 0) {
if (eventsPolled < 0) {
ALOGV("writerTask ignored error %d from %s", eventsPolled, device->common.module->name);
ALOGE("ERROR: Fix %s so it does not return error from poll()", device->common.module->name);
}
continue;
}
pthread_mutex_lock(&queue_mutex);
queue->markAsWritten(eventsPolled);
ALOGV("writerTask wrote %d events", eventsPolled);
if (waiting_for_data) {
ALOGV("writerTask - broadcast data_available_cond");
pthread_cond_broadcast(&data_available_cond);
}
pthread_mutex_unlock(&queue_mutex);
}
// never actually returns
return NULL;
}
/*
* Cache of all sensors, with original handles replaced by global handles.
* This will be handled to get_sensors_list() callers.
*/
static struct sensor_t const* global_sensors_list = NULL;
static int global_sensors_count = -1;
/*
* Extends a sensors_poll_device_1 by including all the sub-module's devices.
*/
struct sensors_poll_context_t {
/*
* This is the device that SensorDevice.cpp uses to make API calls
* to the multihal, which fans them out to sub-HALs.
*/
sensors_poll_device_1 proxy_device; // must be first
void addSubHwDevice(struct hw_device_t*);
int activate(int handle, int enabled);
int setDelay(int handle, int64_t ns);
int poll(sensors_event_t* data, int count);
int batch(int handle, int flags, int64_t period_ns, int64_t timeout);
int flush(int handle);
int inject_sensor_data(const sensors_event_t *data);
int register_direct_channel(const struct sensors_direct_mem_t* mem,
int channel_handle);
int config_direct_report(int sensor_handle,
int channel_handle,
const struct sensors_direct_cfg_t *config);
int close();
std::vector<hw_device_t*> sub_hw_devices;
std::vector<SensorEventQueue*> queues;
std::vector<pthread_t> threads;
int nextReadIndex;
sensors_poll_device_t* get_v0_device_by_handle(int global_handle);
sensors_poll_device_1_t* get_v1_device_by_handle(int global_handle);
sensors_poll_device_1_t* get_primary_v1_device();
int get_device_version_by_handle(int global_handle);
void copy_event_remap_handle(sensors_event_t* src, sensors_event_t* dest, int sub_index);
};
void sensors_poll_context_t::addSubHwDevice(struct hw_device_t* sub_hw_device) {
ALOGV("addSubHwDevice");
this->sub_hw_devices.push_back(sub_hw_device);
SensorEventQueue *queue = new SensorEventQueue(SENSOR_EVENT_QUEUE_CAPACITY);
this->queues.push_back(queue);
TaskContext* taskContext = new TaskContext();
taskContext->device = (sensors_poll_device_t*) sub_hw_device;
taskContext->queue = queue;
pthread_t writerThread;
pthread_create(&writerThread, NULL, writerTask, taskContext);
this->threads.push_back(writerThread);
}
// Returns the device pointer, or NULL if the global handle is invalid.
sensors_poll_device_t* sensors_poll_context_t::get_v0_device_by_handle(int global_handle) {
int sub_index = get_module_index(global_handle);
if (sub_index < 0 || sub_index >= (int) this->sub_hw_devices.size()) {
return NULL;
}
return (sensors_poll_device_t*) this->sub_hw_devices[sub_index];
}
// Returns the device pointer, or NULL if the global handle is invalid.
sensors_poll_device_1_t* sensors_poll_context_t::get_v1_device_by_handle(int global_handle) {
int sub_index = get_module_index(global_handle);
if (sub_index < 0 || sub_index >= (int) this->sub_hw_devices.size()) {
return NULL;
}
return (sensors_poll_device_1_t*) this->sub_hw_devices[sub_index];
}
// Returns the device pointer, or NULL if primary hal does not exist
sensors_poll_device_1_t* sensors_poll_context_t::get_primary_v1_device() {
if (sub_hw_devices.size() < 1) {
return nullptr;
}
return (sensors_poll_device_1_t*) this->sub_hw_devices[0];
}
// Returns the device version, or -1 if the handle is invalid.
int sensors_poll_context_t::get_device_version_by_handle(int handle) {
sensors_poll_device_t* v0 = this->get_v0_device_by_handle(handle);
if (v0) {
return v0->common.version;
} else {
return -1;
}
}
// Android N and hire require sensor HALs to be at least 1_3 compliant
#define HAL_VERSION_IS_COMPLIANT(version) \
(version >= SENSORS_DEVICE_API_VERSION_1_3)
// Returns true if HAL is compliant, false if HAL is not compliant or if handle is invalid
static bool halIsCompliant(sensors_poll_context_t *ctx, int handle) {
int version = ctx->get_device_version_by_handle(handle);
return version != -1 && HAL_VERSION_IS_COMPLIANT(version);
}
static bool halIsAPILevelCompliant(sensors_poll_context_t *ctx, int handle, int level) {
int version = ctx->get_device_version_by_handle(handle);
return version != -1 && (version >= level);
}
static bool halSupportDirectSensorReport(sensors_poll_device_1_t* v1) {
return v1 != nullptr && HAL_VERSION_IS_COMPLIANT(v1->common.version) &&
v1->register_direct_channel != nullptr && v1->config_direct_report != nullptr;
}
const char *apiNumToStr(int version) {
switch(version) {
case SENSORS_DEVICE_API_VERSION_1_0:
return "SENSORS_DEVICE_API_VERSION_1_0";
case SENSORS_DEVICE_API_VERSION_1_1:
return "SENSORS_DEVICE_API_VERSION_1_1";
case SENSORS_DEVICE_API_VERSION_1_2:
return "SENSORS_DEVICE_API_VERSION_1_2";
case SENSORS_DEVICE_API_VERSION_1_3:
return "SENSORS_DEVICE_API_VERSION_1_3";
case SENSORS_DEVICE_API_VERSION_1_4:
return "SENSORS_DEVICE_API_VERSION_1_4";
default:
return "UNKNOWN";
}
}
int sensors_poll_context_t::activate(int handle, int enabled) {
int retval = -EINVAL;
ALOGV("activate");
int local_handle = get_local_handle(handle);
sensors_poll_device_t* v0 = this->get_v0_device_by_handle(handle);
if (halIsCompliant(this, handle) && local_handle >= 0 && v0) {
retval = v0->activate(v0, local_handle, enabled);
} else {
ALOGE("IGNORING activate(enable %d) call to non-API-compliant sensor handle=%d !",
enabled, handle);
}
ALOGV("retval %d", retval);
return retval;
}
int sensors_poll_context_t::setDelay(int handle, int64_t ns) {
int retval = -EINVAL;
ALOGV("setDelay");
int local_handle = get_local_handle(handle);
sensors_poll_device_t* v0 = this->get_v0_device_by_handle(handle);
if (halIsCompliant(this, handle) && local_handle >= 0 && v0) {
retval = v0->setDelay(v0, local_handle, ns);
} else {
ALOGE("IGNORING setDelay() call for non-API-compliant sensor handle=%d !", handle);
}
ALOGV("retval %d", retval);
return retval;
}
void sensors_poll_context_t::copy_event_remap_handle(sensors_event_t* dest, sensors_event_t* src,
int sub_index) {
memcpy(dest, src, sizeof(struct sensors_event_t));
// A normal event's "sensor" field is a local handle. Convert it to a global handle.
// A meta-data event must have its sensor set to 0, but it has a nested event
// with a local handle that needs to be converted to a global handle.
FullHandle full_handle;
full_handle.moduleIndex = sub_index;
// If it's a metadata event, rewrite the inner payload, not the sensor field.
// If the event's sensor field is unregistered for any reason, rewrite the sensor field
// with a -1, instead of writing an incorrect but plausible sensor number, because
// get_global_handle() returns -1 for unknown FullHandles.
if (dest->type == SENSOR_TYPE_META_DATA) {
full_handle.localHandle = dest->meta_data.sensor;
dest->meta_data.sensor = get_global_handle(&full_handle);
} else {
full_handle.localHandle = dest->sensor;
dest->sensor = get_global_handle(&full_handle);
}
}
int sensors_poll_context_t::poll(sensors_event_t *data, int maxReads) {
ALOGV("poll");
int empties = 0;
int queueCount = 0;
int eventsRead = 0;
pthread_mutex_lock(&queue_mutex);
queueCount = (int)this->queues.size();
while (eventsRead == 0) {
while (empties < queueCount && eventsRead < maxReads) {
SensorEventQueue* queue = this->queues.at(this->nextReadIndex);
sensors_event_t* event = queue->peek();
if (event == NULL) {
empties++;
} else {
empties = 0;
this->copy_event_remap_handle(&data[eventsRead], event, nextReadIndex);
if (data[eventsRead].sensor == SENSORS_HANDLE_BASE - 1) {
// Bad handle, do not pass corrupted event upstream !
ALOGW("Dropping bad local handle event packet on the floor");
} else {
eventsRead++;
}
queue->dequeue();
}
this->nextReadIndex = (this->nextReadIndex + 1) % queueCount;
}
if (eventsRead == 0) {
// The queues have been scanned and none contain data, so wait.
ALOGV("poll stopping to wait for data");
waiting_for_data = true;
pthread_cond_wait(&data_available_cond, &queue_mutex);
waiting_for_data = false;
empties = 0;
}
}
pthread_mutex_unlock(&queue_mutex);
ALOGV("poll returning %d events.", eventsRead);
return eventsRead;
}
int sensors_poll_context_t::batch(int handle, int flags, int64_t period_ns, int64_t timeout) {
ALOGV("batch");
int retval = -EINVAL;
int local_handle = get_local_handle(handle);
sensors_poll_device_1_t* v1 = this->get_v1_device_by_handle(handle);
if (halIsCompliant(this, handle) && local_handle >= 0 && v1) {
retval = v1->batch(v1, local_handle, flags, period_ns, timeout);
} else {
ALOGE("IGNORING batch() call to non-API-compliant sensor handle=%d !", handle);
}
ALOGV("retval %d", retval);
return retval;
}
int sensors_poll_context_t::flush(int handle) {
ALOGV("flush");
int retval = -EINVAL;
int local_handle = get_local_handle(handle);
sensors_poll_device_1_t* v1 = this->get_v1_device_by_handle(handle);
if (halIsCompliant(this, handle) && local_handle >= 0 && v1) {
retval = v1->flush(v1, local_handle);
} else {
ALOGE("IGNORING flush() call to non-API-compliant sensor handle=%d !", handle);
}
ALOGV("retval %d", retval);
return retval;
}
int sensors_poll_context_t::inject_sensor_data(const sensors_event_t *data) {
int retval = -EINVAL;
ALOGV("inject_sensor_data");
if (data->sensor == -1) {
// operational parameter
sensors_poll_device_1_t* v1 = get_primary_v1_device();
if (v1 && v1->common.version >= SENSORS_DEVICE_API_VERSION_1_4) {
retval = v1->inject_sensor_data(v1, data);
} else {
ALOGE("IGNORED inject_sensor_data(operational param) call to non-API-compliant sensor");
return -ENOSYS;
}
} else {
// Get handle for the sensor owning the event being injected
int local_handle = get_local_handle(data->sensor);
sensors_poll_device_1_t* v1 = this->get_v1_device_by_handle(data->sensor);
if (halIsAPILevelCompliant(this, data->sensor, SENSORS_DEVICE_API_VERSION_1_4) &&
local_handle >= 0 && v1) {
// if specific sensor is used, we have to replace global sensor handle
// with local one, before passing to concrete HAL
sensors_event_t data_copy = *data;
data_copy.sensor = local_handle;
retval = v1->inject_sensor_data(v1, &data_copy);
} else {
ALOGE("IGNORED inject_sensor_data(type=%d, handle=%d) call to non-API-compliant sensor",
data->type, data->sensor);
retval = -ENOSYS;
}
}
ALOGV("retval %d", retval);
return retval;
}
int sensors_poll_context_t::register_direct_channel(const struct sensors_direct_mem_t* mem,
int channel_handle) {
int retval = -EINVAL;
ALOGV("register_direct_channel");
sensors_poll_device_1_t* v1 = get_primary_v1_device();
if (v1 && halSupportDirectSensorReport(v1)) {
retval = v1->register_direct_channel(v1, mem, channel_handle);
} else {
ALOGE("IGNORED register_direct_channel(mem=%p, handle=%d) call to non-API-compliant sensor",
mem, channel_handle);
retval = -ENOSYS;
}
ALOGV("retval %d", retval);
return retval;
}
int sensors_poll_context_t::config_direct_report(int sensor_handle,
int channel_handle,
const struct sensors_direct_cfg_t *config) {
int retval = -EINVAL;
ALOGV("config_direct_report");
if (config != nullptr) {
int local_handle = get_local_handle(sensor_handle);
sensors_poll_device_1_t* v1 = get_primary_v1_device();
if (v1 && halSupportDirectSensorReport(v1)) {
retval = v1->config_direct_report(v1, local_handle, channel_handle, config);
} else {
ALOGE("IGNORED config_direct_report(sensor=%d, channel=%d, rate_level=%d) call to "
"non-API-compliant sensor", sensor_handle, channel_handle, config->rate_level);
retval = -ENOSYS;
}
}
ALOGV("retval %d", retval);
return retval;
}
int sensors_poll_context_t::close() {
ALOGV("close");
for (std::vector<hw_device_t*>::iterator it = this->sub_hw_devices.begin();
it != this->sub_hw_devices.end(); it++) {
hw_device_t* dev = *it;
int retval = dev->close(dev);
ALOGV("retval %d", retval);
}
return 0;
}
static int device__close(struct hw_device_t *dev) {
pthread_mutex_lock(&init_modules_mutex);
sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev;
if (ctx != NULL) {
int retval = ctx->close();
delete ctx;
return retval;
}
if (sub_hw_modules != nullptr) {
delete sub_hw_modules;
sub_hw_modules = nullptr;
}
if (so_handles != nullptr) {
for (auto handle : *so_handles) {
dlclose(handle);
}
delete so_handles;
so_handles = nullptr;
}
pthread_mutex_unlock(&init_modules_mutex);
return 0;
}
static int device__activate(struct sensors_poll_device_t *dev, int handle,
int enabled) {
sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev;
return ctx->activate(handle, enabled);
}
static int device__setDelay(struct sensors_poll_device_t *dev, int handle,
int64_t ns) {
sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev;
return ctx->setDelay(handle, ns);
}
static int device__poll(struct sensors_poll_device_t *dev, sensors_event_t* data,
int count) {
sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev;
return ctx->poll(data, count);
}
static int device__batch(struct sensors_poll_device_1 *dev, int handle,
int flags, int64_t period_ns, int64_t timeout) {
sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev;
return ctx->batch(handle, flags, period_ns, timeout);
}
static int device__flush(struct sensors_poll_device_1 *dev, int handle) {
sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev;
return ctx->flush(handle);
}
static int device__inject_sensor_data(struct sensors_poll_device_1 *dev,
const sensors_event_t *data) {
sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev;
return ctx->inject_sensor_data(data);
}
static int device__register_direct_channel(struct sensors_poll_device_1 *dev,
const struct sensors_direct_mem_t* mem,
int channel_handle) {
sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev;
return ctx->register_direct_channel(mem, channel_handle);
}
static int device__config_direct_report(struct sensors_poll_device_1 *dev,
int sensor_handle,
int channel_handle,
const struct sensors_direct_cfg_t *config) {
sensors_poll_context_t* ctx = (sensors_poll_context_t*) dev;
return ctx->config_direct_report(sensor_handle, channel_handle, config);
}
static int open_sensors(const struct hw_module_t* module, const char* name,
struct hw_device_t** device);
/*
* Adds valid paths from the config file to the vector passed in.
* The vector must not be null.
*/
static std::vector<std::string> get_so_paths() {
std::vector<std::string> so_paths;
const std::vector<const char *> config_path_list(
{ MULTI_HAL_CONFIG_FILE_PATH, DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH });
std::ifstream stream;
const char *path = nullptr;
for (auto i : config_path_list) {
std::ifstream f(i);
if (f) {
stream = std::move(f);
path = i;
break;
}
}
if(!stream) {
ALOGW("No multihal config file found");
return so_paths;
}
ALOGE_IF(strcmp(path, DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH) == 0,
"Multihal configuration file path %s is not compatible with Treble "
"requirements. Please move it to %s.",
path, MULTI_HAL_CONFIG_FILE_PATH);
ALOGV("Multihal config file found at %s", path);
std::string line;
while (std::getline(stream, line)) {
ALOGV("config file line: '%s'", line.c_str());
so_paths.push_back(line);
}
return so_paths;
}
/*
* Ensures that the sub-module array is initialized.
* This can be first called from get_sensors_list or from open_sensors.
*/
static void lazy_init_modules() {
pthread_mutex_lock(&init_modules_mutex);
if (sub_hw_modules != NULL) {
pthread_mutex_unlock(&init_modules_mutex);
return;
}
std::vector<std::string> so_paths(get_so_paths());
// dlopen the module files and cache their module symbols in sub_hw_modules
sub_hw_modules = new std::vector<hw_module_t *>();
so_handles = new std::vector<void *>();
dlerror(); // clear any old errors
const char* sym = HAL_MODULE_INFO_SYM_AS_STR;
for (const auto &s : so_paths) {
const char* path = s.c_str();
void* lib_handle = dlopen(path, RTLD_LAZY);
if (lib_handle == NULL) {
ALOGW("dlerror(): %s", dlerror());
} else {
ALOGI("Loaded library from %s", path);
ALOGV("Opening symbol \"%s\"", sym);
// clear old errors
dlerror();
struct hw_module_t* module = (hw_module_t*) dlsym(lib_handle, sym);
const char* error;
if ((error = dlerror()) != NULL) {
ALOGW("Error calling dlsym: %s", error);
} else if (module == NULL) {
ALOGW("module == NULL");
} else {
ALOGV("Loaded symbols from \"%s\"", sym);
sub_hw_modules->push_back(module);
so_handles->push_back(lib_handle);
lib_handle = nullptr;
}
}
if (lib_handle != nullptr) {
dlclose(lib_handle);
}
}
pthread_mutex_unlock(&init_modules_mutex);
}
/*
* Lazy-initializes global_sensors_count, global_sensors_list, and module_sensor_handles.
*/
static void lazy_init_sensors_list() {
ALOGV("lazy_init_sensors_list");
pthread_mutex_lock(&init_sensors_mutex);
if (global_sensors_list != NULL) {
// already initialized
pthread_mutex_unlock(&init_sensors_mutex);
ALOGV("lazy_init_sensors_list - early return");
return;
}
ALOGV("lazy_init_sensors_list needs to do work");
lazy_init_modules();
// Count all the sensors, then allocate an array of blanks.
global_sensors_count = 0;
const struct sensor_t *subhal_sensors_list;
for (std::vector<hw_module_t*>::iterator it = sub_hw_modules->begin();
it != sub_hw_modules->end(); it++) {
struct sensors_module_t *module = (struct sensors_module_t*) *it;
global_sensors_count += module->get_sensors_list(module, &subhal_sensors_list);
ALOGV("increased global_sensors_count to %d", global_sensors_count);
}
// The global_sensors_list is full of consts.
// Manipulate this non-const list, and point the const one to it when we're done.
sensor_t* mutable_sensor_list = new sensor_t[global_sensors_count];
// index of the next sensor to set in mutable_sensor_list
int mutable_sensor_index = 0;
int module_index = 0;
for (std::vector<hw_module_t*>::iterator it = sub_hw_modules->begin();
it != sub_hw_modules->end(); it++) {
hw_module_t *hw_module = *it;
ALOGV("examine one module");
// Read the sub-module's sensor list.
struct sensors_module_t *module = (struct sensors_module_t*) hw_module;
int module_sensor_count = module->get_sensors_list(module, &subhal_sensors_list);
ALOGV("the module has %d sensors", module_sensor_count);
// Copy the HAL's sensor list into global_sensors_list,
// with the handle changed to be a global handle.
for (int i = 0; i < module_sensor_count; i++) {
ALOGV("examining one sensor");
const struct sensor_t *local_sensor = &subhal_sensors_list[i];
int local_handle = local_sensor->handle;
memcpy(&mutable_sensor_list[mutable_sensor_index], local_sensor,
sizeof(struct sensor_t));
// sensor direct report is only for primary module
if (module_index != 0) {
mutable_sensor_list[mutable_sensor_index].flags &=
~(SENSOR_FLAG_MASK_DIRECT_REPORT | SENSOR_FLAG_MASK_DIRECT_CHANNEL);
}
// Overwrite the global version's handle with a global handle.
int global_handle = assign_global_handle(module_index, local_handle);
mutable_sensor_list[mutable_sensor_index].handle = global_handle;
ALOGV("module_index %d, local_handle %d, global_handle %d",
module_index, local_handle, global_handle);
mutable_sensor_index++;
}
module_index++;
}
// Set the const static global_sensors_list to the mutable one allocated by this function.
global_sensors_list = mutable_sensor_list;
pthread_mutex_unlock(&init_sensors_mutex);
ALOGV("end lazy_init_sensors_list");
}
static int module__get_sensors_list(__unused struct sensors_module_t* module,
struct sensor_t const** list) {
ALOGV("module__get_sensors_list start");
lazy_init_sensors_list();
*list = global_sensors_list;
ALOGV("global_sensors_count: %d", global_sensors_count);
for (int i = 0; i < global_sensors_count; i++) {
ALOGV("sensor type: %d", global_sensors_list[i].type);
}
return global_sensors_count;
}
static struct hw_module_methods_t sensors_module_methods = {
.open = open_sensors
};
struct sensors_module_t HAL_MODULE_INFO_SYM = {
.common = {
.tag = HARDWARE_MODULE_TAG,
.version_major = 1,
.version_minor = 1,
.id = SENSORS_HARDWARE_MODULE_ID,
.name = "MultiHal Sensor Module",
.author = "Google, Inc",
.methods = &sensors_module_methods,
.dso = NULL,
.reserved = {0},
},
.get_sensors_list = module__get_sensors_list
};
struct sensors_module_t *get_multi_hal_module_info() {
return (&HAL_MODULE_INFO_SYM);
}
static int open_sensors(const struct hw_module_t* hw_module, const char* name,
struct hw_device_t** hw_device_out) {
ALOGV("open_sensors begin...");
lazy_init_modules();
// Create proxy device, to return later.
sensors_poll_context_t *dev = new sensors_poll_context_t();
memset(dev, 0, sizeof(sensors_poll_device_1_t));
dev->proxy_device.common.tag = HARDWARE_DEVICE_TAG;
dev->proxy_device.common.version = SENSORS_DEVICE_API_VERSION_1_4;
dev->proxy_device.common.module = const_cast<hw_module_t*>(hw_module);
dev->proxy_device.common.close = device__close;
dev->proxy_device.activate = device__activate;
dev->proxy_device.setDelay = device__setDelay;
dev->proxy_device.poll = device__poll;
dev->proxy_device.batch = device__batch;
dev->proxy_device.flush = device__flush;
dev->proxy_device.inject_sensor_data = device__inject_sensor_data;
dev->proxy_device.register_direct_channel = device__register_direct_channel;
dev->proxy_device.config_direct_report = device__config_direct_report;
dev->nextReadIndex = 0;
// Open() the subhal modules. Remember their devices in a vector parallel to sub_hw_modules.
for (std::vector<hw_module_t*>::iterator it = sub_hw_modules->begin();
it != sub_hw_modules->end(); it++) {
sensors_module_t *sensors_module = (sensors_module_t*) *it;
struct hw_device_t* sub_hw_device;
int sub_open_result = sensors_module->common.methods->open(*it, name, &sub_hw_device);
if (!sub_open_result) {
if (!HAL_VERSION_IS_COMPLIANT(sub_hw_device->version)) {
ALOGE("SENSORS_DEVICE_API_VERSION_1_3 or newer is required for all sensor HALs");
ALOGE("This HAL reports non-compliant API level : %s",
apiNumToStr(sub_hw_device->version));
ALOGE("Sensors belonging to this HAL will get ignored !");
}
dev->addSubHwDevice(sub_hw_device);
}
}
// Prepare the output param and return
*hw_device_out = &dev->proxy_device.common;
ALOGV("...open_sensors end");
return 0;
}

View file

@ -1,29 +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_LIBHARDWARE_MODULES_SENSORS_MULTIHAL_H_
#define HARDWARE_LIBHARDWARE_MODULES_SENSORS_MULTIHAL_H_
#include <hardware/sensors.h>
#include <hardware/hardware.h>
static const char* MULTI_HAL_CONFIG_FILE_PATH = "/vendor/etc/sensors/hals.conf";
// Depracated because system partition HAL config file does not satisfy treble requirements.
static const char* DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH = "/system/etc/sensors/hals.conf";
struct sensors_module_t *get_multi_hal_module_info(void);
#endif // HARDWARE_LIBHARDWARE_MODULES_SENSORS_MULTIHAL_H_

View file

@ -2,4 +2,3 @@ type adsprpcd_file, file_type;
type bt_firmware_file, file_type; type bt_firmware_file, file_type;
type firmware_file, file_type; type firmware_file, file_type;
type persist_file, file_type; type persist_file, file_type;
type proc_touchpanel, fs_type, proc_type;

View file

@ -5,7 +5,6 @@
/persist(/.*)? u:object_r:persist_file:s0 /persist(/.*)? u:object_r:persist_file:s0
# HALs # HALs
/system/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service\.realme_sdm710 u:object_r:hal_fingerprint_sdm710_exec:s0
/system/bin/hw/android\.hardware\.power@1\.2-service-qti u:object_r:hal_power_default_exec:s0 /system/bin/hw/android\.hardware\.power@1\.2-service-qti u:object_r:hal_power_default_exec:s0
/(product|system/product)/vendor_overlay/[0-9]+/bin/hw/android\.hardware\.light@2\.0-service u:object_r:hal_light_default_exec:s0 /(product|system/product)/vendor_overlay/[0-9]+/bin/hw/android\.hardware\.light@2\.0-service u:object_r:hal_light_default_exec:s0
/(product|system/product)/vendor_overlay/[0-9]+/bin/hw/android\.hardware\.usb@1\.0-service u:object_r:hal_usb_default_exec:s0 /(product|system/product)/vendor_overlay/[0-9]+/bin/hw/android\.hardware\.usb@1\.0-service u:object_r:hal_usb_default_exec:s0

View file

@ -1 +0,0 @@
genfscon proc /touchpanel u:object_r:proc_touchpanel:s0

View file

@ -1,6 +0,0 @@
type hal_fingerprint_sdm710, coredomain, domain;
hal_client_domain(hal_fingerprint_sdm710, hal_fingerprint)
hal_server_domain(hal_fingerprint_sdm710, hal_fingerprint)
type hal_fingerprint_sdm710_exec, vendor_file_type, exec_type, file_type;
init_daemon_domain(hal_fingerprint_sdm710)

View file

@ -1,2 +0,0 @@
allow hal_power proc_touchpanel:dir search;
allow hal_power proc_touchpanel:file w_file_perms;

View file

@ -1,5 +1,2 @@
allow init proc_touchpanel:dir search;
allow init proc_touchpanel:file { write setattr open};
# Allow init to mount vendor configs # Allow init to mount vendor configs
allow init vendor_configs_file:dir mounton; allow init vendor_configs_file:dir mounton;