Fix IntentHandler behavior
Bug: 4473779
Plus, TESTS! Huzzah!
Change-Id: I043e100d99d4653b7fb7885217d7fb305930a137
diff --git a/src/com/android/browser/BookmarkUtils.java b/src/com/android/browser/BookmarkUtils.java
index 491c16c..23765f4 100644
--- a/src/com/android/browser/BookmarkUtils.java
+++ b/src/com/android/browser/BookmarkUtils.java
@@ -115,10 +115,7 @@
static Intent createAddToHomeIntent(Context context, String url, String title,
Bitmap touchIcon, Bitmap favicon) {
Intent i = new Intent(INSTALL_SHORTCUT);
- Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- long urlHash = url.hashCode();
- long uniqueId = (urlHash << 32) | shortcutIntent.hashCode();
- shortcutIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId));
+ Intent shortcutIntent = createShortcutIntent(url);
i.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
i.putExtra(Intent.EXTRA_SHORTCUT_NAME, title);
i.putExtra(Intent.EXTRA_SHORTCUT_ICON, createIcon(context, touchIcon, favicon,
@@ -129,6 +126,14 @@
return i;
}
+ static Intent createShortcutIntent(String url) {
+ Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
+ long urlHash = url.hashCode();
+ long uniqueId = (urlHash << 32) | shortcutIntent.hashCode();
+ shortcutIntent.putExtra(Browser.EXTRA_APPLICATION_ID, Long.toString(uniqueId));
+ return shortcutIntent;
+ }
+
private static Bitmap getIconBackground(Context context, BookmarkIconType type, int density) {
if (type == BookmarkIconType.ICON_HOME_SHORTCUT) {
// Want to create a shortcut icon on the homescreen, so the icon