From 6ab2e4a91ee5aa0d91442f29ac17652b87cf3a89 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Sun, 27 Jan 2019 23:18:32 -0800 Subject: [PATCH] Fix InputMethodSettings#getInt() for nonexistent key when copy-on-write is on It turns out that InputMethodSettings#getInt() has always returned 0 instead of the specified default value when copy-on-write is on and the specified key does not exist since the mechanism was introduced to support direct-boot [1]. Most likely this would not have been a big issue, but let's fix it just in case. [1]: I9c6f9bb3d51174198e5f73588637f87ea0d90e11 68645a638ad1bfb734b2b0f56b17fe206bb891c5 Bug: 26279466 Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases Change-Id: If2abc0604372cf394105db9395706aaa0f570431 --- .../java/com/android/server/inputmethod/InputMethodUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java index 326984c7202c5..4349b4aa36032 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodUtils.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodUtils.java @@ -872,7 +872,7 @@ final class InputMethodUtils { private int getInt(String key, int defaultValue) { if (mCopyOnWrite && mCopyOnWriteDataStore.containsKey(key)) { final String result = mCopyOnWriteDataStore.get(key); - return result != null ? Integer.parseInt(result) : 0; + return result != null ? Integer.parseInt(result) : defaultValue; } return Settings.Secure.getIntForUser(mResolver, key, defaultValue, mCurrentUserId); }