Merge "Fake accessibility service used by UiAutomation not destroyed." into jb-mr2-dev
This commit is contained in:
@@ -49,6 +49,8 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
|
||||
|
||||
private final Object mLock = new Object();
|
||||
|
||||
private final Binder mToken = new Binder();
|
||||
|
||||
private int mInitialFrozenRotation = INITIAL_FROZEN_ROTATION_UNSPECIFIED;
|
||||
|
||||
private IAccessibilityServiceClient mClient;
|
||||
@@ -164,7 +166,7 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
|
||||
try {
|
||||
// Calling out with a lock held is fine since if the system
|
||||
// process is gone the client calling in will be killed.
|
||||
manager.registerUiTestAutomationService(client, info);
|
||||
manager.registerUiTestAutomationService(mToken, client, info);
|
||||
mClient = client;
|
||||
} catch (RemoteException re) {
|
||||
throw new IllegalStateException("Error while registering UiTestAutomationService.", re);
|
||||
|
||||
@@ -50,7 +50,7 @@ interface IAccessibilityManager {
|
||||
|
||||
void removeAccessibilityInteractionConnection(IWindow windowToken);
|
||||
|
||||
void registerUiTestAutomationService(IAccessibilityServiceClient client,
|
||||
void registerUiTestAutomationService(IBinder owner, IAccessibilityServiceClient client,
|
||||
in AccessibilityServiceInfo info);
|
||||
|
||||
void unregisterUiTestAutomationService(IAccessibilityServiceClient client);
|
||||
|
||||
@@ -528,7 +528,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void registerUiTestAutomationService(IAccessibilityServiceClient serviceClient,
|
||||
public void registerUiTestAutomationService(IBinder owner, IAccessibilityServiceClient serviceClient,
|
||||
AccessibilityServiceInfo accessibilityServiceInfo) {
|
||||
mSecurityPolicy.enforceCallingPermission(Manifest.permission.RETRIEVE_WINDOW_CONTENT,
|
||||
FUNCTION_REGISTER_UI_TEST_AUTOMATION_SERVICE);
|
||||
@@ -543,6 +543,15 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
+ "already registered!");
|
||||
}
|
||||
|
||||
try {
|
||||
owner.linkToDeath(userState.mUiAutomationSerivceOnwerDeathRecipient, 0);
|
||||
} catch (RemoteException re) {
|
||||
Slog.e(LOG_TAG, "Couldn't register for the death of a"
|
||||
+ " UiTestAutomationService!", re);
|
||||
return;
|
||||
}
|
||||
|
||||
userState.mUiAutomationServiceOwner = owner;
|
||||
userState.mUiAutomationServiceClient = serviceClient;
|
||||
|
||||
// Set the temporary state.
|
||||
@@ -1697,8 +1706,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
if (!mIsAutomation) {
|
||||
mContext.unbindService(this);
|
||||
} else {
|
||||
userState.mUiAutomationService = null;
|
||||
userState.mUiAutomationServiceClient = null;
|
||||
userState.destroyUiAutomationService();
|
||||
}
|
||||
removeServiceLocked(this, userState);
|
||||
dispose();
|
||||
@@ -2110,8 +2118,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
// the state based on values in the settings database.
|
||||
userState.mInstalledServices.remove(mAccessibilityServiceInfo);
|
||||
userState.mEnabledServices.remove(mComponentName);
|
||||
userState.mUiAutomationService = null;
|
||||
userState.mUiAutomationServiceClient = null;
|
||||
userState.destroyUiAutomationService();
|
||||
}
|
||||
onUserStateChangedLocked(userState);
|
||||
}
|
||||
@@ -2604,6 +2611,20 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
private Service mUiAutomationService;
|
||||
private IAccessibilityServiceClient mUiAutomationServiceClient;
|
||||
|
||||
private IBinder mUiAutomationServiceOwner;
|
||||
private final DeathRecipient mUiAutomationSerivceOnwerDeathRecipient =
|
||||
new DeathRecipient() {
|
||||
@Override
|
||||
public void binderDied() {
|
||||
mUiAutomationServiceOwner.unlinkToDeath(
|
||||
mUiAutomationSerivceOnwerDeathRecipient, 0);
|
||||
mUiAutomationServiceOwner = null;
|
||||
if (mUiAutomationService != null) {
|
||||
mUiAutomationService.binderDied();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public UserState(int userId) {
|
||||
mUserId = userId;
|
||||
}
|
||||
@@ -2624,8 +2645,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
// Clear UI test automation state.
|
||||
if (mUiAutomationService != null) {
|
||||
mUiAutomationService.binderDied();
|
||||
mUiAutomationService = null;
|
||||
mUiAutomationServiceClient = null;
|
||||
}
|
||||
|
||||
// Unbind all services.
|
||||
@@ -2647,6 +2666,16 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
mIsEnhancedWebAccessibilityEnabled = false;
|
||||
mIsDisplayMagnificationEnabled = false;
|
||||
}
|
||||
|
||||
public void destroyUiAutomationService() {
|
||||
mUiAutomationService = null;
|
||||
mUiAutomationServiceClient = null;
|
||||
if (mUiAutomationServiceOwner != null) {
|
||||
mUiAutomationServiceOwner.unlinkToDeath(
|
||||
mUiAutomationSerivceOnwerDeathRecipient, 0);
|
||||
mUiAutomationServiceOwner = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class AccessibilityContentObserver extends ContentObserver {
|
||||
|
||||
Reference in New Issue
Block a user