Commit Graph

389 Commits

Author SHA1 Message Date
Rhed Jao
41118f33b1 Update a11y recommended timeout api.
Update api name to getRecommendedTimeoutMillis.
Api returns timeout for interactive or non-interactive controls.
Also provide the options for a11y service to specify two kinds of
timeout.

Bug: 111210981
Test: atest SettingsBackupTest
Test: atest AccessibilityManagerTest
Test: atest AccessibilityServiceInfoTest
Change-Id: I37d35796fd72bb4d6628a6bb33b111987f321552
2018-11-09 10:24:07 +08:00
Phil Weaver
667c2d0fa6 Clean up a11y bindInstantService and package check
Two orthogonal changes:
1. Making bindInstantService property internal to UserState and
putting a permission check on the setter.

Having the setter in SecurityPolicy didn't make sense to me
since the field was public anyway.

I'm removing the permission check on the getter for the system,
since the field is checked anyway in getInstalledA11yServices.
So it seems like it's possible to determine the value of this
value without the permission. It also just doesn't seem like
reading this value has any security implications.

I'm doing this as part of pulling SecurityPolicy out of AMS. It
felt silly to have a permission check that was only enforced
if the caller went out of its way to have it enforced.

2. Making list of valid packages independent of the caller.

Bug: 110715236
Fixes: 118701258
Test: A11y CTS
Change-Id: I43ad0b3f3e30eae1c2a3582db672217d957919df
2018-10-30 14:29:47 -07:00
Phil Weaver
27beee50d3 Make performAccessibilityShortcut a SystemAPI
Also create a new MANAGE_ACCESSIBILITY permission to
perform the shortcut.

Bug: 116118615
Test: make, activate accessibility shortcut
Change-Id: Ic65a0cdf7393429e14cb98f4fb0734d20069b05a
2018-10-30 10:10:41 -07:00
sanryhuang
95d6d82b13 Enable Per-display support on MagnificationController.
Refactor
1. Create DisplayMagnification to support multi-display
2. Using PooledLambda to simplify the existing code

Bug: 112273690
Test: MagnificationControllerTest, MagnificationGestureHandlerTest and
Manual test.

Change-Id: I19436b4671421dc58c0036e55f75178c1f413e9e
2018-10-22 20:55:24 +08:00
Jackal Guo
a1300eb05c Merge "Add null check for WindowInfo" 2018-10-10 23:32:22 +00:00
Jackal Guo
e97db706ce Add null check for WindowInfo
The WindowInfo may be null if the target window can't be found in
current mWindowInfoById. Add null guard to prevent from NPE here.

Bug: 116652152
Test: atest CtsAccessibilityServiceTestCases
Test: atest CtsAccessibilityTestCases
Change-Id: Iaf2446e66420289be4154e90fbe213bbca9fd41f
2018-10-09 17:59:26 +08:00
TreeHugger Robot
f4c7bdd1a6 Merge "Add synchronization to UiAutomationManager." 2018-10-08 20:48:38 +00:00
Phil Weaver
dd577717f4 Add synchronization to UiAutomationManager.
The client change method needs to be called with a lock
held, and there's a one-off bug that looks like two threads
were shutting down UiAutomation simultaneously. Adding
a lock to prevent this from happening.

Bug: 111170405
Bug: 110845380
Test: A11y CTS and unit tests. I can't repro the issue, so
I can't write a test that specifically causes the problem
that this test makes pass.

Change-Id: Ia01603fcca5bcee70efd24e7af667d47d3057d61
2018-10-05 17:48:36 -07:00
Jackal Guo
f798d6e758 Correct the state of the accessibility service
When an accessibility service package changes, it would be unbound.
This also causes it's removed from mBoundServices and adding into
mBindingServices currently. Hence, nothing happens since it's not
in mBoundServices in onPackageUpdateFinished(). Also, this service
wouldn't be bound since it is kept in mBindingServices. Remove the
accessibility service from mBindingServices after update, remove,
and force stop.

Bug: 116758044
Test: atest CtsAccessibilityServiceTestCases
Test: atest CtsAccessibilityTestCases
Test: update, remove, and force stop an enabled a11y service, and
      check if it could work again.
