Deprecate obtain and recycle for AccessibilityNodeInfo
Test: Feature removal, should not interfere with existing unit tests Fixes: 208469173 Change-Id: I894d94ff75dd3dbf39528d11726b99135dd957c8
This commit is contained in:
@@ -51272,9 +51272,9 @@ package android.view.accessibility {
|
||||
method public int getRecordCount();
|
||||
method public int getWindowChanges();
|
||||
method public void initFromParcel(android.os.Parcel);
|
||||
method public static android.view.accessibility.AccessibilityEvent obtain(int);
|
||||
method public static android.view.accessibility.AccessibilityEvent obtain(android.view.accessibility.AccessibilityEvent);
|
||||
method public static android.view.accessibility.AccessibilityEvent obtain();
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityEvent obtain(int);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityEvent obtain(android.view.accessibility.AccessibilityEvent);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityEvent obtain();
|
||||
method public void setAction(int);
|
||||
method public void setContentChangeTypes(int);
|
||||
method public void setEventTime(long);
|
||||
@@ -51462,13 +51462,13 @@ package android.view.accessibility {
|
||||
method public boolean isShowingHintText();
|
||||
method public boolean isTextEntryKey();
|
||||
method public boolean isVisibleToUser();
|
||||
method public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View);
|
||||
method public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View, int);
|
||||
method public static android.view.accessibility.AccessibilityNodeInfo obtain();
|
||||
method public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.accessibility.AccessibilityNodeInfo);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.View, int);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo obtain();
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo obtain(android.view.accessibility.AccessibilityNodeInfo);
|
||||
method public boolean performAction(int);
|
||||
method public boolean performAction(int, android.os.Bundle);
|
||||
method public void recycle();
|
||||
method @Deprecated public void recycle();
|
||||
method public boolean refresh();
|
||||
method public boolean refreshWithExtraData(String, android.os.Bundle);
|
||||
method @Deprecated public void removeAction(int);
|
||||
@@ -51647,8 +51647,8 @@ package android.view.accessibility {
|
||||
method public int getRowCount();
|
||||
method public int getSelectionMode();
|
||||
method public boolean isHierarchical();
|
||||
method public static android.view.accessibility.AccessibilityNodeInfo.CollectionInfo obtain(int, int, boolean);
|
||||
method public static android.view.accessibility.AccessibilityNodeInfo.CollectionInfo obtain(int, int, boolean, int);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo.CollectionInfo obtain(int, int, boolean);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo.CollectionInfo obtain(int, int, boolean, int);
|
||||
field public static final int SELECTION_MODE_MULTIPLE = 2; // 0x2
|
||||
field public static final int SELECTION_MODE_NONE = 0; // 0x0
|
||||
field public static final int SELECTION_MODE_SINGLE = 1; // 0x1
|
||||
@@ -51666,9 +51666,9 @@ package android.view.accessibility {
|
||||
method @Nullable public String getRowTitle();
|
||||
method @Deprecated public boolean isHeading();
|
||||
method public boolean isSelected();
|
||||
method public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(int, int, int, int, boolean);
|
||||
method public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(int, int, int, int, boolean, boolean);
|
||||
method @NonNull public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(@Nullable String, int, int, @Nullable String, int, int, boolean, boolean);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(int, int, int, int, boolean);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(int, int, int, int, boolean, boolean);
|
||||
method @Deprecated @NonNull public static android.view.accessibility.AccessibilityNodeInfo.CollectionItemInfo obtain(@Nullable String, int, int, @Nullable String, int, int, boolean, boolean);
|
||||
}
|
||||
|
||||
public static final class AccessibilityNodeInfo.ExtraRenderingInfo {
|
||||
@@ -51683,7 +51683,7 @@ package android.view.accessibility {
|
||||
method public float getMax();
|
||||
method public float getMin();
|
||||
method public int getType();
|
||||
method public static android.view.accessibility.AccessibilityNodeInfo.RangeInfo obtain(int, float, float, float);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityNodeInfo.RangeInfo obtain(int, float, float, float);
|
||||
field public static final int RANGE_TYPE_FLOAT = 1; // 0x1
|
||||
field public static final int RANGE_TYPE_INT = 0; // 0x0
|
||||
field public static final int RANGE_TYPE_PERCENT = 2; // 0x2
|
||||
@@ -51737,9 +51737,9 @@ package android.view.accessibility {
|
||||
method public boolean isFullScreen();
|
||||
method public boolean isPassword();
|
||||
method public boolean isScrollable();
|
||||
method public static android.view.accessibility.AccessibilityRecord obtain(android.view.accessibility.AccessibilityRecord);
|
||||
method public static android.view.accessibility.AccessibilityRecord obtain();
|
||||
method public void recycle();
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityRecord obtain(android.view.accessibility.AccessibilityRecord);
|
||||
method @Deprecated public static android.view.accessibility.AccessibilityRecord obtain();
|
||||
method @Deprecated public void recycle();
|
||||
method public void setAddedCount(int);
|
||||
method public void setBeforeText(CharSequence);
|
||||
method public void setChecked(boolean);
|
||||
|
||||
@@ -2867,7 +2867,6 @@ package android.view.accessibility {
|
||||
method public void addChild(@NonNull android.os.IBinder);
|
||||
method public long getSourceNodeId();
|
||||
method public void setLeashedParent(@Nullable android.os.IBinder, int);
|
||||
method public static void setNumInstancesInUseCounter(java.util.concurrent.atomic.AtomicInteger);
|
||||
method public void writeToParcelNoRecycle(android.os.Parcel, int);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pools.SynchronizedPool;
|
||||
|
||||
import com.android.internal.util.BitUtils;
|
||||
|
||||
@@ -806,10 +805,6 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
|
||||
*/
|
||||
public static final int TYPES_ALL_MASK = 0xFFFFFFFF;
|
||||
|
||||
private static final int MAX_POOL_SIZE = 10;
|
||||
private static final SynchronizedPool<AccessibilityEvent> sPool =
|
||||
new SynchronizedPool<>(MAX_POOL_SIZE);
|
||||
|
||||
@UnsupportedAppUsage
|
||||
private @EventType int mEventType;
|
||||
private CharSequence mPackageName;
|
||||
@@ -1170,7 +1165,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
|
||||
*/
|
||||
public static AccessibilityEvent obtainWindowsChangedEvent(
|
||||
int windowId, int windowChangeTypes) {
|
||||
final AccessibilityEvent event = AccessibilityEvent.obtain(TYPE_WINDOWS_CHANGED);
|
||||
final AccessibilityEvent event = new AccessibilityEvent(TYPE_WINDOWS_CHANGED);
|
||||
event.setWindowId(windowId);
|
||||
event.setWindowChanges(windowChangeTypes);
|
||||
event.setImportantForAccessibility(true);
|
||||
@@ -1178,69 +1173,58 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cached instance if such is available or a new one is
|
||||
* instantiated with its type property set.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* constructor {@link #AccessibilityEvent(int)} instead.
|
||||
* Instantiates a new AccessibilityEvent instance with its type property set.
|
||||
*
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #AccessibilityEvent()} instead.
|
||||
* @param eventType The event type.
|
||||
* @return An instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public static AccessibilityEvent obtain(int eventType) {
|
||||
AccessibilityEvent event = AccessibilityEvent.obtain();
|
||||
AccessibilityEvent event = new AccessibilityEvent();
|
||||
event.setEventType(eventType);
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cached instance if such is available or a new one is
|
||||
* created. The returned instance is initialized from the given
|
||||
* Instantiates a new AccessibilityEvent instance.
|
||||
* The returned instance is initialized from the given
|
||||
* <code>event</code>.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* constructor {@link #AccessibilityEvent(AccessibilityEvent)} instead.
|
||||
*
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #AccessibilityEvent()} instead.
|
||||
* @param event The other event.
|
||||
* @return An instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public static AccessibilityEvent obtain(AccessibilityEvent event) {
|
||||
AccessibilityEvent eventClone = AccessibilityEvent.obtain();
|
||||
AccessibilityEvent eventClone = new AccessibilityEvent();
|
||||
eventClone.init(event);
|
||||
return eventClone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cached instance if such is available or a new one is
|
||||
* instantiated.
|
||||
* Instantiates a new AccessibilityEvent instance.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #AccessibilityEvent()} instead.
|
||||
*
|
||||
* @return An instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public static AccessibilityEvent obtain() {
|
||||
AccessibilityEvent event = sPool.acquire();
|
||||
if (event == null) event = new AccessibilityEvent();
|
||||
if (DEBUG_ORIGIN) event.originStackTrace = Thread.currentThread().getStackTrace();
|
||||
return event;
|
||||
return new AccessibilityEvent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recycles an instance back to be reused.
|
||||
* <p>
|
||||
* <b>Note: You must not touch the object after calling this function.</b>
|
||||
* </p>
|
||||
* Previously would recycle an instance back to be reused.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial, and recycling is not necessary.
|
||||
*
|
||||
* @throws IllegalStateException If the event is already recycled.
|
||||
* @deprecated Object pooling has been discontinued. Calling this function now will have
|
||||
* no effect.
|
||||
*/
|
||||
@Override
|
||||
public void recycle() {
|
||||
clear();
|
||||
sPool.release(this);
|
||||
}
|
||||
@Deprecated
|
||||
public void recycle() {}
|
||||
|
||||
/**
|
||||
* Clears the state of this instance.
|
||||
@@ -1260,7 +1244,6 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
|
||||
if (mRecords != null) {
|
||||
while (!mRecords.isEmpty()) {
|
||||
AccessibilityRecord record = mRecords.remove(0);
|
||||
record.recycle();
|
||||
}
|
||||
}
|
||||
if (DEBUG_ORIGIN) originStackTrace = null;
|
||||
@@ -1288,7 +1271,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
|
||||
if (recordCount > 0) {
|
||||
mRecords = new ArrayList<>(recordCount);
|
||||
for (int i = 0; i < recordCount; i++) {
|
||||
AccessibilityRecord record = AccessibilityRecord.obtain();
|
||||
AccessibilityRecord record = new AccessibilityRecord();
|
||||
readAccessibilityRecordFromParcel(record, parcel);
|
||||
record.mConnectionId = mConnectionId;
|
||||
mRecords.add(record);
|
||||
@@ -1527,7 +1510,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<AccessibilityEvent> CREATOR =
|
||||
new Parcelable.Creator<AccessibilityEvent>() {
|
||||
public AccessibilityEvent createFromParcel(Parcel parcel) {
|
||||
AccessibilityEvent event = AccessibilityEvent.obtain();
|
||||
AccessibilityEvent event = new AccessibilityEvent();
|
||||
event.initFromParcel(parcel);
|
||||
return event;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,6 @@ import android.util.ArrayMap;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Log;
|
||||
import android.util.LongArray;
|
||||
import android.util.Pools.SynchronizedPool;
|
||||
import android.util.Size;
|
||||
import android.util.TypedValue;
|
||||
import android.view.SurfaceView;
|
||||
@@ -68,7 +67,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* This class represents a node of the window content as well as actions that
|
||||
@@ -723,9 +721,6 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
*/
|
||||
private static final int VIRTUAL_DESCENDANT_ID_SHIFT = 32;
|
||||
|
||||
// TODO(b/129300068): Remove sNumInstancesInUse.
|
||||
private static AtomicInteger sNumInstancesInUse;
|
||||
|
||||
/**
|
||||
* Gets the accessibility view id which identifies a View in the view three.
|
||||
*
|
||||
@@ -769,11 +764,6 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
return (((long) virtualDescendantId) << VIRTUAL_DESCENDANT_ID_SHIFT) | accessibilityViewId;
|
||||
}
|
||||
|
||||
// Housekeeping.
|
||||
private static final int MAX_POOL_SIZE = 50;
|
||||
private static final SynchronizedPool<AccessibilityNodeInfo> sPool =
|
||||
new SynchronizedPool<>(MAX_POOL_SIZE);
|
||||
|
||||
private static final AccessibilityNodeInfo DEFAULT = new AccessibilityNodeInfo();
|
||||
|
||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
|
||||
@@ -869,7 +859,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* @param info The other info.
|
||||
*/
|
||||
public AccessibilityNodeInfo(@NonNull AccessibilityNodeInfo info) {
|
||||
init(info, false /* usePoolingInfo */);
|
||||
init(info);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1009,13 +999,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
if (refreshedInfo == null) {
|
||||
return false;
|
||||
}
|
||||
// Hard-to-reproduce bugs seem to be due to some tools recycling a node on another
|
||||
// thread. If that happens, the init will re-seal the node, which then is in a bad state
|
||||
// when it is obtained. Enforce sealing again before we init to fail when a node has been
|
||||
// recycled during a refresh to catch such errors earlier.
|
||||
enforceSealed();
|
||||
init(refreshedInfo, true /* usePoolingInfo */);
|
||||
refreshedInfo.recycle();
|
||||
init(refreshedInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3599,25 +3583,23 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* Returns a cached instance if such is available otherwise a new one
|
||||
* and sets the source.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #AccessibilityNodeInfo(View)} instead.
|
||||
*
|
||||
* @param source The source view.
|
||||
* @return An instance.
|
||||
*
|
||||
* @see #setSource(View)
|
||||
*/
|
||||
@Deprecated
|
||||
public static AccessibilityNodeInfo obtain(View source) {
|
||||
AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
|
||||
info.setSource(source);
|
||||
return info;
|
||||
return new AccessibilityNodeInfo(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cached instance if such is available otherwise a new one
|
||||
* and sets the source.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #AccessibilityNodeInfo(View, int)} instead.
|
||||
*
|
||||
* @param root The root of the virtual subtree.
|
||||
@@ -3626,71 +3608,45 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
*
|
||||
* @see #setSource(View, int)
|
||||
*/
|
||||
@Deprecated
|
||||
public static AccessibilityNodeInfo obtain(View root, int virtualDescendantId) {
|
||||
AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
|
||||
info.setSource(root, virtualDescendantId);
|
||||
return info;
|
||||
return new AccessibilityNodeInfo(root, virtualDescendantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cached instance if such is available otherwise a new one.
|
||||
* Instantiates a new AccessibilityNodeInfo.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #AccessibilityNodeInfo()} instead.
|
||||
*
|
||||
* @return An instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public static AccessibilityNodeInfo obtain() {
|
||||
AccessibilityNodeInfo info = sPool.acquire();
|
||||
if (sNumInstancesInUse != null) {
|
||||
sNumInstancesInUse.incrementAndGet();
|
||||
}
|
||||
return (info != null) ? info : new AccessibilityNodeInfo();
|
||||
return new AccessibilityNodeInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cached instance if such is available or a new one is
|
||||
* create. The returned instance is initialized from the given
|
||||
* Instantiates a new AccessibilityNodeInfo initialized from the given
|
||||
* <code>info</code>.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #AccessibilityNodeInfo(AccessibilityNodeInfo)} instead.
|
||||
*
|
||||
* @param info The other info.
|
||||
* @return An instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public static AccessibilityNodeInfo obtain(AccessibilityNodeInfo info) {
|
||||
AccessibilityNodeInfo infoClone = AccessibilityNodeInfo.obtain();
|
||||
infoClone.init(info, true /* usePoolingInfo */);
|
||||
return infoClone;
|
||||
return new AccessibilityNodeInfo(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance back to be reused.
|
||||
* <p>
|
||||
* <strong>Note:</strong> You must not touch the object after calling this function.
|
||||
* Would previously return an instance back to be reused.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial, and recycling is not necessary.
|
||||
*
|
||||
* @throws IllegalStateException If the info is already recycled.
|
||||
* @deprecated Object pooling has been discontinued. Calling this function now will have
|
||||
* no effect.
|
||||
*/
|
||||
public void recycle() {
|
||||
clear();
|
||||
sPool.release(this);
|
||||
if (sNumInstancesInUse != null) {
|
||||
sNumInstancesInUse.decrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a counter that will be incremented on obtain() and decremented on recycle()
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public static void setNumInstancesInUseCounter(AtomicInteger counter) {
|
||||
sNumInstancesInUse = counter;
|
||||
}
|
||||
@Deprecated
|
||||
public void recycle() {}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -3704,7 +3660,6 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
writeToParcelNoRecycle(parcel, flags);
|
||||
// Since instances of this class are fetched via synchronous i.e. blocking
|
||||
// calls in IPCs we always recycle as soon as the instance is marshaled.
|
||||
recycle();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -4000,9 +3955,8 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* Initializes this instance from another one.
|
||||
*
|
||||
* @param other The other instance.
|
||||
* @param usePoolingInfos whether using pooled object internally or not
|
||||
*/
|
||||
private void init(AccessibilityNodeInfo other, boolean usePoolingInfos) {
|
||||
private void init(AccessibilityNodeInfo other) {
|
||||
mSealed = other.mSealed;
|
||||
mSourceNodeId = other.mSourceNodeId;
|
||||
mParentNodeId = other.mParentNodeId;
|
||||
@@ -4062,11 +4016,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
|
||||
mExtras = other.mExtras != null ? new Bundle(other.mExtras) : null;
|
||||
|
||||
if (usePoolingInfos) {
|
||||
initPoolingInfos(other);
|
||||
} else {
|
||||
initCopyInfos(other);
|
||||
}
|
||||
initCopyInfos(other);
|
||||
|
||||
final TouchDelegateInfo otherInfo = other.mTouchDelegateInfo;
|
||||
mTouchDelegateInfo = (otherInfo != null)
|
||||
@@ -4077,21 +4027,6 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
mLeashedParentNodeId = other.mLeashedParentNodeId;
|
||||
}
|
||||
|
||||
private void initPoolingInfos(AccessibilityNodeInfo other) {
|
||||
if (mRangeInfo != null) mRangeInfo.recycle();
|
||||
mRangeInfo = (other.mRangeInfo != null)
|
||||
? RangeInfo.obtain(other.mRangeInfo) : null;
|
||||
if (mCollectionInfo != null) mCollectionInfo.recycle();
|
||||
mCollectionInfo = (other.mCollectionInfo != null)
|
||||
? CollectionInfo.obtain(other.mCollectionInfo) : null;
|
||||
if (mCollectionItemInfo != null) mCollectionItemInfo.recycle();
|
||||
mCollectionItemInfo = (other.mCollectionItemInfo != null)
|
||||
? CollectionItemInfo.obtain(other.mCollectionItemInfo) : null;
|
||||
if (mExtraRenderingInfo != null) mExtraRenderingInfo.recycle();
|
||||
mExtraRenderingInfo = (other.mExtraRenderingInfo != null)
|
||||
? ExtraRenderingInfo.obtain(other.mExtraRenderingInfo) : null;
|
||||
}
|
||||
|
||||
private void initCopyInfos(AccessibilityNodeInfo other) {
|
||||
RangeInfo ri = other.mRangeInfo;
|
||||
mRangeInfo = (ri == null) ? null
|
||||
@@ -4203,27 +4138,24 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
? parcel.readBundle()
|
||||
: null;
|
||||
|
||||
if (mRangeInfo != null) mRangeInfo.recycle();
|
||||
mRangeInfo = isBitSet(nonDefaultFields, fieldIndex++)
|
||||
? RangeInfo.obtain(
|
||||
? new RangeInfo(
|
||||
parcel.readInt(),
|
||||
parcel.readFloat(),
|
||||
parcel.readFloat(),
|
||||
parcel.readFloat())
|
||||
: null;
|
||||
|
||||
if (mCollectionInfo != null) mCollectionInfo.recycle();
|
||||
mCollectionInfo = isBitSet(nonDefaultFields, fieldIndex++)
|
||||
? CollectionInfo.obtain(
|
||||
? new CollectionInfo(
|
||||
parcel.readInt(),
|
||||
parcel.readInt(),
|
||||
parcel.readInt() == 1,
|
||||
parcel.readInt())
|
||||
: null;
|
||||
|
||||
if (mCollectionItemInfo != null) mCollectionItemInfo.recycle();
|
||||
mCollectionItemInfo = isBitSet(nonDefaultFields, fieldIndex++)
|
||||
? CollectionItemInfo.obtain(
|
||||
? new CollectionItemInfo(
|
||||
parcel.readString(),
|
||||
parcel.readInt(),
|
||||
parcel.readInt(),
|
||||
@@ -4239,8 +4171,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
}
|
||||
|
||||
if (isBitSet(nonDefaultFields, fieldIndex++)) {
|
||||
if (mExtraRenderingInfo != null) mExtraRenderingInfo.recycle();
|
||||
mExtraRenderingInfo = ExtraRenderingInfo.obtain();
|
||||
mExtraRenderingInfo = new ExtraRenderingInfo(null);
|
||||
mExtraRenderingInfo.mLayoutSize = (Size) parcel.readValue(null);
|
||||
mExtraRenderingInfo.mTextSizeInPx = parcel.readFloat();
|
||||
mExtraRenderingInfo.mTextSizeUnit = parcel.readInt();
|
||||
@@ -4263,7 +4194,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* Clears the state of this instance.
|
||||
*/
|
||||
private void clear() {
|
||||
init(DEFAULT, true /* usePoolingInfo */);
|
||||
init(DEFAULT);
|
||||
}
|
||||
|
||||
private static boolean isDefaultStandardAction(AccessibilityAction action) {
|
||||
@@ -5233,7 +5164,6 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* handled by the {@link AccessibilityNodeInfo} to which this object is attached.
|
||||
*/
|
||||
public static final class RangeInfo {
|
||||
private static final int MAX_POOL_SIZE = 10;
|
||||
|
||||
/** Range type: integer. */
|
||||
public static final int RANGE_TYPE_INT = 0;
|
||||
@@ -5242,35 +5172,16 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
/** Range type: percent with values from zero to one hundred. */
|
||||
public static final int RANGE_TYPE_PERCENT = 2;
|
||||
|
||||
private static final SynchronizedPool<RangeInfo> sPool =
|
||||
new SynchronizedPool<AccessibilityNodeInfo.RangeInfo>(MAX_POOL_SIZE);
|
||||
|
||||
private int mType;
|
||||
private float mMin;
|
||||
private float mMax;
|
||||
private float mCurrent;
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance that is a clone of another one.
|
||||
* Instantiates a new RangeInfo.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* constructor {@link AccessibilityNodeInfo.RangeInfo#RangeInfo(int,
|
||||
* float, float, float)} instead.
|
||||
*
|
||||
* @param other The instance to clone.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static RangeInfo obtain(RangeInfo other) {
|
||||
return obtain(other.mType, other.mMin, other.mMax, other.mCurrent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* constructor {@link AccessibilityNodeInfo.RangeInfo#RangeInfo(int,
|
||||
* float, float, float)} instead.
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link AccessibilityNodeInfo.RangeInfo#RangeInfo(int, float, float,
|
||||
* float)} instead.
|
||||
*
|
||||
* @param type The type of the range.
|
||||
* @param min The minimum value. Use {@code Float.NEGATIVE_INFINITY} if the range has no
|
||||
@@ -5279,17 +5190,9 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* maximum.
|
||||
* @param current The current value.
|
||||
*/
|
||||
@Deprecated
|
||||
public static RangeInfo obtain(int type, float min, float max, float current) {
|
||||
RangeInfo info = sPool.acquire();
|
||||
if (info == null) {
|
||||
return new RangeInfo(type, min, max, current);
|
||||
}
|
||||
|
||||
info.mType = type;
|
||||
info.mMin = min;
|
||||
info.mMax = max;
|
||||
info.mCurrent = current;
|
||||
return info;
|
||||
return new RangeInfo(type, min, max, current);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5352,12 +5255,11 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
/**
|
||||
* Recycles this instance.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial, and recycling is not necessary.
|
||||
* @deprecated Object pooling has been discontinued. Calling this function now will have
|
||||
* no effect.
|
||||
*/
|
||||
void recycle() {
|
||||
clear();
|
||||
sPool.release(this);
|
||||
}
|
||||
@Deprecated
|
||||
void recycle() {}
|
||||
|
||||
private void clear() {
|
||||
mType = 0;
|
||||
@@ -5390,20 +5292,15 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
/** Selection mode where multiple items may be selected. */
|
||||
public static final int SELECTION_MODE_MULTIPLE = 2;
|
||||
|
||||
private static final int MAX_POOL_SIZE = 20;
|
||||
|
||||
private static final SynchronizedPool<CollectionInfo> sPool =
|
||||
new SynchronizedPool<>(MAX_POOL_SIZE);
|
||||
|
||||
private int mRowCount;
|
||||
private int mColumnCount;
|
||||
private boolean mHierarchical;
|
||||
private int mSelectionMode;
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance that is a clone of another one.
|
||||
* Instantiates a CollectionInfo that is a clone of another one.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link
|
||||
* AccessibilityNodeInfo.CollectionInfo#CollectionInfo} instead.
|
||||
*
|
||||
@@ -5411,14 +5308,14 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* @hide
|
||||
*/
|
||||
public static CollectionInfo obtain(CollectionInfo other) {
|
||||
return CollectionInfo.obtain(other.mRowCount, other.mColumnCount, other.mHierarchical,
|
||||
return new CollectionInfo(other.mRowCount, other.mColumnCount, other.mHierarchical,
|
||||
other.mSelectionMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link
|
||||
* AccessibilityNodeInfo.CollectionInfo#CollectionInfo(int, int,
|
||||
* boolean)} instead.
|
||||
@@ -5429,13 +5326,13 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
*/
|
||||
public static CollectionInfo obtain(int rowCount, int columnCount,
|
||||
boolean hierarchical) {
|
||||
return obtain(rowCount, columnCount, hierarchical, SELECTION_MODE_NONE);
|
||||
return new CollectionInfo(rowCount, columnCount, hierarchical, SELECTION_MODE_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link
|
||||
* AccessibilityNodeInfo.CollectionInfo#CollectionInfo(int, int,
|
||||
* boolean, int)} instead.
|
||||
@@ -5452,16 +5349,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
*/
|
||||
public static CollectionInfo obtain(int rowCount, int columnCount,
|
||||
boolean hierarchical, int selectionMode) {
|
||||
final CollectionInfo info = sPool.acquire();
|
||||
if (info == null) {
|
||||
return new CollectionInfo(rowCount, columnCount, hierarchical, selectionMode);
|
||||
}
|
||||
|
||||
info.mRowCount = rowCount;
|
||||
info.mColumnCount = columnCount;
|
||||
info.mHierarchical = hierarchical;
|
||||
info.mSelectionMode = selectionMode;
|
||||
return info;
|
||||
return new CollectionInfo(rowCount, columnCount, hierarchical, selectionMode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5533,14 +5421,13 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Recycles this instance.
|
||||
* Previously would recycle this instance.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial, and recycling is not necessary.
|
||||
* @deprecated Object pooling has been discontinued. Calling this function now will have
|
||||
* no effect.
|
||||
*/
|
||||
void recycle() {
|
||||
clear();
|
||||
sPool.release(this);
|
||||
}
|
||||
@Deprecated
|
||||
void recycle() {}
|
||||
|
||||
private void clear() {
|
||||
mRowCount = 0;
|
||||
@@ -5564,15 +5451,10 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* </p>
|
||||
*/
|
||||
public static final class CollectionItemInfo {
|
||||
private static final int MAX_POOL_SIZE = 20;
|
||||
|
||||
private static final SynchronizedPool<CollectionItemInfo> sPool =
|
||||
new SynchronizedPool<>(MAX_POOL_SIZE);
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance that is a clone of another one.
|
||||
* Instantiates a CollectionItemInfo that is a clone of another one.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link
|
||||
* AccessibilityNodeInfo.CollectionItemInfo#CollectionItemInfo}
|
||||
* instead.
|
||||
@@ -5580,20 +5462,20 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* @param other The instance to clone.
|
||||
* @hide
|
||||
*/
|
||||
@Deprecated
|
||||
public static CollectionItemInfo obtain(CollectionItemInfo other) {
|
||||
return CollectionItemInfo.obtain(other.mRowTitle, other.mRowIndex, other.mRowSpan,
|
||||
other.mColumnTitle, other.mColumnIndex, other.mColumnSpan, other.mHeading,
|
||||
other.mSelected);
|
||||
return new CollectionItemInfo(other.mRowTitle, other.mRowIndex, other.mRowSpan,
|
||||
other.mColumnTitle, other.mColumnIndex, other.mColumnSpan, other.mHeading,
|
||||
other.mSelected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance.
|
||||
* Instantiates a new CollectionItemInfo.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link
|
||||
* AccessibilityNodeInfo.CollectionItemInfo#CollectionItemInfo(int,
|
||||
* int, int, int, boolean)} instead.
|
||||
*
|
||||
* @param rowIndex The row index at which the item is located.
|
||||
* @param rowSpan The number of rows the item spans.
|
||||
* @param columnIndex The column index at which the item is located.
|
||||
@@ -5601,37 +5483,39 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* @param heading Whether the item is a heading. (Prefer
|
||||
* {@link AccessibilityNodeInfo#setHeading(boolean)}).
|
||||
*/
|
||||
@Deprecated
|
||||
public static CollectionItemInfo obtain(int rowIndex, int rowSpan,
|
||||
int columnIndex, int columnSpan, boolean heading) {
|
||||
return obtain(rowIndex, rowSpan, columnIndex, columnSpan, heading, false);
|
||||
return new CollectionItemInfo(rowIndex, rowSpan, columnIndex, columnSpan, heading,
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance.
|
||||
* Instantiates a new CollectionItemInfo.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Creates a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link
|
||||
* AccessibilityNodeInfo.CollectionItemInfo#CollectionItemInfo(int,
|
||||
* int, int, int, boolean, boolean)} instead.
|
||||
*
|
||||
* int, int, int, boolean)} instead.
|
||||
* @param rowIndex The row index at which the item is located.
|
||||
* @param rowSpan The number of rows the item spans.
|
||||
* @param columnIndex The column index at which the item is located.
|
||||
* @param columnSpan The number of columns the item spans.
|
||||
* @param heading Whether the item is a heading. (Prefer
|
||||
* {@link AccessibilityNodeInfo#setHeading(boolean)})
|
||||
* {@link AccessibilityNodeInfo#setHeading(boolean)}).
|
||||
* @param selected Whether the item is selected.
|
||||
*/
|
||||
@Deprecated
|
||||
public static CollectionItemInfo obtain(int rowIndex, int rowSpan,
|
||||
int columnIndex, int columnSpan, boolean heading, boolean selected) {
|
||||
return obtain(null, rowIndex, rowSpan, null, columnIndex,
|
||||
columnSpan, heading, selected);
|
||||
return new CollectionItemInfo(rowIndex, rowSpan, columnIndex, columnSpan, heading,
|
||||
selected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance.
|
||||
* Instantiates a new CollectionItemInfo.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Creates a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Creates a new instance using the
|
||||
* constructor {@link
|
||||
* AccessibilityNodeInfo.CollectionItemInfo#CollectionItemInfo(int,
|
||||
* int, int, int, boolean, boolean)} instead.
|
||||
@@ -5646,25 +5530,13 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
* {@link AccessibilityNodeInfo#setHeading(boolean)})
|
||||
* @param selected Whether the item is selected.
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
public static CollectionItemInfo obtain(@Nullable String rowTitle, int rowIndex,
|
||||
int rowSpan, @Nullable String columnTitle, int columnIndex, int columnSpan,
|
||||
boolean heading, boolean selected) {
|
||||
final CollectionItemInfo info = sPool.acquire();
|
||||
if (info == null) {
|
||||
return new CollectionItemInfo(rowTitle, rowIndex, rowSpan, columnTitle,
|
||||
columnIndex, columnSpan, heading, selected);
|
||||
}
|
||||
|
||||
info.mRowIndex = rowIndex;
|
||||
info.mRowSpan = rowSpan;
|
||||
info.mColumnIndex = columnIndex;
|
||||
info.mColumnSpan = columnSpan;
|
||||
info.mHeading = heading;
|
||||
info.mSelected = selected;
|
||||
info.mRowTitle = rowTitle;
|
||||
info.mColumnTitle = columnTitle;
|
||||
return info;
|
||||
return new CollectionItemInfo(rowTitle, rowIndex, rowSpan, columnTitle, columnIndex,
|
||||
columnSpan, heading, selected);
|
||||
}
|
||||
|
||||
private boolean mHeading;
|
||||
@@ -5810,12 +5682,11 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
/**
|
||||
* Recycles this instance.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial, and recycling is not necessary.
|
||||
* @deprecated Object pooling has been discontinued. Calling this function now will have
|
||||
* no effect.
|
||||
*/
|
||||
void recycle() {
|
||||
clear();
|
||||
sPool.release(this);
|
||||
}
|
||||
@Deprecated
|
||||
void recycle() {}
|
||||
|
||||
private void clear() {
|
||||
mColumnIndex = 0;
|
||||
@@ -6010,34 +5881,34 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
*/
|
||||
public static final class ExtraRenderingInfo {
|
||||
private static final int UNDEFINED_VALUE = -1;
|
||||
private static final int MAX_POOL_SIZE = 20;
|
||||
private static final SynchronizedPool<ExtraRenderingInfo> sPool =
|
||||
new SynchronizedPool<>(MAX_POOL_SIZE);
|
||||
|
||||
private Size mLayoutSize;
|
||||
private float mTextSizeInPx = UNDEFINED_VALUE;
|
||||
private int mTextSizeUnit = UNDEFINED_VALUE;
|
||||
|
||||
/**
|
||||
* Obtains a pooled instance.
|
||||
* Instantiates an ExtraRenderingInfo, by copying an existing one.
|
||||
*
|
||||
* @hide
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #ExtraRenderingInfo(ExtraRenderingInfo)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
public static ExtraRenderingInfo obtain() {
|
||||
final ExtraRenderingInfo info = sPool.acquire();
|
||||
if (info == null) {
|
||||
return new ExtraRenderingInfo(null);
|
||||
}
|
||||
return info;
|
||||
return new ExtraRenderingInfo(null);
|
||||
}
|
||||
|
||||
/** Obtains a pooled instance that is a clone of another one. */
|
||||
/**
|
||||
* Instantiates an ExtraRenderingInfo, by copying an existing one.
|
||||
*
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #ExtraRenderingInfo(ExtraRenderingInfo)} instead.
|
||||
* @param other
|
||||
*/
|
||||
@Deprecated
|
||||
private static ExtraRenderingInfo obtain(ExtraRenderingInfo other) {
|
||||
ExtraRenderingInfo extraRenderingInfo = ExtraRenderingInfo.obtain();
|
||||
extraRenderingInfo.mLayoutSize = other.mLayoutSize;
|
||||
extraRenderingInfo.mTextSizeInPx = other.mTextSizeInPx;
|
||||
extraRenderingInfo.mTextSizeUnit = other.mTextSizeUnit;
|
||||
return extraRenderingInfo;
|
||||
return new ExtraRenderingInfo(other);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6127,14 +5998,13 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Recycles this instance.
|
||||
* Previously would recycle this instance.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial, and recycling is not necessary.
|
||||
* @deprecated Object pooling has been discontinued. Calling this function now will have
|
||||
* no effect.
|
||||
*/
|
||||
void recycle() {
|
||||
clear();
|
||||
sPool.release(this);
|
||||
}
|
||||
@Deprecated
|
||||
void recycle() {}
|
||||
|
||||
private void clear() {
|
||||
mLayoutSize = null;
|
||||
@@ -6150,7 +6020,7 @@ public class AccessibilityNodeInfo implements Parcelable {
|
||||
new Parcelable.Creator<AccessibilityNodeInfo>() {
|
||||
@Override
|
||||
public AccessibilityNodeInfo createFromParcel(Parcel parcel) {
|
||||
AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
|
||||
AccessibilityNodeInfo info = new AccessibilityNodeInfo();
|
||||
info.initFromParcel(parcel);
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -78,13 +78,6 @@ public class AccessibilityRecord {
|
||||
| AccessibilityNodeInfo.FLAG_PREFETCH_SIBLINGS
|
||||
| AccessibilityNodeInfo.FLAG_PREFETCH_DESCENDANTS;
|
||||
|
||||
// Housekeeping
|
||||
private static final int MAX_POOL_SIZE = 10;
|
||||
private static final Object sPoolLock = new Object();
|
||||
private static AccessibilityRecord sPool;
|
||||
private static int sPoolSize;
|
||||
private AccessibilityRecord mNext;
|
||||
private boolean mIsInPool;
|
||||
|
||||
@UnsupportedAppUsage
|
||||
boolean mSealed;
|
||||
@@ -821,15 +814,14 @@ public class AccessibilityRecord {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cached instance if such is available or a new one is
|
||||
* instantiated. The instance is initialized with data from the
|
||||
* Instantiates a new record initialized with data from the
|
||||
* given record.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* constructor {@link #AccessibilityRecord(AccessibilityRecord)} instead.
|
||||
*
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #AccessibilityRecord()} instead.
|
||||
* @return An instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public static AccessibilityRecord obtain(AccessibilityRecord record) {
|
||||
AccessibilityRecord clone = AccessibilityRecord.obtain();
|
||||
clone.init(record);
|
||||
@@ -837,51 +829,25 @@ public class AccessibilityRecord {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a cached instance if such is available or a new one is
|
||||
* instantiated.
|
||||
* Instantiates a new record.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial. Create a new instance using the
|
||||
* @deprecated Object pooling has been discontinued. Create a new instance using the
|
||||
* constructor {@link #AccessibilityRecord()} instead.
|
||||
*
|
||||
* @return An instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public static AccessibilityRecord obtain() {
|
||||
synchronized (sPoolLock) {
|
||||
if (sPool != null) {
|
||||
AccessibilityRecord record = sPool;
|
||||
sPool = sPool.mNext;
|
||||
sPoolSize--;
|
||||
record.mNext = null;
|
||||
record.mIsInPool = false;
|
||||
return record;
|
||||
}
|
||||
return new AccessibilityRecord();
|
||||
}
|
||||
return new AccessibilityRecord();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an instance back to be reused.
|
||||
* <p>
|
||||
* <strong>Note:</strong> You must not touch the object after calling this function.
|
||||
* Would previously return an instance back to be reused.
|
||||
*
|
||||
* <p>In most situations object pooling is not beneficial, and recycling is not necessary.
|
||||
*
|
||||
* @throws IllegalStateException If the record is already recycled.
|
||||
* @deprecated Object pooling has been discontinued. Calling this function now will have
|
||||
* no effect.
|
||||
*/
|
||||
public void recycle() {
|
||||
if (mIsInPool) {
|
||||
throw new IllegalStateException("Record already recycled!");
|
||||
}
|
||||
clear();
|
||||
synchronized (sPoolLock) {
|
||||
if (sPoolSize <= MAX_POOL_SIZE) {
|
||||
mNext = sPool;
|
||||
sPool = this;
|
||||
mIsInPool = true;
|
||||
sPoolSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Deprecated
|
||||
public void recycle() { }
|
||||
|
||||
/**
|
||||
* Initialize this record from another one.
|
||||
|
||||
@@ -42,14 +42,14 @@ public class AccessibilityEventTest {
|
||||
// and assertAccessibilityEventCleared
|
||||
|
||||
/** The number of properties of the {@link AccessibilityEvent} class. */
|
||||
private static final int A11Y_EVENT_NON_STATIC_FIELD_COUNT = 34;
|
||||
private static final int A11Y_EVENT_NON_STATIC_FIELD_COUNT = 32;
|
||||
|
||||
// The number of fields tested in the corresponding CTS AccessibilityRecordTest:
|
||||
// assertAccessibilityRecordCleared, fullyPopulateAccessibilityRecord,
|
||||
// and assertEqualAccessibilityRecord
|
||||
|
||||
/** The number of properties of the {@link AccessibilityRecord} class. */
|
||||
private static final int A11Y_RECORD_NON_STATIC_FIELD_COUNT = 25;
|
||||
private static final int A11Y_RECORD_NON_STATIC_FIELD_COUNT = 23;
|
||||
|
||||
@Test
|
||||
public void testImportantForAccessibiity_getSetWorkAcrossParceling() {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package android.view.accessibility;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertSame;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -187,17 +186,6 @@ public class AccessibilityManagerTest {
|
||||
assertFalse("Must be disabled since the mock service is disabled", manager.isEnabled());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendAccessibilityEvent_AccessibilityEnabled() throws Exception {
|
||||
AccessibilityEvent sentEvent = AccessibilityEvent.obtain(
|
||||
AccessibilityEvent.TYPE_ANNOUNCEMENT);
|
||||
|
||||
AccessibilityManager manager = createManager(WITH_A11Y_ENABLED);
|
||||
manager.sendAccessibilityEvent(sentEvent);
|
||||
|
||||
assertSame("The event should be recycled.", sentEvent, AccessibilityEvent.obtain());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendAccessibilityEvent_AccessibilityDisabled() throws Exception {
|
||||
AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2009 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.accessibility;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* This class exercises the caching and recycling of {@link AccessibilityEvent}s.
|
||||
*/
|
||||
public class RecycleAccessibilityEventTest extends TestCase {
|
||||
|
||||
private static final String CLASS_NAME = "foo.bar.baz.Test";
|
||||
private static final String PACKAGE_NAME = "foo.bar.baz";
|
||||
private static final String TEXT = "Some stuff";
|
||||
|
||||
private static final String CONTENT_DESCRIPTION = "Content description";
|
||||
private static final int ITEM_COUNT = 10;
|
||||
private static final int CURRENT_ITEM_INDEX = 1;
|
||||
|
||||
private static final int FROM_INDEX = 1;
|
||||
private static final int ADDED_COUNT = 2;
|
||||
private static final int REMOVED_COUNT = 1;
|
||||
|
||||
/**
|
||||
* If an {@link AccessibilityEvent} is marshaled/unmarshaled correctly
|
||||
*/
|
||||
@SmallTest
|
||||
public void testAccessibilityEventViewTextChangedType() {
|
||||
AccessibilityEvent first =
|
||||
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
|
||||
assertNotNull(first);
|
||||
|
||||
first.setClassName(CLASS_NAME);
|
||||
first.setPackageName(PACKAGE_NAME);
|
||||
first.getText().add(TEXT);
|
||||
first.setFromIndex(FROM_INDEX);
|
||||
first.setAddedCount(ADDED_COUNT);
|
||||
first.setRemovedCount(REMOVED_COUNT);
|
||||
first.setChecked(true);
|
||||
first.setContentDescription(CONTENT_DESCRIPTION);
|
||||
first.setItemCount(ITEM_COUNT);
|
||||
first.setCurrentItemIndex(CURRENT_ITEM_INDEX);
|
||||
first.setEnabled(true);
|
||||
first.setPassword(true);
|
||||
|
||||
first.recycle();
|
||||
|
||||
assertNotNull(first);
|
||||
assertNull(first.getClassName());
|
||||
assertNull(first.getPackageName());
|
||||
assertEquals(0, first.getText().size());
|
||||
assertFalse(first.isChecked());
|
||||
assertNull(first.getContentDescription());
|
||||
assertEquals(-1, first.getItemCount());
|
||||
assertEquals(AccessibilityEvent.INVALID_POSITION, first.getCurrentItemIndex());
|
||||
assertFalse(first.isEnabled());
|
||||
assertFalse(first.isPassword());
|
||||
assertEquals(-1, first.getFromIndex());
|
||||
assertEquals(-1, first.getAddedCount());
|
||||
assertEquals(-1, first.getRemovedCount());
|
||||
|
||||
// get another event from the pool (this must be the recycled first)
|
||||
AccessibilityEvent second = AccessibilityEvent.obtain();
|
||||
assertEquals(first, second);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user