Loading core/java/android/companion/virtual/computercontrol/ComputerControlSession.java +17 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,23 @@ public final class ComputerControlSession implements AutoCloseable { } } /** * Sends a long press event to the computer control session for the given coordinates. * * <p>The coordinates are in relative display space, e.g. (0.5, 0.5) is the center of the * display.</p> */ public void longPress(@IntRange(from = 0) int x, @IntRange(from = 0) int y) { if (x < 0 || y < 0) { throw new IllegalArgumentException("Long press coordinates must be non-negative"); } try { mSession.longPress(x, y); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Returns the ID of the single trusted virtual display for this session. */ public int getVirtualDisplayId() { try { Loading core/java/android/companion/virtual/computercontrol/IComputerControlSession.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ interface IComputerControlSession { /* Injects a swipe event into the trusted virtual display. */ void swipe(int fromX, int fromY, int toX, int toY); /** Injects a long press event into the trusted virtual display. */ void longPress(int x, int y); /** Returns the ID of the single trusted virtual display for this session. */ int getVirtualDisplayId(); Loading core/tests/coretests/src/android/companion/virtual/computercontrol/ComputerControlSessionTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -172,4 +172,16 @@ public class ComputerControlSessionTest { assertThrows(IllegalArgumentException.class, () -> mSession.swipe(1, 2, -3, 4)); assertThrows(IllegalArgumentException.class, () -> mSession.swipe(1, 2, 3, -4)); } @Test public void longPress_longPresses() throws RemoteException { mSession.longPress(1, 2); verify(mMockSession).longPress(eq(1), eq(2)); } @Test public void longPressNotInRange_throws() { assertThrows(IllegalArgumentException.class, () -> mSession.longPress(-1, 2)); assertThrows(IllegalArgumentException.class, () -> mSession.longPress(1, -2)); } } libs/computercontrol/src/com/android/extensions/computercontrol/ComputerControlSession.java +8 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,14 @@ public final class ComputerControlSession implements AutoCloseable { mAccessibilityProxy.resetStabilityState(); } /** * Sends a long press event to the computer control session for the given coordinates. */ public void longPress(@IntRange(from = 0) int x, @IntRange(from = 0) int y) { mSession.longPress(x, y); mAccessibilityProxy.resetStabilityState(); } /** * Injects a {@link TouchEvent} into the computer control session. */ Loading libs/computercontrol/tests/src/com/android/extensions/computercontrol/ComputerControlSessionTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,12 @@ public class ComputerControlSessionTest { verify(mIComputerControlSession).swipe(eq(1), eq(2), eq(3), eq(4)); } @Test public void longPress_longPresses() throws Exception { mSession.longPress(1, 2); verify(mIComputerControlSession).longPress(eq(1), eq(2)); } @Test public void sendKeyEvent_sendsKeyEvent() throws Exception { KeyEvent event = new KeyEvent.Builder() Loading Loading
core/java/android/companion/virtual/computercontrol/ComputerControlSession.java +17 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,23 @@ public final class ComputerControlSession implements AutoCloseable { } } /** * Sends a long press event to the computer control session for the given coordinates. * * <p>The coordinates are in relative display space, e.g. (0.5, 0.5) is the center of the * display.</p> */ public void longPress(@IntRange(from = 0) int x, @IntRange(from = 0) int y) { if (x < 0 || y < 0) { throw new IllegalArgumentException("Long press coordinates must be non-negative"); } try { mSession.longPress(x, y); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** Returns the ID of the single trusted virtual display for this session. */ public int getVirtualDisplayId() { try { Loading
core/java/android/companion/virtual/computercontrol/IComputerControlSession.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,9 @@ interface IComputerControlSession { /* Injects a swipe event into the trusted virtual display. */ void swipe(int fromX, int fromY, int toX, int toY); /** Injects a long press event into the trusted virtual display. */ void longPress(int x, int y); /** Returns the ID of the single trusted virtual display for this session. */ int getVirtualDisplayId(); Loading
core/tests/coretests/src/android/companion/virtual/computercontrol/ComputerControlSessionTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -172,4 +172,16 @@ public class ComputerControlSessionTest { assertThrows(IllegalArgumentException.class, () -> mSession.swipe(1, 2, -3, 4)); assertThrows(IllegalArgumentException.class, () -> mSession.swipe(1, 2, 3, -4)); } @Test public void longPress_longPresses() throws RemoteException { mSession.longPress(1, 2); verify(mMockSession).longPress(eq(1), eq(2)); } @Test public void longPressNotInRange_throws() { assertThrows(IllegalArgumentException.class, () -> mSession.longPress(-1, 2)); assertThrows(IllegalArgumentException.class, () -> mSession.longPress(1, -2)); } }
libs/computercontrol/src/com/android/extensions/computercontrol/ComputerControlSession.java +8 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,14 @@ public final class ComputerControlSession implements AutoCloseable { mAccessibilityProxy.resetStabilityState(); } /** * Sends a long press event to the computer control session for the given coordinates. */ public void longPress(@IntRange(from = 0) int x, @IntRange(from = 0) int y) { mSession.longPress(x, y); mAccessibilityProxy.resetStabilityState(); } /** * Injects a {@link TouchEvent} into the computer control session. */ Loading
libs/computercontrol/tests/src/com/android/extensions/computercontrol/ComputerControlSessionTest.java +6 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,12 @@ public class ComputerControlSessionTest { verify(mIComputerControlSession).swipe(eq(1), eq(2), eq(3), eq(4)); } @Test public void longPress_longPresses() throws Exception { mSession.longPress(1, 2); verify(mIComputerControlSession).longPress(eq(1), eq(2)); } @Test public void sendKeyEvent_sendsKeyEvent() throws Exception { KeyEvent event = new KeyEvent.Builder() Loading