1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.core.view.accessibility;
18 
19 import android.annotation.SuppressLint;
20 import android.os.Parcelable;
21 import android.view.View;
22 import android.view.accessibility.AccessibilityEvent;
23 import android.view.accessibility.AccessibilityNodeInfo;
24 import android.view.accessibility.AccessibilityRecord;
25 
26 import org.jspecify.annotations.NonNull;
27 import org.jspecify.annotations.Nullable;
28 
29 import java.util.List;
30 
31 /**
32  * Helper for accessing {@link AccessibilityRecord}.
33  */
34 public class AccessibilityRecordCompat {
35     private final AccessibilityRecord mRecord;
36 
37     /**
38      * @deprecated This is not type safe. If you want to modify an
39      * {@link AccessibilityEvent}'s properties defined in
40      * {@link AccessibilityRecord} use
41      * {@link AccessibilityEventCompat#asRecord(AccessibilityEvent)}. This method will be removed
42      * in a subsequent release of the support library.
43      */
44     @Deprecated
AccessibilityRecordCompat(Object record)45     public AccessibilityRecordCompat(Object record) {
46         mRecord = (AccessibilityRecord) record;
47     }
48 
49     /**
50      * @return The wrapped implementation.
51      *
52      * @deprecated This method will be removed in a subsequent release of
53      * the support library.
54      */
55     @Deprecated
getImpl()56     public Object getImpl() {
57         return mRecord;
58     }
59 
60     /**
61      * Returns a cached instance if such is available or a new one is
62      * instantiated. The instance is initialized with data from the
63      * given record.
64      *
65      * @return An instance.
66      *
67      * @deprecated Use {@link AccessibilityRecord#obtain(AccessibilityRecord)} directly.
68      */
69     @SuppressWarnings("deprecation")
70     @Deprecated
obtain(AccessibilityRecordCompat record)71     public static AccessibilityRecordCompat obtain(AccessibilityRecordCompat record) {
72         return new AccessibilityRecordCompat(AccessibilityRecord.obtain(record.mRecord));
73     }
74 
75     /**
76      * Returns a cached instance if such is available or a new one is
77      * instantiated.
78      *
79      * @return An instance.
80      *
81      * @deprecated Use {@link AccessibilityRecord#obtain()} directly.
82      */
83     @SuppressWarnings("deprecation")
84     @Deprecated
obtain()85     public static AccessibilityRecordCompat obtain() {
86         return new AccessibilityRecordCompat(AccessibilityRecord.obtain());
87     }
88 
89     /**
90      * Sets the event source.
91      *
92      * @param source The source.
93      *
94      * @throws IllegalStateException If called from an AccessibilityService.
95      *
96      * @deprecated Use {@link AccessibilityRecord#setSource(View)} directly.
97      */
98     @SuppressLint("KotlinPropertyAccess")
99     @Deprecated
setSource(View source)100     public void setSource(View source) {
101         mRecord.setSource(source);
102     }
103 
104     /**
105      * Sets the source to be a virtual descendant of the given <code>root</code>.
106      * If <code>virtualDescendantId</code> equals to {@link View#NO_ID} the root
107      * is set as the source.
108      * <p>
109      * A virtual descendant is an imaginary View that is reported as a part of the view
110      * hierarchy for accessibility purposes. This enables custom views that draw complex
111      * content to report them selves as a tree of virtual views, thus conveying their
112      * logical structure.
113      * </p>
114      *
115      * @param root The root of the virtual subtree.
116      * @param virtualDescendantId The id of the virtual descendant.
117      *
118      * @deprecated Use {@link #setSource(AccessibilityRecord, View, int)} instead.
119      */
120     @Deprecated
setSource(View root, int virtualDescendantId)121     public void setSource(View root, int virtualDescendantId) {
122         AccessibilityRecordCompat.setSource(mRecord, root, virtualDescendantId);
123     }
124 
125     /**
126      * Sets the source to be a virtual descendant of the given <code>root</code>.
127      * If <code>virtualDescendantId</code> equals to {@link View#NO_ID} the root
128      * is set as the source.
129      * <p>
130      * A virtual descendant is an imaginary View that is reported as a part of the view
131      * hierarchy for accessibility purposes. This enables custom views that draw complex
132      * content to report them selves as a tree of virtual views, thus conveying their
133      * logical structure.
134      * </p>
135      *
136      * @param record The {@link AccessibilityRecord} instance to use.
137      * @param root The root of the virtual subtree.
138      * @param virtualDescendantId The id of the virtual descendant.
139      * @deprecated Call {@link AccessibilityRecord#setSource()} directly.
140      */
141     @Deprecated
142     @androidx.annotation.ReplaceWith(expression = "record.setSource(root, virtualDescendantId)")
setSource(@onNull AccessibilityRecord record, @Nullable View root, int virtualDescendantId)143     public static void setSource(@NonNull AccessibilityRecord record, @Nullable View root,
144             int virtualDescendantId) {
145         record.setSource(root, virtualDescendantId);
146     }
147 
148     /**
149      * Gets the {@link AccessibilityNodeInfo} of
150      * the event source.
151      * <p>
152      * <strong>Note:</strong> It is a client responsibility to recycle the
153      * received info by calling
154      * {@link AccessibilityNodeInfo#recycle()
155      * AccessibilityNodeInfo#recycle()} to avoid creating of multiple instances.
156      *</p>
157      *
158      * @return The info of the source.
159      *
160      * @deprecated Use {@link AccessibilityRecord#getSource()} directly.
161      */
162     @SuppressLint("KotlinPropertyAccess")
163     @Deprecated
getSource()164     public AccessibilityNodeInfoCompat getSource() {
165         return AccessibilityNodeInfoCompat.wrapNonNullInstance(mRecord.getSource());
166     }
167 
168     /**
169      * Gets the id of the window from which the event comes from.
170      *
171      * @return The window id.
172      *
173      * @deprecated Use {@link AccessibilityRecord#getWindowId()} directly.
174      */
175     @Deprecated
getWindowId()176     public int getWindowId() {
177         return mRecord.getWindowId();
178     }
179 
180     /**
181      * Gets if the source is checked.
182      *
183      * @return True if the view is checked, false otherwise.
184      *
185      * @deprecated Use {@link AccessibilityRecord#isChecked()} directly.
186      */
187     @Deprecated
isChecked()188     public boolean isChecked() {
189         return mRecord.isChecked();
190     }
191 
192     /**
193      * Sets if the source is checked.
194      *
195      * @param isChecked True if the view is checked, false otherwise.
196      *
197      * @throws IllegalStateException If called from an AccessibilityService.
198      *
199      * @deprecated Use {@link AccessibilityRecord#setChecked(boolean)} directly.
200      */
201     @Deprecated
setChecked(boolean isChecked)202     public void setChecked(boolean isChecked) {
203         mRecord.setChecked(isChecked);
204     }
205 
206     /**
207      * Gets if the source is enabled.
208      *
209      * @return True if the view is enabled, false otherwise.
210      *
211      * @deprecated Use {@link AccessibilityRecord#isEnabled()} directly.
212      */
213     @Deprecated
isEnabled()214     public boolean isEnabled() {
215         return mRecord.isEnabled();
216     }
217 
218     /**
219      * Sets if the source is enabled.
220      *
221      * @param isEnabled True if the view is enabled, false otherwise.
222      *
223      * @throws IllegalStateException If called from an AccessibilityService.
224      *
225      * @deprecated Use {@link AccessibilityRecord#isEnabled()} directly.
226      */
227     @Deprecated
setEnabled(boolean isEnabled)228     public void setEnabled(boolean isEnabled) {
229         mRecord.setEnabled(isEnabled);
230     }
231 
232     /**
233      * Gets if the source is a password field.
234      *
235      * @return True if the view is a password field, false otherwise.
236      *
237      * @deprecated Use {@link AccessibilityRecord#isPassword()} directly.
238      */
239     @Deprecated
isPassword()240     public boolean isPassword() {
241         return mRecord.isPassword();
242     }
243 
244     /**
245      * Sets if the source is a password field.
246      *
247      * @param isPassword True if the view is a password field, false otherwise.
248      *
249      * @throws IllegalStateException If called from an AccessibilityService.
250      *
251      * @deprecated Use {@link AccessibilityRecord#setPassword(boolean)} directly.
252      */
253     @Deprecated
setPassword(boolean isPassword)254     public void setPassword(boolean isPassword) {
255         mRecord.setPassword(isPassword);
256     }
257 
258     /**
259      * Gets if the source is taking the entire screen.
260      *
261      * @return True if the source is full screen, false otherwise.
262      *
263      * @deprecated Use {@link AccessibilityRecord#isFullScreen()} directly.
264      */
265     @Deprecated
isFullScreen()266     public boolean isFullScreen() {
267         return mRecord.isFullScreen();
268     }
269 
270     /**
271      * Sets if the source is taking the entire screen.
272      *
273      * @param isFullScreen True if the source is full screen, false otherwise.
274      *
275      * @throws IllegalStateException If called from an AccessibilityService.
276      *
277      * @deprecated Use {@link AccessibilityRecord#setFullScreen(boolean)} directly.
278      */
279     @Deprecated
setFullScreen(boolean isFullScreen)280     public void setFullScreen(boolean isFullScreen) {
281         mRecord.setFullScreen(isFullScreen);
282     }
283 
284     /**
285      * Gets if the source is scrollable.
286      *
287      * @return True if the source is scrollable, false otherwise.
288      *
289      * @deprecated Use {@link AccessibilityRecord#isScrollable()} directly.
290      */
291     @Deprecated
isScrollable()292     public boolean isScrollable() {
293         return mRecord.isScrollable();
294     }
295 
296     /**
297      * Sets if the source is scrollable.
298      *
299      * @param scrollable True if the source is scrollable, false otherwise.
300      *
301      * @throws IllegalStateException If called from an AccessibilityService.
302      *
303      * @deprecated Use {@link AccessibilityRecord#setScrollable(boolean)} directly.
304      */
305     @Deprecated
setScrollable(boolean scrollable)306     public void setScrollable(boolean scrollable) {
307         mRecord.setScrollable(scrollable);
308     }
309 
310     /**
311      * Gets the number of items that can be visited.
312      *
313      * @return The number of items.
314      *
315      * @deprecated Use {@link AccessibilityRecord#getItemCount()} directly.
316      */
317     @Deprecated
getItemCount()318     public int getItemCount() {
319         return mRecord.getItemCount();
320     }
321 
322     /**
323      * Sets the number of items that can be visited.
324      *
325      * @param itemCount The number of items.
326      *
327      * @throws IllegalStateException If called from an AccessibilityService.
328      *
329      * @deprecated Use {@link AccessibilityRecord#setItemCount(int)} directly.
330      */
331     @Deprecated
setItemCount(int itemCount)332     public void setItemCount(int itemCount) {
333         mRecord.setItemCount(itemCount);
334     }
335 
336     /**
337      * Gets the index of the source in the list of items the can be visited.
338      *
339      * @return The current item index.
340      *
341      * @deprecated Use {@link AccessibilityRecord#getCurrentItemIndex()} directly.
342      */
343     @Deprecated
getCurrentItemIndex()344     public int getCurrentItemIndex() {
345         return mRecord.getCurrentItemIndex();
346     }
347 
348     /**
349      * Sets the index of the source in the list of items that can be visited.
350      *
351      * @param currentItemIndex The current item index.
352      *
353      * @throws IllegalStateException If called from an AccessibilityService.
354      *
355      * @deprecated Use {@link AccessibilityRecord#setCurrentItemIndex(int)} directly.
356      */
357     @Deprecated
setCurrentItemIndex(int currentItemIndex)358     public void setCurrentItemIndex(int currentItemIndex) {
359         mRecord.setCurrentItemIndex(currentItemIndex);
360     }
361 
362     /**
363      * Gets the index of the first character of the changed sequence,
364      * or the beginning of a text selection or the index of the first
365      * visible item when scrolling.
366      *
367      * @return The index of the first character or selection
368      *        start or the first visible item.
369      *
370      * @deprecated Use {@link AccessibilityRecord#getFromIndex()} directly.
371      */
372     @Deprecated
getFromIndex()373     public int getFromIndex() {
374         return mRecord.getFromIndex();
375     }
376 
377     /**
378      * Sets the index of the first character of the changed sequence
379      * or the beginning of a text selection or the index of the first
380      * visible item when scrolling.
381      *
382      * @param fromIndex The index of the first character or selection
383      *        start or the first visible item.
384      *
385      * @throws IllegalStateException If called from an AccessibilityService.
386      *
387      * @deprecated Use {@link AccessibilityRecord#setFromIndex(int)} directly.
388      */
389     @Deprecated
setFromIndex(int fromIndex)390     public void setFromIndex(int fromIndex) {
391         mRecord.setFromIndex(fromIndex);
392     }
393 
394     /**
395      * Gets the index of text selection end or the index of the last
396      * visible item when scrolling.
397      *
398      * @return The index of selection end or last item index.
399      *
400      * @deprecated Use {@link AccessibilityRecord#getToIndex()} directly.
401      */
402     @Deprecated
getToIndex()403     public int getToIndex() {
404         return mRecord.getToIndex();
405     }
406 
407     /**
408      * Sets the index of text selection end or the index of the last
409      * visible item when scrolling.
410      *
411      * @param toIndex The index of selection end or last item index.
412      *
413      * @deprecated Use {@link AccessibilityRecord#setToIndex(int)} directly.
414      */
415     @Deprecated
setToIndex(int toIndex)416     public void setToIndex(int toIndex) {
417         mRecord.setToIndex(toIndex);
418     }
419 
420     /**
421      * Gets the scroll offset of the source left edge in pixels.
422      *
423      * @return The scroll.
424      *
425      * @deprecated Use {@link AccessibilityRecord#getScrollX()} directly.
426      */
427     @Deprecated
getScrollX()428     public int getScrollX() {
429         return mRecord.getScrollX();
430     }
431 
432     /**
433      * Sets the scroll offset of the source left edge in pixels.
434      *
435      * @param scrollX The scroll.
436      *
437      * @deprecated Use {@link AccessibilityRecord#setScrollX(int)} directly.
438      */
439     @Deprecated
setScrollX(int scrollX)440     public void setScrollX(int scrollX) {
441         mRecord.setScrollX(scrollX);
442     }
443 
444     /**
445      * Gets the scroll offset of the source top edge in pixels.
446      *
447      * @return The scroll.
448      *
449      * @deprecated Use {@link AccessibilityRecord#getScrollY()} directly.
450      */
451     @Deprecated
getScrollY()452     public int getScrollY() {
453         return mRecord.getScrollY();
454     }
455 
456     /**
457      * Sets the scroll offset of the source top edge in pixels.
458      *
459      * @param scrollY The scroll.
460      *
461      * @deprecated Use {@link AccessibilityRecord#setScrollY(int)} directly.
462      */
463     @Deprecated
setScrollY(int scrollY)464     public void setScrollY(int scrollY) {
465         mRecord.setScrollY(scrollY);
466     }
467 
468     /**
469      * Gets the max scroll offset of the source left edge in pixels.
470      *
471      * @return The max scroll.
472      *
473      * @deprecated Use {@link #getMaxScrollX(AccessibilityRecord)} instead.
474      */
475     @Deprecated
getMaxScrollX()476     public int getMaxScrollX() {
477         return AccessibilityRecordCompat.getMaxScrollX(mRecord);
478     }
479 
480     /**
481      * Gets the max scroll offset of the source left edge in pixels.
482      *
483      * @param record The {@link AccessibilityRecord} instance to use.
484      * @return The max scroll.
485      * @deprecated Call {@link AccessibilityRecord#getMaxScrollX()} directly.
486      */
487     @Deprecated
488     @androidx.annotation.ReplaceWith(expression = "record.getMaxScrollX()")
getMaxScrollX(@onNull AccessibilityRecord record)489     public static int getMaxScrollX(@NonNull AccessibilityRecord record) {
490         return record.getMaxScrollX();
491     }
492 
493     /**
494      * Sets the max scroll offset of the source left edge in pixels.
495      *
496      * @param maxScrollX The max scroll.
497      *
498      * @deprecated Use {@link #setMaxScrollX(AccessibilityRecord, int)} instead.
499      */
500     @Deprecated
setMaxScrollX(int maxScrollX)501     public void setMaxScrollX(int maxScrollX) {
502         AccessibilityRecordCompat.setMaxScrollX(mRecord, maxScrollX);
503     }
504 
505     /**
506      * Sets the max scroll offset of the source left edge in pixels.
507      *
508      * @param record The {@link AccessibilityRecord} instance to use.
509      * @param maxScrollX The max scroll.
510      * @deprecated Call {@link AccessibilityRecord#setMaxScrollX()} directly.
511      */
512     @Deprecated
513     @androidx.annotation.ReplaceWith(expression = "record.setMaxScrollX(maxScrollX)")
setMaxScrollX(@onNull AccessibilityRecord record, int maxScrollX)514     public static void setMaxScrollX(@NonNull AccessibilityRecord record, int maxScrollX) {
515         record.setMaxScrollX(maxScrollX);
516     }
517 
518     /**
519      * Gets the max scroll offset of the source top edge in pixels.
520      *
521      * @return The max scroll.
522      *
523      * @deprecated Use {@link #getMaxScrollY(AccessibilityRecord)} instead.
524      */
525     @Deprecated
getMaxScrollY()526     public int getMaxScrollY() {
527         return AccessibilityRecordCompat.getMaxScrollY(mRecord);
528     }
529 
530     /**
531      * Gets the max scroll offset of the source top edge in pixels.
532      *
533      * @param record The {@link AccessibilityRecord} instance to use.
534      * @return The max scroll.
535      * @deprecated Call {@link AccessibilityRecord#getMaxScrollY()} directly.
536      */
537     @Deprecated
538     @androidx.annotation.ReplaceWith(expression = "record.getMaxScrollY()")
getMaxScrollY(@onNull AccessibilityRecord record)539     public static int getMaxScrollY(@NonNull AccessibilityRecord record) {
540         return record.getMaxScrollY();
541     }
542 
543     /**
544      * Sets the max scroll offset of the source top edge in pixels.
545      *
546      * @param maxScrollY The max scroll.
547      *
548      * @deprecated Use {@link #setMaxScrollY(AccessibilityRecord, int)} instead.
549      */
550     @Deprecated
setMaxScrollY(int maxScrollY)551     public void setMaxScrollY(int maxScrollY) {
552         AccessibilityRecordCompat.setMaxScrollY(mRecord, maxScrollY);
553     }
554 
555     /**
556      * Sets the max scroll offset of the source top edge in pixels.
557      *
558      * @param record The {@link AccessibilityRecord} instance to use.
559      * @param maxScrollY The max scroll.
560      * @deprecated Call {@link AccessibilityRecord#setMaxScrollY()} directly.
561      */
562     @Deprecated
563     @androidx.annotation.ReplaceWith(expression = "record.setMaxScrollY(maxScrollY)")
setMaxScrollY(@onNull AccessibilityRecord record, int maxScrollY)564     public static void setMaxScrollY(@NonNull AccessibilityRecord record, int maxScrollY) {
565         record.setMaxScrollY(maxScrollY);
566     }
567 
568     /**
569      * Gets the number of added characters.
570      *
571      * @return The number of added characters.
572      *
573      * @deprecated Use {@link AccessibilityRecord#getAddedCount()} directly.
574      */
575     @Deprecated
getAddedCount()576     public int getAddedCount() {
577         return mRecord.getAddedCount();
578     }
579 
580     /**
581      * Sets the number of added characters.
582      *
583      * @param addedCount The number of added characters.
584      *
585      * @throws IllegalStateException If called from an AccessibilityService.
586      *
587      * @deprecated Use {@link AccessibilityRecord#setAddedCount(int)} directly.
588      */
589     @Deprecated
setAddedCount(int addedCount)590     public void setAddedCount(int addedCount) {
591         mRecord.setAddedCount(addedCount);
592     }
593 
594     /**
595      * Gets the number of removed characters.
596      *
597      * @return The number of removed characters.
598      *
599      * @deprecated Use {@link AccessibilityRecord#getRemovedCount()} directly.
600      */
601     @Deprecated
getRemovedCount()602     public int getRemovedCount() {
603         return mRecord.getRemovedCount();
604     }
605 
606     /**
607      * Sets the number of removed characters.
608      *
609      * @param removedCount The number of removed characters.
610      *
611      * @throws IllegalStateException If called from an AccessibilityService.
612      *
613      * @deprecated Use {@link AccessibilityRecord#setRemovedCount(int)} directly.
614      */
615     @Deprecated
setRemovedCount(int removedCount)616     public void setRemovedCount(int removedCount) {
617         mRecord.setRemovedCount(removedCount);
618     }
619 
620     /**
621      * Gets the class name of the source.
622      *
623      * @return The class name.
624      *
625      * @deprecated Use {@link AccessibilityRecord#getClassName()} directly.
626      */
627     @Deprecated
getClassName()628     public CharSequence getClassName() {
629         return mRecord.getClassName();
630     }
631 
632     /**
633      * Sets the class name of the source.
634      *
635      * @param className The lass name.
636      *
637      * @throws IllegalStateException If called from an AccessibilityService.
638      *
639      * @deprecated Use {@link AccessibilityRecord#setClassName(CharSequence)} directly.
640      */
641     @Deprecated
setClassName(CharSequence className)642     public void setClassName(CharSequence className) {
643         mRecord.setClassName(className);
644     }
645 
646     /**
647      * Gets the text of the event. The index in the list represents the priority
648      * of the text. Specifically, the lower the index the higher the priority.
649      *
650      * @return The text.
651      *
652      * @deprecated Use {@link AccessibilityRecord#getText()} directly.
653      */
654     @Deprecated
getText()655     public List<CharSequence> getText() {
656         return mRecord.getText();
657     }
658 
659     /**
660      * Sets the text before a change.
661      *
662      * @return The text before the change.
663      *
664      * @deprecated Use {@link AccessibilityRecord#getBeforeText()} directly.
665      */
666     @Deprecated
getBeforeText()667     public CharSequence getBeforeText() {
668         return mRecord.getBeforeText();
669     }
670 
671     /**
672      * Sets the text before a change.
673      *
674      * @param beforeText The text before the change.
675      *
676      * @throws IllegalStateException If called from an AccessibilityService.
677      *
678      * @deprecated Use {@link AccessibilityRecord#setBeforeText(CharSequence)} directly.
679      */
680     @Deprecated
setBeforeText(CharSequence beforeText)681     public void setBeforeText(CharSequence beforeText) {
682         mRecord.setBeforeText(beforeText);
683     }
684 
685     /**
686      * Gets the description of the source.
687      *
688      * @return The description.
689      *
690      * @deprecated Use {@link AccessibilityRecord#getContentDescription()} directly.
691      */
692     @Deprecated
getContentDescription()693     public CharSequence getContentDescription() {
694         return mRecord.getContentDescription();
695     }
696 
697     /**
698      * Sets the description of the source.
699      *
700      * @param contentDescription The description.
701      *
702      * @throws IllegalStateException If called from an AccessibilityService.
703      *
704      * @deprecated Use {@link AccessibilityRecord#setContentDescription(CharSequence)} directly.
705      */
706     @Deprecated
setContentDescription(CharSequence contentDescription)707     public void setContentDescription(CharSequence contentDescription) {
708         mRecord.setContentDescription(contentDescription);
709     }
710 
711     /**
712      * Gets the {@link Parcelable} data.
713      *
714      * @return The parcelable data.
715      *
716      * @deprecated Use {@link AccessibilityRecord#getParcelableData()} directly.
717      */
718     @Deprecated
getParcelableData()719     public Parcelable getParcelableData() {
720         return mRecord.getParcelableData();
721     }
722 
723     /**
724      * Sets the {@link Parcelable} data of the event.
725      *
726      * @param parcelableData The parcelable data.
727      *
728      * @throws IllegalStateException If called from an AccessibilityService.
729      *
730      * @deprecated Use {@link AccessibilityRecord#setParcelableData(Parcelable)} directly.
731      */
732     @Deprecated
setParcelableData(Parcelable parcelableData)733     public void setParcelableData(Parcelable parcelableData) {
734         mRecord.setParcelableData(parcelableData);
735     }
736 
737     /**
738      * Return an instance back to be reused.
739      * <p>
740      * <strong>Note:</strong> You must not touch the object after calling this
741      * function.
742      * </p>
743      *
744      * @throws IllegalStateException If the record is already recycled.
745      *
746      * @deprecated Use {@link AccessibilityRecord#recycle()} directly.
747      */
748     @Deprecated
recycle()749     public void recycle() {
750         mRecord.recycle();
751     }
752 
753     /**
754      * @deprecated Use {@link AccessibilityRecord#hashCode()} directly.
755      */
756     @Deprecated
757     @Override
hashCode()758     public int hashCode() {
759         return (mRecord == null) ? 0 : mRecord.hashCode();
760     }
761 
762     /**
763      * @deprecated Use {@link AccessibilityRecord} directly.
764      */
765     @Deprecated
766     @Override
equals(Object obj)767     public boolean equals(Object obj) {
768         if (this == obj) {
769             return true;
770         }
771         if (!(obj instanceof AccessibilityRecordCompat)) {
772             return false;
773         }
774         AccessibilityRecordCompat other = (AccessibilityRecordCompat) obj;
775         if (mRecord == null) {
776             return other.mRecord == null;
777         }
778         return mRecord.equals(other.mRecord);
779     }
780 }
781