WebView fix for devices running <LRW48.

googlefood is currently running 45I and so will not be able to run
the latest APK we built. Add a patch for the issue, and will repsin
APKs to push out.

Bug: 17172566
Change-Id: Ic4d4fb2f677951d1143a97c27cf4bd9541f2d5fa
diff --git a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
index f82707f..99f68fa 100644
--- a/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
+++ b/chromium/java/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
@@ -106,22 +106,29 @@
         // Load glue-layer support library.
         System.loadLibrary("webviewchromium_plat_support");
 
-        // Use shared preference to check for package downgrade.
-        mWebViewPrefs = ActivityThread.currentApplication().getSharedPreferences(
-                            CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE);
-        int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0);
-        int currentVersion = WebViewFactory.getLoadedPackageInfo().versionCode;
-        if (lastVersion > currentVersion) {
-            // The WebView package has been downgraded since we last ran in this application.
-            // Delete the WebView data directory's contents.
-            String dataDir = PathUtils.getDataDirectory(ActivityThread.currentApplication());
-            Log.i(TAG, "WebView package downgraded from " + lastVersion + " to " + currentVersion +
-                       "; deleting contents of " + dataDir);
-            FileUtils.deleteContents(new File(dataDir));
+        // TODO: temporary try/catch while framework builds catch up with WebView builds.
+        // Remove this.
+        try {
+            // Use shared preference to check for package downgrade.
+            mWebViewPrefs = ActivityThread.currentApplication().getSharedPreferences(
+                                CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE);
+            int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0);
+            int currentVersion = WebViewFactory.getLoadedPackageInfo().versionCode;
+            if (lastVersion > currentVersion) {
+                // The WebView package has been downgraded since we last ran in this application.
+                // Delete the WebView data directory's contents.
+                String dataDir = PathUtils.getDataDirectory(ActivityThread.currentApplication());
+                Log.i(TAG, "WebView package downgraded from " + lastVersion + " to " + currentVersion +
+                           "; deleting contents of " + dataDir);
+                FileUtils.deleteContents(new File(dataDir));
+            }
+            if (lastVersion != currentVersion) {
+                mWebViewPrefs.edit().putInt(VERSION_CODE_PREF, currentVersion).apply();
+            }
+        } catch (NoSuchMethodError e) {
+            Log.w(TAG, "Not doing version downgrade check as framework is too old.");
         }
-        if (lastVersion != currentVersion) {
-            mWebViewPrefs.edit().putInt(VERSION_CODE_PREF, currentVersion).apply();
-        }
+
         // Now safe to use WebView data directory.
     }