mirror of
https://github.com/team-infusion-developers/android_hardware_samsung.git
synced 2024-11-06 21:55:41 +00:00
commit
cf3be66482
11 changed files with 289 additions and 30 deletions
42
hidl/consumerir/Android.mk
Normal file
42
hidl/consumerir/Android.mk
Normal file
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
# Copyright (C) 2020 The LineageOS Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
ConsumerIr.cpp \
|
||||
service.cpp
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libbase \
|
||||
libbinder \
|
||||
libhidlbase \
|
||||
libhidltransport \
|
||||
libutils \
|
||||
android.hardware.ir@1.0
|
||||
|
||||
LOCAL_MODULE := android.hardware.ir@1.0-service.samsung
|
||||
LOCAL_INIT_RC := android.hardware.ir@1.0-service.samsung.rc
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_OWNER := samsung
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
61
hidl/consumerir/ConsumerIr.cpp
Normal file
61
hidl/consumerir/ConsumerIr.cpp
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (C) 2020 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.
|
||||
*/
|
||||
|
||||
#include "ConsumerIr.h"
|
||||
|
||||
#include <samsung_ir.h>
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/strings.h>
|
||||
|
||||
using android::base::Join;
|
||||
using android::base::WriteStringToFile;
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace ir {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
// Methods from ::android::hardware::ir::V1_0::IConsumerIr follow.
|
||||
Return<bool> ConsumerIr::transmit(int32_t carrierFreq, const hidl_vec<int32_t>& pattern) {
|
||||
float factor;
|
||||
std::vector<int32_t> buffer{carrierFreq};
|
||||
|
||||
#ifndef MS_IR_SIGNAL
|
||||
// Calculate factor of conversion from microseconds to pulses
|
||||
factor = 1000000 / carrierFreq;
|
||||
#else
|
||||
factor = 1;
|
||||
#endif
|
||||
|
||||
for (const int32_t& number : pattern) {
|
||||
buffer.emplace_back(number / factor);
|
||||
}
|
||||
|
||||
return WriteStringToFile(Join(buffer, ','), IR_PATH, true);
|
||||
}
|
||||
|
||||
Return<void> ConsumerIr::getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) {
|
||||
_hidl_cb(true, consumerirFreqs);
|
||||
return Void();
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace ir
|
||||
} // namespace hardware
|
||||
} // namespace android
|
46
hidl/consumerir/ConsumerIr.h
Normal file
46
hidl/consumerir/ConsumerIr.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_IR_V1_0_CONSUMERIR_H
|
||||
#define ANDROID_HARDWARE_IR_V1_0_CONSUMERIR_H
|
||||
|
||||
#include <android/hardware/ir/1.0/IConsumerIr.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace ir {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
class ConsumerIr : public IConsumerIr {
|
||||
public:
|
||||
// Methods from ::android::hardware::ir::V1_0::IConsumerIr follow.
|
||||
Return<bool> transmit(int32_t carrierFreq, const hidl_vec<int32_t>& pattern) override;
|
||||
Return<void> getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) override;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace ir
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_IR_V1_0_CONSUMERIR_H
|
|
@ -0,0 +1,4 @@
|
|||
service vendor.ir-hal-1-0 /vendor/bin/hw/android.hardware.ir@1.0-service.samsung
|
||||
class hal
|
||||
user system
|
||||
group system
|
52
hidl/consumerir/include/samsung_ir.h
Normal file
52
hidl/consumerir/include/samsung_ir.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2020 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SAMSUNG_CONSUMERIR_H
|
||||
#define SAMSUNG_CONSUMERIR_H
|
||||
|
||||
#include <android/hardware/ir/1.0/IConsumerIr.h>
|
||||
|
||||
using android::hardware::ir::V1_0::ConsumerIrFreqRange;
|
||||
|
||||
/*
|
||||
* Board specific nodes
|
||||
*
|
||||
* If your kernel exposes these controls in another place, you can either
|
||||
* symlink to the locations given here, or override this header in your
|
||||
* device tree.
|
||||
*/
|
||||
#define IR_PATH "/sys/class/sec/sec_ir/ir_send"
|
||||
|
||||
/*
|
||||
* Board specific configs
|
||||
*
|
||||
* If your device needs a different configuration, you
|
||||
* can override this header in your device tree
|
||||
*/
|
||||
// Some devices need MS_IR_SIGNAL to avoid ms to pulses conversionn
|
||||
//#define MS_IR_SIGNAL
|
||||
|
||||
static const std::vector<ConsumerIrFreqRange> consumerirFreqs = {
|
||||
{.min = 30000, .max = 30000},
|
||||
{.min = 33000, .max = 33000},
|
||||
{.min = 36000, .max = 36000},
|
||||
{.min = 38000, .max = 38000},
|
||||
{.min = 40000, .max = 40000},
|
||||
{.min = 56000, .max = 56000},
|
||||
};
|
||||
|
||||
#endif // SAMSUNG_CONSUMERIR_H
|
54
hidl/consumerir/service.cpp
Normal file
54
hidl/consumerir/service.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2020 The LineageOS Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.ir@1.0-service.samsung"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
#include "ConsumerIr.h"
|
||||
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
using android::hardware::ir::V1_0::IConsumerIr;
|
||||
using android::hardware::ir::V1_0::implementation::ConsumerIr;
|
||||
|
||||
using android::OK;
|
||||
using android::sp;
|
||||
using android::status_t;
|
||||
|
||||
int main() {
|
||||
sp<IConsumerIr> ir = new ConsumerIr();
|
||||
|
||||
configureRpcThreadpool(1, true);
|
||||
|
||||
status_t status = ir->registerAsService();
|
||||
|
||||
if (status != OK) {
|
||||
LOG(ERROR) << "Could not register service for IR HAL";
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
LOG(INFO) << "IR HAL service is Ready.";
|
||||
joinRpcThreadpool();
|
||||
|
||||
shutdown:
|
||||
// In normal operation, we don't expect the thread pool to shutdown
|
||||
LOG(ERROR) << "IR HAL failed to join thread pool.";
|
||||
return 1;
|
||||
}
|
|
@ -31,10 +31,18 @@ LOCAL_SHARED_LIBRARIES := \
|
|||
libutils \
|
||||
android.hardware.biometrics.fingerprint@2.1
|
||||
|
||||
ifeq ($(TARGET_SEC_FP_CALL_NOTIFY_ON_CANCEL),true)
|
||||
LOCAL_CFLAGS += -DCALL_NOTIFY_ON_CANCEL
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_SEC_FP_USES_PERCENTAGE_SAMPLES),true)
|
||||
LOCAL_CFLAGS += -DUSES_PERCENTAGE_SAMPLES
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_SEC_FP_CALL_CANCEL_ON_ENROLL_COMPLETION),true)
|
||||
LOCAL_CFLAGS += -DCALL_CANCEL_ON_ENROLL_COMPLETION
|
||||
endif
|
||||
|
||||
LOCAL_MODULE := android.hardware.biometrics.fingerprint@2.1-service.samsung
|
||||
LOCAL_INIT_RC := android.hardware.biometrics.fingerprint@2.1-service.samsung.rc
|
||||
LOCAL_MODULE_RELATIVE_PATH := hw
|
||||
|
|
|
@ -173,7 +173,18 @@ Return<uint64_t> BiometricsFingerprint::getAuthenticatorId() {
|
|||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::cancel() {
|
||||
return ErrorFilter(ss_fingerprint_cancel());
|
||||
int32_t ret = ss_fingerprint_cancel();
|
||||
|
||||
#ifdef CALL_NOTIFY_ON_CANCEL
|
||||
if (ret == 0) {
|
||||
fingerprint_msg_t msg{};
|
||||
msg.type = FINGERPRINT_ERROR;
|
||||
msg.data.error = FINGERPRINT_ERROR_CANCELED;
|
||||
notify(&msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ErrorFilter(ret);
|
||||
}
|
||||
|
||||
Return<RequestStatus> BiometricsFingerprint::enumerate() {
|
||||
|
@ -288,19 +299,22 @@ void BiometricsFingerprint::notify(const fingerprint_msg_t* msg) {
|
|||
}
|
||||
} break;
|
||||
case FINGERPRINT_TEMPLATE_ENROLLING:
|
||||
#ifdef USES_PERCENTAGE_SAMPLES
|
||||
const_cast<fingerprint_msg_t*>(msg)->data.enroll.samples_remaining =
|
||||
100 - msg->data.enroll.samples_remaining;
|
||||
#endif
|
||||
#ifdef CALL_CANCEL_ON_ENROLL_COMPLETION
|
||||
if(msg->data.enroll.samples_remaining == 0) {
|
||||
thisPtr->ss_fingerprint_cancel();
|
||||
}
|
||||
#endif
|
||||
LOG(DEBUG) << "onEnrollResult(fid=" << msg->data.enroll.finger.fid
|
||||
<< ", gid=" << msg->data.enroll.finger.gid
|
||||
<< ", rem=" << msg->data.enroll.samples_remaining << ")";
|
||||
if (thisPtr->mClientCallback
|
||||
if (!thisPtr->mClientCallback
|
||||
->onEnrollResult(devId, msg->data.enroll.finger.fid,
|
||||
msg->data.enroll.finger.gid, msg->data.enroll.samples_remaining)
|
||||
.isOk()) {
|
||||
#ifdef USES_PERCENTAGE_SAMPLES
|
||||
fingerprint_msg_t* newMsg = (fingerprint_msg_t*)msg;
|
||||
newMsg->data.enroll.samples_remaining = 100 - msg->data.enroll.samples_remaining;
|
||||
msg = newMsg;
|
||||
#endif
|
||||
} else {
|
||||
LOG(ERROR) << "failed to invoke fingerprint onEnrollResult callback";
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
BasedOnStyle: Google
|
||||
AccessModifierOffset: -2
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
ColumnLimit: 100
|
||||
CommentPragmas: NOLINT:.*
|
||||
DerivePointerAlignment: false
|
||||
IndentWidth: 4
|
||||
PointerAlignment: Left
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
PenaltyExcessCharacter: 32
|
|
@ -1,11 +0,0 @@
|
|||
BasedOnStyle: Google
|
||||
AccessModifierOffset: -2
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
ColumnLimit: 100
|
||||
CommentPragmas: NOLINT:.*
|
||||
DerivePointerAlignment: false
|
||||
IndentWidth: 4
|
||||
PointerAlignment: Left
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
PenaltyExcessCharacter: 32
|
Loading…
Reference in a new issue