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

Commit 8bf31dca authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Add debug log for empty IME list in switcher menu

This adds a debug log when we are trying to show the IME switcher menu
but we have an empty IME (and IME subtype) list, which should never be
the case. It should help understand the cause of b/325198431.

Bug: 325198431
Test: n/a
Change-Id: Ib07be176106fbc03f92f3fe99058994918fe1168
parent 65145b2b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -881,6 +881,8 @@ public final class InputMethodInfo implements Parcelable {
                + Integer.toHexString(mIsDefaultResId));
        pw.println(prefix + "Service:");
        mService.dump(pw, prefix + "  ");
        pw.println(prefix + "InputMethodSubtype array: count=" + mSubtypes.getCount());
        mSubtypes.dump(pw, prefix + "  ");
    }

    @Override
+15 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.icu.util.ULocale;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Printer;
import android.util.Slog;

import com.android.internal.inputmethod.SubtypeLocaleUtils;
@@ -791,6 +792,20 @@ public final class InputMethodSubtype implements Parcelable {
        dest.writeInt(mIsAsciiCapable ? 1 : 0);
    }

    void dump(@NonNull Printer pw, @NonNull String prefix) {
        pw.println(prefix + "mSubtypeNameOverride=" + mSubtypeNameOverride
                + " mPkLanguageTag=" + mPkLanguageTag
                + " mPkLayoutType=" + mPkLayoutType
                + " mSubtypeId=" + mSubtypeId
                + " mSubtypeLocale=" + mSubtypeLocale
                + " mSubtypeLanguageTag=" + mSubtypeLanguageTag
                + " mSubtypeMode=" + mSubtypeMode
                + " mIsAuxiliary=" + mIsAuxiliary
                + " mOverridesImplicitlyEnabledSubtype=" + mOverridesImplicitlyEnabledSubtype
                + " mIsAsciiCapable=" + mIsAsciiCapable
                + " mSubtypeHashCode=" + mSubtypeHashCode);
    }

    public static final @android.annotation.NonNull Parcelable.Creator<InputMethodSubtype> CREATOR
            = new Parcelable.Creator<InputMethodSubtype>() {
        @Override
+15 −0
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@

package android.view.inputmethod;

import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.os.BadParcelableException;
import android.os.Parcel;
import android.util.Printer;
import android.util.Slog;

import java.io.ByteArrayInputStream;
@@ -174,6 +176,19 @@ public class InputMethodSubtypeArray {
    private volatile byte[] mCompressedData;
    private volatile int mDecompressedSize;

    void dump(@NonNull Printer pw, @NonNull String prefix) {
        final var innerPrefix = prefix + "  ";
        for (int i = 0; i < mCount; i++) {
            pw.println(prefix + "InputMethodSubtype #" + i + ":");
            final var subtype = get(i);
            if (subtype != null) {
                subtype.dump(pw, innerPrefix);
            } else {
                pw.println(innerPrefix + "missing subtype");
            }
        }
    }

    private static byte[] marshall(final InputMethodSubtype[] array) {
        Parcel parcel = null;
        try {
+8 −0
Original line number Diff line number Diff line
@@ -5021,6 +5021,14 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                            .getSortedInputMethodAndSubtypeList(
                                    showAuxSubtypes, isScreenLocked, true /* forImeMenu */,
                                    mContext, mSettings.getMethodMap(), mSettings.getUserId());
                    if (imList.isEmpty()) {
                        Slog.w(TAG, "Show switching menu failed, imList is empty,"
                                + " showAuxSubtypes: " + showAuxSubtypes
                                + " isScreenLocked: " + isScreenLocked
                                + " userId: " + mSettings.getUserId());
                        return false;
                    }

                    mMenuController.showInputMethodMenuLocked(showAuxSubtypes, displayId,
                            lastInputMethodId, lastInputMethodSubtypeId, imList);
                }
+0 −4
Original line number Diff line number Diff line
@@ -80,10 +80,6 @@ final class InputMethodMenuController {

        final int userId = mService.getCurrentImeUserIdLocked();

        if (imList.isEmpty()) {
            return;
        }

        hideInputMethodMenuLocked();

        if (preferredInputMethodSubtypeId == NOT_A_SUBTYPE_ID) {
Loading