Pass along our package name as the app id if one is not passed in for
web search intents.
Fixes http://b/2020191
diff --git a/src/com/android/websearch/WebSearch.java b/src/com/android/websearch/WebSearch.java
index 6b97681..04391ed 100644
--- a/src/com/android/websearch/WebSearch.java
+++ b/src/com/android/websearch/WebSearch.java
@@ -49,8 +49,12 @@
if (engine != null) {
// The browser can pass along an application id which it uses to figure out which
// window to place a new search into. So if this exists, we'll pass it back to
- // the browser.
+ // the browser. Otherwise, add our own package name as the application id, so that
+ // the browser can organize all searches launched from this provider together.
String applicationId = intent.getStringExtra(Browser.EXTRA_APPLICATION_ID);
+ if (applicationId == null) {
+ applicationId = getPackageName();
+ }
// Format the URI to launch and open it in the browser.
String query = intent.getStringExtra(SearchManager.QUERY);
@@ -60,9 +64,7 @@
+ intent.getComponent());
} else {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(launchUri));
- if (applicationId != null) {
- intent.putExtra(Browser.EXTRA_APPLICATION_ID, applicationId);
- }
+ intent.putExtra(Browser.EXTRA_APPLICATION_ID, applicationId);
startActivity(intent);
}
}