summaryrefslogtreecommitdiffstats
path: root/services/java/com
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2013-02-15 12:18:33 -0800
committerSvetoslav <svetoslavganov@google.com>2013-02-15 12:29:17 -0800
commit5fec0c5ee5bbd83fd651644c90ff78fe32680a42 (patch)
tree80edc8e93041a4870ca92394dcec01779bbf0a55 /services/java/com
parent00e592272ee44cba41832e3cf0a0ffb2de56585d (diff)
downloadframeworks_base-5fec0c5ee5bbd83fd651644c90ff78fe32680a42.zip
frameworks_base-5fec0c5ee5bbd83fd651644c90ff78fe32680a42.tar.gz
frameworks_base-5fec0c5ee5bbd83fd651644c90ff78fe32680a42.tar.bz2
User switch not handled properly in the accessibility manager service.
On user switch the transient state of the old user was not cleared which means that when we switch back to this user the operational state such as which event types were dispatched, what state was sent to local managers, etc is stale. This leads to semi-updated state and broken behavior. Now if the user becomes inactive, we are clearing all transient state which will be recreated when the user becomes active. bug:8196652 Change-Id: Ie9e0d712b6d567e5074b328f1bb87afaa5395c06
Diffstat (limited to 'services/java/com')
-rw-r--r--services/java/com/android/server/accessibility/AccessibilityManagerService.java59
1 files changed, 47 insertions, 12 deletions
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
index e5cba62..7c02929 100644
--- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -718,7 +718,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
synchronized (mLock) {
// Disconnect from services for the old user.
UserState oldUserState = getUserStateLocked(mCurrentUserId);
- unbindAllServicesLocked(oldUserState);
+ oldUserState.onSwitchToAnotherUser();
// Disable the local managers for the old user.
if (oldUserState.mClients.getRegisteredCallbackCount() > 0) {
@@ -737,11 +737,14 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
if (userState.mUiAutomationService != null) {
// Switching users disables the UI automation service.
userState.mUiAutomationService.binderDied();
- } else if (readConfigurationForUserStateLocked(userState)) {
- // Update the user state if needed.
- onUserStateChangedLocked(userState);
}
+ readConfigurationForUserStateLocked(userState);
+ // Even if reading did not yield change, we have to update
+ // the state since the context in which the current user
+ // state was used has changed since it was inactive.
+ onUserStateChangedLocked(userState);
+
if (announceNewUser) {
// Schedule announcement of the current user if needed.
mMainHandler.sendEmptyMessageDelayed(MainHandler.MSG_ANNOUNCE_NEW_USER_IF_NEEDED,
@@ -2561,11 +2564,21 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
private class UserState {
public final int mUserId;
- public final CopyOnWriteArrayList<Service> mBoundServices = new CopyOnWriteArrayList<Service>();
+ // Non-transient state.
public final RemoteCallbackList<IAccessibilityManagerClient> mClients =
new RemoteCallbackList<IAccessibilityManagerClient>();
+ public final SparseArray<AccessibilityConnectionWrapper> mInteractionConnections =
+ new SparseArray<AccessibilityConnectionWrapper>();
+
+ public final SparseArray<IBinder> mWindowTokens = new SparseArray<IBinder>();
+
+ // Transient state.
+
+ public final CopyOnWriteArrayList<Service> mBoundServices =
+ new CopyOnWriteArrayList<Service>();
+
public final Map<ComponentName, Service> mComponentNameToServiceMap =
new HashMap<ComponentName, Service>();
@@ -2579,15 +2592,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
public final Set<ComponentName> mTouchExplorationGrantedServices =
new HashSet<ComponentName>();
- public final SparseArray<AccessibilityConnectionWrapper>
- mInteractionConnections =
- new SparseArray<AccessibilityConnectionWrapper>();
-
- public final SparseArray<IBinder> mWindowTokens = new SparseArray<IBinder>();
-
public int mHandledFeedbackTypes = 0;
- public int mLastSentClientState;
+ public int mLastSentClientState = -1;
public boolean mIsAccessibilityEnabled;
public boolean mIsTouchExplorationEnabled;
@@ -2612,6 +2619,34 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
}
return clientState;
}
+
+ public void onSwitchToAnotherUser() {
+ // Clear UI test automation state.
+ if (mUiAutomationService != null) {
+ mUiAutomationService.binderDied();
+ mUiAutomationService = null;
+ mUiAutomationServiceClient = null;
+ }
+
+ // Unbind all services.
+ unbindAllServicesLocked(this);
+
+ // Clear service management state.
+ mBoundServices.clear();
+ mBindingServices.clear();
+
+ // Clear event management state.
+ mHandledFeedbackTypes = 0;
+ mLastSentClientState = -1;
+
+ // Clear state persisted in settings.
+ mEnabledServices.clear();
+ mTouchExplorationGrantedServices.clear();
+ mIsAccessibilityEnabled = false;
+ mIsTouchExplorationEnabled = false;
+ mIsEnhancedWebAccessibilityEnabled = false;
+ mIsDisplayMagnificationEnabled = false;
+ }
}
private final class AccessibilityContentObserver extends ContentObserver {