Fix for internal storage intialization
The internal storage path needs to be intialized
before comparing it with download path.
Change-Id: I0b2fab3baa2229ce53efe6709345e5a78e9911f6
diff --git a/src/com/android/browser/DownloadHandler.java b/src/com/android/browser/DownloadHandler.java
index e8d9807..419e4b4 100644
--- a/src/com/android/browser/DownloadHandler.java
+++ b/src/com/android/browser/DownloadHandler.java
@@ -285,8 +285,6 @@
String url, String userAgent, String contentDisposition,
String mimetype, String referer, boolean privateBrowsing, long contentLength) {
- initStorageDefaultPath(activity);
-
contentDisposition = trimContentDisposition(contentDisposition);
String filename = URLUtil.guessFileName(url,
@@ -372,6 +370,11 @@
fileInfo.putBoolean("privateBrowsing", privateBrowsing);
fileInfo.putString("filename", filename);
Intent intent = new Intent("android.intent.action.BROWSERDOWNLOAD");
+
+ // Since there could be multiple browsers capable of handling
+ // the same intent we assure that the same package handles it
+ intent.setPackage(activity.getPackageName());
+
intent.putExtras(fileInfo);
activity.startActivity(intent);
}
@@ -485,6 +488,12 @@
return false;
}
+ // assure that internal storage is initialized before
+ // comparing it with download path
+ if (mInternalStorage == null) {
+ initStorageDefaultPath(activity);
+ }
+
if (!(isPhoneStorageSupported() && downloadPath.contains(mInternalStorage))) {
String status = getExternalStorageState(activity);
if (!status.equals(Environment.MEDIA_MOUNTED)) {