Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ab2e4a9 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

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
     68645a63

Bug: 26279466
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Change-Id: If2abc0604372cf394105db9395706aaa0f570431
parent 18f11cd4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);
        }