From 6cca1599f78549716ef120245e54fa1961976dda Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Sun, 20 Sep 2009 12:40:03 -0700 Subject: [PATCH] Fix issue #1862317: Browser does not appear to honor anchors (#es) in links Also a little improved debugging output of bad resource identifiers. Change-Id: I054064ef22855608ffd722e4ccf12ce57d1992b2 --- core/java/android/content/Intent.java | 21 ++++++++++++++++----- libs/utils/ResourceTypes.cpp | 12 ++++++++++-- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index c1b9f28d3b8ec..7366b8bff41c2 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -2531,6 +2531,7 @@ public class Intent implements Parcelable { * * @param uri The URI to turn into an Intent. * @param flags Additional processing flags. Either 0 or + * {@link #URI_INTENT_SCHEME}. * * @return Intent The newly created Intent object. * @@ -2664,24 +2665,24 @@ public class Intent implements Parcelable { int i = uri.lastIndexOf('#'); if (i >= 0) { - Uri data = null; String action = null; - if (i > 0) { - data = Uri.parse(uri.substring(0, i)); - } + final int intentFragmentStart = i; + boolean isIntentFragment = false; i++; if (uri.regionMatches(i, "action(", 0, 7)) { + isIntentFragment = true; i += 7; int j = uri.indexOf(')', i); action = uri.substring(i, j); i = j + 1; } - intent = new Intent(action, data); + intent = new Intent(action); if (uri.regionMatches(i, "categories(", 0, 11)) { + isIntentFragment = true; i += 11; int j = uri.indexOf(')', i); while (i < j) { @@ -2696,6 +2697,7 @@ public class Intent implements Parcelable { } if (uri.regionMatches(i, "type(", 0, 5)) { + isIntentFragment = true; i += 5; int j = uri.indexOf(')', i); intent.mType = uri.substring(i, j); @@ -2703,6 +2705,7 @@ public class Intent implements Parcelable { } if (uri.regionMatches(i, "launchFlags(", 0, 12)) { + isIntentFragment = true; i += 12; int j = uri.indexOf(')', i); intent.mFlags = Integer.decode(uri.substring(i, j)).intValue(); @@ -2710,6 +2713,7 @@ public class Intent implements Parcelable { } if (uri.regionMatches(i, "component(", 0, 10)) { + isIntentFragment = true; i += 10; int j = uri.indexOf(')', i); int sep = uri.indexOf('!', i); @@ -2722,6 +2726,7 @@ public class Intent implements Parcelable { } if (uri.regionMatches(i, "extras(", 0, 7)) { + isIntentFragment = true; i += 7; final int closeParen = uri.indexOf(')', i); @@ -2793,6 +2798,12 @@ public class Intent implements Parcelable { } } + if (isIntentFragment) { + intent.mData = Uri.parse(uri.substring(0, intentFragmentStart)); + } else { + intent.mData = Uri.parse(uri); + } + if (intent.mAction == null) { // By default, if no action is specified, then use VIEW. intent.mAction = ACTION_VIEW; diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp index f80843d8dc9e8..a5a8cc953e61c 100644 --- a/libs/utils/ResourceTypes.cpp +++ b/libs/utils/ResourceTypes.cpp @@ -1740,7 +1740,11 @@ bool ResTable::getResourceName(uint32_t resID, resource_name* outName) const const int e = Res_GETENTRY(resID); if (p < 0) { - LOGW("No package identifier when getting name for resource number 0x%08x", resID); + if (Res_GETPACKAGE(resID)+1 == 0) { + LOGW("No package identifier when getting name for resource number 0x%08x", resID); + } else { + LOGW("Resources don't contain pacakge for resource number 0x%08x", resID); + } return false; } if (t < 0) { @@ -1786,7 +1790,11 @@ ssize_t ResTable::getResource(uint32_t resID, Res_value* outValue, bool mayBeBag const int e = Res_GETENTRY(resID); if (p < 0) { - LOGW("No package identifier when getting value for resource number 0x%08x", resID); + if (Res_GETPACKAGE(resID)+1 == 0) { + LOGW("No package identifier when getting name for resource number 0x%08x", resID); + } else { + LOGW("Resources don't contain pacakge for resource number 0x%08x", resID); + } return BAD_INDEX; } if (t < 0) {