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

Commit 8864beef authored by Ján Sebechlebský's avatar Ján Sebechlebský Committed by Android (Google) Code Review
Browse files

Merge "Use dedicated lock in InputController" into udc-dev

parents 6cab17b4 2d4ad028
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ class InputController {
     */
    private static final int DEVICE_NAME_MAX_LENGTH = 80;

    final Object mLock;
    final Object mLock = new Object();

    /* Token -> file descriptor associations. */
    @GuardedBy("mLock")
@@ -101,18 +101,17 @@ class InputController {
    private final WindowManager mWindowManager;
    private final DeviceCreationThreadVerifier mThreadVerifier;

    InputController(@NonNull Object lock, @NonNull Handler handler,
    InputController(@NonNull Handler handler,
            @NonNull WindowManager windowManager) {
        this(lock, new NativeWrapper(), handler, windowManager,
        this(new NativeWrapper(), handler, windowManager,
                // Verify that virtual devices are not created on the handler thread.
                () -> !handler.getLooper().isCurrentThread());
    }

    @VisibleForTesting
    InputController(@NonNull Object lock, @NonNull NativeWrapper nativeWrapper,
    InputController(@NonNull NativeWrapper nativeWrapper,
            @NonNull Handler handler, @NonNull WindowManager windowManager,
            @NonNull DeviceCreationThreadVerifier threadVerifier) {
        mLock = lock;
        mHandler = handler;
        mNativeWrapper = nativeWrapper;
        mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
+0 −1
Original line number Diff line number Diff line
@@ -259,7 +259,6 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub
        mDisplayManager = displayManager;
        if (inputController == null) {
            mInputController = new InputController(
                    mVirtualDeviceLock,
                    context.getMainThreadHandler(),
                    context.getSystemService(WindowManager.class));
        } else {
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public class InputControllerTest {

        // Allow virtual devices to be created on the looper thread for testing.
        final InputController.DeviceCreationThreadVerifier threadVerifier = () -> true;
        mInputController = new InputController(new Object(), mNativeWrapperMock,
        mInputController = new InputController(mNativeWrapperMock,
                new Handler(TestableLooper.get(this).getLooper()),
                InstrumentationRegistry.getTargetContext().getSystemService(WindowManager.class),
                threadVerifier);
+1 −1
Original line number Diff line number Diff line
@@ -355,7 +355,7 @@ public class VirtualDeviceManagerServiceTest {
                TestableLooper.get(this), mNativeWrapperMock, mIInputManagerMock);
        // Allow virtual devices to be created on the looper thread for testing.
        final InputController.DeviceCreationThreadVerifier threadVerifier = () -> true;
        mInputController = new InputController(new Object(), mNativeWrapperMock,
        mInputController = new InputController(mNativeWrapperMock,
                new Handler(TestableLooper.get(this).getLooper()),
                mContext.getSystemService(WindowManager.class), threadVerifier);
        mSensorController =