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

Commit 2ffddde1 authored by Evan Rosky's avatar Evan Rosky
Browse files

Use Divider ShellRoot to ferry divider to Accessibility

This is kinda a hack until we have more robust WM and
accessibility infrastructure in place. It assumes that the
shell-root for docked divider only has one window in it.

Bug: 152368950
Test: Enter split-screen with Talkback on. Touch divider.
Change-Id: I401c6f889540054a8ee691bea714dc7a1b1658c8
parent 2b80990b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1246,6 +1246,16 @@ final class AccessibilityController {
                    }
                }

                for (int i = dc.mShellRoots.size() - 1; i >= 0; --i) {
                    final WindowInfo info = dc.mShellRoots.valueAt(i).getWindowInfo();
                    if (info == null) {
                        continue;
                    }
                    info.layer = addedWindows.size();
                    windows.add(info);
                    addedWindows.add(info.token);
                }

                // Remove child/parent references to windows that were not added.
                final int windowCount = windows.size();
                for (int i = 0; i < windowCount; i++) {
+1 −2
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
@@ -574,7 +573,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    /** Corner radius that windows should have in order to match the display. */
    private final float mWindowCornerRadius;

    private final SparseArray<ShellRoot> mShellRoots = new SparseArray<>();
    final SparseArray<ShellRoot> mShellRoots = new SparseArray<>();
    RemoteInsetsControlTarget mRemoteInsetsControlTarget = null;
    private final IBinder.DeathRecipient mRemoteInsetsDeath =
            () -> {
+5 −0
Original line number Diff line number Diff line
@@ -45,6 +45,11 @@ public class DockedStackDividerController {

    void setTouchRegion(Rect touchRegion) {
        mTouchRegion.set(touchRegion);
        // We need to report touchable region changes to accessibility.
        if (mDisplayContent.mWmService.mAccessibilityController != null) {
            mDisplayContent.mWmService.mAccessibilityController.onSomeWindowResizedOrMovedLocked(
                    mDisplayContent.getDisplayId());
        }
    }

    void getTouchRegion(Rect outRegion) {
+24 −0
Original line number Diff line number Diff line
@@ -23,12 +23,14 @@ import static com.android.server.wm.WindowManagerService.MAX_ANIMATION_DURATION;

import android.annotation.NonNull;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Slog;
import android.view.DisplayInfo;
import android.view.IWindow;
import android.view.SurfaceControl;
import android.view.WindowInfo;
import android.view.animation.Animation;

/**
@@ -102,5 +104,27 @@ public class ShellRoot {
        mToken.startAnimation(mToken.getPendingTransaction(), adapter, false /* hidden */,
                ANIMATION_TYPE_WINDOW_ANIMATION, null /* animationFinishedCallback */);
    }

    WindowInfo getWindowInfo() {
        if (mToken.windowType != TYPE_DOCK_DIVIDER) {
            return null;
        }
        if (!mDisplayContent.getDefaultTaskDisplayArea().isSplitScreenModeActivated()) {
            return null;
        }
        WindowInfo windowInfo = WindowInfo.obtain();
        windowInfo.displayId = mToken.getDisplayArea().getDisplayContent().mDisplayId;
        windowInfo.type = mToken.windowType;
        windowInfo.layer = mToken.getWindowLayerFromType();
        windowInfo.token = mClient.asBinder();
        windowInfo.title = "Splitscreen Divider";
        windowInfo.focused = false;
        windowInfo.inPictureInPicture = false;
        windowInfo.hasFlagWatchOutsideTouch = false;
        final Rect regionRect = new Rect();
        mDisplayContent.getDockedDividerController().getTouchRegion(regionRect);
        windowInfo.regionInScreen.set(regionRect);
        return windowInfo;
    }
}