Use android.os.Debug.getCallers instead of self implementation.

This changes debug message format but does not change any other behavior.

Maintaining InputMethodUtils.getStackTrace() doesn't make much sense
because we already have a similar method in android.os.Debug.

since there is already utility function in Android. The length 10 is
sufficient for identifying caller modules.

getStackTrace() is introduced by
Ib23849d352db33f0747aa9d5a178f00ac726c13b just for debugging purpose as a
part of Bug 6931482.

Bug: 22285167
Change-Id: If3a6c0d2f51dc3774eef14b4f496b5b59ddcf5a6
diff --git a/core/java/com/android/internal/inputmethod/InputMethodUtils.java b/core/java/com/android/internal/inputmethod/InputMethodUtils.java
index 191b5a7..b85d5eb 100644
--- a/core/java/com/android/internal/inputmethod/InputMethodUtils.java
+++ b/core/java/com/android/internal/inputmethod/InputMethodUtils.java
@@ -84,20 +84,6 @@
 
     // ----------------------------------------------------------------------
     // Utilities for debug
-    public static String getStackTrace() {
-        final StringBuilder sb = new StringBuilder();
-        try {
-            throw new RuntimeException();
-        } catch (RuntimeException e) {
-            final StackTraceElement[] frames = e.getStackTrace();
-            // Start at 1 because the first frame is here and we don't care about it
-            for (int j = 1; j < frames.length; ++j) {
-                sb.append(frames[j].toString() + "\n");
-            }
-        }
-        return sb.toString();
-    }
-
     public static String getApiCallStack() {
         String apiCallStack = "";
         try {
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 66a2308..0a0ee3f 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -73,6 +73,7 @@
 import android.net.Uri;
 import android.os.Binder;
 import android.os.Bundle;
+import android.os.Debug;
 import android.os.Environment;
 import android.os.Handler;
 import android.os.IBinder;
@@ -1098,8 +1099,8 @@
             }
             return true;
         }
-        Slog.w(TAG, "--- IPC called from background users. Ignore. \n"
-                + InputMethodUtils.getStackTrace());
+        Slog.w(TAG, "--- IPC called from background users. Ignore. callers="
+                + Debug.getCallers(10));
         return false;
     }
 
@@ -2858,7 +2859,7 @@
             HashMap<String, InputMethodInfo> map, boolean resetDefaultEnabledIme) {
         if (DEBUG) {
             Slog.d(TAG, "--- re-buildInputMethodList reset = " + resetDefaultEnabledIme
-                    + " \n ------ \n" + InputMethodUtils.getStackTrace());
+                    + " \n ------ caller=" + Debug.getCallers(10));
         }
         list.clear();
         map.clear();