From 4e44a5ec8e25ba3df3c378648b2b3aa27b45ca0d Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Wed, 27 Jul 2016 16:24:37 -0700 Subject: [PATCH] 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 --- .../android/settings/inputmethod/InputMethodPreference.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java index 2c277002b28..b2c28001a25 100755 --- a/src/com/android/settings/inputmethod/InputMethodPreference.java +++ b/src/com/android/settings/inputmethod/InputMethodPreference.java @@ -35,7 +35,6 @@ import android.widget.Toast; 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 @@ class InputMethodPreference extends RestrictedSwitchPreference implements OnPref 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 @@ class InputMethodPreference extends RestrictedSwitchPreference implements OnPref 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();