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

Commit f1c120f6 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10658274 from 1700661a to udc-qpr1-release

Change-Id: Ife12ba77091fb7d2c8433a96c5f2bd0ef7e0e523
parents 84a489d6 1700661a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -29,7 +29,7 @@ namespace android {
// --- InputVerifier ---
// --- InputVerifier ---


InputVerifier::InputVerifier(const std::string& name)
InputVerifier::InputVerifier(const std::string& name)
      : mVerifier(android::input::verifier::create(name)){};
      : mVerifier(android::input::verifier::create(rust::String::lossy(name))){};


Result<void> InputVerifier::processMovement(int32_t deviceId, int32_t action, uint32_t pointerCount,
Result<void> InputVerifier::processMovement(int32_t deviceId, int32_t action, uint32_t pointerCount,
                                            const PointerProperties* pointerProperties,
                                            const PointerProperties* pointerProperties,
+1 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ cc_test {
        "InputDevice_test.cpp",
        "InputDevice_test.cpp",
        "InputEvent_test.cpp",
        "InputEvent_test.cpp",
        "InputPublisherAndConsumer_test.cpp",
        "InputPublisherAndConsumer_test.cpp",
        "InputVerifier_test.cpp",
        "MotionPredictor_test.cpp",
        "MotionPredictor_test.cpp",
        "RingBuffer_test.cpp",
        "RingBuffer_test.cpp",
        "TfLiteMotionPredictor_test.cpp",
        "TfLiteMotionPredictor_test.cpp",
+29 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2023 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 <gtest/gtest.h>
#include <input/InputVerifier.h>
#include <string>

namespace android {

TEST(InputVerifierTest, CreationWithInvalidUtfStringDoesNotCrash) {
    constexpr char bytes[] = {static_cast<char>(0xC0), static_cast<char>(0x80)};
    const std::string name(bytes, sizeof(bytes));
    InputVerifier verifier(name);
}

} // namespace android
+29 −11
Original line number Original line Diff line number Diff line
@@ -5522,6 +5522,9 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
        // Turn off the display
        // Turn off the display


        if (displayId == mActiveDisplayId) {
        if (displayId == mActiveDisplayId) {
            if (const auto display = getActivatableDisplay()) {
                onActiveDisplayChangedLocked(activeDisplay.get(), *display);
            } else {
                if (setSchedFifo(false) != NO_ERROR) {
                if (setSchedFifo(false) != NO_ERROR) {
                    ALOGW("Failed to set SCHED_OTHER after powering off active display: %s",
                    ALOGW("Failed to set SCHED_OTHER after powering off active display: %s",
                          strerror(errno));
                          strerror(errno));
@@ -5536,6 +5539,7 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& display, hal:
                    mScheduler->enableSyntheticVsync();
                    mScheduler->enableSyntheticVsync();
                }
                }
            }
            }
        }


        // Disable VSYNC before turning off the display.
        // Disable VSYNC before turning off the display.
        requestHardwareVsync(displayId, false);
        requestHardwareVsync(displayId, false);
@@ -7951,6 +7955,20 @@ void SurfaceFlinger::onActiveDisplaySizeChanged(const DisplayDevice& activeDispl
    getRenderEngine().onActiveDisplaySizeChanged(activeDisplay.getSize());
    getRenderEngine().onActiveDisplaySizeChanged(activeDisplay.getSize());
}
}


sp<DisplayDevice> SurfaceFlinger::getActivatableDisplay() const {
    if (mPhysicalDisplays.size() == 1) return nullptr;

    // TODO(b/255635821): Choose the pacesetter display, considering both internal and external
    // displays. For now, pick the other internal display, assuming a dual-display foldable.
    return findDisplay([this](const DisplayDevice& display) REQUIRES(mStateLock) {
        const auto idOpt = PhysicalDisplayId::tryCast(display.getId());
        return idOpt && *idOpt != mActiveDisplayId && display.isPoweredOn() &&
                mPhysicalDisplays.get(*idOpt)
                        .transform(&PhysicalDisplay::isInternal)
                        .value_or(false);
    });
}

void SurfaceFlinger::onActiveDisplayChangedLocked(const DisplayDevice* inactiveDisplayPtr,
void SurfaceFlinger::onActiveDisplayChangedLocked(const DisplayDevice* inactiveDisplayPtr,
                                                  const DisplayDevice& activeDisplay) {
                                                  const DisplayDevice& activeDisplay) {
    ATRACE_CALL();
    ATRACE_CALL();
+5 −1
Original line number Original line Diff line number Diff line
@@ -934,7 +934,8 @@ private:
    template <typename Predicate>
    template <typename Predicate>
    sp<DisplayDevice> findDisplay(Predicate p) const REQUIRES(mStateLock) {
    sp<DisplayDevice> findDisplay(Predicate p) const REQUIRES(mStateLock) {
        const auto it = std::find_if(mDisplays.begin(), mDisplays.end(),
        const auto it = std::find_if(mDisplays.begin(), mDisplays.end(),
                                     [&](const auto& pair) { return p(*pair.second); });
                                     [&](const auto& pair)
                                             REQUIRES(mStateLock) { return p(*pair.second); });


        return it == mDisplays.end() ? nullptr : it->second;
        return it == mDisplays.end() ? nullptr : it->second;
    }
    }
@@ -1047,6 +1048,9 @@ private:
    VirtualDisplayId acquireVirtualDisplay(ui::Size, ui::PixelFormat) REQUIRES(mStateLock);
    VirtualDisplayId acquireVirtualDisplay(ui::Size, ui::PixelFormat) REQUIRES(mStateLock);
    void releaseVirtualDisplay(VirtualDisplayId);
    void releaseVirtualDisplay(VirtualDisplayId);


    // Returns a display other than `mActiveDisplayId` that can be activated, if any.
    sp<DisplayDevice> getActivatableDisplay() const REQUIRES(mStateLock, kMainThreadContext);

    void onActiveDisplayChangedLocked(const DisplayDevice* inactiveDisplayPtr,
    void onActiveDisplayChangedLocked(const DisplayDevice* inactiveDisplayPtr,
                                      const DisplayDevice& activeDisplay)
                                      const DisplayDevice& activeDisplay)
            REQUIRES(mStateLock, kMainThreadContext);
            REQUIRES(mStateLock, kMainThreadContext);
Loading