0

I've seen strange crash reports from my app.

android.view.accessibility.CaptioningManager$1.onChange (CaptioningManager.java:226)
android.database.ContentObserver.onChange (ContentObserver.java:145)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:703)

http://crashes.to/s/db9e325f0f5

It looks like that there is a problem when accessibility functions are enabled. But how I can detect on what UI element or screen that error appears?

I tried to enable accessibility on my own device and navigate through all application screens, but don't receive an exeption.

EDIT

Can this error be caused by using Span in TextView?

 // welcome text
 TextView welcome = (TextView) view.findViewById(R.id.home_user_name);
 welcome.setText(Html.fromHtml(getString(R.string.home_welcome_text, accountManager.getActiveUser())));
 // change...
 welcome.append(" ");
 SpannableString str = SpannableString.valueOf(getString(R.string.home_user_change));
 str.setSpan(new URLSpan(getString(R.string.home_user_change)) {
        @Override
        public void onClick(View view) {
            mGuiHandler.sendEmptyMessage(MESSAGE_CHANGE_USER);
        }
 }, 0, str.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
 welcome.append(str);
 welcome.setMovementMethod(LinkMovementMethod.getInstance());
Artem Mostyaev
  • 3,874
  • 10
  • 53
  • 60

1 Answers1

1

First, this isn't part of the accessibility service APIs. It is part of the View's implementation of accessibility. See the google code project. CaptioningManager is in the core/java/android/view/accessibility package. So, this crash is happening regardless of whether accessibility is on or not, or the very least, independent of what accessibility service may be on.

In Captioning Manager on line 235 (the version on Google Code is out of date, but pretty close.). The onChange function is like this:

    @Override
    public void onChange(boolean selfChange, Uri uri) {
        final String uriPath = uri.getPath();
        final String name = uriPath.substring(uriPath.lastIndexOf('/') + 1);
        if (Secure.ACCESSIBILITY_CAPTIONING_ENABLED.equals(name)) {
            notifyEnabledChanged();
        } else if (Secure.ACCESSIBILITY_CAPTIONING_LOCALE.equals(name)) {
            notifyLocaleChanged();
        } else if (Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE.equals(name)) {
            notifyFontScaleChanged();
        } else {
            // We only need a single callback when multiple style properties
            // change in rapid succession.
            mHandler.removeCallbacks(mStyleChangedRunnable);
            mHandler.post(mStyleChangedRunnable);
        }
    }

This is being called by the ContentObserver class, from this point:

    /**
 * Dispatches a change notification to the observer. Includes the changed
 * content Uri when available and also the user whose content changed.
 *
 * @param selfChange True if this is a self-change notification.
 * @param uri The Uri of the changed content, or null if unknown.
 * @param userId The user whose content changed. Can be either a specific
 *         user or {@link UserHandle#USER_ALL}.
 *
 * @hide
 */
public void onChange(boolean selfChange, Uri uri, int userId) {
    onChange(selfChange, uri);
}

Notice in the documentation for the ContentObserver class explicitly states that the uri can be null, but the CaptioningManager immediately calls getPath without checking fi the value is null. This is why it is crashing. The uri passed to onChange is null.

Now, this is where it gets a little fuzzy right. The rest is private, not available on Google Code. SO, we can only guess as to what zygote is doing. Although, it likely wouldn't be helpful, even if we could see it.

Now, what can we glean from this. In the documentation for the CaptioningManager we see the following explanation for its purpose:

Contains methods for accessing and monitoring preferred video captioning state and visual properties.

So, based on all of this, check any URIs or other properties of any video and perhaps other media elements in your application...

MobA11y
  • 18,425
  • 3
  • 49
  • 76
  • Thank you for real deep investigation! Application doesn't include any video or other media. But it has some external links and one Span in TextViews. Can that be the reason? I've added spans` code into question. – Artem Mostyaev Feb 15 '16 at 12:02
  • It's plausible that that is the reason. It's also possible that there is just a bug in the OS Code. – MobA11y Feb 15 '16 at 16:02