Merge "Add AccessibilityManager#removeClient" into sc-dev
This commit is contained in:
@@ -516,6 +516,25 @@ public final class AccessibilityManager {
|
|||||||
return mClient;
|
return mClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters the IAccessibilityManagerClient from the backing service
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public boolean removeClient() {
|
||||||
|
synchronized (mLock) {
|
||||||
|
IAccessibilityManager service = getServiceLocked();
|
||||||
|
if (service == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return service.removeClient(mClient, mUserId);
|
||||||
|
} catch (RemoteException re) {
|
||||||
|
Log.e(LOG_TAG, "AccessibilityManagerService is dead", re);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ interface IAccessibilityManager {
|
|||||||
|
|
||||||
long addClient(IAccessibilityManagerClient client, int userId);
|
long addClient(IAccessibilityManagerClient client, int userId);
|
||||||
|
|
||||||
|
boolean removeClient(IAccessibilityManagerClient client, int userId);
|
||||||
|
|
||||||
List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList(int userId);
|
List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList(int userId);
|
||||||
|
|
||||||
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
|
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
|
||||||
|
|||||||
@@ -115,6 +115,13 @@ public class AccessibilityManagerTest {
|
|||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemoveManager() throws Exception {
|
||||||
|
AccessibilityManager manager = createManager(WITH_A11Y_ENABLED);
|
||||||
|
manager.removeClient();
|
||||||
|
verify(mMockService).removeClient(manager.getClient(), UserHandle.USER_CURRENT);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAccessibilityServiceList() throws Exception {
|
public void testGetAccessibilityServiceList() throws Exception {
|
||||||
// create a list of installed accessibility services the mock service returns
|
// create a list of installed accessibility services the mock service returns
|
||||||
|
|||||||
@@ -709,6 +709,34 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeClient(IAccessibilityManagerClient callback, int userId) {
|
||||||
|
// TODO(b/190216606): Add tracing for removeClient when implementation is the same in master
|
||||||
|
|
||||||
|
synchronized (mLock) {
|
||||||
|
final int resolvedUserId = mSecurityPolicy
|
||||||
|
.resolveCallingUserIdEnforcingPermissionsLocked(userId);
|
||||||
|
|
||||||
|
AccessibilityUserState userState = getUserStateLocked(resolvedUserId);
|
||||||
|
if (mSecurityPolicy.isCallerInteractingAcrossUsers(userId)) {
|
||||||
|
boolean unregistered = mGlobalClients.unregister(callback);
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.i(LOG_TAG,
|
||||||
|
"Removed global client for pid:" + Binder.getCallingPid() + "state: "
|
||||||
|
+ unregistered);
|
||||||
|
}
|
||||||
|
return unregistered;
|
||||||
|
} else {
|
||||||
|
boolean unregistered = userState.mUserClients.unregister(callback);
|
||||||
|
if (DEBUG) {
|
||||||
|
Slog.i(LOG_TAG, "Removed user client for pid:" + Binder.getCallingPid()
|
||||||
|
+ " and userId:" + resolvedUserId + "state: " + unregistered);
|
||||||
|
}
|
||||||
|
return unregistered;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendAccessibilityEvent(AccessibilityEvent event, int userId) {
|
public void sendAccessibilityEvent(AccessibilityEvent event, int userId) {
|
||||||
if (mTraceManager.isA11yTracingEnabled()) {
|
if (mTraceManager.isA11yTracingEnabled()) {
|
||||||
@@ -3271,6 +3299,14 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
pw.println();
|
pw.println();
|
||||||
}
|
}
|
||||||
mA11yWindowManager.dump(fd, pw, args);
|
mA11yWindowManager.dump(fd, pw, args);
|
||||||
|
pw.println("Global client list info:{");
|
||||||
|
mGlobalClients.dump(pw, " Client list ");
|
||||||
|
pw.println(" Registered clients:{");
|
||||||
|
for (int i = 0; i < mGlobalClients.getRegisteredCallbackCount(); i++) {
|
||||||
|
AccessibilityManagerService.Client client = (AccessibilityManagerService.Client)
|
||||||
|
mGlobalClients.getRegisteredCallbackCookie(i);
|
||||||
|
pw.append(Arrays.toString(client.mPackageNames));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import com.android.internal.accessibility.AccessibilityShortcutController;
|
|||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -573,6 +574,15 @@ class AccessibilityUserState {
|
|||||||
pw.append(componentName.toShortString());
|
pw.append(componentName.toShortString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pw.println("}");
|
||||||
|
pw.println(" Client list info:{");
|
||||||
|
mUserClients.dump(pw, " Client list ");
|
||||||
|
pw.println(" Registered clients:{");
|
||||||
|
for (int i = 0; i < mUserClients.getRegisteredCallbackCount(); i++) {
|
||||||
|
AccessibilityManagerService.Client client = (AccessibilityManagerService.Client)
|
||||||
|
mUserClients.getRegisteredCallbackCookie(i);
|
||||||
|
pw.append(Arrays.toString(client.mPackageNames));
|
||||||
|
}
|
||||||
pw.println("}]");
|
pw.println("}]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user