summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
diff options
context:
space:
mode:
authorAlex Johnston <acjohnston@google.com>2021-02-23 14:24:24 +0000
committerAlex Johnston <acjohnston@google.com>2021-03-16 10:12:46 +0000
commita47f5c1a1c0259e62451ce1674c4ab54c0b664db (patch)
treed3d676011fd4f968a8764311f413e272e6b79eda /src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
parentfcdd955dff96dba90f86fc68a34c346d7ee83081 (diff)
downloadpackages_apps_Settings-a47f5c1a1c0259e62451ce1674c4ab54c0b664db.tar.gz
packages_apps_Settings-a47f5c1a1c0259e62451ce1674c4ab54c0b664db.tar.bz2
packages_apps_Settings-a47f5c1a1c0259e62451ce1674c4ab54c0b664db.zip
Allow enabled IMEs to be disabled in Settings
* If an IME is not in the permitted IME list and is enabled, the user should be able to disable it. * This prevents the IME from being stuck in a state where the user cannot disable it and as a result the user's device becomes uncompliant with their IT admin's policy. Manual testing steps: * Install TestDPC * Set up work profile using TestDPC * Install swiftkey in the work profile * set permitted input methods (in TestDPC) to only system * Use adb to enable Swiftkey * Go to Settings and verify Swiftkey can be disabled * Once disabled, verify Swiftkey cannot be re-enabled. Bug: 180517539 Test: manual testing Change-Id: I7bdd3a0c4fed4d16006445b7774fd1006cc2b569
Diffstat (limited to 'src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java')
-rw-r--r--src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
index 686558c73a..d41a3783c7 100644
--- a/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
+++ b/src/com/android/settings/inputmethod/AvailableVirtualKeyboardFragment.java
@@ -91,11 +91,19 @@ public final class AvailableVirtualKeyboardFragment extends SettingsPreferenceFr
List<String> permittedList = mDpm.getPermittedInputMethodsForCurrentUser();
final Context context = getPrefContext();
final List<InputMethodInfo> imis = mInputMethodSettingValues.getInputMethodList();
+ final List<InputMethodInfo> enabledImis = mImm.getEnabledInputMethodList();
final int numImis = (imis == null ? 0 : imis.size());
for (int i = 0; i < numImis; ++i) {
final InputMethodInfo imi = imis.get(i);
+ // TODO (b/182876800): Move this logic out of isAllowedByOrganization and
+ // into a new boolean.
+ // If an input method is enabled but not included in the permitted list, then set it as
+ // allowed by organization. Doing so will allow the user to disable the input method and
+ // remain complaint with the organization's policy. Once disabled, the input method
+ // cannot be re-enabled because it is not in the permitted list.
final boolean isAllowedByOrganization = permittedList == null
- || permittedList.contains(imi.getPackageName());
+ || permittedList.contains(imi.getPackageName())
+ || enabledImis.contains(imi);
final InputMethodPreference pref = new InputMethodPreference(
context, imi, true, isAllowedByOrganization, this);
pref.setIcon(imi.loadIcon(context.getPackageManager()));