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
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 3393d7d..87efb8d 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -3048,14 +3048,6 @@
}
}
- private void launchAssistAction() {
- launchAssistAction(null, Integer.MIN_VALUE);
- }
-
- private void launchAssistAction(String hint) {
- launchAssistAction(hint, Integer.MIN_VALUE);
- }
-
private void launchAssistAction(String hint, int deviceId) {
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
Bundle args = null;
@@ -3063,8 +3055,29 @@
args = new Bundle();
args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, deviceId);
}
- ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
- .launchAssistAction(hint, UserHandle.myUserId(), args);
+ if ((mContext.getResources().getConfiguration().uiMode
+ & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) {
+ // On TV, use legacy handling until assistants are implemented in the proper way.
+ ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
+ .launchLegacyAssist(hint, UserHandle.myUserId(), args);
+ } else {
+ try {
+ if (hint != null) {
+ if (args == null) {
+ args = new Bundle();
+ }
+ args.putBoolean(hint, true);
+ }
+ IStatusBarService statusbar = getStatusBarService();
+ if (statusbar != null) {
+ statusbar.startAssist(args);
+ }
+ } catch (RemoteException e) {
+ Slog.e(TAG, "RemoteException when starting assist", e);
+ // re-acquire status bar service next time it is needed.
+ mStatusBarService = null;
+ }
+ }
}
private void startActivityAsUser(Intent intent, UserHandle handle) {