Do database access in the background thread to prevent ANR.
Bug: 2222528
diff --git a/src/com/android/browser/DownloadTouchIcon.java b/src/com/android/browser/DownloadTouchIcon.java
index 1761dd4..99f1930 100644
--- a/src/com/android/browser/DownloadTouchIcon.java
+++ b/src/com/android/browser/DownloadTouchIcon.java
@@ -36,7 +36,7 @@
import java.io.IOException;
import java.io.InputStream;
-class DownloadTouchIcon extends AsyncTask<String, Void, Bitmap> {
+class DownloadTouchIcon extends AsyncTask<String, Void, Void> {
private final ContentResolver mContentResolver;
private final Cursor mCursor;
private final String mOriginalUrl;
@@ -64,7 +64,7 @@
}
@Override
- public Bitmap doInBackground(String... values) {
+ public Void doInBackground(String... values) {
String url = values[0];
AndroidHttpClient client = AndroidHttpClient.newInstance(
@@ -84,7 +84,7 @@
if (content != null) {
Bitmap icon = BitmapFactory.decodeStream(
content, null, null);
- return icon;
+ storeIcon(icon);
}
}
}
@@ -105,8 +105,7 @@
}
}
- @Override
- public void onPostExecute(Bitmap icon) {
+ private void storeIcon(Bitmap icon) {
// Do this first in case the download failed.
if (mTab != null) {
// Remove the touch icon loader from the BrowserActivity.