Add logging for proxies
Add dump logic for ProxyManager, ProxyAccessibilityServiceConnection, and the focused window. Add debug logging in ProxyManager. Bug: 254545943 Test: adb shell dumpsys accessibility Change-Id: Iad85c4d1e505c5a7bbc4e68ddee0316dc6e73d78
This commit is contained in:
@@ -3928,6 +3928,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
mGlobalClients.getRegisteredCallbackCookie(i);
|
||||
pw.append(Arrays.toString(client.mPackageNames));
|
||||
}
|
||||
pw.println();
|
||||
mProxyManager.dump(fd, pw, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -910,6 +910,10 @@ public class AccessibilityWindowManager {
|
||||
pw.println(" Top Focused Window Id = " + mTopFocusedWindowId);
|
||||
pw.println(" Accessibility Focused Window Id = " + mAccessibilityFocusedWindowId
|
||||
+ " ]");
|
||||
if (mIsProxy) {
|
||||
pw.println("Proxy accessibility focused window = "
|
||||
+ mProxyDisplayAccessibilityFocusedWindow);
|
||||
}
|
||||
pw.println();
|
||||
if (mWindows != null) {
|
||||
final int windowCount = mWindows.size();
|
||||
|
||||
@@ -38,14 +38,18 @@ import android.os.RemoteCallback;
|
||||
import android.os.RemoteException;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.accessibility.AccessibilityDisplayProxy;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.accessibility.AccessibilityWindowInfo;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.util.DumpUtils;
|
||||
import com.android.server.wm.WindowManagerInternal;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -61,6 +65,8 @@ import java.util.Set;
|
||||
* TODO(241429275): Initialize this when a proxy is registered.
|
||||
*/
|
||||
public class ProxyAccessibilityServiceConnection extends AccessibilityServiceConnection {
|
||||
private static final String LOG_TAG = "ProxyAccessibilityServiceConnection";
|
||||
|
||||
private int mDisplayId;
|
||||
private List<AccessibilityServiceInfo> mInstalledAndEnabledServices;
|
||||
|
||||
@@ -565,4 +571,25 @@ public class ProxyAccessibilityServiceConnection extends AccessibilityServiceCon
|
||||
public void setAnimationScale(float scale) throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException("setAnimationScale is not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
|
||||
if (!DumpUtils.checkDumpPermission(mContext, LOG_TAG, pw)) return;
|
||||
synchronized (mLock) {
|
||||
pw.append("Proxy[displayId=" + mDisplayId);
|
||||
pw.append(", feedbackType"
|
||||
+ AccessibilityServiceInfo.feedbackTypeToString(mFeedbackType));
|
||||
pw.append(", capabilities=" + mAccessibilityServiceInfo.getCapabilities());
|
||||
pw.append(", eventTypes="
|
||||
+ AccessibilityEvent.eventTypeToString(mEventTypes));
|
||||
pw.append(", notificationTimeout=" + mNotificationTimeout);
|
||||
pw.append(", focusStrokeWidth=").append(String.valueOf(mFocusStrokeWidth));
|
||||
pw.append(", focusColor=").append(String.valueOf(mFocusColor));
|
||||
pw.append(", installedAndEnabledServiceCount=").append(String.valueOf(
|
||||
mInstalledAndEnabledServices.size()));
|
||||
pw.append(", installedAndEnabledServices=").append(
|
||||
mInstalledAndEnabledServices.toString());
|
||||
pw.append("]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.hardware.display.DisplayManager;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Display;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
@@ -30,6 +31,8 @@ import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import com.android.server.wm.WindowManagerInternal;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -42,6 +45,9 @@ import java.util.List;
|
||||
* TODO(262244375): Add unit tests.
|
||||
*/
|
||||
public class ProxyManager {
|
||||
private static final boolean DEBUG = false;
|
||||
private static final String LOG_TAG = "ProxyManager";
|
||||
|
||||
// Names used to populate ComponentName and ResolveInfo in connection.mA11yServiceInfo and in
|
||||
// the infos of connection.setInstalledAndEnabledServices
|
||||
static final String PROXY_COMPONENT_PACKAGE_NAME = "ProxyPackage";
|
||||
@@ -79,6 +85,9 @@ public class ProxyManager {
|
||||
AbstractAccessibilityServiceConnection.SystemSupport systemSupport,
|
||||
AccessibilityTrace trace,
|
||||
WindowManagerInternal windowManagerInternal) throws RemoteException {
|
||||
if (DEBUG) {
|
||||
Slog.v(LOG_TAG, "Register proxy for display id: " + displayId);
|
||||
}
|
||||
|
||||
// Set a default AccessibilityServiceInfo that is used before the proxy's info is
|
||||
// populated. A proxy has the touch exploration and window capabilities.
|
||||
@@ -134,6 +143,9 @@ public class ProxyManager {
|
||||
if (mProxyA11yServiceConnections.contains(displayId)) {
|
||||
mProxyA11yServiceConnections.remove(displayId);
|
||||
removed = true;
|
||||
if (DEBUG) {
|
||||
Slog.v(LOG_TAG, "Unregister proxy for display id " + displayId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (removed) {
|
||||
@@ -155,19 +167,25 @@ public class ProxyManager {
|
||||
*/
|
||||
public boolean isProxyed(int displayId) {
|
||||
synchronized (mLock) {
|
||||
return mProxyA11yServiceConnections.contains(displayId);
|
||||
final boolean tracked = mProxyA11yServiceConnections.contains(displayId);
|
||||
if (DEBUG) {
|
||||
Slog.v(LOG_TAG, "Tracking proxy display " + displayId + " : " + tracked);
|
||||
}
|
||||
return tracked;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends AccessibilityEvents to all proxies.
|
||||
* {@link android.view.accessibility.AccessibilityDisplayProxy} will filter based on display.
|
||||
* TODO(b/250929565): Filtering should happen in the system, not in the proxy.
|
||||
* Sends AccessibilityEvents to a proxy given the event's displayId.
|
||||
*/
|
||||
public void sendAccessibilityEventLocked(AccessibilityEvent event) {
|
||||
final ProxyAccessibilityServiceConnection proxy =
|
||||
mProxyA11yServiceConnections.get(event.getDisplayId());
|
||||
if (proxy != null) {
|
||||
if (DEBUG) {
|
||||
Slog.v(LOG_TAG, "Send proxy event " + event + " for display id "
|
||||
+ event.getDisplayId());
|
||||
}
|
||||
proxy.notifyAccessibilityEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -186,6 +204,9 @@ public class ProxyManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (DEBUG) {
|
||||
Slog.v(LOG_TAG, "At least one proxy can retrieve windows: " + observingWindows);
|
||||
}
|
||||
return observingWindows;
|
||||
}
|
||||
|
||||
@@ -205,6 +226,14 @@ public class ProxyManager {
|
||||
clientState |= AccessibilityManager.STATE_FLAG_TOUCH_EXPLORATION_ENABLED;
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
Slog.v(LOG_TAG, "Accessibility is enabled for all proxies: "
|
||||
+ ((clientState & AccessibilityManager.STATE_FLAG_ACCESSIBILITY_ENABLED) != 0));
|
||||
Slog.v(LOG_TAG, "Touch exploration is enabled for all proxies: "
|
||||
+ ((clientState & AccessibilityManager.STATE_FLAG_TOUCH_EXPLORATION_ENABLED)
|
||||
!= 0));
|
||||
}
|
||||
return clientState;
|
||||
// TODO(b/254545943): When A11yManager is separated, include support for other properties.
|
||||
}
|
||||
@@ -234,6 +263,10 @@ public class ProxyManager {
|
||||
mProxyA11yServiceConnections.valueAt(i);
|
||||
relevantEventTypes |= proxy.getRelevantEventTypes();
|
||||
}
|
||||
if (DEBUG) {
|
||||
Slog.v(LOG_TAG, "Relevant event types for all proxies: "
|
||||
+ AccessibilityEvent.eventTypeToString(relevantEventTypes));
|
||||
}
|
||||
return relevantEventTypes;
|
||||
}
|
||||
|
||||
@@ -275,4 +308,25 @@ public class ProxyManager {
|
||||
void setAccessibilityInputFilter(AccessibilityInputFilter filter) {
|
||||
mA11yInputFilter = filter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints information belonging to each display that is controlled by an
|
||||
* AccessibilityDisplayProxy.
|
||||
*/
|
||||
void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||
synchronized (mLock) {
|
||||
pw.println();
|
||||
pw.println("Proxy manager state:");
|
||||
pw.println(" Number of proxy connections: " + mProxyA11yServiceConnections.size());
|
||||
pw.println(" Registered proxy connections:");
|
||||
for (int i = 0; i < mProxyA11yServiceConnections.size(); i++) {
|
||||
final ProxyAccessibilityServiceConnection proxy =
|
||||
mProxyA11yServiceConnections.valueAt(i);
|
||||
if (proxy != null) {
|
||||
proxy.dump(fd, pw, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user