Check if InputMethodService is Direct Boot aware
This is a small follow up CL to the previous CL [1] that added
functionality to show a warning dialog when Direct Boot unaware apps and
IMEs are being selected.
In the previous CL, we checked whether the package to which the IME
belogs to is (fully or partially) Direct Boot aware. If the package is
partially Direct Boot aware but the InputMethodService in question is
still Direct Boot unaware, the user will not see the warning dialog.
Luckily in InputMethodPreference we already have InputMethodInfo that
indirectly exposes ServiceInfo#directBootAware. By directly checking
that bit we can simplify the logic and avoid such false negatives.
[1]: I0498904d2f664fb41e8c1e6bb30d1cbf437cf4b9
4a8136b51b746961aac6f5ce2459effef8c22680
Bug: 27196876
Change-Id: I869a7bd87748f09f7032a60b34ac0dbdc4a00b72
diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java
index 2c27700..b2c2800 100755
--- a/src/com/android/settings/inputmethod/InputMethodPreference.java
+++ b/src/com/android/settings/inputmethod/InputMethodPreference.java
@@ -35,7 +35,6 @@
import com.android.internal.inputmethod.InputMethodUtils;
import com.android.settings.R;
-import com.android.settings.Utils;
import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedSwitchPreference;
@@ -149,7 +148,7 @@
if (InputMethodUtils.isSystemIme(mImi)) {
// Enable a system IME. No need to show a security warning dialog,
// but we might need to prompt if it's not Direct Boot aware.
- if (Utils.isPackageDirectBootAware(getContext(), mImi.getPackageName())) {
+ if (mImi.getServiceInfo().directBootAware) {
setCheckedInternal(true);
} else {
showDirectBootWarnDialog();
@@ -245,7 +244,7 @@
public void onClick(final DialogInterface dialog, final int which) {
// The user confirmed to enable a 3rd party IME, but we might
// need to prompt if it's not Direct Boot aware.
- if (Utils.isPackageDirectBootAware(getContext(), mImi.getPackageName())) {
+ if (mImi.getServiceInfo().directBootAware) {
setCheckedInternal(true);
} else {
showDirectBootWarnDialog();