diff options
author | Kenny Guy <kennyguy@google.com> | 2014-08-21 13:20:21 +0100 |
---|---|---|
committer | Kenny Guy <kennyguy@google.com> | 2014-08-21 17:15:49 +0100 |
commit | 333f2bc71a0866053f8e2fce8efbfb0bcec68811 (patch) | |
tree | 81db561524dbe7c980ce1a4c4adbe5f62109f482 /src/com/android/settings/inputmethod | |
parent | 10673f1a1e330cf20ddab04fbc09cce3f18d111d (diff) | |
download | packages_apps_Settings-333f2bc71a0866053f8e2fce8efbfb0bcec68811.zip packages_apps_Settings-333f2bc71a0866053f8e2fce8efbfb0bcec68811.tar.gz packages_apps_Settings-333f2bc71a0866053f8e2fce8efbfb0bcec68811.tar.bz2 |
Disable non-permitted accessibility services and IMEs
Bug: 14469005
Change-Id: I4986f035318854c27ecb92bbe2f0c977d53b6361
Diffstat (limited to 'src/com/android/settings/inputmethod')
-rw-r--r-- | src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java | 11 | ||||
-rwxr-xr-x | src/com/android/settings/inputmethod/InputMethodPreference.java | 12 |
2 files changed, 20 insertions, 3 deletions
diff --git a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java index f18694c..d0bc0cc 100644 --- a/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java +++ b/src/com/android/settings/inputmethod/InputMethodAndLanguageSettings.java @@ -18,6 +18,7 @@ package com.android.settings.inputmethod; import android.app.Activity; import android.app.Fragment; +import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.ContentResolver; import android.content.Context; @@ -34,6 +35,7 @@ import android.hardware.input.InputManager; import android.hardware.input.KeyboardLayout; import android.os.Bundle; import android.os.Handler; +import android.os.UserHandle; import android.preference.CheckBoxPreference; import android.preference.ListPreference; import android.preference.Preference; @@ -102,6 +104,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment private SettingsObserver mSettingsObserver; private Intent mIntentWaitingForResult; private InputMethodSettingValuesWrapper mInputMethodSettingValues; + private DevicePolicyManager mDpm; @Override public void onCreate(Bundle icicle) { @@ -175,6 +178,8 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment mHandler = new Handler(); mSettingsObserver = new SettingsObserver(mHandler, activity); + mDpm = (DevicePolicyManager) (getActivity(). + getSystemService(Context.DEVICE_POLICY_SERVICE)); } private void updateInputMethodSelectorSummary(int value) { @@ -403,6 +408,7 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment mKeyboardSettingsCategory.removePreference(pref); } mInputMethodPreferenceList.clear(); + List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser(); final Context context = getActivity(); final List<InputMethodInfo> imis = mShowsOnlyFullImeAndKeyboardList ? mInputMethodSettingValues.getInputMethodList() @@ -410,8 +416,11 @@ public class InputMethodAndLanguageSettings extends SettingsPreferenceFragment final int N = (imis == null ? 0 : imis.size()); for (int i = 0; i < N; ++i) { final InputMethodInfo imi = imis.get(i); + final boolean isAllowedByOrganization = permittedList == null + || permittedList.contains(imi.getPackageName()); final InputMethodPreference pref = new InputMethodPreference( - context, imi, mShowsOnlyFullImeAndKeyboardList /* hasSwitch */, this); + context, imi, mShowsOnlyFullImeAndKeyboardList /* hasSwitch */, + isAllowedByOrganization, this); mInputMethodPreferenceList.add(pref); } final Collator collator = Collator.getInstance(); diff --git a/src/com/android/settings/inputmethod/InputMethodPreference.java b/src/com/android/settings/inputmethod/InputMethodPreference.java index 111f79b..5cf5d6a 100755 --- a/src/com/android/settings/inputmethod/InputMethodPreference.java +++ b/src/com/android/settings/inputmethod/InputMethodPreference.java @@ -68,6 +68,7 @@ class InputMethodPreference extends SwitchPreference implements OnPreferenceClic private final boolean mHasPriorityInSorting; private final OnSavePreferenceListener mOnSaveListener; private final InputMethodSettingValuesWrapper mInputMethodSettingValues; + private final boolean mIsAllowedByOrganization; private AlertDialog mDialog = null; @@ -78,14 +79,18 @@ class InputMethodPreference extends SwitchPreference implements OnPreferenceClic * @param imi The {@link InputMethodInfo} of this preference. * @param isImeEnabler true if this preference is the IME enabler that has enable/disable * switches for all available IMEs, not the list of enabled IMEs. + * @param isAllowedByOrganization false if the IME has been disabled by a device or profile + owner. * @param onSaveListener The listener called when this preference has been changed and needs * to save the state to shared preference. */ InputMethodPreference(final Context context, final InputMethodInfo imi, - final boolean isImeEnabler, final OnSavePreferenceListener onSaveListener) { + final boolean isImeEnabler, final boolean isAllowedByOrganization, + final OnSavePreferenceListener onSaveListener) { super(context); setPersistent(false); mImi = imi; + mIsAllowedByOrganization = isAllowedByOrganization; mOnSaveListener = onSaveListener; if (!isImeEnabler) { // Hide switch widget. @@ -178,7 +183,7 @@ class InputMethodPreference extends SwitchPreference implements OnPreferenceClic mImi, getContext()); // Only when this preference has a switch and an input method should be always enabled, // this preference should be disabled to prevent accidentally disabling an input method. - setEnabled(!(isAlwaysChecked && isImeEnabler())); + setEnabled(!((isAlwaysChecked && isImeEnabler()) || (!mIsAllowedByOrganization))); setChecked(mInputMethodSettingValues.isEnabledImi(mImi)); setSummary(getSummaryString()); } @@ -189,6 +194,9 @@ class InputMethodPreference extends SwitchPreference implements OnPreferenceClic private String getSummaryString() { final Context context = getContext(); + if (!mIsAllowedByOrganization) { + return context.getString(R.string.accessibility_feature_or_input_method_not_allowed); + } final InputMethodManager imm = getInputMethodManager(); final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(mImi, true); final ArrayList<CharSequence> subtypeLabels = new ArrayList<>(); |