Fix issue #2538211: system server crash

Change-Id: Ib440650129ca35e25c8c770113af21fef239178d
ClassCastException: com.android.internal.widget.PointerLocationView
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 9df8ac3..74943f3 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -1500,8 +1500,10 @@
                         focus.getFocusedRect(mTempRect);
                         if (DEBUG_INPUT_RESIZE) Log.v(TAG, "Focus " + focus
                                 + ": focusRect=" + mTempRect.toShortString());
-                        ((ViewGroup) mView).offsetDescendantRectToMyCoords(
-                                focus, mTempRect);
+                        if (mView instanceof ViewGroup) {
+                            ((ViewGroup) mView).offsetDescendantRectToMyCoords(
+                                    focus, mTempRect);
+                        }
                         if (DEBUG_INPUT_RESIZE) Log.v(TAG,
                                 "Focus in window: focusRect="
                                 + mTempRect.toShortString()
@@ -2491,8 +2493,12 @@
                                 // of previous focused into the coord system of
                                 // newly focused view
                                 focused.getFocusedRect(mTempRect);
-                                ((ViewGroup) mView).offsetDescendantRectToMyCoords(focused, mTempRect);
-                                ((ViewGroup) mView).offsetRectIntoDescendantCoords(v, mTempRect);
+                                if (mView instanceof ViewGroup) {
+                                    ((ViewGroup) mView).offsetDescendantRectToMyCoords(
+                                            focused, mTempRect);
+                                    ((ViewGroup) mView).offsetRectIntoDescendantCoords(
+                                            v, mTempRect);
+                                }
                                 focusPassed = v.requestFocus(direction, mTempRect);
                             }