Fix NPE while dispatching input event.

- occasionally, TvView can be detached while
  the input event is being processed.

BUG: 14791903
Change-Id: Id1def32ace1bf9765ae30a00ea4579670d1d40aa
This commit is contained in:
Chulwoo Lee
2014-05-14 11:31:51 +09:00
parent e049c23980
commit c3e00c3ffc

View File

@@ -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);
}
}
};