public static boolean isThisKeyboardSetAsDefaultIME(Context context) {
    final String defaultIME =
        Settings.Secure.getString(
            context.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
    return isThisKeyboardSetAsDefaultIME(defaultIME, context.getPackageName());
  }
@Test
  public void testIsThisKeyboardSetAsDefaultIME() throws Exception {
    final String MY_IME_PACKAGE = "net.evendanan.ime";
    assertFalse(
        SetupSupport.isThisKeyboardSetAsDefaultIME(
            new ComponentName("net.some.one.else", "net.some.one.else.IME").flattenToString(),
            MY_IME_PACKAGE));
    assertFalse(
        SetupSupport.isThisKeyboardSetAsDefaultIME(
            new ComponentName("net.some.one.else", "net.some.other.IME").flattenToString(),
            MY_IME_PACKAGE));
    assertFalse(
        SetupSupport.isThisKeyboardSetAsDefaultIME(
            new ComponentName("net.some.one.else", ".IME").flattenToString(), MY_IME_PACKAGE));
    assertFalse(SetupSupport.isThisKeyboardSetAsDefaultIME(null, MY_IME_PACKAGE));

    assertTrue(
        SetupSupport.isThisKeyboardSetAsDefaultIME(
            new ComponentName(MY_IME_PACKAGE, MY_IME_PACKAGE + ".IME").flattenToString(),
            MY_IME_PACKAGE));
    assertTrue(
        SetupSupport.isThisKeyboardSetAsDefaultIME(
            new ComponentName(MY_IME_PACKAGE, "net.some.other.IME").flattenToString(),
            MY_IME_PACKAGE));
    assertTrue(
        SetupSupport.isThisKeyboardSetAsDefaultIME(
            new ComponentName(MY_IME_PACKAGE, ".IME").flattenToString(), MY_IME_PACKAGE));
  }