private Drawable getSubtypeIcon( InputMethodInfoCompatWrapper imi, InputMethodSubtypeCompatWrapper subtype) { final PackageManager pm = mService.getPackageManager(); if (imi != null) { final String imiPackageName = imi.getPackageName(); if (DBG) { Log.d( TAG, "Update icons of IME: " + imiPackageName + "," + getSubtypeLocale(subtype) + "," + subtype.getMode()); } if (subtype != null) { return pm.getDrawable( imiPackageName, subtype.getIconResId(), imi.getServiceInfo().applicationInfo); } else if (imi.getSubtypeCount() > 0 && imi.getSubtypeAt(0) != null) { return pm.getDrawable( imiPackageName, imi.getSubtypeAt(0).getIconResId(), imi.getServiceInfo().applicationInfo); } else { try { return pm.getApplicationInfo(imiPackageName, 0).loadIcon(pm); } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "IME can't be found: " + imiPackageName); } } } return null; }