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

Commit 77356fa0 authored by Pierre-Hugues Husson's avatar Pierre-Hugues Husson Committed by Bruno Martins
Browse files

surfaceflinger: Add support for Udfps extension lib



 * Supports changed z Udfps order
 * Supports changed Udfps usage bits

TheScarastic: Adapt to extension lib and support 12 BiometricPrompt
ArianK16a: Adapt layer name to UdfpsControllerOverlay for Android 13
    and only compare the prefix. Drop the BufferQueueLayer change
    because it seems unnecessary.

Co-authored-by: default avatarTheScarastic <warabhishek@gmail.com>
Change-Id: Id95aa73e06b4223a6b4f05c69fa2fc494f9a97b1
parent 259f1c9c
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -61,7 +61,10 @@ cc_defaults {

cc_library {
    name: "libcompositionengine",
    defaults: ["libcompositionengine_defaults"],
    defaults: [
        "libcompositionengine_defaults",
        "surfaceflinger_udfps_lib_defaults",
    ],
    srcs: [
        "src/planner/CachedSet.cpp",
        "src/planner/Flattener.cpp",
@@ -83,6 +86,7 @@ cc_library {
        "src/OutputLayer.cpp",
        "src/OutputLayerCompositionState.cpp",
        "src/RenderSurface.cpp",
        "src/UdfpsExtension.cpp",
    ],
    local_include_dirs: ["include"],
    export_include_dirs: ["include"],
@@ -111,6 +115,14 @@ cc_library {
    export_include_dirs: ["include"],
}

cc_library_static {
    name: "surfaceflinger_udfps_lib",
    srcs: [
        "src/UdfpsExtension.cpp",
    ],
    export_include_dirs: ["include"],
}

cc_test {
    name: "libcompositionengine_test",
    test_suites: ["device-tests"],
+29 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021-2022 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 <stdint.h>

#ifndef __UDFPS_EXTENSION__H__
#define __UDFPS_EXTENSION__H__

#define UDFPS_BIOMETRIC_PROMPT_LAYER_NAME "BiometricPrompt"
#define UDFPS_LAYER_NAME "UdfpsControllerOverlay"
#define UDFPS_TOUCHED_LAYER_NAME "SurfaceView[UdfpsControllerOverlay](BLAST)"

extern uint32_t getUdfpsZOrder(uint32_t z, bool touched);
extern uint64_t getUdfpsUsageBits(uint64_t usageBits, bool touched);

#endif /* __UDFPS_EXTENSION__H__ */
+12 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <compositionengine/DisplayColorProfile.h>
#include <compositionengine/LayerFECompositionState.h>
#include <compositionengine/Output.h>
#include <compositionengine/UdfpsExtension.h>
#include <compositionengine/impl/HwcBufferCache.h>
#include <compositionengine/impl/OutputCompositionState.h>
#include <compositionengine/impl/OutputLayer.h>
@@ -454,7 +455,17 @@ void OutputLayer::writeOutputDependentGeometryStateToHWC(HWC2::Layer* hwcLayer,
              sourceCrop.bottom, to_string(error).c_str(), static_cast<int32_t>(error));
    }

    if (auto error = hwcLayer->setZOrder(z); error != hal::Error::NONE) {
    uint32_t z_udfps = z;
    if ((strncmp(getLayerFE().getDebugName(), UDFPS_LAYER_NAME, strlen(UDFPS_LAYER_NAME)) == 0) ||
        (strncmp(getLayerFE().getDebugName(), UDFPS_BIOMETRIC_PROMPT_LAYER_NAME,
                 strlen(UDFPS_BIOMETRIC_PROMPT_LAYER_NAME)) == 0)) {
        z_udfps = getUdfpsZOrder(z, false);
    } else if (strncmp(getLayerFE().getDebugName(), UDFPS_TOUCHED_LAYER_NAME,
                       strlen(UDFPS_TOUCHED_LAYER_NAME)) == 0) {
        z_udfps = getUdfpsZOrder(z, true);
    }

    if (auto error = hwcLayer->setZOrder(z_udfps); error != hal::Error::NONE) {
        ALOGE("[%s] Failed to set Z %u: %s (%d)", getLayerFE().getDebugName(), z,
              to_string(error).c_str(), static_cast<int32_t>(error));
    }
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright 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 TARGET_PROVIDES_UDFPS_LIB
#include <compositionengine/UdfpsExtension.h>

uint32_t getUdfpsZOrder(uint32_t z, __unused bool touched) {
    return z;
}

uint64_t getUdfpsUsageBits(uint64_t usageBits, __unused bool touched) {
    return usageBits;
}
#endif