Commit Graph

7 Commits

Author SHA1 Message Date
Prabir Pradhan
5693cee2f9 Allow its WindowInfosListener to outlive PointerController
A strong pointer to PointerController::DisplayInfoListener is given away
when the listener is registered, so PC cannot guarantee that the
listener is destroyed when it is destroyed. This means the listener can
outlive PC, so there is a race condition between PC's destruction and an
update to the listener.

While it could be argued that it is the caller's responsibility to
ensure that the listener is not updated after it is unregistered, there
is no way to guarantee that using strong pointers. Here, we can be
defensive and protect against this case.

Bug: 212672261
Test: atest libinputservice_test
Change-Id: I358a725980cc8c7d6ad0483a9b2a8b8715a03424
2022-01-17 04:35:47 -08:00
Liam Harrington
c782be6e6f Refactor of PointerController
Abstracted logic that applies to all pointer types into general
PointerController class and moved implementation of logic specific
to the mouse cursor and touch spots to MouseCursorController and
TouchSpotController, respectively.
Test: Pixel 3XL device, atest PointerController_test, compile

Change-Id: Ia5825c37ca75951cc8bcd7d5102c986bd957e69f
2020-08-06 20:22:26 +00:00
Michael Wright
6853fe6d78 Move PointerController enums to enum classes.
Bug: 160010896
Test: atest PointerController_test, compile
Change-Id: I6c7bfc91023ce6cd2dc8f82b0d72731f871ad3ea
Merged-In: I6c7bfc91023ce6cd2dc8f82b0d72731f871ad3ea
2020-07-07 10:43:01 -07:00
Michael Wright
a0bc6b1d09 Move PointerController from sp to shared_ptr
Bug: 160010896
Test: atest PointerController_test, manual usage
Change-Id: I4e665d00c56b44c9c1a4ea8cb27ffd10ade3315b
Merged-In: I4e665d00c56b44c9c1a4ea8cb27ffd10ade3315b
2020-07-07 10:11:58 -07:00
Prabir Pradhan
ca7d72347e PointerController: Add guards to ensure display is valid
This change makes it so that PointerController does not ask its Policy
to load any resources for any displays until a DisplayViewport is set,
and verifies this with unit tests.

Bug: 145699789
Bug: 146385350
Test: atest libinputservice_test
Change-Id: I2e48e7ac4700e6f9fdf939a7bd0e6639b051ade6
Merged-In: I2e48e7ac4700e6f9fdf939a7bd0e6639b051ade6
2020-05-28 14:03:22 -07:00
Garfield Tan
e9c6151756 Stop loading animation for addtional cursor type.
In the test below it only expects MockSprite#setIcon() being called
once, but with animation it may be called multiple times.

Bug: 144947344
Test: atest PoitnerControllerTest#updatePointerIcon
Change-Id: I5c4908fb8301cae144fd637c831f2012a35862e3
Merged-In: I5c4908fb8301cae144fd637c831f2012a35862e3
2020-05-28 14:03:21 -07:00
Garfield Tan
c15eb91b04 Add cursor type and hotspot to surface metadata.
Also bootstrap unit tests for PointerController. Need to mark 3
functions of SpriteController virtual so their behaviors can be
overridden.

Bug: 130822623
Test: SurfaceFlinger can get cursor type and hotspot.
Change-Id: I739cd03214364144bb4e22a166ecc7abfd3492fe
Merged-In: I739cd03214364144bb4e22a166ecc7abfd3492fe
2020-05-28 14:03:21 -07:00