Fix double-checked locking in InputMethodSubtype
No functional change. Fixes: 35737935 Test: run cts test and confirmed all tests passed cts-tradefed run singleCommand cts-dev -m CtsInputMethodTestCases Change-Id: I44e5e91b6462c3c7d023f50365b30da9cf98c509
This commit is contained in:
committed by
Yohei Yukawa
parent
9d2a3adfdf
commit
da5790de78
@@ -520,27 +520,27 @@ public final class InputMethodSubtype implements Parcelable {
|
||||
}
|
||||
|
||||
private HashMap<String, String> getExtraValueHashMap() {
|
||||
if (mExtraValueHashMapCache == null) {
|
||||
synchronized(this) {
|
||||
if (mExtraValueHashMapCache == null) {
|
||||
mExtraValueHashMapCache = new HashMap<String, String>();
|
||||
final String[] pairs = mSubtypeExtraValue.split(EXTRA_VALUE_PAIR_SEPARATOR);
|
||||
final int N = pairs.length;
|
||||
for (int i = 0; i < N; ++i) {
|
||||
final String[] pair = pairs[i].split(EXTRA_VALUE_KEY_VALUE_SEPARATOR);
|
||||
if (pair.length == 1) {
|
||||
mExtraValueHashMapCache.put(pair[0], null);
|
||||
} else if (pair.length > 1) {
|
||||
if (pair.length > 2) {
|
||||
Slog.w(TAG, "ExtraValue has two or more '='s");
|
||||
}
|
||||
mExtraValueHashMapCache.put(pair[0], pair[1]);
|
||||
}
|
||||
synchronized (this) {
|
||||
HashMap<String, String> extraValueMap = mExtraValueHashMapCache;
|
||||
if (extraValueMap != null) {
|
||||
return extraValueMap;
|
||||
}
|
||||
extraValueMap = new HashMap<>();
|
||||
final String[] pairs = mSubtypeExtraValue.split(EXTRA_VALUE_PAIR_SEPARATOR);
|
||||
for (int i = 0; i < pairs.length; ++i) {
|
||||
final String[] pair = pairs[i].split(EXTRA_VALUE_KEY_VALUE_SEPARATOR);
|
||||
if (pair.length == 1) {
|
||||
extraValueMap.put(pair[0], null);
|
||||
} else if (pair.length > 1) {
|
||||
if (pair.length > 2) {
|
||||
Slog.w(TAG, "ExtraValue has two or more '='s");
|
||||
}
|
||||
extraValueMap.put(pair[0], pair[1]);
|
||||
}
|
||||
}
|
||||
mExtraValueHashMapCache = extraValueMap;
|
||||
return extraValueMap;
|
||||
}
|
||||
return mExtraValueHashMapCache;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user