| Index: chrome/android/java/src/org/chromium/chrome/browser/omaha/VersionNumberGetter.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omaha/VersionNumberGetter.java b/chrome/android/java/src/org/chromium/chrome/browser/omaha/VersionNumberGetter.java
|
| index f6a47daa2cb84061dda32dd60b54167be6de70b1..447892042948e69a7cc238d0abc945db96dfd3a2 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/omaha/VersionNumberGetter.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/omaha/VersionNumberGetter.java
|
| @@ -34,4 +34,31 @@ public class VersionNumberGetter {
|
| public String getCurrentlyUsedVersion(Context context) {
|
| return BuildInfo.getPackageVersionName(context);
|
| }
|
| +
|
| + /**
|
| + * Gets the milestone from an AboutVersionStrings#getApplicationVersion string. These strings
|
| + * are of the format "ProductName xx.xx.xx.xx".
|
| + *
|
| + * @param version The version to extract the milestone number from.
|
| + * @return The milestone of the given version string.
|
| + */
|
| + public static int getMilestoneFromVersionNumber(String version) {
|
| + if (version.isEmpty()) {
|
| + throw new IllegalArgumentException("Application version incorrectly formatted");
|
| + }
|
| +
|
| + version = version.replaceAll("[^\\d.]", "");
|
| +
|
| + // Parse out the version numbers.
|
| + String[] pieces = version.split("\\.");
|
| + if (pieces.length != 4) {
|
| + throw new IllegalArgumentException("Application version incorrectly formatted");
|
| + }
|
| +
|
| + try {
|
| + return Integer.parseInt(pieces[0]);
|
| + } catch (NumberFormatException e) {
|
| + throw new IllegalArgumentException("Application version incorrectly formatted");
|
| + }
|
| + }
|
| }
|
|
|