diff options
author | Patrick Scott <phanna@android.com> | 2011-01-18 08:50:20 -0500 |
---|---|---|
committer | Patrick Scott <phanna@android.com> | 2011-01-18 08:50:20 -0500 |
commit | 081caaa34ab5af0694087c3203e39be25797455a (patch) | |
tree | b510cb77c241d276b21b20e98d4a7f8cb94eeb0d /src/com/android/browser/GoogleAccountLogin.java | |
parent | bf1d10af39eb23d68db69a8eda9e12e62f1a9682 (diff) | |
download | packages_apps_Browser-081caaa34ab5af0694087c3203e39be25797455a.zip packages_apps_Browser-081caaa34ab5af0694087c3203e39be25797455a.tar.gz packages_apps_Browser-081caaa34ab5af0694087c3203e39be25797455a.tar.bz2 |
Protect access to mWebView by checking mRunnable.
If the user cancels the login event, mRunnable will be reset and the WebView
destroyed. Check for a null mRunnable before accessing mWebView.
Bug: 3361009
Bug: 3349815
Change-Id: Idd9a2b788673d9ec95bfa083a4af7df705c22fcd
Diffstat (limited to 'src/com/android/browser/GoogleAccountLogin.java')
-rw-r--r-- | src/com/android/browser/GoogleAccountLogin.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/com/android/browser/GoogleAccountLogin.java b/src/com/android/browser/GoogleAccountLogin.java index 04b3957..855c407 100644 --- a/src/com/android/browser/GoogleAccountLogin.java +++ b/src/com/android/browser/GoogleAccountLogin.java @@ -86,9 +86,17 @@ public class GoogleAccountLogin extends Thread implements .appendQueryParameter("SID", mSid) .appendQueryParameter("LSID", mLsid) .build().toString(); + // Check mRunnable to see if the request has been canceled. Otherwise + // we might access a destroyed WebView. + String ua = null; + synchronized (this) { + if (mRunnable == null) { + return; + } + ua = mWebView.getSettings().getUserAgentString(); + } // Intentionally not using Proxy. - AndroidHttpClient client = AndroidHttpClient.newInstance( - mWebView.getSettings().getUserAgentString()); + AndroidHttpClient client = AndroidHttpClient.newInstance(ua); HttpPost request = new HttpPost(url); String result = null; @@ -119,7 +127,15 @@ public class GoogleAccountLogin extends Thread implements .build().toString(); mActivity.runOnUiThread(new Runnable() { @Override public void run() { - mWebView.loadUrl(newUrl); + // Check mRunnable in case the request has been canceled. This + // is most likely not necessary as run() is the only non-UI + // thread that calls done() but I am paranoid. + synchronized (GoogleAccountLogin.this) { + if (mRunnable == null) { + return; + } + mWebView.loadUrl(newUrl); + } } }); } |