Change-Id: I61f8ac3ad92480b296f9970c9bb92af8f6767f1a
2018-10-04 12:23:21 +08:00
Dieter Hsu
a7fa814e95 Fix accessibility services tests to work with atest
- Remove @BeforeClass `Looper.prepare()` that do not work with atest
- Fix TouchExplorerTest: mock AccessibilityGestureDetector to not create
  internal handler.
- Fix broken tests in MagnificationControllerTest
- Remove @FlakyTest annotation from MagnificationControllerTest &
  FingerprintGestureControllerTest

When using atest, timeout is applied to command `am instrument`. Then
@BeforeClass & @Before are both running on instrument thread, but test
cases are running on a seperate thread. It dispatch messages immediately
if the looper is associated to the same thread. When runniung tests with
atest, dispatching the message is not always done in the same thread. So
verifying the expectation on test thread would be flaky.

The solution to use a looper associated with test thread would be ugly.
Because the looper related stuff should set up without @Before or
@BeforeClass including preparing a looper on demand in a utility
function for every test case needed.

Here changing the handler behavior to enqueue but to dispatch messages
explictly from test could serialize the execution. This would use main
looper (no need to prepare) to create handler, but dispatch and clear
messages ourself. Not good enough but less ugly to run `am instrument`
with or without timeout.

Bug: 74748946
Test: atest -d FrameworksServicesTests:com.android.server.accessibility
Test: adb shell am instrument -w -e package com.android.server.accessibility \
      com.android.frameworks.servicestests/androidx.test.runner.AndroidJUnitRunner

Change-Id: Ib67d8b7305511d218b23f4b5ab0b0a12bea9ae10
2018-09-14 08:57:44 +00:00
Jackal Guo
f6493516eb Merge "Accessibility actions should trigger ACTION_OUTSIDE" 2018-09-13 05:09:49 +00:00
Rhed Jao
f78014e7be Merge "Adding a11y ui minimum timeout api." 2018-09-13 01:44:13 +00:00
Rhed Jao
e972881f59 Adding a11y ui minimum timeout api.
Bug: 111210981
Test: atest SettingsBackupTest
Test: atest AccessibilityManagerTest
Test: atest AccessibilityServiceInfoTest
Change-Id: I706d05f9b4a9e2daec06243493989b442be107db
2018-09-12 09:56:58 +08:00
Jackal Guo
ac2b62e9b5 Accessibility actions should trigger ACTION_OUTSIDE
Some accessibility actions (e.g., click) aren't counted as touch
currently. Hence, windows that are monitoring touches outside of
themselves wouldn't be notified when an accessibility action
takes place on another window.

WindowsInfo doesn't record if a window monitoring touches outside
nowadays. In order to find out this kind of window, add the field
for it.

Bug: 76228634
Bug: 62725890
Test: check if dialogs (e.g., volume panel or a11y menu) dismiss
      after performing a11y action click.
Test: atest CtsAccessibilityServiceTestCases
Test: atest CtsAccessibilityTestCases
Test: atest WindowStateTests
Change-Id: I4fd84848b8a445e6df22251d68449ae8b502c601
2018-09-05 16:35:03 +08:00
Phil Weaver
e05fba4e94 Change API name for a11y keyboard flag
Bug: 113855740
Test: make
Change-Id: Ia41360cb5e2bf5d845027add13dec34bc246f403
2018-09-04 17:08:56 -07:00
Dieter Hsu
01f426fd5e Add TouchExplorerTest
- Add test cases to check sent action-change-to-non-move motion events
  is not contain history.
- Fix AccessilityGestureDetector TODO that will affect atest test fail

Bug: 74069091
Test: atest FrameworksServicesTests:TouchExplorerTest FrameworksServicesTests:AccessibilityGestureDetectorTest

Change-Id: Iae4321eaeea15021dfed4503da4665398d899c07
2018-08-24 15:38:59 +08:00
Jackal Guo
ea479da1e0 disableSelf doesn't recover the init state of value
It leaves empty string instead of null for the value of
secure.enabled_accessibility_services. It may cause other tests
fails.

