InputMethodManagerServiceTestBase: make robust against setup failure

Fixes an issue where if setup fails, teardown will throw an NPE and
hide the real issue.

Bug: 272633154
Change-Id: I16f5c6d90720f3845a7da5229de3537c9a9dc668
Test: n/a
diff --git a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
index 7cd55f3..9829e57 100644
--- a/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
+++ b/services/tests/InputMethodSystemServerTests/src/com/android/server/inputmethod/InputMethodManagerServiceTestBase.java
@@ -240,7 +240,9 @@
 
     @After
     public void tearDown() {
-        mInputMethodManagerService.mInputMethodDeviceConfigs.destroy();
+        if (mInputMethodManagerService != null) {
+            mInputMethodManagerService.mInputMethodDeviceConfigs.destroy();
+        }
 
         if (mServiceThread != null) {
             mServiceThread.quitSafely();