From 7b1c8d717fffa72fdb19243f7a4d438fdf9bbe48 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Wed, 19 Dec 2018 11:21:04 -0800 Subject: Remove entries with zero from subtype.xml As mentioned in its JavaDoc, the way to remove additional subtypes from the IME is passing an empty InputMethodSubtype array as folows: imm#setAdditionalInputMethodSubtypes(imi, new InputMethodSubtype[]); While there is no problem from the viewpoint of IME developers, a harmless but redundant entry for that IME remains in subtype.xml. With this CL, such a redundant entry will be removed. Bug: 121223050 Test: Manually verified as follows 1. Build and flash aosp_taimen-userdebug into taimen 2. Make sure that the device fully boots up 3. adb reboot # to avoid Bug 121259290 4. adb root 5. adb shell cat /data/system/inputmethod/subtypes.xml -> make sure the content looks as follows: 6. Open AOSP Keyboard settings 7. Go to "Appearance & Layouts" -> "Custom input styles" 8. Remove all layouts. 9. adb shell cat /data/system/inputmethod/subtypes.xml -> make sure the content looks as follows: Change-Id: I30820e570e42d5dbc4fd1b6e311b2a8d2553be6d --- .../com/android/server/inputmethod/InputMethodManagerService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 67293b9c9ea0..47c5f492a7e0 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -3274,7 +3274,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub final int packageNum = packageInfos.length; for (int i = 0; i < packageNum; ++i) { if (packageInfos[i].equals(imi.getPackageName())) { - mFileManager.addInputMethodSubtypes(imi, subtypes); + if (subtypes.length > 0) { + mFileManager.addInputMethodSubtypes(imi, subtypes); + } else { + mFileManager.deleteAllInputMethodSubtypes(imi.getId()); + } final long ident = Binder.clearCallingIdentity(); try { buildInputMethodListLocked(false /* resetDefaultEnabledIme */); -- cgit v1.2.3-59-g8ed1b