Bug: 111317486
Test: atest CtsAccessibilityServiceTestCases
Test: manual check the value of settings providers after test
Change-Id: I3f882ba00145ffa555514117c4684aec9ce33947
2018-08-21 11:41:43 +08:00
Jackal Guo
7080e1a588 Avoid duplicated touch events
TouchExplorer doesn't check for double tap (and hold) so there may
be duplicated TYPE_TOUCH_INTERACTION_START/END events.

Bug: 66730372
Test: manual
Test: CtsAccessibilityServiceTestCases
Test: CtsAccessibilityTestCases
Change-Id: Iece13d3a401f13d8a7dcda2147b2865eee5e5f33
2018-08-09 10:01:28 +08:00
Dieter Hsu
1979bad271 Remove dupe events while 2-fingers scrolling
Move events may contain a history of other move events. When we split
the event, each of the resulting events has history. When the system
dispatches the events, it also dispatches the ones in the history.

We change these events with actions which are NOT ACTION_MOVE and
inject to input. But those histories are no longer consistent with what
happened and are causing InputDispatcher::injectInputEvent to enqueue
duplicated events of each historical pointer coord.

Bug: 74069091
Test: manual
Test: atest CtsAccessibilityTestCases
Test: atest CtsAccessibilityServiceTestCases

Change-Id: I2a9f5526cbeecfcc379f86624607190e16265405
2018-08-06 06:08:07 +00:00
Phil Weaver
a92586955a Merge "Eliminate race condition for a11y windows" 2018-08-03 22:58:42 +00:00
Jackal Guo
9e795d828a Merge "Magnification isn't reset when service is disabled" 2018-08-03 01:23:38 +00:00
TreeHugger Robot
637415892c Merge "Remove batchMotionEvent in AccessibilityInputFilter." 2018-08-02 07:10:42 +00:00
Phil Weaver
c72faad7ab Eliminate race condition for a11y windows
Update the window list when a new window is registered
with a11y.

Bug: 111766358
Test: A11y CTS.
Change-Id: Id5ec3db3da1849b5de91cce55a67d8241e489e1f
2018-07-31 16:02:07 -07:00
Jackal Guo
1418a6b07f Magnification isn't reset when service is disabled
If the disabled service is the last service to magnify, reset the
magnification.

Bug: 28623059
Test: manual
Test: atest CtsAccessibilityTestCases
Test: atest CtsAccessibilityServiceTestCases
Test: testResetIfNeeded_resetsOnlyIfLastMagnifyingServiceIsDisabled
Change-Id: I6b12a5251b5fede8d2c9eb06048bf9fa4bd70f8b
2018-07-31 11:24:29 +08:00
Phil Weaver
b5df055d34 Merge "Enhance a11y soft keyboard controller" 2018-07-27 23:43:32 +00:00
Phil Weaver
03a65b04d8 Enhance a11y soft keyboard controller
Allow a11y services to request that the soft keyboard be
shown even when the hard keyboard is attached.

Defer to users who override this behavior, and put things
back the way they were when a service requesting this
behavior stops.

Bug: 31012180
Test: Adding CTS tests in linked CL, ran a11y unit tests,
modified TestBack to use the new flag and verified behavior
with a hard keyboard and verfied that settings behave as
expected when overriding and rebooting.
Change-Id: I530481e102ac376a4506b662862ee1ee74815b40
2018-07-27 12:58:18 -07:00
Rhed Jao
fe39083a97 Remove batchMotionEvent in AccessibilityInputFilter.
Change-Id: I65da739528cb8ff329721015de0adf5b269c46c5
Fixes: b/77939003
Test: A11y CTS
2018-07-26 14:15:09 +08:00
Jackal Guo
1528c875e3 Correct return value of MagnificationController#reset
It only returns true if magnification changes from magnifying to
non-magnifying. This is inconsistent with the docs. Return true if
the magnification scale and center is reset.

Bug: 64616261
Test: atest CtsAccessibilityTestCases
Test: atest CtsAccessibilityServiceTestCases
Change-Id: I0c496c5c45c2e35025f1887842a2a9741c440af1
2018-07-24 17:49:16 +08:00
Jackal Guo
d447b5cfc6 Merge "Using transformed event for standard gesture detector" 2018-07-20 03:26:27 +00:00
Jackal Guo
79ea482641 Using transformed event for standard gesture detector
TouchExplorer uses raw event in both a11y and standard gestures
detection, but transformed event in following movement. This
inconsistency causes significant difference of distance between
their locations when screen is magnified and long press would fail.
Passing transformed events for standard gesture detector instead.

