Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e27dc2b0 authored by Seigo Nonaka's avatar Seigo Nonaka
Browse files

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
parent dda53bf0
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -84,20 +84,6 @@ public class InputMethodUtils {

    // ----------------------------------------------------------------------
    // 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 {
+4 −3
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import android.inputmethodservice.InputMethodService;
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 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            }
            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 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            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();