Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec0a12cf authored by Karl Rosaen's avatar Karl Rosaen
Browse files

Don't start search from a dialog if there is no activity associated with

the search manager at that point.

Still works:
- hitting search when a managed dialog of an app is showing will dismiss
  the dialog and start in-app search (if it supports it), falling back
  on global search
- hitting search when a dialog of an app (not managed by the activity) will
  dismiss the dialog and start global search
- hitting search when a system dialog is showing will just dismiss the dialog.
parent 841ed859
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -788,6 +788,11 @@ public class Dialog implements DialogInterface, Window.Callback,
        final SearchManager searchManager = (SearchManager) mContext
                .getSystemService(Context.SEARCH_SERVICE);

        // can't start search without an associated activity (e.g a system dialog)
        if (!searchManager.hasIdent()) {
            return false;
        }

        // associate search with owner activity if possible (otherwise it will default to
        // global search).
        final ComponentName appName = mOwnerActivity == null ? null
+4 −0
Original line number Diff line number Diff line
@@ -1537,6 +1537,10 @@ public class SearchManager
                ServiceManager.getService(Context.SEARCH_SERVICE));
    }

    /*package*/ boolean hasIdent() {
        return mIdent != 0;
    }
    
    /*package*/ void setIdent(int ident) {
        if (mIdent != 0) {
            throw new IllegalStateException("mIdent already set");