Bug: 67378068
Test: manually test if double tap and hold works while Talkback
and Magnification are both enabled.
Test: manually test if Talkback and Magnification work as expected.
Test: AccessibilityGestureDetectorTest

Change-Id: I0e1dc59e25bc36f1f99ba6ecdb05c9c488b6f47e
2018-07-19 11:33:54 +08:00
Rhed Jao
8a39cef7f8 Update AccessibilityManagerService to use SystemService
Bug: 70221242
Test: atest CtsAccessibilityServiceTestCases
Change-Id: Icdf0772d0be93168a954fdd746cada4d5d507eb4
2018-07-18 13:42:35 +08:00
TreeHugger Robot
24158ba81b Merge "Make sure keys get flushed when connection falls apart." 2018-07-02 17:58:20 +00:00
Qasid Sadiq
5bbc301350 Make sure keys get flushed when connection falls apart.
This is for the event that a key has been intercepted, sent to the app,
and the app hasn't handled it yet. If the connection dies, the key is
lost. So flush all pending keys.

Test: Unit test (this would have caught me introducing this bug in the
first place).

Bug:74593001
Change-Id: I5a94aafe5c58f18a3e9ca46f7cd5a9cb71d38aaa
2018-06-27 22:33:11 +00:00
Wale Ogunwale
9e4f3e077f Introduced WindowProcessController/Listener (10/n)
One heavy dependence between the current AMS service and activities
is process management which is heavy affected by activities and their
current state. We introduce WindowProcessController and WindowProcessListener
objects as a structured way for the process changes in AM package to
be communicated to the WM package and WindowProcessListner for activity
changes in the WM package to the communicated back to the AM package.
The ProcessRecord object in AM will own the WindowProcessController object
and also implement the WindowProcessListener.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790
Change-Id: I9e96e841b0f95e99a597cb4629fa5d2fe45760b6
2018-06-22 14:26:24 -07:00
Wale Ogunwale
6767eaee94 Split internal interface activities from current AM interface (3/n)
3rd step in unifying the window hierarchy that is currently split
within AM and WM packages. We separate the the internal interface used
to communicate within system server dealing with activities and their
containers (tasks, stack, display) from the rest of AM internal
interface.

Test: Existing tests pass
Test: go/wm-smoke-auto
Bug: 80414790
Change-Id: Idad77721c1fe10621b9be5dced42a0a11f0183e5
2018-06-15 08:43:22 -07:00
Qasid Sadiq
fba2c8fb58 After an ax service permanently crashes, it won't eat keys
The volume keys will work again, the ax button will reset back to the
correct state, and a bunch of other things.
This is cause we are not tracking the state of the service correctly in
this "Service won't run, but is on" state. Previously we just assumed it
was on.

Bug: 74593001
Test: Verified on device. By getting testback to crash. Tested, turning
service on and off in settings. Crashing it once, and having it restart
automiatically. Continuesouly crashing it until the system decides this
is bad. And after that state rebooting to make sure the service starts
up again.

Change-Id: I00e9c978d6807d8508968286a7545e48f9ae5800
2018-06-07 15:51:37 -07:00
Yuki Awano
0b47dde976 Fix magnification offset min and max calculation
- Magnification offset is in screen coordinate. It needs to take care
  about left and top of magnification bounds when calculating min and
  max.

Bug: 77152978
Test: None
Change-Id: I5ee7835c88eed080d9b22901977b0b5f76737703
2018-05-25 16:47:11 +09:00
Phil Weaver
466b71e1a2 Add config value for fingerprint gesture support
Also correcting docs for using the fingerprint gesture
flag.

Bug: 76419487
Test: Verified with a test a11y service that gestures are
not available. Adding a unit test to verify this case.

Change-Id: I90233613777013e8b117a2d94f767be292c80019
2018-04-20 15:53:58 -07:00
Phil Weaver
985617969f Don't clear a11y focus with lock held
The bug I'm fixing is kind of weird, but in the trace it
showed lock contention with onWindowsForAccessibilityChanged
holding the lock for a long time. So I've cleaned up that
method a bit, looking for trouble. The only concrete thing
I see that's wrong is that I was clearing a11y focus, which
involves calling the app that last reported having focus.
That was done with the lock held. Now doing it through the
handler.

