fix system sometimes enabling wrong subtype

This commit is contained in:
Helium314 2024-06-13 20:36:04 +02:00
parent 237adc991b
commit d1c2ad0a39
2 changed files with 6 additions and 0 deletions

View file

@ -853,6 +853,11 @@ public class LatinIME extends InputMethodService implements
public void onCurrentInputMethodSubtypeChanged(final InputMethodSubtype subtype) { public void onCurrentInputMethodSubtypeChanged(final InputMethodSubtype subtype) {
// Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged() // Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged()
// is not guaranteed. It may even be called at the same time on a different thread. // is not guaranteed. It may even be called at the same time on a different thread.
if (subtype.hashCode() == 0xf000000f) {
// For some reason sometimes the system wants to set the dummy subtype, which messes with the currently enabled subtype.
// Now that the dummy subtype has a fixed id, we can easily avoid enabling it.
return;
}
InputMethodSubtype oldSubtype = mRichImm.getCurrentSubtype().getRawSubtype(); InputMethodSubtype oldSubtype = mRichImm.getCurrentSubtype().getRawSubtype();
StatsUtils.onSubtypeChanged(oldSubtype, subtype); StatsUtils.onSubtypeChanged(oldSubtype, subtype);
mRichImm.onSubtypeChanged(subtype); mRichImm.onSubtypeChanged(subtype);

View file

@ -24,6 +24,7 @@ the system picker crashes on some devices for unknown reasons.
<subtype android:icon="@drawable/ic_ime_switcher" <subtype android:icon="@drawable/ic_ime_switcher"
android:imeSubtypeExtraValue="dummy" android:imeSubtypeExtraValue="dummy"
android:imeSubtypeMode="keyboard" android:imeSubtypeMode="keyboard"
android:subtypeId="0xf000000f"
android:isAsciiCapable="true" android:isAsciiCapable="true"
/> />
</input-method> </input-method>