From c3e00c3ffc3b1406712f1f19b8d1cd815eee88da Mon Sep 17 00:00:00 2001 From: Chulwoo Lee Date: Wed, 14 May 2014 11:31:51 +0900 Subject: [PATCH] Fix NPE while dispatching input event. - occasionally, TvView can be detached while the input event is being processed. BUG: 14791903 Change-Id: Id1def32ace1bf9765ae30a00ea4579670d1d40aa --- core/java/android/tv/TvView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/java/android/tv/TvView.java b/core/java/android/tv/TvView.java index 7eaa86b6642a0..772157508b0d5 100644 --- a/core/java/android/tv/TvView.java +++ b/core/java/android/tv/TvView.java @@ -31,6 +31,7 @@ import android.view.MotionEvent; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceView; +import android.view.ViewRootImpl; /** * View playing TV @@ -89,7 +90,10 @@ public class TvView extends SurfaceView { if (dispatchUnhandledInputEvent(event)) { return; } - getViewRootImpl().dispatchUnhandledInputEvent(event); + ViewRootImpl viewRootImpl = getViewRootImpl(); + if (viewRootImpl != null) { + viewRootImpl.dispatchUnhandledInputEvent(event); + } } };