OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package com.android.webview.chromium; | 5 package com.android.webview.chromium; |
6 | 6 |
7 import android.Manifest; | 7 import android.Manifest; |
8 import android.app.ActivityManager; | 8 import android.app.ActivityManager; |
9 import android.content.ComponentCallbacks2; | 9 import android.content.ComponentCallbacks2; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 System.loadLibrary("webviewchromium_plat_support"); | 214 System.loadLibrary("webviewchromium_plat_support"); |
215 | 215 |
216 // Use shared preference to check for package downgrade. | 216 // Use shared preference to check for package downgrade. |
217 mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreference
s( | 217 mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreference
s( |
218 CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE); | 218 CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE); |
219 int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0); | 219 int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0); |
220 int currentVersion = packageInfo.versionCode; | 220 int currentVersion = packageInfo.versionCode; |
221 if (!versionCodeGE(currentVersion, lastVersion)) { | 221 if (!versionCodeGE(currentVersion, lastVersion)) { |
222 // The WebView package has been downgraded since we last ran in this
application. | 222 // The WebView package has been downgraded since we last ran in this
application. |
223 // Delete the WebView data directory's contents. | 223 // Delete the WebView data directory's contents. |
224 String dataDir = PathUtils.getDataDirectory(ContextUtils.getApplicat
ionContext()); | 224 String dataDir = PathUtils.getDataDirectory(); |
225 Log.i(TAG, "WebView package downgraded from " + lastVersion + " to "
+ currentVersion | 225 Log.i(TAG, "WebView package downgraded from " + lastVersion + " to "
+ currentVersion |
226 + "; deleting contents of " + dataDir); | 226 + "; deleting contents of " + dataDir); |
227 deleteContents(new File(dataDir)); | 227 deleteContents(new File(dataDir)); |
228 } | 228 } |
229 if (lastVersion != currentVersion) { | 229 if (lastVersion != currentVersion) { |
230 mWebViewPrefs.edit().putInt(VERSION_CODE_PREF, currentVersion).apply
(); | 230 mWebViewPrefs.edit().putInt(VERSION_CODE_PREF, currentVersion).apply
(); |
231 } | 231 } |
232 // Now safe to use WebView data directory. | 232 // Now safe to use WebView data directory. |
233 } | 233 } |
234 | 234 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 mWebViewDatabase = new WebViewDatabaseAdapter(this, awDatabase); | 561 mWebViewDatabase = new WebViewDatabaseAdapter(this, awDatabase); |
562 } | 562 } |
563 } | 563 } |
564 return mWebViewDatabase; | 564 return mWebViewDatabase; |
565 } | 565 } |
566 | 566 |
567 WebViewDelegate getWebViewDelegate() { | 567 WebViewDelegate getWebViewDelegate() { |
568 return mWebViewDelegate; | 568 return mWebViewDelegate; |
569 } | 569 } |
570 } | 570 } |
OLD | NEW |