From 8d41901e6669b5916f4fcbbf262445ca906e1556 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Wed, 19 Jun 2013 16:28:30 -0700 Subject: [PATCH] Improper initialization of the accessibility manager service. Initially the current user in the accessibility manager service is the owner. This is correct since the system should be able to respond to queries immediately and their result depends on the current user. However, the system is calling the user switch callback with the current user which is the same as the one we initialized with. Switching the user causes clearing state for the old user winch is in case the current one. Hence, we are losing state for the current user. This behavior was masked from the fact that accidentally no events in the system were fired before the first use user switch call. repo Losing current user state puts the manager service in an inconsistent state and it binds to accessibility services more than once. As a result the accessibility layer starts to misbehave rendering the device useless to a blind user. Now we are ignoring user switch callbacks if the new user is the same as the current one. Since we can no longer initialize at the first user switch, this change adds explicit system ready method called from the system server at the right moment. bug:9496697 Change-Id: Icb39e929ea44e6c0360aba7ddc12f941ca2c9f98 --- .../accessibility/AccessibilityManagerService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index 2f8250fbf1a23..f1e4b0c74a20d 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -195,6 +195,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { private int mCurrentUserId = UserHandle.USER_OWNER; + //TODO: Remove this hack + private boolean mInitialized; + private UserState getCurrentUserStateLocked() { return getUserStateLocked(mCurrentUserId); } @@ -771,6 +774,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { private void switchUser(int userId) { synchronized (mLock) { + if (mCurrentUserId == userId && mInitialized) { + return; + } + // Disconnect from services for the old user. UserState oldUserState = getUserStateLocked(mCurrentUserId); oldUserState.onSwitchToAnotherUser(); @@ -1283,6 +1290,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { } private void onUserStateChangedLocked(UserState userState) { + // TODO: Remove this hack + mInitialized = true; updateLegacyCapabilities(userState); updateServicesLocked(userState); updateFilterKeyEventsLocked(userState);