Fix CME in ModelSpecificDistanceCalculator
@@ -269,7 +269,7 @@ public class ModelSpecificDistanceCalculator implements DistanceCalculator {
}
private void buildModelMap(String jsonString) throws JSONException {
- mModelMap = new HashMap<AndroidModel, DistanceCalculator>();
+ HashMap<AndroidModel, DistanceCalculator> map = new HashMap<AndroidModel, DistanceCalculator>();
JSONObject jsonObject = new JSONObject(jsonString);
JSONArray array = jsonObject.getJSONArray("models");
for (int i = 0; i < array.length(); i++) {
@@ -290,19 +290,20 @@ public class ModelSpecificDistanceCalculator implements DistanceCalculator {
new CurveFittedDistanceCalculator(coefficient1,coefficient2,coefficient3);
AndroidModel androidModel = new AndroidModel(version, buildNumber, model, manufacturer);
- mModelMap.put(androidModel, distanceCalculator);
+ map.put(androidModel, distanceCalculator);
if (defaultFlag) {
mDefaultModel = androidModel;
}
}
+ mModelMap = map;
}
private void loadDefaultModelMap() {
- mModelMap = new HashMap<AndroidModel, DistanceCalculator>();
try {
buildModelMap(stringFromFilePath(CONFIG_FILE));
}
catch (Exception e) {
+ mModelMap = new HashMap<AndroidModel, DistanceCalculator>();
LogManager.e(e, TAG, "Cannot build model distance calculations");
}
}
