From 982d21b9dc73eebd4b68a63579cf8be78c788c32 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 9 May 2013 14:43:16 -0700 Subject: 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 --- .../android/internal/policy/impl/keyguard/KeyguardHostView.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'policy') diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java index fbeca4f..c470870 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java @@ -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; -- cgit v1.1