Refactoring of the Accessibility.

1. The accessibility manager service updates its internal state
   based on which settings are enabled, what accessibility services
   are installed and what features are requested by the enabled
   services. It was trying to do the minimal amount of work to
   react to contextual changes like these which resulted in missed
   cases and complex code. Now there is a single method that reads
   the contextual information and single method that reacts to
   contextual changes. This makes the code much easier to maintain.

2. The accessibility manager service was not updating its internal
   state when requested features from accessibility services change.
   It was relying on changing system settings and reacting to the
   settings change. This is problematic since the internal state is
   not updated atomically which leads to race condition bugs. For
   example, if touch exploration is enabled and a service requests
   it is disabled, the internal state will not be updated but a
   request for a settings change will be made. Now while the settings
   change is propagating another request form the same service
   comes to enable touch exploration but the system incorrectly
   thinks touch exploration is enabled. At the end the feature is
   disabled even though it was requested.

3. Fixed a potential NPE if the accessibility input filter's event
   handler was nullified between processing two event batches.

4. Fixed a bug where, if magnification is enabled, it does not work
   on the settings screen since the magnified bounds are not pushed
   from the window manager to the accessibility manager.

Change-Id: Idf629a06480e12f0d88372762df6c024fe0d7856
4 files changed