Merge "Invoking Assistant on keydown"
This commit is contained in:
committed by
Android (Google) Code Review
commit
040f7da5bc
@@ -630,7 +630,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
private static final int MSG_SYSTEM_KEY_PRESS = 21;
|
private static final int MSG_SYSTEM_KEY_PRESS = 21;
|
||||||
private static final int MSG_HANDLE_ALL_APPS = 22;
|
private static final int MSG_HANDLE_ALL_APPS = 22;
|
||||||
private static final int MSG_LAUNCH_ASSIST = 23;
|
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_POWER_VERY_LONG_PRESS = 25;
|
||||||
private static final int MSG_RINGER_TOGGLE_CHORD = 26;
|
private static final int MSG_RINGER_TOGGLE_CHORD = 26;
|
||||||
|
|
||||||
@@ -670,9 +669,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
final String hint = (String) msg.obj;
|
final String hint = (String) msg.obj;
|
||||||
launchAssistAction(hint, deviceId);
|
launchAssistAction(hint, deviceId);
|
||||||
break;
|
break;
|
||||||
case MSG_LAUNCH_ASSIST_LONG_PRESS:
|
|
||||||
launchAssistLongPressAction();
|
|
||||||
break;
|
|
||||||
case MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK:
|
case MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK:
|
||||||
launchVoiceAssistWithWakeLock();
|
launchVoiceAssistWithWakeLock();
|
||||||
break;
|
break;
|
||||||
@@ -3258,28 +3254,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
// There are several different flavors of "assistant" that can be launched from
|
// There are several different flavors of "assistant" that can be launched from
|
||||||
// various parts of the UI.
|
// 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 */
|
/** Asks the status bar to startAssist(), usually a full "assistant" interface */
|
||||||
private void launchAssistAction(String hint, int deviceId) {
|
private void launchAssistAction(String hint, int deviceId) {
|
||||||
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
|
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
|
||||||
@@ -3967,12 +3941,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
|||||||
}
|
}
|
||||||
case KeyEvent.KEYCODE_ASSIST: {
|
case KeyEvent.KEYCODE_ASSIST: {
|
||||||
final boolean longPressed = event.getRepeatCount() > 0;
|
final boolean longPressed = event.getRepeatCount() > 0;
|
||||||
if (down && longPressed) {
|
if (down && !longPressed) {
|
||||||
Message msg = mHandler.obtainMessage(MSG_LAUNCH_ASSIST_LONG_PRESS);
|
|
||||||
msg.setAsynchronous(true);
|
|
||||||
msg.sendToTarget();
|
|
||||||
}
|
|
||||||
if (!down && !longPressed) {
|
|
||||||
Message msg = mHandler.obtainMessage(MSG_LAUNCH_ASSIST, event.getDeviceId(),
|
Message msg = mHandler.obtainMessage(MSG_LAUNCH_ASSIST, event.getDeviceId(),
|
||||||
0 /* unused */, null /* hint */);
|
0 /* unused */, null /* hint */);
|
||||||
msg.setAsynchronous(true);
|
msg.setAsynchronous(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user