Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1188a0c authored by Jeff Pu's avatar Jeff Pu Committed by Android (Google) Code Review
Browse files

Merge "Fingerprint virtual HAL checkin (part 1) - udfps and side fingerprint...

Merge "Fingerprint virtual HAL checkin (part 1) - udfps and side fingerprint sensor instance - sensor location configuration - misc. fixes/workarounds"
parents 0bd64f4c 63f33c79
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@ cc_binary {
    local_include_dirs: ["include"],
    srcs: [
        "FakeFingerprintEngine.cpp",
        "FakeFingerprintEngineRear.cpp",
        "FakeFingerprintEngineUdfps.cpp",
        "FakeFingerprintEngineSide.cpp",
        "Fingerprint.cpp",
        "Session.cpp",
        "main.cpp",
@@ -41,6 +44,32 @@ cc_test {
    shared_libs: [
        "libbase",
        "libbinder_ndk",
        "android.hardware.biometrics.common.thread",
    ],
    static_libs: [
        "libandroid.hardware.biometrics.fingerprint.VirtualProps",
        "android.hardware.biometrics.fingerprint-V2-ndk",
        "android.hardware.biometrics.common-V2-ndk",
        "android.hardware.keymaster-V3-ndk",
        "android.hardware.biometrics.common.util",
    ],
    vendor: true,
    test_suites: ["general-tests"],
    require_root: true,
}

cc_test {
    name: "android.hardware.biometrics.fingerprint.FakeFingerprintEngineUdfpsTest",
    local_include_dirs: ["include"],
    srcs: [
        "tests/FakeFingerprintEngineUdfpsTest.cpp",
        "FakeFingerprintEngineUdfps.cpp",
        "FakeFingerprintEngine.cpp",
    ],
    shared_libs: [
        "libbase",
        "libbinder_ndk",
        "android.hardware.biometrics.common.thread",
    ],
    static_libs: [
        "libandroid.hardware.biometrics.fingerprint.VirtualProps",
+66 −1
Original line number Diff line number Diff line
@@ -15,8 +15,10 @@
 */

#include "FakeFingerprintEngine.h"
#include "Fingerprint.h"

#include <android-base/logging.h>
#include <android-base/parseint.h>

#include <fingerprint.sysprop.h>

@@ -24,6 +26,7 @@
#include "util/Util.h"

using namespace ::android::fingerprint::virt;
using ::android::base::ParseInt;

namespace aidl::android::hardware::biometrics::fingerprint {

@@ -172,6 +175,11 @@ void FakeFingerprintEngine::enumerateEnrollmentsImpl(ISessionCallback* cb) {
    BEGIN_OP(0);

    std::vector<int32_t> ids;
    // There are some enrollment sync issue with framework, which results in
    //  a single template removal during the very firt sync command after reboot.
    //  This is a workaround for now. TODO(b/243129174)
    ids.push_back(-1);

    for (auto& enrollment : FingerprintHalProperties::enrollments()) {
        auto id = enrollment.value_or(0);
        if (id > 0) {
@@ -203,7 +211,11 @@ void FakeFingerprintEngine::removeEnrollmentsImpl(ISessionCallback* cb,

void FakeFingerprintEngine::getAuthenticatorIdImpl(ISessionCallback* cb) {
    BEGIN_OP(0);
    cb->onAuthenticatorIdRetrieved(FingerprintHalProperties::authenticator_id().value_or(0));
    int64_t authenticatorId = FingerprintHalProperties::authenticator_id().value_or(0);
    if (FingerprintHalProperties::enrollments().size() > 0 && authenticatorId == 0) {
        authenticatorId = 99999999;  // default authenticatorId, TODO(b/230515082)
    }
    cb->onAuthenticatorIdRetrieved(authenticatorId);
}

void FakeFingerprintEngine::invalidateAuthenticatorIdImpl(ISessionCallback* cb) {
@@ -221,4 +233,57 @@ void FakeFingerprintEngine::resetLockoutImpl(ISessionCallback* cb,
    cb->onLockoutCleared();
}

ndk::ScopedAStatus FakeFingerprintEngine::onPointerDownImpl(int32_t /*pointerId*/, int32_t /*x*/,
                                                            int32_t /*y*/, float /*minor*/,
                                                            float /*major*/) {
    BEGIN_OP(0);
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus FakeFingerprintEngine::onPointerUpImpl(int32_t /*pointerId*/) {
    BEGIN_OP(0);
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus FakeFingerprintEngine::onUiReadyImpl() {
    BEGIN_OP(0);
    return ndk::ScopedAStatus::ok();
}

bool FakeFingerprintEngine::getSensorLocationConfig(SensorLocation& out) {
    auto loc = FingerprintHalProperties::sensor_location().value_or("");
    auto isValidStr = false;
    auto dim = Util::split(loc, ":");

    if (dim.size() < 3 or dim.size() > 4) {
        if (!loc.empty()) LOG(WARNING) << "Invalid sensor location input (x:y:radius):" + loc;
        return false;
    } else {
        int32_t x, y, r;
        std::string d = "";
        if (dim.size() >= 3) {
            isValidStr = ParseInt(dim[0], &x) && ParseInt(dim[1], &y) && ParseInt(dim[2], &r);
        }
        if (dim.size() >= 4) {
            d = dim[3];
        }
        if (isValidStr) out = {0, x, y, r, d};

        return isValidStr;
    }
}
SensorLocation FakeFingerprintEngine::getSensorLocation() {
    SensorLocation location;

    if (getSensorLocationConfig(location)) {
        return location;
    } else {
        return defaultSensorLocation();
    }
}

SensorLocation FakeFingerprintEngine::defaultSensorLocation() {
    return {0 /* displayId (not used) */, 0 /* sensorLocationX */, 0 /* sensorLocationY */,
            0 /* sensorRadius */, "" /* display */};
}
}  // namespace aidl::android::hardware::biometrics::fingerprint
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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 "FakeFingerprintEngineRear.h"

#include <android-base/logging.h>
#include <android-base/parseint.h>

#include <fingerprint.sysprop.h>

#include "util/CancellationSignal.h"
#include "util/Util.h"

using namespace ::android::fingerprint::virt;

namespace aidl::android::hardware::biometrics::fingerprint {}
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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 "FakeFingerprintEngineSide.h"

#include <android-base/logging.h>

#include <fingerprint.sysprop.h>

#include "util/CancellationSignal.h"
#include "util/Util.h"

using namespace ::android::fingerprint::virt;

namespace aidl::android::hardware::biometrics::fingerprint {

SensorLocation FakeFingerprintEngineSide::defaultSensorLocation() {
    SensorLocation location;

    return {0 /* displayId (not used) */, defaultSensorLocationX /* sensorLocationX */,
            defaultSensorLocationY /* sensorLocationY */, defaultSensorRadius /* sensorRadius */,
            "" /* display */};
}
}  // namespace aidl::android::hardware::biometrics::fingerprint
+58 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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 "FakeFingerprintEngineUdfps.h"

#include <android-base/logging.h>

#include <fingerprint.sysprop.h>

#include "util/CancellationSignal.h"
#include "util/Util.h"

using namespace ::android::fingerprint::virt;

namespace aidl::android::hardware::biometrics::fingerprint {

SensorLocation FakeFingerprintEngineUdfps::defaultSensorLocation() {
    return {0 /* displayId (not used) */, defaultSensorLocationX /* sensorLocationX */,
            defaultSensorLocationY /* sensorLocationY */, defaultSensorRadius /* sensorRadius */,
            "" /* display */};
}

ndk::ScopedAStatus FakeFingerprintEngineUdfps::onPointerDownImpl(int32_t /*pointerId*/,
                                                                 int32_t /*x*/, int32_t /*y*/,
                                                                 float /*minor*/, float /*major*/) {
    BEGIN_OP(0);

    // TODO(b/230515082): if need to handle display touch events

    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus FakeFingerprintEngineUdfps::onPointerUpImpl(int32_t /*pointerId*/) {
    BEGIN_OP(0);
    // TODO(b/230515082)
    return ndk::ScopedAStatus::ok();
}

ndk::ScopedAStatus FakeFingerprintEngineUdfps::onUiReadyImpl() {
    BEGIN_OP(0);
    // TODO(b/230515082)
    return ndk::ScopedAStatus::ok();
}

}  // namespace aidl::android::hardware::biometrics::fingerprint
Loading