From 165ce066b701ba0153000f0692bfc7032655d17d Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Mon, 6 Jul 2015 16:18:11 -0700 Subject: Fix assist for hardware long-press Activating the assistant will now route through SysUI, so we have the logic whether to start an activity or to start a voice interaction session in one single place. Bug: 22201770 Change-Id: I0f4699533aea2a1e595ee25a844434c82f548c01 --- core/java/android/app/SearchManager.java | 49 +++++++++++++++++--------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'core/java/android/app/SearchManager.java') diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java index 45799a1..9e32164 100644 --- a/core/java/android/app/SearchManager.java +++ b/core/java/android/app/SearchManager.java @@ -946,27 +946,9 @@ public class SearchManager * * @hide */ - public Intent getAssistIntent(Context context, boolean inclContext) { - return getAssistIntent(context, inclContext, UserHandle.myUserId()); - } - - /** - * Gets an intent for launching installed assistant activity, or null if not available. - * @return The assist intent. - * - * @hide - */ - public Intent getAssistIntent(Context context, boolean inclContext, int userHandle) { + public Intent getAssistIntent(boolean inclContext) { try { - if (mService == null) { - return null; - } - ComponentName comp = mService.getAssistIntent(userHandle); - if (comp == null) { - return null; - } Intent intent = new Intent(Intent.ACTION_ASSIST); - intent.setComponent(comp); if (inclContext) { IActivityManager am = ActivityManagerNative.getDefault(); Bundle extras = am.getAssistContextExtras(ActivityManager.ASSIST_CONTEXT_BASIC); @@ -982,17 +964,38 @@ public class SearchManager } /** - * Launch an assist action for the current top activity. + * Starts the assistant. + * + * @param args the args to pass to the assistant + * + * @hide + */ + public void launchAssist(Bundle args) { + try { + if (mService == null) { + return; + } + mService.launchAssist(args); + } catch (RemoteException re) { + Log.e(TAG, "launchAssist() failed: " + re); + } + } + + /** + * Starts the legacy assistant (i.e. the {@link Intent#ACTION_ASSIST}). + * + * @param args the args to pass to the assistant + * * @hide */ - public boolean launchAssistAction(String hint, int userHandle, Bundle args) { + public boolean launchLegacyAssist(String hint, int userHandle, Bundle args) { try { if (mService == null) { return false; } - return mService.launchAssistAction(hint, userHandle, args); + return mService.launchLegacyAssist(hint, userHandle, args); } catch (RemoteException re) { - Log.e(TAG, "launchAssistAction() failed: " + re); + Log.e(TAG, "launchAssist() failed: " + re); return false; } } -- cgit v1.1