add error handling in GameTextInput

With some IMEs window insets might be null sometimes, so we have to take
this into account.

Fix: 314924320
Test: build and run AGDKTunnel
Change-Id: I3f8edb39f1c4cb4a0a5cc61a8dfc4e4fb52015a8
diff --git a/game-text-input/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java b/game-text-input/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java
index 7052762..2de0f9d 100644
--- a/game-text-input/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java
+++ b/game-text-input/src/main/java/com/google/androidgamesdk/gametextinput/InputConnection.java
@@ -601,7 +601,16 @@
    * @return The current IME insets
    */
   public Insets getImeInsets() {
+    if (this.targetView == null) {
+      return Insets.NONE;
+    }
+
     WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(this.targetView);
+
+    if (insets == null) {
+      return Insets.NONE;
+    }
+
     return insets.getInsets(WindowInsetsCompat.Type.ime());
   }
 
@@ -611,7 +620,16 @@
    * @return whether software IME is visible or not.
    */
   public boolean isSoftwareKeyboardVisible() {
+    if (this.targetView == null) {
+      return false;
+    }
+
     WindowInsetsCompat insets = ViewCompat.getRootWindowInsets(this.targetView);
+
+    if (insets == null) {
+      return false;
+    }
+
     return insets.isVisible(WindowInsetsCompat.Type.ime());
   }