This commit is contained in:
@@ -21,9 +21,12 @@ import com.android.internal.content.PackageMonitor;
|
|||||||
import android.app.ISearchManager;
|
import android.app.ISearchManager;
|
||||||
import android.app.SearchManager;
|
import android.app.SearchManager;
|
||||||
import android.app.SearchableInfo;
|
import android.app.SearchableInfo;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.os.Process;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -51,17 +54,37 @@ public class SearchManagerService extends ISearchManager.Stub {
|
|||||||
*/
|
*/
|
||||||
public SearchManagerService(Context context) {
|
public SearchManagerService(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mContext.registerReceiver(new BootCompletedReceiver(),
|
||||||
|
new IntentFilter(Intent.ACTION_BOOT_COMPLETED));
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized Searchables getSearchables() {
|
private synchronized Searchables getSearchables() {
|
||||||
if (mSearchables == null) {
|
if (mSearchables == null) {
|
||||||
|
Log.i(TAG, "Building list of searchable activities");
|
||||||
|
new MyPackageMonitor().register(mContext, true);
|
||||||
mSearchables = new Searchables(mContext);
|
mSearchables = new Searchables(mContext);
|
||||||
mSearchables.buildSearchableList();
|
mSearchables.buildSearchableList();
|
||||||
new MyPackageMonitor().register(mContext, true);
|
|
||||||
}
|
}
|
||||||
return mSearchables;
|
return mSearchables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the initial searchables list after boot.
|
||||||
|
*/
|
||||||
|
private final class BootCompletedReceiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
|
||||||
|
mContext.unregisterReceiver(BootCompletedReceiver.this);
|
||||||
|
getSearchables();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes the "searchables" list when packages are added/removed.
|
* Refreshes the "searchables" list when packages are added/removed.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user