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

Commit 6f8792bb authored by Yabin Huang's avatar Yabin Huang Committed by Android (Google) Code Review
Browse files

Merge "Add hidden APIs to allow to get and set task ID in AccessibilityWindowInfo" into sc-v2-dev

parents 8dfe5d9a 1cd59c50
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;

import android.app.ActivityTaskManager;
import android.graphics.Region;
import android.os.IBinder;
import android.os.Parcel;
@@ -51,6 +52,7 @@ public class WindowInfo implements Parcelable {
    public boolean inPictureInPicture;
    public boolean hasFlagWatchOutsideTouch;
    public int displayId = Display.INVALID_DISPLAY;
    public int taskId = ActivityTaskManager.INVALID_TASK_ID;

    private WindowInfo() {
        /* do nothing - hide constructor */
@@ -67,6 +69,7 @@ public class WindowInfo implements Parcelable {
    public static WindowInfo obtain(WindowInfo other) {
        WindowInfo window = obtain();
        window.displayId = other.displayId;
        window.taskId = other.taskId;
        window.type = other.type;
        window.layer = other.layer;
        window.token = other.token;
@@ -103,6 +106,7 @@ public class WindowInfo implements Parcelable {
    @Override
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeInt(displayId);
        parcel.writeInt(taskId);
        parcel.writeInt(type);
        parcel.writeInt(layer);
        parcel.writeStrongBinder(token);
@@ -129,6 +133,7 @@ public class WindowInfo implements Parcelable {
        builder.append("WindowInfo[");
        builder.append("title=").append(title);
        builder.append(", displayId=").append(displayId);
        builder.append(", taskId=").append(taskId);
        builder.append(", type=").append(type);
        builder.append(", layer=").append(layer);
        builder.append(", token=").append(token);
@@ -146,6 +151,7 @@ public class WindowInfo implements Parcelable {

    private void initFromParcel(Parcel parcel) {
        displayId = parcel.readInt();
        taskId = parcel.readInt();
        type = parcel.readInt();
        layer = parcel.readInt();
        token = parcel.readStrongBinder();
@@ -169,6 +175,7 @@ public class WindowInfo implements Parcelable {

    private void clear() {
        displayId = Display.INVALID_DISPLAY;
        taskId = ActivityTaskManager.INVALID_TASK_ID;
        type = 0;
        layer = 0;
        token = null;
+29 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.view.accessibility;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.app.ActivityTaskManager;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Parcel;
@@ -114,6 +115,7 @@ public final class AccessibilityWindowInfo implements Parcelable {
    private int mBooleanProperties;
    private int mId = UNDEFINED_WINDOW_ID;
    private int mParentId = UNDEFINED_WINDOW_ID;
    private int mTaskId = ActivityTaskManager.INVALID_TASK_ID;
    private Region mRegionInScreen = new Region();
    private LongArray mChildIds;
    private CharSequence mTitle;
@@ -306,6 +308,28 @@ public final class AccessibilityWindowInfo implements Parcelable {
        mId = id;
    }

    /**
     * Gets the task ID.
     *
     * @return The task ID.
     *
     * @hide
     */
    public int getTaskId() {
        return mTaskId;
    }

    /**
     * Sets the task ID.
     *
     * @param taskId The task ID.
     *
     * @hide
     */
    public void setTaskId(int taskId) {
        mTaskId = taskId;
    }

    /**
     * Sets the unique id of the IAccessibilityServiceConnection over which
     * this instance can send requests to the system.
@@ -578,6 +602,7 @@ public final class AccessibilityWindowInfo implements Parcelable {
        parcel.writeInt(mBooleanProperties);
        parcel.writeInt(mId);
        parcel.writeInt(mParentId);
        parcel.writeInt(mTaskId);
        mRegionInScreen.writeToParcel(parcel, flags);
        parcel.writeCharSequence(mTitle);
        parcel.writeLong(mAnchorId);
@@ -608,6 +633,7 @@ public final class AccessibilityWindowInfo implements Parcelable {
        mBooleanProperties = other.mBooleanProperties;
        mId = other.mId;
        mParentId = other.mParentId;
        mTaskId = other.mTaskId;
        mRegionInScreen.set(other.mRegionInScreen);
        mTitle = other.mTitle;
        mAnchorId = other.mAnchorId;
@@ -631,6 +657,7 @@ public final class AccessibilityWindowInfo implements Parcelable {
        mBooleanProperties = parcel.readInt();
        mId = parcel.readInt();
        mParentId = parcel.readInt();
        mTaskId = parcel.readInt();
        mRegionInScreen = Region.CREATOR.createFromParcel(parcel);
        mTitle = parcel.readCharSequence();
        mAnchorId = parcel.readLong();
@@ -676,6 +703,7 @@ public final class AccessibilityWindowInfo implements Parcelable {
        builder.append("title=").append(mTitle);
        builder.append(", displayId=").append(mDisplayId);
        builder.append(", id=").append(mId);
        builder.append(", taskId=").append(mTaskId);
        builder.append(", type=").append(typeToString(mType));
        builder.append(", layer=").append(mLayer);
        builder.append(", region=").append(mRegionInScreen);
@@ -719,6 +747,7 @@ public final class AccessibilityWindowInfo implements Parcelable {
        mBooleanProperties = 0;
        mId = UNDEFINED_WINDOW_ID;
        mParentId = UNDEFINED_WINDOW_ID;
        mTaskId = ActivityTaskManager.INVALID_TASK_ID;
        mRegionInScreen.setEmpty();
        mChildIds = null;
        mConnectionId = UNDEFINED_WINDOW_ID;
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;

import android.app.ActivityTaskManager;
import android.os.IBinder;
import android.os.Parcel;
import android.platform.test.annotations.Presubmit;
@@ -83,6 +84,7 @@ public class WindowInfoTest {
        assertEquals(0, w.layer);
        assertEquals(AccessibilityNodeInfo.UNDEFINED_NODE_ID, w.accessibilityIdOfAnchor);
        assertEquals(Display.INVALID_DISPLAY, w.displayId);
        assertEquals(ActivityTaskManager.INVALID_TASK_ID, w.taskId);
        assertNull(w.title);
        assertNull(w.token);
        assertNull(w.childTokens);
@@ -123,6 +125,7 @@ public class WindowInfoTest {
        windowInfo.displayId = 2;
        windowInfo.layer = 3;
        windowInfo.accessibilityIdOfAnchor = 4L;
        windowInfo.taskId = 5;
        windowInfo.title = "title";
        windowInfo.token = mock(IBinder.class);
        windowInfo.childTokens = new ArrayList<>();
+4 −0
Original line number Diff line number Diff line
@@ -499,6 +499,9 @@ public class AccessibilityWindowManager {
            if (oldWindow.displayId != newWindow.displayId) {
                return true;
            }
            if (oldWindow.taskId != newWindow.taskId) {
                return true;
            }
            return false;
        }

@@ -699,6 +702,7 @@ public class AccessibilityWindowManager {
            reportedWindow.setAnchorId(window.accessibilityIdOfAnchor);
            reportedWindow.setPictureInPicture(window.inPictureInPicture);
            reportedWindow.setDisplayId(window.displayId);
            reportedWindow.setTaskId(window.taskId);

            final int parentId = findWindowIdLocked(userId, window.parentToken);
            if (parentId >= 0) {
+2 −0
Original line number Diff line number Diff line
@@ -193,6 +193,7 @@ import static com.android.server.wm.WindowStateProto.WINDOW_FRAMES;
import android.annotation.CallSuper;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityTaskManager;
import android.app.AppOpsManager;
import android.app.admin.DevicePolicyCache;
import android.app.compat.CompatChanges;
@@ -4824,6 +4825,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        windowInfo.focused = isFocused();
        Task task = getTask();
        windowInfo.inPictureInPicture = (task != null) && task.inPinnedWindowingMode();
        windowInfo.taskId = task == null ? ActivityTaskManager.INVALID_TASK_ID : task.mTaskId;
        windowInfo.hasFlagWatchOutsideTouch =
                (mAttrs.flags & WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH) != 0;