Bug: 77298850
Test: Ran a11y CTS and unit tests.
Change-Id: I667707412a0e3ba98639d0cb43858e8c6b52a5a7
2018-04-04 04:49:12 +00:00
Eugene Susla
bd573236f8 [DO NOT MERGE] Sort A11yService#getWindows by layer descending
This is what A11yService#getWindows promises in the javadoc.

Fixes: 71581072
Test: using testback ensure the order is correct
Change-Id: I5038c4de29c60e235b65751f7bd7771ef35eb339
(cherry picked from commit f40da1a884)
2018-04-03 21:36:01 +00:00
Tony Mak
6f2e97e235 Not allow shell to dump screen by using ui-automator if...
DISALLOW_DEBUGGING_FEATURES is set

(adb unroot first)
Test: Turn on DISALLOW_DEBUGGING_FEATURES in work profile.
      Can dump personal window + Cannot dump work window by using
      adb shell uiautomator dump
Test: Turn off DISALLOW_DEBUGGING_FEATURES in work profile.
      Can dump window in both profiles
Test: atest CtsAccessibilityServiceTestCases
Test: Enable talkback, try launching a few apps and interact with them.

Fixes: 73147467

Change-Id: I044a1546f9b568b0d19714154d6e7e5ab7232d26
2018-03-29 08:20:10 +00:00
TreeHugger Robot
c863d506cf Merge "Expose if running a11y service has crashed" into pi-dev 2018-03-20 20:16:08 +00:00
Phil Weaver
c09a021987 Expose if running a11y service has crashed
Using a hidden variable to communicate this for enabled
services. Used in Settings to report the current status.

Fixes: 35219990
Test: Adding unit test to verify that crashed value is
populated correctly. Run a11y unit and cts tests.

Change-Id: Ia47a8bd1d750186c504758df21e05a8a76c285cb
2018-03-13 09:54:28 -07:00
Phil Weaver
53454a1c84 Don't let non-touchable windows retain a11y focus
Accessibility services can't see non-touchable windows,
so those windows should not be allowed to have
accessibility focus.

Bug: 70986605
Test: Manually went through bug steps, verified that
double-tapping on the screen has no effect.

Change-Id: I7be72331c5704f7aa99714a01bbb2e336eea15e1
2018-03-09 16:00:24 -08:00
TreeHugger Robot
3a1b5d1867 Merge "Fix bug in clearing a11y focus" 2018-02-27 05:32:53 +00:00
Phil Weaver
7bb765e74d Fix bug in clearing a11y focus
Pooled lambda change dropped the argument.

Fixes: 73889458
Test: Turn on TalkBack, select things in different
windows, observe that focus clears in one window
when it is set in another.

Change-Id: I9755ffbce1b5305a24f5b9ac7b8f59069c917995
2018-02-26 12:54:40 -08:00
Phil Weaver
6343b32ae0 Make equality check more robust for a11y button
Fixes: 72734254
Test: "adb shell settings put secure
accessibility_button_target_component blah" no longer
crashes.

Change-Id: I1c8b56386c135f111a8f5ab3f5b76d2991a6c5a1
2018-02-26 11:28:03 -08:00
Phil Weaver
fde445631a Merge "Stop throwing exceptions in TouchExplorer" 2018-02-24 13:57:09 +00:00
Phil Weaver
9404bea49a Stop throwing exceptions in TouchExplorer
These crash the system. Resetting and trying to muddle
through seems like a better solution than restarting
the device.

Bug: 68269250
Test: make, try TalkBack a bit. The crashes were so rare that
the code I'm changing *almost* never executes.

Change-Id: I7931417832cb2ce39de5c8b00312c12354d76803
2018-02-23 11:26:25 -08:00
Eugene Susla
75fbfc7ec1 Use PooledLambda in A11yManagerService
This replaces the usage of handler messages with PooledLambda

Test: cts tests
Change-Id: I0c9db5deddef7c69444d1fbadc19d10e4071a4d0
2018-02-21 13:38:52 -08:00