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
4a8136b51b
Bug: 27196876
Change-Id: I869a7bd87748f09f7032a60b34ac0dbdc4a00b72
This commit is contained in:
@@ -35,7 +35,6 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.android.internal.inputmethod.InputMethodUtils;
|
import com.android.internal.inputmethod.InputMethodUtils;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
import com.android.settingslib.RestrictedSwitchPreference;
|
import com.android.settingslib.RestrictedSwitchPreference;
|
||||||
|
|
||||||
@@ -149,7 +148,7 @@ class InputMethodPreference extends RestrictedSwitchPreference implements OnPref
|
|||||||
if (InputMethodUtils.isSystemIme(mImi)) {
|
if (InputMethodUtils.isSystemIme(mImi)) {
|
||||||
// Enable a system IME. No need to show a security warning dialog,
|
// 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.
|
// 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);
|
setCheckedInternal(true);
|
||||||
} else {
|
} else {
|
||||||
showDirectBootWarnDialog();
|
showDirectBootWarnDialog();
|
||||||
@@ -245,7 +244,7 @@ class InputMethodPreference extends RestrictedSwitchPreference implements OnPref
|
|||||||
public void onClick(final DialogInterface dialog, final int which) {
|
public void onClick(final DialogInterface dialog, final int which) {
|
||||||
// The user confirmed to enable a 3rd party IME, but we might
|
// The user confirmed to enable a 3rd party IME, but we might
|
||||||
// need to prompt if it's not Direct Boot aware.
|
// need to prompt if it's not Direct Boot aware.
|
||||||
if (Utils.isPackageDirectBootAware(getContext(), mImi.getPackageName())) {
|
if (mImi.getServiceInfo().directBootAware) {
|
||||||
setCheckedInternal(true);
|
setCheckedInternal(true);
|
||||||
} else {
|
} else {
|
||||||
showDirectBootWarnDialog();
|
showDirectBootWarnDialog();
|
||||||
|
Reference in New Issue
Block a user