From bc7cb1e861db77a012ae306802c999ed9bf6cc8b Mon Sep 17 00:00:00 2001 From: Madhava Srinivasan Date: Thu, 29 Oct 2020 21:47:58 +0000 Subject: [PATCH] Invoking Assistant on keydown This change alters the behavior of when Assistant is launched on TV. Also, removed the "long press" assist behavior and associated logic. Bug: 117490624 Bug: 134613904 Test: make; ADT-3 Change-Id: I23a9c8f1b440b095b6afeeac2314bc9ecd329400 --- .../server/policy/PhoneWindowManager.java | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 8b677a99b22ae..7d76c4ce98086 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -630,7 +630,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { private static final int MSG_SYSTEM_KEY_PRESS = 21; private static final int MSG_HANDLE_ALL_APPS = 22; private static final int MSG_LAUNCH_ASSIST = 23; - private static final int MSG_LAUNCH_ASSIST_LONG_PRESS = 24; private static final int MSG_POWER_VERY_LONG_PRESS = 25; private static final int MSG_RINGER_TOGGLE_CHORD = 26; @@ -670,9 +669,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { final String hint = (String) msg.obj; launchAssistAction(hint, deviceId); break; - case MSG_LAUNCH_ASSIST_LONG_PRESS: - launchAssistLongPressAction(); - break; case MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK: launchVoiceAssistWithWakeLock(); break; @@ -3249,28 +3245,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { // There are several different flavors of "assistant" that can be launched from // various parts of the UI. - /** starts ACTION_SEARCH_LONG_PRESS, usually a voice search prompt */ - private void launchAssistLongPressAction() { - performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, false, - "Assist - Long Press"); - sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); - - // launch the search activity - Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - try { - // TODO: This only stops the factory-installed search manager. - // Need to formalize an API to handle others - SearchManager searchManager = getSearchManager(); - if (searchManager != null) { - searchManager.stopSearch(); - } - startActivityAsUser(intent, UserHandle.CURRENT); - } catch (ActivityNotFoundException e) { - Slog.w(TAG, "No activity to handle assist long press action.", e); - } - } - /** Asks the status bar to startAssist(), usually a full "assistant" interface */ private void launchAssistAction(String hint, int deviceId) { sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); @@ -3958,12 +3932,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } case KeyEvent.KEYCODE_ASSIST: { final boolean longPressed = event.getRepeatCount() > 0; - if (down && longPressed) { - Message msg = mHandler.obtainMessage(MSG_LAUNCH_ASSIST_LONG_PRESS); - msg.setAsynchronous(true); - msg.sendToTarget(); - } - if (!down && !longPressed) { + if (down && !longPressed) { Message msg = mHandler.obtainMessage(MSG_LAUNCH_ASSIST, event.getDeviceId(), 0 /* unused */, null /* hint */); msg.setAsynchronous(true);