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

Commit e4ddb19a authored by Android (Google) Code Review's avatar Android (Google) Code Review Committed by The Android Open Source Project
Browse files

am efae672d: Merge change 725 into donut

Merge commit 'efae672d'

* commit 'efae672d':
  Add 'includeInGlobalSearch' attribute to searchable meta-data.
parents cb6c7248 efae672d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,4 +22,5 @@ import android.server.search.SearchableInfo;
/** @hide */
interface ISearchManager {
   SearchableInfo getSearchableInfo(in ComponentName launchActivity, boolean globalSearch);
   List<SearchableInfo> getSearchablesInGlobalSearch();
}
+18 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import android.os.ServiceManager;
import android.server.search.SearchableInfo;
import android.view.KeyEvent;

import java.util.List;

/**
 * This class provides access to the system search services.
 * 
@@ -1655,4 +1657,20 @@ public class SearchManager
        return context.getContentResolver().query(uri, null, selection, selArgs, null);
    }
     
    /**
     * Returns a list of the searchable activities that can be included in global search.
     * 
     * @return a list containing searchable information for all searchable activities
     *         that have the <code>exported</code> attribute set in their searchable
     *         meta-data.
     * 
     * @hide because SearchableInfo is not part of the API.
     */
    public static List<SearchableInfo> getSearchablesInGlobalSearch() {
        try {
            return sService.getSearchablesInGlobalSearch();
        } catch (RemoteException e) {
            return null;
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;

import java.util.List;

/**
 * This is a simplified version of the Search Manager service.  It no longer handles
 * presentation (UI).  Its function is to maintain the map & list of "searchable" 
@@ -144,4 +146,11 @@ public class SearchManagerService extends ISearchManager.Stub
        return si;
    }
    
    /**
     * Returns a list of the searchable activities that can be included in global search.
     */
    public List<SearchableInfo> getSearchablesInGlobalSearch() {
        return mSearchables.getSearchablesInGlobalSearchList();
    }

}
+15 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ public final class SearchableInfo implements Parcelable {
    private int mSearchButtonText = 0;
    private int mSearchInputType = 0;
    private int mSearchImeOptions = 0;
    private boolean mIncludeInGlobalSearch = false;
    private String mSuggestAuthority = null;
    private String mSuggestPath = null;
    private String mSuggestSelection = null;
@@ -236,6 +237,8 @@ public final class SearchableInfo implements Parcelable {
                InputType.TYPE_TEXT_VARIATION_NORMAL);
        mSearchImeOptions = a.getInt(com.android.internal.R.styleable.Searchable_imeOptions, 
                EditorInfo.IME_ACTION_SEARCH);
        mIncludeInGlobalSearch = a.getBoolean(
                com.android.internal.R.styleable.Searchable_includeInGlobalSearch, false);

        setSearchModeFlags();
        if (DBG_INHIBIT_SUGGESTIONS == 0) {
@@ -575,6 +578,16 @@ public final class SearchableInfo implements Parcelable {
        return mSearchImeOptions;
    }
    
    /**
     * Checks whether the searchable is exported.
     *
     * @return The value of the <code>exported</code> attribute,
     *         or <code>false</code> if the attribute is not set.
     */
    public boolean shouldIncludeInGlobalSearch() {
        return mIncludeInGlobalSearch;
    }

    /**
     * Support for parcelable and aidl operations.
     */
@@ -606,6 +619,7 @@ public final class SearchableInfo implements Parcelable {
        mSearchButtonText = in.readInt();
        mSearchInputType = in.readInt();
        mSearchImeOptions = in.readInt();
        mIncludeInGlobalSearch = in.readInt() != 0;
        setSearchModeFlags();

        mSuggestAuthority = in.readString();
@@ -644,6 +658,7 @@ public final class SearchableInfo implements Parcelable {
        dest.writeInt(mSearchButtonText);
        dest.writeInt(mSearchInputType);
        dest.writeInt(mSearchImeOptions);
        dest.writeInt(mIncludeInGlobalSearch ? 1 : 0);
        
        dest.writeString(mSuggestAuthority);
        dest.writeString(mSuggestPath);
+15 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class Searchables {
    
    private HashMap<ComponentName, SearchableInfo> mSearchablesMap = null;
    private ArrayList<SearchableInfo> mSearchablesList = null;
    private ArrayList<SearchableInfo> mSearchablesInGlobalSearchList = null;
    private SearchableInfo mDefaultSearchable = null;
    
    /**
@@ -189,6 +190,8 @@ public class Searchables {
                                = new HashMap<ComponentName, SearchableInfo>();
        ArrayList<SearchableInfo> newSearchablesList
                                = new ArrayList<SearchableInfo>();
        ArrayList<SearchableInfo> newSearchablesInGlobalSearchList
                                = new ArrayList<SearchableInfo>();

        final PackageManager pm = mContext.getPackageManager();
        
@@ -208,6 +211,9 @@ public class Searchables {
                if (searchable != null) {
                    newSearchablesList.add(searchable);
                    newSearchablesMap.put(searchable.mSearchActivity, searchable);
                    if (searchable.shouldIncludeInGlobalSearch()) {
                        newSearchablesInGlobalSearchList.add(searchable);
                    }
                }
            }
        }
@@ -219,8 +225,9 @@ public class Searchables {

        // Store a consistent set of new values
        synchronized (this) {
            mSearchablesList = newSearchablesList;
            mSearchablesMap = newSearchablesMap;
            mSearchablesList = newSearchablesList;
            mSearchablesInGlobalSearchList = newSearchablesInGlobalSearchList;
            mDefaultSearchable = newDefaultSearchable;
        }
    }
@@ -232,4 +239,11 @@ public class Searchables {
        ArrayList<SearchableInfo> result = new ArrayList<SearchableInfo>(mSearchablesList);
        return result;
    }
    
    /**
     * Returns a list of the searchable activities that can be included in global search.
     */
    public synchronized ArrayList<SearchableInfo> getSearchablesInGlobalSearchList() {
        return new ArrayList<SearchableInfo>(mSearchablesInGlobalSearchList);
    }
}
Loading