use of android.app.SearchManager in project android_frameworks_base by crdroidandroid.
the class SearchManagerTest method testStopSearchIdempotent.
/**
* Tests that stopSearch() can be called when the search UI is not visible and can be
* called multiple times without startSearch() in between.
*/
public void testStopSearchIdempotent() throws Exception {
SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
assertNotNull(searchManager);
searchManager.stopSearch();
searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.stopSearch();
}
use of android.app.SearchManager in project android_frameworks_base by crdroidandroid.
the class SearchManagerTest method testStartSearchIdempotent.
/**
* Tests that startSearch() can be called multiple times without stopSearch()
* in between.
*/
public void testStartSearchIdempotent() throws Exception {
SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
assertNotNull(searchManager);
searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
}
use of android.app.SearchManager in project android_frameworks_base by AOSPA.
the class AssistUtils method getAssistComponentForUser.
public ComponentName getAssistComponentForUser(int userId) {
final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), Settings.Secure.ASSISTANT, userId);
if (setting != null) {
return ComponentName.unflattenFromString(setting);
}
// Fallback to keep backward compatible behavior when there is no user setting.
if (activeServiceSupportsAssistGesture()) {
return getActiveServiceComponentName();
}
Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(false);
PackageManager pm = mContext.getPackageManager();
ResolveInfo info = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, userId);
if (info != null) {
return new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name);
}
return null;
}
use of android.app.SearchManager in project android_frameworks_base by AOSPA.
the class PhoneWindow method launchDefaultSearch.
/**
* Helper method for adding launch-search to most applications. Opens the
* search window using default settings.
*
* @return true if search window opened
*/
private boolean launchDefaultSearch(KeyEvent event) {
boolean result;
final Callback cb = getCallback();
if (cb == null || isDestroyed()) {
result = false;
} else {
sendCloseSystemWindows("search");
int deviceId = event.getDeviceId();
SearchEvent searchEvent = null;
if (deviceId != 0) {
searchEvent = new SearchEvent(InputDevice.getDevice(deviceId));
}
try {
result = cb.onSearchRequested(searchEvent);
} catch (AbstractMethodError e) {
Log.e(TAG, "WindowCallback " + cb.getClass().getName() + " does not implement" + " method onSearchRequested(SearchEvent); fa", e);
result = cb.onSearchRequested();
}
}
if (!result && (getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) {
// On TVs, if the app doesn't implement search, we want to launch assist.
Bundle args = new Bundle();
args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, event.getDeviceId());
return ((SearchManager) getContext().getSystemService(Context.SEARCH_SERVICE)).launchLegacyAssist(null, UserHandle.myUserId(), args);
}
return result;
}
use of android.app.SearchManager in project android_frameworks_base by AOSPA.
the class AssistManager method startAssistActivity.
private void startAssistActivity(Bundle args, @NonNull ComponentName assistComponent) {
if (!mBar.isDeviceProvisioned()) {
return;
}
// Close Recent Apps if needed
mBar.animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL | CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL);
boolean structureEnabled = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1, UserHandle.USER_CURRENT) != 0;
final Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(structureEnabled);
if (intent == null) {
return;
}
intent.setComponent(assistComponent);
intent.putExtras(args);
if (structureEnabled) {
showDisclosure();
}
try {
final ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, R.anim.search_launch_enter, R.anim.search_launch_exit);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
AsyncTask.execute(new Runnable() {
@Override
public void run() {
mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(UserHandle.USER_CURRENT));
}
});
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Activity not found for " + intent.getAction());
}
}
Aggregations