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

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

Snap for 8519467 from f7f5aac0 to tm-release

Change-Id: Iddcb6623126f32c452abea1bbf1df72c9c980461
parents b9d88df7 f7f5aac0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ status_t ScreenCaptureResults::writeToParcel(android::Parcel* parcel) const {
    }

    SAFE_PARCEL(parcel->writeBool, capturedSecureLayers);
    SAFE_PARCEL(parcel->writeBool, capturedHdrLayers);
    SAFE_PARCEL(parcel->writeUint32, static_cast<uint32_t>(capturedDataspace));
    SAFE_PARCEL(parcel->writeInt32, result);
    return NO_ERROR;
@@ -57,6 +58,7 @@ status_t ScreenCaptureResults::readFromParcel(const android::Parcel* parcel) {
    }

    SAFE_PARCEL(parcel->readBool, &capturedSecureLayers);
    SAFE_PARCEL(parcel->readBool, &capturedHdrLayers);
    uint32_t dataspace = 0;
    SAFE_PARCEL(parcel->readUint32, &dataspace);
    capturedDataspace = static_cast<ui::Dataspace>(dataspace);
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ public:
    sp<GraphicBuffer> buffer;
    sp<Fence> fence = Fence::NO_FENCE;
    bool capturedSecureLayers{false};
    bool capturedHdrLayers{false};
    ui::Dataspace capturedDataspace{ui::Dataspace::V0_SRGB};
    status_t result = OK;
};
+18 −6
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@

namespace android {

// The default velocity control parameters that has no effect.
static const VelocityControlParameters FLAT_VELOCITY_CONTROL_PARAMS{};

// --- CursorMotionAccumulator ---

CursorMotionAccumulator::CursorMotionAccumulator() {
@@ -154,8 +157,9 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration*
        mHWheelScale = 1.0f;
    }

    if ((!changes && config->pointerCaptureRequest.enable) ||
        (changes & InputReaderConfiguration::CHANGE_POINTER_CAPTURE)) {
    const bool configurePointerCapture = (!changes && config->pointerCaptureRequest.enable) ||
            (changes & InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
    if (configurePointerCapture) {
        if (config->pointerCaptureRequest.enable) {
            if (mParameters.mode == Parameters::MODE_POINTER) {
                mParameters.mode = Parameters::MODE_POINTER_RELATIVE;
@@ -180,11 +184,19 @@ void CursorInputMapper::configure(nsecs_t when, const InputReaderConfiguration*
        }
    }

    if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED)) {
    if (!changes || (changes & InputReaderConfiguration::CHANGE_POINTER_SPEED) ||
        configurePointerCapture) {
        if (config->pointerCaptureRequest.enable) {
            // Disable any acceleration or scaling when Pointer Capture is enabled.
            mPointerVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
            mWheelXVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
            mWheelYVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
        } else {
            mPointerVelocityControl.setParameters(config->pointerVelocityControlParameters);
            mWheelXVelocityControl.setParameters(config->wheelVelocityControlParameters);
            mWheelYVelocityControl.setParameters(config->wheelVelocityControlParameters);
        }
    }

    if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
        mOrientation = DISPLAY_ORIENTATION_0;
+57 −1
Original line number Diff line number Diff line
@@ -375,6 +375,11 @@ public:

    float getPointerGestureMovementSpeedRatio() { return mConfig.pointerGestureMovementSpeedRatio; }

    void setVelocityControlParams(const VelocityControlParameters& params) {
        mConfig.pointerVelocityControlParameters = params;
        mConfig.wheelVelocityControlParameters = params;
    }

private:
    uint32_t mNextPointerCaptureSequenceNumber = 0;

@@ -2949,7 +2954,10 @@ protected:
    }

    void configureDevice(uint32_t changes) {
        if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
        if (!changes ||
            (changes &
             (InputReaderConfiguration::CHANGE_DISPLAY_INFO |
              InputReaderConfiguration::CHANGE_POINTER_CAPTURE))) {
            mReader->requestRefreshConfiguration(changes);
            mReader->loopOnce();
        }
@@ -4913,6 +4921,54 @@ TEST_F(CursorInputMapperTest, Process_PointerCapture) {
    ASSERT_NO_FATAL_FAILURE(assertPosition(*mFakePointerController, 110.0f, 220.0f));
}

/**
 * When Pointer Capture is enabled, we expect to report unprocessed relative movements, so any
 * pointer acceleration or speed processing should not be applied.
 */
TEST_F(CursorInputMapperTest, PointerCaptureDisablesVelocityProcessing) {
    addConfigurationProperty("cursor.mode", "pointer");
    const VelocityControlParameters testParams(5.f /*scale*/, 0.f /*low threshold*/,
                                               100.f /*high threshold*/, 10.f /*acceleration*/);
    mFakePolicy->setVelocityControlParams(testParams);
    CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();

    NotifyDeviceResetArgs resetArgs;
    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyDeviceResetWasCalled(&resetArgs));
    ASSERT_EQ(ARBITRARY_TIME, resetArgs.eventTime);
    ASSERT_EQ(DEVICE_ID, resetArgs.deviceId);

    NotifyMotionArgs args;

    // Move and verify scale is applied.
    process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_X, 10);
    process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20);
    process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0);
    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
    ASSERT_EQ(AINPUT_SOURCE_MOUSE, args.source);
    ASSERT_EQ(AMOTION_EVENT_ACTION_HOVER_MOVE, args.action);
    const float relX = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X);
    const float relY = args.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y);
    ASSERT_GT(relX, 10);
    ASSERT_GT(relY, 20);

    // Enable Pointer Capture
    mFakePolicy->setPointerCapture(true);
    configureDevice(InputReaderConfiguration::CHANGE_POINTER_CAPTURE);
    NotifyPointerCaptureChangedArgs captureArgs;
    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyCaptureWasCalled(&captureArgs));
    ASSERT_TRUE(captureArgs.request.enable);

    // Move and verify scale is not applied.
    process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_X, 10);
    process(mapper, ARBITRARY_TIME, READ_TIME, EV_REL, REL_Y, 20);
    process(mapper, ARBITRARY_TIME, READ_TIME, EV_SYN, SYN_REPORT, 0);
    ASSERT_NO_FATAL_FAILURE(mFakeListener->assertNotifyMotionWasCalled(&args));
    ASSERT_EQ(AINPUT_SOURCE_MOUSE_RELATIVE, args.source);
    ASSERT_EQ(AMOTION_EVENT_ACTION_MOVE, args.action);
    ASSERT_EQ(10, args.pointerCoords[0].getX());
    ASSERT_EQ(20, args.pointerCoords[0].getY());
}

TEST_F(CursorInputMapperTest, Process_ShouldHandleDisplayId) {
    CursorInputMapper& mapper = addMapperAndConfigure<CursorInputMapper>();

+1 −0
Original line number Diff line number Diff line
@@ -6804,6 +6804,7 @@ std::shared_future<renderengine::RenderEngineResult> SurfaceFlinger::renderScree
                if (regionSampling) {
                    settings.backgroundBlurRadius = 0;
                }
                captureResults.capturedHdrLayers |= isHdrDataspace(settings.sourceDataspace);
            }

            clientCompositionLayers.insert(clientCompositionLayers.end(),
Loading