Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f597a64e authored by mincheli's avatar mincheli
Browse files

Dumps magnification information when calling dumpsys accessibility

To make the magnification debugging easier, we add the dump information for magnification.

AccessibilityManagerService dumps magnification information
of the controlling magnifiers on the displays
When
1. $adb shell dumpsys accessibility
2. CTS a11y test cause failed,

Bug: 214835232
Test: manual - Turn on the magnifier and $adb shell dumpsys accessibility
Change-Id: I39c393e6c41928f303c2aee8c0d7f0f6478162f9
parent 03a3c96b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3497,6 +3497,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
            pw.append("hasWindowMagnificationConnection=").append(
                    String.valueOf(getWindowMagnificationMgr().isConnected()));
            pw.println();
            mMagnificationProcessor.dump(pw, getValidDisplayList());
            final int userCount = mUserStates.size();
            for (int i = 0; i < userCount; i++) {
                mUserStates.valueAt(i).dump(fd, pw, args);
+29 −0
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@ import static android.view.accessibility.MagnificationAnimationCallback.STUB_ANI
import android.accessibilityservice.MagnificationConfig;
import android.annotation.NonNull;
import android.graphics.Region;
import android.view.Display;

import java.io.PrintWriter;
import java.util.ArrayList;

/**
 * Processor class for AccessibilityService connection to control magnification on the specified
@@ -360,4 +364,29 @@ public class MagnificationProcessor {
    private void unregister(int displayId) {
        mController.getFullScreenMagnificationController().unregister(displayId);
    }

    /** Dumps {@link MagnificationConfig} and magnification region of magnifiers on the displays. */
    public void dump(final PrintWriter pw, ArrayList<Display> displaysList) {
        for (int i = 0; i < displaysList.size(); i++) {
            final int displayId = displaysList.get(i).getDisplayId();
            final MagnificationConfig config = getMagnificationConfig(displayId);
            pw.println("Magnifier on display#" + displayId);
            pw.append("    " + config).println();
            final Region region = new Region();
            getCurrentMagnificationRegion(displayId, region, true);
            if (!region.isEmpty()) {
                pw.append("    Magnification region=").append(region.toString()).println();
            }
            pw.append("    IdOfLastServiceToMagnify="
                    + getIdOfLastServiceToMagnify(config.getMode(), displayId)).println();
        }
    }

    private int getIdOfLastServiceToMagnify(int mode, int displayId) {
        return (mode == MAGNIFICATION_MODE_FULLSCREEN)
                ? mController.getFullScreenMagnificationController()
                .getIdOfLastServiceToMagnify(displayId)
                : mController.getWindowMagnificationMgr().getIdOfLastServiceToMagnify(
                        displayId);
    }
}
+18 −0
Original line number Diff line number Diff line
@@ -318,6 +318,22 @@ public class WindowMagnificationManager implements
        mMagnificationFollowTypingEnabled = enabled;
    }

    /**
     * Get the ID of the last service that changed the magnification config.
     *
     * @param displayId The logical display id.
     * @return The id
     */
    public int getIdOfLastServiceToMagnify(int displayId) {
        synchronized (mLock) {
            final WindowMagnifier magnifier = mWindowMagnifiers.get(displayId);
            if (magnifier != null) {
                return magnifier.mIdOfLastServiceToControl;
            }
        }
        return INVALID_SERVICE_ID;
    }

    /**
     * Enable or disable tracking typing focus for the specific magnification window.
     *
@@ -466,6 +482,7 @@ public class WindowMagnificationManager implements
        boolean previousEnabled;
        synchronized (mLock) {
            if (mConnectionWrapper == null) {
                Slog.w(TAG, "enableWindowMagnification failed: connection null");
                return false;
            }
            WindowMagnifier magnifier = mWindowMagnifiers.get(displayId);
@@ -508,6 +525,7 @@ public class WindowMagnificationManager implements
        synchronized (mLock) {
            WindowMagnifier magnifier = mWindowMagnifiers.get(displayId);
            if (magnifier == null || mConnectionWrapper == null) {
                Slog.w(TAG, "disableWindowMagnification failed: connection " + mConnectionWrapper);
                return false;
            }
            disabled = magnifier.disableWindowMagnificationInternal(animationCallback);