public static boolean compareVersion(String serverVersion, String localVersion, Context context) {
    boolean versionIsNew = false;

    if (serverVersion.isEmpty() || localVersion.isEmpty()) {
      return false;
    }

    final SimpleDateFormat format = OTAConfig.getInstance(context).getFormat();
    if (format == null) {
      try {
        int serverNumber = Integer.parseInt(serverVersion.replaceAll("[\\D]", ""));
        int currentNumber = Integer.parseInt(localVersion.replaceAll("[\\D]", ""));
        versionIsNew = serverNumber > currentNumber;
      } catch (NumberFormatException e) {
        OTAUtils.logError(e);
      }
    } else {
      try {
        Date serverDate = format.parse(serverVersion);
        Date currentDate = format.parse(localVersion);
        versionIsNew = serverDate.after(currentDate);
      } catch (ParseException e) {
        OTAUtils.logError(e);
      }
    }

    return versionIsNew;
  }
  public static boolean checkServerVersion(String serverVersion, Context context) {
    String localVersion = getFullLocalVersion(context);
    localVersion = extractVersionFrom(localVersion, context);
    serverVersion = extractVersionFrom(serverVersion, context);

    OTAUtils.logInfo("serverVersion: " + serverVersion);
    OTAUtils.logInfo("localVersion: " + localVersion);

    return compareVersion(serverVersion, localVersion, context);
  }
 public static String getFullLocalVersion(Context context) {
   String source = OTAConfig.getInstance(context).getVersionSource();
   String sourceString = "";
   if (source.equalsIgnoreCase(UNAME_R)) {
     sourceString = OTAUtils.runCommand(UNAME_R);
   } else {
     sourceString = OTAUtils.getBuildProp(source);
   }
   return sourceString;
 }