Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -52418,6 +52418,7 @@ package android.view.accessibility { method public void getBoundsInScreen(android.graphics.Rect); method public android.view.accessibility.AccessibilityWindowInfo getChild(int); method public int getChildCount(); method public int getDisplayId(); method public int getId(); method public int getLayer(); method public android.view.accessibility.AccessibilityWindowInfo getParent(); core/java/android/view/WindowInfo.java +6 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public class WindowInfo implements Parcelable { public long accessibilityIdOfAnchor = AccessibilityNodeInfo.UNDEFINED_NODE_ID; public boolean inPictureInPicture; public boolean hasFlagWatchOutsideTouch; public int displayId = Display.INVALID_DISPLAY; private WindowInfo() { /* do nothing - hide constructor */ Loading @@ -65,6 +66,7 @@ public class WindowInfo implements Parcelable { public static WindowInfo obtain(WindowInfo other) { WindowInfo window = obtain(); window.displayId = other.displayId; window.type = other.type; window.layer = other.layer; window.token = other.token; Loading Loading @@ -100,6 +102,7 @@ public class WindowInfo implements Parcelable { @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(displayId); parcel.writeInt(type); parcel.writeInt(layer); parcel.writeStrongBinder(token); Loading @@ -125,6 +128,7 @@ public class WindowInfo implements Parcelable { StringBuilder builder = new StringBuilder(); builder.append("WindowInfo["); builder.append("title=").append(title); builder.append(", displayId=").append(displayId); builder.append(", type=").append(type); builder.append(", layer=").append(layer); builder.append(", token=").append(token); Loading @@ -140,6 +144,7 @@ public class WindowInfo implements Parcelable { } private void initFromParcel(Parcel parcel) { displayId = parcel.readInt(); type = parcel.readInt(); layer = parcel.readInt(); token = parcel.readStrongBinder(); Loading @@ -162,6 +167,7 @@ public class WindowInfo implements Parcelable { } private void clear() { displayId = Display.INVALID_DISPLAY; type = 0; layer = 0; token = null; Loading core/java/android/view/accessibility/AccessibilityWindowInfo.java +29 −38 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.os.Parcelable; import android.text.TextUtils; import android.util.LongArray; import android.util.Pools.SynchronizedPool; import android.view.Display; import android.view.accessibility.AccessibilityEvent.WindowsChangeTypes; import java.util.Objects; Loading Loading @@ -100,6 +101,7 @@ public final class AccessibilityWindowInfo implements Parcelable { private static AtomicInteger sNumInstancesInUse; // Data. private int mDisplayId = Display.INVALID_DISPLAY; private int mType = UNDEFINED_WINDOW_ID; private int mLayer = UNDEFINED_WINDOW_ID; private int mBooleanProperties; Loading Loading @@ -427,6 +429,27 @@ public final class AccessibilityWindowInfo implements Parcelable { mChildIds.add(childId); } /** * Sets the display Id. * * @param displayId The display id. * * @hide */ public void setDisplayId(int displayId) { mDisplayId = displayId; } /** * Returns the ID of the display this window is on, for use with * {@link android.hardware.display.DisplayManager#getDisplay(int)}. * * @return The logical display id. */ public int getDisplayId() { return mDisplayId; } /** * Returns a cached instance if such is available or a new one is * created. Loading Loading @@ -493,6 +516,7 @@ public final class AccessibilityWindowInfo implements Parcelable { @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(mDisplayId); parcel.writeInt(mType); parcel.writeInt(mLayer); parcel.writeInt(mBooleanProperties); Loading Loading @@ -522,6 +546,7 @@ public final class AccessibilityWindowInfo implements Parcelable { * @param other The other instance. */ private void init(AccessibilityWindowInfo other) { mDisplayId = other.mDisplayId; mType = other.mType; mLayer = other.mLayer; mBooleanProperties = other.mBooleanProperties; Loading @@ -543,6 +568,7 @@ public final class AccessibilityWindowInfo implements Parcelable { } private void initFromParcel(Parcel parcel) { mDisplayId = parcel.readInt(); mType = parcel.readInt(); mLayer = parcel.readInt(); mBooleanProperties = parcel.readInt(); Loading Loading @@ -591,6 +617,7 @@ public final class AccessibilityWindowInfo implements Parcelable { StringBuilder builder = new StringBuilder(); builder.append("AccessibilityWindowInfo["); builder.append("title=").append(mTitle); builder.append(", displayId=").append(mDisplayId); builder.append(", id=").append(mId); builder.append(", type=").append(typeToString(mType)); builder.append(", layer=").append(mLayer); Loading Loading @@ -628,6 +655,7 @@ public final class AccessibilityWindowInfo implements Parcelable { * Clears the internal state. */ private void clear() { mDisplayId = Display.INVALID_DISPLAY; mType = UNDEFINED_WINDOW_ID; mLayer = UNDEFINED_WINDOW_ID; mBooleanProperties = 0; Loading Loading @@ -688,44 +716,6 @@ public final class AccessibilityWindowInfo implements Parcelable { } } /** * Checks whether this window changed. The argument should be * another state of the same window, which is have the same id * and type as they never change. * * @param other The new state. * @return Whether something changed. * * @hide */ public boolean changed(AccessibilityWindowInfo other) { if (other.mId != mId) { throw new IllegalArgumentException("Not same window."); } if (other.mType != mType) { throw new IllegalArgumentException("Not same type."); } if (!mBoundsInScreen.equals(other.mBoundsInScreen)) { return true; } if (mLayer != other.mLayer) { return true; } if (mBooleanProperties != other.mBooleanProperties) { return true; } if (mParentId != other.mParentId) { return true; } if (mChildIds == null) { if (other.mChildIds != null) { return true; } } else if (!mChildIds.equals(other.mChildIds)) { return true; } return false; } /** * Reports how this window differs from a possibly different state of the same window. The Loading Loading @@ -778,6 +768,7 @@ public final class AccessibilityWindowInfo implements Parcelable { if (!Objects.equals(mChildIds, other.mChildIds)) { changes |= AccessibilityEvent.WINDOWS_CHANGE_CHILDREN; } //TODO(b/1338122): Add DISPLAY_CHANGED type for multi-display return changes; } Loading core/tests/coretests/src/android/view/WindowInfoTest.java 0 → 100644 +137 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import android.os.IBinder; import android.os.Parcel; import android.platform.test.annotations.Presubmit; import android.view.accessibility.AccessibilityNodeInfo; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import java.util.ArrayList; /** * Class for testing {@link WindowInfo}. */ @Presubmit @RunWith(AndroidJUnit4.class) public class WindowInfoTest { @SmallTest @Test public void testObtain() { WindowInfo w1 = WindowInfo.obtain(); assertNotNull(w1); initTestWindowInfo(w1); WindowInfo w2 = WindowInfo.obtain(w1); assertNotSame(w1, w2); areWindowsEqual(w1, w2); } @SmallTest @Test public void testParceling() { Parcel parcel = Parcel.obtain(); WindowInfo w1 = WindowInfo.obtain(); initTestWindowInfo(w1); w1.writeToParcel(parcel, 0); parcel.setDataPosition(0); WindowInfo w2 = WindowInfo.CREATOR.createFromParcel(parcel); assertNotSame(w1, w2); areWindowsEqual(w1, w2); parcel.recycle(); } @SmallTest @Test public void testDefaultValues() { WindowInfo w = WindowInfo.obtain(); assertEquals(0, w.type); assertEquals(0, w.layer); assertEquals(AccessibilityNodeInfo.UNDEFINED_NODE_ID, w.accessibilityIdOfAnchor); assertEquals(Display.INVALID_DISPLAY, w.displayId); assertNull(w.title); assertNull(w.token); assertNull(w.childTokens); assertNull(w.parentToken); assertNull(w.activityToken); assertFalse(w.focused); assertFalse(w.inPictureInPicture); assertFalse(w.hasFlagWatchOutsideTouch); assertTrue(w.boundsInScreen.isEmpty()); } @SmallTest @Test public void testRecycle() { WindowInfo w = WindowInfo.obtain(); w.recycle(); try { w.recycle(); fail("Expected IllegalStateException"); } catch (IllegalStateException e) { // Expected. } } private boolean areWindowsEqual(WindowInfo w1, WindowInfo w2) { boolean equality = w1.toString().contentEquals(w2.toString()); equality &= w1.token == w2.token; equality &= w1.childTokens.equals(w2.childTokens); equality &= w1.parentToken == w2.parentToken; equality &= w1.activityToken == w2.activityToken; equality &= w1.boundsInScreen.equals(w2.boundsInScreen); return equality; } private void initTestWindowInfo(WindowInfo windowInfo) { windowInfo.type = 1; windowInfo.displayId = 2; windowInfo.layer = 3; windowInfo.accessibilityIdOfAnchor = 4L; windowInfo.title = "title"; windowInfo.token = mock(IBinder.class); windowInfo.childTokens = new ArrayList<>(); windowInfo.childTokens.add(mock(IBinder.class)); windowInfo.parentToken = mock(IBinder.class); windowInfo.activityToken = mock(IBinder.class); windowInfo.focused = true; windowInfo.inPictureInPicture = true; windowInfo.hasFlagWatchOutsideTouch = true; windowInfo.boundsInScreen.set(0, 0, 1080, 1080); } } services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java +1 −0 Original line number Diff line number Diff line Loading @@ -1009,6 +1009,7 @@ public class AccessibilityWindowManager reportedWindow.setTitle(window.title); reportedWindow.setAnchorId(window.accessibilityIdOfAnchor); reportedWindow.setPictureInPicture(window.inPictureInPicture); reportedWindow.setDisplayId(window.displayId); final int parentId = findWindowIdLocked(userId, window.parentToken); if (parentId >= 0) { Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -52418,6 +52418,7 @@ package android.view.accessibility { method public void getBoundsInScreen(android.graphics.Rect); method public android.view.accessibility.AccessibilityWindowInfo getChild(int); method public int getChildCount(); method public int getDisplayId(); method public int getId(); method public int getLayer(); method public android.view.accessibility.AccessibilityWindowInfo getParent();
core/java/android/view/WindowInfo.java +6 −0 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ public class WindowInfo implements Parcelable { public long accessibilityIdOfAnchor = AccessibilityNodeInfo.UNDEFINED_NODE_ID; public boolean inPictureInPicture; public boolean hasFlagWatchOutsideTouch; public int displayId = Display.INVALID_DISPLAY; private WindowInfo() { /* do nothing - hide constructor */ Loading @@ -65,6 +66,7 @@ public class WindowInfo implements Parcelable { public static WindowInfo obtain(WindowInfo other) { WindowInfo window = obtain(); window.displayId = other.displayId; window.type = other.type; window.layer = other.layer; window.token = other.token; Loading Loading @@ -100,6 +102,7 @@ public class WindowInfo implements Parcelable { @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(displayId); parcel.writeInt(type); parcel.writeInt(layer); parcel.writeStrongBinder(token); Loading @@ -125,6 +128,7 @@ public class WindowInfo implements Parcelable { StringBuilder builder = new StringBuilder(); builder.append("WindowInfo["); builder.append("title=").append(title); builder.append(", displayId=").append(displayId); builder.append(", type=").append(type); builder.append(", layer=").append(layer); builder.append(", token=").append(token); Loading @@ -140,6 +144,7 @@ public class WindowInfo implements Parcelable { } private void initFromParcel(Parcel parcel) { displayId = parcel.readInt(); type = parcel.readInt(); layer = parcel.readInt(); token = parcel.readStrongBinder(); Loading @@ -162,6 +167,7 @@ public class WindowInfo implements Parcelable { } private void clear() { displayId = Display.INVALID_DISPLAY; type = 0; layer = 0; token = null; Loading
core/java/android/view/accessibility/AccessibilityWindowInfo.java +29 −38 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.os.Parcelable; import android.text.TextUtils; import android.util.LongArray; import android.util.Pools.SynchronizedPool; import android.view.Display; import android.view.accessibility.AccessibilityEvent.WindowsChangeTypes; import java.util.Objects; Loading Loading @@ -100,6 +101,7 @@ public final class AccessibilityWindowInfo implements Parcelable { private static AtomicInteger sNumInstancesInUse; // Data. private int mDisplayId = Display.INVALID_DISPLAY; private int mType = UNDEFINED_WINDOW_ID; private int mLayer = UNDEFINED_WINDOW_ID; private int mBooleanProperties; Loading Loading @@ -427,6 +429,27 @@ public final class AccessibilityWindowInfo implements Parcelable { mChildIds.add(childId); } /** * Sets the display Id. * * @param displayId The display id. * * @hide */ public void setDisplayId(int displayId) { mDisplayId = displayId; } /** * Returns the ID of the display this window is on, for use with * {@link android.hardware.display.DisplayManager#getDisplay(int)}. * * @return The logical display id. */ public int getDisplayId() { return mDisplayId; } /** * Returns a cached instance if such is available or a new one is * created. Loading Loading @@ -493,6 +516,7 @@ public final class AccessibilityWindowInfo implements Parcelable { @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(mDisplayId); parcel.writeInt(mType); parcel.writeInt(mLayer); parcel.writeInt(mBooleanProperties); Loading Loading @@ -522,6 +546,7 @@ public final class AccessibilityWindowInfo implements Parcelable { * @param other The other instance. */ private void init(AccessibilityWindowInfo other) { mDisplayId = other.mDisplayId; mType = other.mType; mLayer = other.mLayer; mBooleanProperties = other.mBooleanProperties; Loading @@ -543,6 +568,7 @@ public final class AccessibilityWindowInfo implements Parcelable { } private void initFromParcel(Parcel parcel) { mDisplayId = parcel.readInt(); mType = parcel.readInt(); mLayer = parcel.readInt(); mBooleanProperties = parcel.readInt(); Loading Loading @@ -591,6 +617,7 @@ public final class AccessibilityWindowInfo implements Parcelable { StringBuilder builder = new StringBuilder(); builder.append("AccessibilityWindowInfo["); builder.append("title=").append(mTitle); builder.append(", displayId=").append(mDisplayId); builder.append(", id=").append(mId); builder.append(", type=").append(typeToString(mType)); builder.append(", layer=").append(mLayer); Loading Loading @@ -628,6 +655,7 @@ public final class AccessibilityWindowInfo implements Parcelable { * Clears the internal state. */ private void clear() { mDisplayId = Display.INVALID_DISPLAY; mType = UNDEFINED_WINDOW_ID; mLayer = UNDEFINED_WINDOW_ID; mBooleanProperties = 0; Loading Loading @@ -688,44 +716,6 @@ public final class AccessibilityWindowInfo implements Parcelable { } } /** * Checks whether this window changed. The argument should be * another state of the same window, which is have the same id * and type as they never change. * * @param other The new state. * @return Whether something changed. * * @hide */ public boolean changed(AccessibilityWindowInfo other) { if (other.mId != mId) { throw new IllegalArgumentException("Not same window."); } if (other.mType != mType) { throw new IllegalArgumentException("Not same type."); } if (!mBoundsInScreen.equals(other.mBoundsInScreen)) { return true; } if (mLayer != other.mLayer) { return true; } if (mBooleanProperties != other.mBooleanProperties) { return true; } if (mParentId != other.mParentId) { return true; } if (mChildIds == null) { if (other.mChildIds != null) { return true; } } else if (!mChildIds.equals(other.mChildIds)) { return true; } return false; } /** * Reports how this window differs from a possibly different state of the same window. The Loading Loading @@ -778,6 +768,7 @@ public final class AccessibilityWindowInfo implements Parcelable { if (!Objects.equals(mChildIds, other.mChildIds)) { changes |= AccessibilityEvent.WINDOWS_CHANGE_CHILDREN; } //TODO(b/1338122): Add DISPLAY_CHANGED type for multi-display return changes; } Loading
core/tests/coretests/src/android/view/WindowInfoTest.java 0 → 100644 +137 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.view; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import android.os.IBinder; import android.os.Parcel; import android.platform.test.annotations.Presubmit; import android.view.accessibility.AccessibilityNodeInfo; import androidx.test.filters.SmallTest; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import java.util.ArrayList; /** * Class for testing {@link WindowInfo}. */ @Presubmit @RunWith(AndroidJUnit4.class) public class WindowInfoTest { @SmallTest @Test public void testObtain() { WindowInfo w1 = WindowInfo.obtain(); assertNotNull(w1); initTestWindowInfo(w1); WindowInfo w2 = WindowInfo.obtain(w1); assertNotSame(w1, w2); areWindowsEqual(w1, w2); } @SmallTest @Test public void testParceling() { Parcel parcel = Parcel.obtain(); WindowInfo w1 = WindowInfo.obtain(); initTestWindowInfo(w1); w1.writeToParcel(parcel, 0); parcel.setDataPosition(0); WindowInfo w2 = WindowInfo.CREATOR.createFromParcel(parcel); assertNotSame(w1, w2); areWindowsEqual(w1, w2); parcel.recycle(); } @SmallTest @Test public void testDefaultValues() { WindowInfo w = WindowInfo.obtain(); assertEquals(0, w.type); assertEquals(0, w.layer); assertEquals(AccessibilityNodeInfo.UNDEFINED_NODE_ID, w.accessibilityIdOfAnchor); assertEquals(Display.INVALID_DISPLAY, w.displayId); assertNull(w.title); assertNull(w.token); assertNull(w.childTokens); assertNull(w.parentToken); assertNull(w.activityToken); assertFalse(w.focused); assertFalse(w.inPictureInPicture); assertFalse(w.hasFlagWatchOutsideTouch); assertTrue(w.boundsInScreen.isEmpty()); } @SmallTest @Test public void testRecycle() { WindowInfo w = WindowInfo.obtain(); w.recycle(); try { w.recycle(); fail("Expected IllegalStateException"); } catch (IllegalStateException e) { // Expected. } } private boolean areWindowsEqual(WindowInfo w1, WindowInfo w2) { boolean equality = w1.toString().contentEquals(w2.toString()); equality &= w1.token == w2.token; equality &= w1.childTokens.equals(w2.childTokens); equality &= w1.parentToken == w2.parentToken; equality &= w1.activityToken == w2.activityToken; equality &= w1.boundsInScreen.equals(w2.boundsInScreen); return equality; } private void initTestWindowInfo(WindowInfo windowInfo) { windowInfo.type = 1; windowInfo.displayId = 2; windowInfo.layer = 3; windowInfo.accessibilityIdOfAnchor = 4L; windowInfo.title = "title"; windowInfo.token = mock(IBinder.class); windowInfo.childTokens = new ArrayList<>(); windowInfo.childTokens.add(mock(IBinder.class)); windowInfo.parentToken = mock(IBinder.class); windowInfo.activityToken = mock(IBinder.class); windowInfo.focused = true; windowInfo.inPictureInPicture = true; windowInfo.hasFlagWatchOutsideTouch = true; windowInfo.boundsInScreen.set(0, 0, 1080, 1080); } }
services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java +1 −0 Original line number Diff line number Diff line Loading @@ -1009,6 +1009,7 @@ public class AccessibilityWindowManager reportedWindow.setTitle(window.title); reportedWindow.setAnchorId(window.accessibilityIdOfAnchor); reportedWindow.setPictureInPicture(window.inPictureInPicture); reportedWindow.setDisplayId(window.displayId); final int parentId = findWindowIdLocked(userId, window.parentToken); if (parentId >= 0) { Loading