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