Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 982d21b9 authored by Jim Miller's avatar Jim Miller
Browse files

Attempt to fix NPE in keyguard

This attempts to fix a bug where it looks like we have null content in
one of the widget pages in keyguard.

Based on the bug description, it's likely the transport control was just
removed from the view hierarchy.  Not sure how the content can be null
in this case, but this will hopefully prevent the crash and give us some
insight into what caused it.

Fixes bug 8886916

Change-Id: I22c26c49f22fa5b06987e8199070a9aaead2ff8a
parent ffe3b5b8
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -326,10 +326,15 @@ public class KeyguardHostView extends KeyguardViewBase {
    }

    private int getWidgetPosition(int id) {
        final int children = mAppWidgetContainer.getChildCount();
        final KeyguardWidgetPager appWidgetContainer = mAppWidgetContainer;
        final int children = appWidgetContainer.getChildCount();
        for (int i = 0; i < children; i++) {
            if (mAppWidgetContainer.getWidgetPageAt(i).getContent().getId() == id) {
            final View content = appWidgetContainer.getWidgetPageAt(i).getContent();
            if (content != null && content.getId() == id) {
                return i;
            } else if (content == null) {
                // Attempt to track down bug #8886916
                Log.w(TAG, "*** Null content at " + "i=" + i + ",id=" + id + ",N=" + children);
            }
        }
        return -1;