Merge "Fix crash when user changes after a11yservice dies" into nyc-mr1-dev
This commit is contained in:
@@ -2224,6 +2224,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
|||||||
|
|
||||||
AccessibilityServiceInfo mAccessibilityServiceInfo;
|
AccessibilityServiceInfo mAccessibilityServiceInfo;
|
||||||
|
|
||||||
|
// The service that's bound to this instance. Whenever this value is non-null, this
|
||||||
|
// object is registered as a death recipient
|
||||||
IBinder mService;
|
IBinder mService;
|
||||||
|
|
||||||
IAccessibilityServiceClient mServiceInterface;
|
IAccessibilityServiceClient mServiceInterface;
|
||||||
@@ -2358,14 +2360,14 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
userState.mBindingServices.add(mComponentName);
|
userState.mBindingServices.add(mComponentName);
|
||||||
mService = userState.mUiAutomationServiceClient.asBinder();
|
|
||||||
mMainHandler.post(new Runnable() {
|
mMainHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Simulate asynchronous connection since in onServiceConnected
|
// Simulate asynchronous connection since in onServiceConnected
|
||||||
// we may modify the state data in case of an error but bind is
|
// we may modify the state data in case of an error but bind is
|
||||||
// called while iterating over the data and bad things can happen.
|
// called while iterating over the data and bad things can happen.
|
||||||
onServiceConnected(mComponentName, mService);
|
onServiceConnected(mComponentName,
|
||||||
|
userState.mUiAutomationServiceClient.asBinder());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
userState.mUiAutomationService = this;
|
userState.mUiAutomationService = this;
|
||||||
@@ -2457,7 +2459,19 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
|||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName componentName, IBinder service) {
|
public void onServiceConnected(ComponentName componentName, IBinder service) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mService = service;
|
if (mService != service) {
|
||||||
|
if (mService != null) {
|
||||||
|
mService.unlinkToDeath(this, 0);
|
||||||
|
}
|
||||||
|
mService = service;
|
||||||
|
try {
|
||||||
|
mService.linkToDeath(this, 0);
|
||||||
|
} catch (RemoteException re) {
|
||||||
|
Slog.e(LOG_TAG, "Failed registering death link");
|
||||||
|
binderDied();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
mServiceInterface = IAccessibilityServiceClient.Stub.asInterface(service);
|
mServiceInterface = IAccessibilityServiceClient.Stub.asInterface(service);
|
||||||
UserState userState = getUserStateLocked(mUserId);
|
UserState userState = getUserStateLocked(mUserId);
|
||||||
addServiceLocked(this, userState);
|
addServiceLocked(this, userState);
|
||||||
@@ -3091,7 +3105,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onAdded() throws RemoteException {
|
public void onAdded() throws RemoteException {
|
||||||
linkToOwnDeathLocked();
|
|
||||||
final long identity = Binder.clearCallingIdentity();
|
final long identity = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
mWindowManagerService.addWindowToken(mOverlayWindowToken,
|
mWindowManagerService.addWindowToken(mOverlayWindowToken,
|
||||||
@@ -3108,17 +3121,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
|||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(identity);
|
Binder.restoreCallingIdentity(identity);
|
||||||
}
|
}
|
||||||
unlinkToOwnDeathLocked();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void linkToOwnDeathLocked() throws RemoteException {
|
|
||||||
mService.linkToDeath(this, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unlinkToOwnDeathLocked() {
|
|
||||||
if (mService != null) {
|
|
||||||
mService.unlinkToDeath(this, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetLocked() {
|
public void resetLocked() {
|
||||||
@@ -3131,7 +3133,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
|||||||
} catch (RemoteException re) {
|
} catch (RemoteException re) {
|
||||||
/* ignore */
|
/* ignore */
|
||||||
}
|
}
|
||||||
mService = null;
|
if (mService != null) {
|
||||||
|
mService.unlinkToDeath(this, 0);
|
||||||
|
mService = null;
|
||||||
|
}
|
||||||
mServiceInterface = null;
|
mServiceInterface = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user