@@ -191,8 +191,11 @@ private void registerPackageChangeAndBootCompletedBroadcastReceiver() {
191191 @ Override
192192 public void onSomePackagesChanged () {
193193 synchronized (mLock ) {
194- populateAccessibilityServiceListLocked ();
195- manageServicesLocked ();
194+ // We will update when the automation service dies.
195+ if (mUiAutomationService == null ) {
196+ populateAccessibilityServiceListLocked ();
197+ manageServicesLocked ();
198+ }
196199 }
197200 }
198201
@@ -242,11 +245,14 @@ public boolean onHandleForceStop(Intent intent, String[] packages,
242245 public void onReceive (Context context , Intent intent ) {
243246 if (intent .getAction () == Intent .ACTION_BOOT_COMPLETED ) {
244247 synchronized (mLock ) {
245- populateAccessibilityServiceListLocked ();
246- handleAccessibilityEnabledSettingChangedLocked ();
247- handleTouchExplorationEnabledSettingChangedLocked ();
248- updateInputFilterLocked ();
249- sendStateToClientsLocked ();
248+ // We will update when the automation service dies.
249+ if (mUiAutomationService == null ) {
250+ populateAccessibilityServiceListLocked ();
251+ handleAccessibilityEnabledSettingChangedLocked ();
252+ handleTouchExplorationEnabledSettingChangedLocked ();
253+ updateInputFilterLocked ();
254+ sendStateToClientsLocked ();
255+ }
250256 }
251257
252258 return ;
@@ -294,9 +300,12 @@ private void registerSettingsContentObservers() {
294300 public void onChange (boolean selfChange ) {
295301 super .onChange (selfChange );
296302 synchronized (mLock ) {
297- handleAccessibilityEnabledSettingChangedLocked ();
298- updateInputFilterLocked ();
299- sendStateToClientsLocked ();
303+ // We will update when the automation service dies.
304+ if (mUiAutomationService == null ) {
305+ handleAccessibilityEnabledSettingChangedLocked ();
306+ updateInputFilterLocked ();
307+ sendStateToClientsLocked ();
308+ }
300309 }
301310 }
302311 });
@@ -309,9 +318,12 @@ public void onChange(boolean selfChange) {
309318 public void onChange (boolean selfChange ) {
310319 super .onChange (selfChange );
311320 synchronized (mLock ) {
312- handleTouchExplorationEnabledSettingChangedLocked ();
313- updateInputFilterLocked ();
314- sendStateToClientsLocked ();
321+ // We will update when the automation service dies.
322+ if (mUiAutomationService == null ) {
323+ handleTouchExplorationEnabledSettingChangedLocked ();
324+ updateInputFilterLocked ();
325+ sendStateToClientsLocked ();
326+ }
315327 }
316328 }
317329 });
@@ -324,7 +336,10 @@ public void onChange(boolean selfChange) {
324336 public void onChange (boolean selfChange ) {
325337 super .onChange (selfChange );
326338 synchronized (mLock ) {
327- manageServicesLocked ();
339+ // We will update when the automation service dies.
340+ if (mUiAutomationService == null ) {
341+ manageServicesLocked ();
342+ }
328343 }
329344 }
330345 });
@@ -747,10 +762,6 @@ private boolean canDispathEventLocked(Service service, AccessibilityEvent event,
747762 * Manages services by starting enabled ones and stopping disabled ones.
748763 */
749764 private void manageServicesLocked () {
750- // While the UI automation service is running it takes over.
751- if (mUiAutomationService != null ) {
752- return ;
753- }
754765 populateEnabledServicesLocked (mEnabledServices );
755766 final int enabledInstalledServicesCount = updateServicesStateLocked (mInstalledServices ,
756767 mEnabledServices );
@@ -926,8 +937,13 @@ private void handleTouchExplorationEnabledSettingChangedLocked() {
926937
927938 private void tryEnableTouchExploration (final Service service ) {
928939 if (!mIsTouchExplorationEnabled && service .mRequestTouchExplorationMode ) {
929- mMainHandler .obtainMessage (MSG_SHOW_ENABLE_TOUCH_EXPLORATION_DIALOG ,
930- service ).sendToTarget ();
940+ if (!service .mIsAutomation ) {
941+ mMainHandler .obtainMessage (MSG_SHOW_ENABLE_TOUCH_EXPLORATION_DIALOG ,
942+ service ).sendToTarget ();
943+ } else {
944+ Settings .Secure .putInt (mContext .getContentResolver (),
945+ Settings .Secure .TOUCH_EXPLORATION_ENABLED , 1 );
946+ }
931947 }
932948 }
933949
@@ -1479,10 +1495,15 @@ public void binderDied() {
14791495 // the state based on values in the settings database.
14801496 if (mIsAutomation ) {
14811497 mUiAutomationService = null ;
1498+
14821499 handleAccessibilityEnabledSettingChangedLocked ();
1500+ sendStateToClientsLocked ();
1501+
14831502 handleTouchExplorationEnabledSettingChangedLocked ();
14841503 updateInputFilterLocked ();
1485- sendStateToClientsLocked ();
1504+
1505+ populateAccessibilityServiceListLocked ();
1506+ manageServicesLocked ();
14861507 }
14871508 }
14881509 }
0 commit comments