private void loadDefaultModelMap() {
   mModelMap = new HashMap<AndroidModel, DistanceCalculator>();
   try {
     buildModelMap(stringFromFilePath(CONFIG_FILE));
   } catch (Exception e) {
     LogManager.e(e, TAG, "Cannot build model distance calculations");
   }
 }
 /**
  * Estimate the distance to the beacon using the DistanceCalculator set on this class. If no
  * DistanceCalculator has been set, return -1 as the distance.
  *
  * @see org.altbeacon.beacon.distance.DistanceCalculator
  * @param txPower
  * @param bestRssiAvailable
  * @return
  */
 protected static Double calculateDistance(int txPower, double bestRssiAvailable) {
   if (Beacon.getDistanceCalculator() != null) {
     return Beacon.getDistanceCalculator().calculateDistance(txPower, bestRssiAvailable);
   } else {
     LogManager.e(TAG, "Distance calculator not set.  Distance will bet set to -1");
     return -1.0;
   }
 }
 private boolean loadModelMapFromFile() {
   File file = new File(mContext.getFilesDir(), CONFIG_FILE);
   FileInputStream inputStream = null;
   BufferedReader reader = null;
   StringBuilder sb = new StringBuilder();
   try {
     inputStream = new FileInputStream(file);
     reader = new BufferedReader(new InputStreamReader(inputStream));
     String line;
     while ((line = reader.readLine()) != null) {
       sb.append(line).append("\n");
     }
   } catch (FileNotFoundException fnfe) {
     // This occurs on the first time the app is run, no error message necessary.
     return false;
   } catch (IOException e) {
     LogManager.e(e, TAG, "Cannot open distance model file %s", file);
     return false;
   } finally {
     if (reader != null) {
       try {
         reader.close();
       } catch (Exception e2) {
       }
     }
     if (inputStream != null) {
       try {
         inputStream.close();
       } catch (Exception e2) {
       }
     }
   }
   try {
     buildModelMap(sb.toString());
     return true;
   } catch (JSONException e) {
     LogManager.e(
         TAG,
         "Cannot update distance models from online database at %s with JSON",
         e,
         mRemoteUpdateUrlString,
         sb.toString());
     return false;
   }
 }