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
68645a638a
Bug: 26279466
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Change-Id: If2abc0604372cf394105db9395706aaa0f570431
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user