Skip to content

Commit 050453e

Browse files
committed
Allow setting of source bounds on global search intents.
This is to allow the launcher to include the source bounds of the search affordance on the homescreen when launching the global search app. Bug: 5235747 Change-Id: I7af1a651d593b6d946aa2fe42d900a9c4470b4e2
1 parent 7a3ba4d commit 050453e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

core/java/android/app/SearchManager.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.content.Intent;
2525
import android.content.pm.ResolveInfo;
2626
import android.database.Cursor;
27+
import android.graphics.Rect;
2728
import android.net.Uri;
2829
import android.os.Bundle;
2930
import android.os.Handler;
@@ -498,8 +499,24 @@ public void startSearch(String initialQuery,
498499
ComponentName launchActivity,
499500
Bundle appSearchData,
500501
boolean globalSearch) {
502+
startSearch(initialQuery, selectInitialQuery, launchActivity,
503+
appSearchData, globalSearch, null);
504+
}
505+
506+
/**
507+
* As {@link #startSearch(String, boolean, ComponentName, Bundle, boolean)} but including
508+
* source bounds for the global search intent.
509+
*
510+
* @hide
511+
*/
512+
public void startSearch(String initialQuery,
513+
boolean selectInitialQuery,
514+
ComponentName launchActivity,
515+
Bundle appSearchData,
516+
boolean globalSearch,
517+
Rect sourceBounds) {
501518
if (globalSearch) {
502-
startGlobalSearch(initialQuery, selectInitialQuery, appSearchData);
519+
startGlobalSearch(initialQuery, selectInitialQuery, appSearchData, sourceBounds);
503520
return;
504521
}
505522

@@ -520,7 +537,7 @@ private void ensureSearchDialog() {
520537
* Starts the global search activity.
521538
*/
522539
/* package */ void startGlobalSearch(String initialQuery, boolean selectInitialQuery,
523-
Bundle appSearchData) {
540+
Bundle appSearchData, Rect sourceBounds) {
524541
ComponentName globalSearchActivity = getGlobalSearchActivity();
525542
if (globalSearchActivity == null) {
526543
Log.w(TAG, "No global search activity found.");
@@ -546,6 +563,7 @@ private void ensureSearchDialog() {
546563
if (selectInitialQuery) {
547564
intent.putExtra(EXTRA_SELECT_QUERY, selectInitialQuery);
548565
}
566+
intent.setSourceBounds(sourceBounds);
549567
try {
550568
if (DBG) Log.d(TAG, "Starting global search: " + intent.toUri(0));
551569
mContext.startActivity(intent);

0 commit comments

Comments
 (0)