diff options
author | Jorim Jaggi <jjaggi@google.com> | 2015-07-06 16:18:11 -0700 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2015-07-08 22:26:24 +0000 |
commit | 165ce066b701ba0153000f0692bfc7032655d17d (patch) | |
tree | f557490ccff7c7dd1787fedd40540d6ccd35d5a3 /packages/SystemUI/src/com/android/systemui | |
parent | 588932a53e63c0a7ee281dea22559c129b40eb99 (diff) | |
download | frameworks_base-165ce066b701ba0153000f0692bfc7032655d17d.zip frameworks_base-165ce066b701ba0153000f0692bfc7032655d17d.tar.gz frameworks_base-165ce066b701ba0153000f0692bfc7032655d17d.tar.bz2 |
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
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui')
5 files changed, 43 insertions, 32 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java index 51d0bf1..0daa5c9 100644 --- a/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java +++ b/packages/SystemUI/src/com/android/systemui/assist/AssistManager.java @@ -30,6 +30,7 @@ import android.widget.ImageView; import com.android.internal.app.AssistUtils; import com.android.internal.app.IVoiceInteractionSessionShowCallback; import com.android.systemui.R; +import com.android.systemui.statusbar.BaseStatusBar; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.phone.PhoneStatusBar; @@ -45,11 +46,6 @@ public class AssistManager { private static final String ASSIST_ICON_METADATA_NAME = "com.android.systemui.action_assist_icon"; - private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() - .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) - .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) - .build(); - private static final long TIMEOUT_SERVICE = 2500; private static final long TIMEOUT_ACTIVITY = 1000; @@ -58,7 +54,7 @@ public class AssistManager { private final AssistDisclosure mAssistDisclosure; private AssistOrbContainer mView; - private final PhoneStatusBar mBar; + private final BaseStatusBar mBar; private final AssistUtils mAssistUtils; private ComponentName mAssistComponent; @@ -92,7 +88,7 @@ public class AssistManager { } }; - public AssistManager(PhoneStatusBar bar, Context context) { + public AssistManager(BaseStatusBar bar, Context context) { mContext = context; mBar = bar; mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); @@ -125,7 +121,8 @@ public class AssistManager { } } - public void onGestureInvoked() { + public void startAssist(Bundle args) { + updateAssistInfo(); if (mAssistComponent == null) { return; } @@ -137,7 +134,7 @@ public class AssistManager { ? TIMEOUT_SERVICE : TIMEOUT_ACTIVITY); } - startAssist(); + startAssistInternal(args); } public void hideAssist() { @@ -168,17 +165,17 @@ public class AssistManager { mView.show(true /* show */, true /* animate */); } - private void startAssist() { + private void startAssistInternal(Bundle args) { if (mAssistComponent != null) { if (isAssistantService()) { - startVoiceInteractor(); + startVoiceInteractor(args); } else { - startAssistActivity(); + startAssistActivity(args); } } } - private void startAssistActivity() { + private void startAssistActivity(Bundle args) { if (!mBar.isDeviceProvisioned()) { return; } @@ -191,13 +188,14 @@ public class AssistManager { Settings.Secure.ASSIST_STRUCTURE_ENABLED, 1, UserHandle.USER_CURRENT) != 0; final Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) - .getAssistIntent(mContext, structureEnabled, UserHandle.USER_CURRENT); + .getAssistIntent(structureEnabled); if (intent == null) { return; } if (mAssistComponent != null) { intent.setComponent(mAssistComponent); } + intent.putExtras(args); if (structureEnabled) { showDisclosure(); @@ -219,8 +217,8 @@ public class AssistManager { } } - private void startVoiceInteractor() { - mAssistUtils.showSessionForActiveService(mShowCallback); + private void startVoiceInteractor(Bundle args) { + mAssistUtils.showSessionForActiveService(args, mShowCallback); } public void launchVoiceAssistFromKeyguard() { @@ -304,8 +302,4 @@ public class AssistManager { public void onUserSwitched(int newUserId) { updateAssistInfo(); } - - public void prepareBeforeInvocation() { - updateAssistInfo(); - } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java index b60c66f..17db471 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java +++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java @@ -52,6 +52,7 @@ import android.os.ParcelFileDescriptor; import android.os.RemoteException; import android.os.SystemProperties; import android.os.UserHandle; +import android.os.UserManager; import android.provider.Settings; import android.util.Log; import android.util.MutableBoolean; @@ -62,6 +63,8 @@ import android.view.DisplayInfo; import android.view.SurfaceControl; import android.view.WindowManager; import android.view.accessibility.AccessibilityManager; + +import com.android.internal.app.AssistUtils; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.recents.Constants; @@ -89,7 +92,7 @@ public class SystemServicesProxy { AppWidgetManager mAwm; PackageManager mPm; IPackageManager mIpm; - SearchManager mSm; + AssistUtils mAssistUtils; WindowManager mWm; Display mDisplay; String mRecentsPackage; @@ -114,7 +117,7 @@ public class SystemServicesProxy { mAwm = AppWidgetManager.getInstance(context); mPm = context.getPackageManager(); mIpm = AppGlobals.getPackageManager(); - mSm = (SearchManager) context.getSystemService(Context.SEARCH_SERVICE); + mAssistUtils = new AssistUtils(context); mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); mDisplay = mWm.getDefaultDisplay(); mRecentsPackage = context.getPackageName(); @@ -133,10 +136,7 @@ public class SystemServicesProxy { mBgProtectionCanvas = new Canvas(); // Resolve the assist intent - Intent assist = mSm.getAssistIntent(context, false); - if (assist != null) { - mAssistComponent = assist.getComponent(); - } + mAssistComponent = mAssistUtils.getAssistComponentForUser(UserHandle.myUserId()); if (Constants.DebugFlags.App.EnableSystemServicesProxy) { // Create a dummy icon @@ -580,6 +580,7 @@ public class SystemServicesProxy { * Returns the first Recents widget from the same package as the global assist activity. */ private AppWidgetProviderInfo resolveSearchAppWidget() { + if (mAssistComponent == null) return null; List<AppWidgetProviderInfo> widgets = mAwm.getInstalledProviders( AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX); for (AppWidgetProviderInfo info : widgets) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 6ad0ef9..f62dc59 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -41,9 +41,9 @@ import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; -import android.graphics.drawable.Icon; import android.os.AsyncTask; import android.os.Build; +import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; @@ -65,7 +65,6 @@ import android.util.Slog; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.view.Display; -import android.view.Gravity; import android.view.IWindowManager; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -2125,4 +2124,11 @@ public abstract class BaseStatusBar extends SystemUI implements mAssistManager.showDisclosure(); } } + + @Override + public void startAssist(Bundle args) { + if (mAssistManager != null) { + mAssistManager.startAssist(args); + } + } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java index 0deff08..a1b07b5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java @@ -16,6 +16,7 @@ package com.android.systemui.statusbar; +import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; @@ -62,6 +63,7 @@ public class CommandQueue extends IStatusBar.Stub { private static final int MSG_APP_TRANSITION_CANCELLED = 20 << MSG_SHIFT; private static final int MSG_APP_TRANSITION_STARTING = 21 << MSG_SHIFT; private static final int MSG_ASSIST_DISCLOSURE = 22 << MSG_SHIFT; + private static final int MSG_START_ASSIST = 23 << MSG_SHIFT; public static final int FLAG_EXCLUDE_NONE = 0; public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0; @@ -106,6 +108,7 @@ public class CommandQueue extends IStatusBar.Stub { public void appTransitionCancelled(); public void appTransitionStarting(long startTime, long duration); public void showAssistDisclosure(); + public void startAssist(Bundle args); } public CommandQueue(Callbacks callbacks, StatusBarIconList list) { @@ -283,6 +286,13 @@ public class CommandQueue extends IStatusBar.Stub { } } + public void startAssist(Bundle args) { + synchronized (mList) { + mHandler.removeMessages(MSG_START_ASSIST); + mHandler.obtainMessage(MSG_START_ASSIST, args).sendToTarget(); + } + } + private final class H extends Handler { public void handleMessage(Message msg) { final int what = msg.what & MSG_MASK; @@ -378,6 +388,9 @@ public class CommandQueue extends IStatusBar.Stub { case MSG_ASSIST_DISCLOSURE: mCallbacks.showAssistDisclosure(); break; + case MSG_START_ASSIST: + mCallbacks.startAssist((Bundle) msg.obj); + break; } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 20f4dc7..c481be1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -81,7 +81,6 @@ import android.view.MotionEvent; import android.view.ThreadedRenderer; import android.view.VelocityTracker; import android.view.View; -import android.view.ViewConfiguration; import android.view.ViewGroup.LayoutParams; import android.view.ViewStub; import android.view.WindowManager; @@ -106,7 +105,6 @@ import com.android.systemui.EventLogConstants; import com.android.systemui.EventLogTags; import com.android.systemui.Prefs; import com.android.systemui.R; -import com.android.systemui.SwipeHelper; import com.android.systemui.assist.AssistManager; import com.android.systemui.doze.DozeHost; import com.android.systemui.doze.DozeLog; @@ -1045,8 +1043,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, if (shouldDisableNavbarGestures()) { return false; } - mAssistManager.prepareBeforeInvocation(); - mAssistManager.onGestureInvoked(); + mAssistManager.startAssist(new Bundle() /* args */); awakenDreams(); if (mNavigationBarView != null) { mNavigationBarView.abortCurrentGesture(); |