diff options
author | Tim Kilbourn <tkilbourn@google.com> | 2015-06-08 16:46:40 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-08 16:46:42 +0000 |
commit | 159f558a39d200e08e06245d64ec1df9a08e7d93 (patch) | |
tree | 3bc7299e40c9c153df85768871a37e425afd59dc | |
parent | 20ac61b8c0abd5af4ce32707e01cc1a501cbb7f0 (diff) | |
parent | 0e5f110fc915a9b044eb04cd07ae7ac588eacc8f (diff) | |
download | frameworks_base-159f558a39d200e08e06245d64ec1df9a08e7d93.zip frameworks_base-159f558a39d200e08e06245d64ec1df9a08e7d93.tar.gz frameworks_base-159f558a39d200e08e06245d64ec1df9a08e7d93.tar.bz2 |
Merge "Pass an args bundle to launchAssistAction." into mnc-dev
-rw-r--r-- | api/current.txt | 1 | ||||
-rw-r--r-- | api/system-current.txt | 1 | ||||
-rw-r--r-- | core/java/android/app/ActivityManagerNative.java | 8 | ||||
-rw-r--r-- | core/java/android/app/IActivityManager.java | 4 | ||||
-rw-r--r-- | core/java/android/app/ISearchManager.aidl | 2 | ||||
-rw-r--r-- | core/java/android/app/SearchManager.java | 4 | ||||
-rw-r--r-- | core/java/android/content/Intent.java | 7 | ||||
-rw-r--r-- | core/java/com/android/internal/policy/PhoneWindow.java | 5 | ||||
-rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 14 | ||||
-rw-r--r-- | services/core/java/com/android/server/policy/PhoneWindowManager.java | 36 | ||||
-rw-r--r-- | services/core/java/com/android/server/search/SearchManagerService.java | 5 |
11 files changed, 51 insertions, 36 deletions
diff --git a/api/current.txt b/api/current.txt index 2e37960..e61253e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -8288,6 +8288,7 @@ package android.content { field public static final deprecated java.lang.String EXTRA_ALLOW_REPLACE = "android.intent.extra.ALLOW_REPLACE"; field public static final java.lang.String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; field public static final java.lang.String EXTRA_ASSIST_CONTEXT = "android.intent.extra.ASSIST_CONTEXT"; + field public static final java.lang.String EXTRA_ASSIST_INPUT_DEVICE_ID = "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; field public static final java.lang.String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; field public static final java.lang.String EXTRA_ASSIST_PACKAGE = "android.intent.extra.ASSIST_PACKAGE"; field public static final java.lang.String EXTRA_ASSIST_UID = "android.intent.extra.ASSIST_UID"; diff --git a/api/system-current.txt b/api/system-current.txt index 7d3da37..8c9ed2e 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -8520,6 +8520,7 @@ package android.content { field public static final deprecated java.lang.String EXTRA_ALLOW_REPLACE = "android.intent.extra.ALLOW_REPLACE"; field public static final java.lang.String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS"; field public static final java.lang.String EXTRA_ASSIST_CONTEXT = "android.intent.extra.ASSIST_CONTEXT"; + field public static final java.lang.String EXTRA_ASSIST_INPUT_DEVICE_ID = "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; field public static final java.lang.String EXTRA_ASSIST_INPUT_HINT_KEYBOARD = "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; field public static final java.lang.String EXTRA_ASSIST_PACKAGE = "android.intent.extra.ASSIST_PACKAGE"; field public static final java.lang.String EXTRA_ASSIST_UID = "android.intent.extra.ASSIST_UID"; diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index 44e47f8..bb553e4 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -2208,7 +2208,8 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM int requestType = data.readInt(); String hint = data.readString(); int userHandle = data.readInt(); - boolean res = launchAssistIntent(intent, requestType, hint, userHandle); + Bundle args = data.readBundle(); + boolean res = launchAssistIntent(intent, requestType, hint, userHandle, args); reply.writeNoException(); reply.writeInt(res ? 1 : 0); return true; @@ -5389,8 +5390,8 @@ class ActivityManagerProxy implements IActivityManager reply.recycle(); } - public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle) - throws RemoteException { + public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle, + Bundle args) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); @@ -5398,6 +5399,7 @@ class ActivityManagerProxy implements IActivityManager data.writeInt(requestType); data.writeString(hint); data.writeInt(userHandle); + data.writeBundle(args); mRemote.transact(LAUNCH_ASSIST_INTENT_TRANSACTION, data, reply, 0); reply.readException(); boolean res = reply.readInt() != 0; diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index 2430ccd..e87eabe 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -438,8 +438,8 @@ public interface IActivityManager extends IInterface { public void reportAssistContextExtras(IBinder token, Bundle extras, AssistStructure structure, AssistContent content) throws RemoteException; - public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle) - throws RemoteException; + public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle, + Bundle args) throws RemoteException; public void killUid(int uid, String reason) throws RemoteException; diff --git a/core/java/android/app/ISearchManager.aidl b/core/java/android/app/ISearchManager.aidl index 6d27910..6094012 100644 --- a/core/java/android/app/ISearchManager.aidl +++ b/core/java/android/app/ISearchManager.aidl @@ -31,5 +31,5 @@ interface ISearchManager { ComponentName getGlobalSearchActivity(); ComponentName getWebSearchActivity(); ComponentName getAssistIntent(int userHandle); - boolean launchAssistAction(String hint, int userHandle); + boolean launchAssistAction(String hint, int userHandle, in Bundle args); } diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java index fa27631..45799a1 100644 --- a/core/java/android/app/SearchManager.java +++ b/core/java/android/app/SearchManager.java @@ -985,12 +985,12 @@ public class SearchManager * Launch an assist action for the current top activity. * @hide */ - public boolean launchAssistAction(String hint, int userHandle) { + public boolean launchAssistAction(String hint, int userHandle, Bundle args) { try { if (mService == null) { return false; } - return mService.launchAssistAction(hint, userHandle); + return mService.launchAssistAction(hint, userHandle, args); } catch (RemoteException re) { Log.e(TAG, "launchAssistAction() failed: " + re); return false; diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index c01ce4f..5c23204 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -1274,6 +1274,13 @@ public class Intent implements Parcelable, Cloneable { "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD"; /** + * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id + * that was used to invoke the assist. + */ + public static final String EXTRA_ASSIST_INPUT_DEVICE_ID = + "android.intent.extra.ASSIST_INPUT_DEVICE_ID"; + + /** * Activity Action: List all available applications * <p>Input: Nothing. * <p>Output: nothing. diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java index 14065b1..c010dfe 100644 --- a/core/java/com/android/internal/policy/PhoneWindow.java +++ b/core/java/com/android/internal/policy/PhoneWindow.java @@ -75,6 +75,7 @@ import com.android.internal.widget.SwipeDismissLayout; import android.app.ActivityManager; import android.app.KeyguardManager; import android.content.Context; +import android.content.Intent; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.content.res.Resources.Theme; @@ -4319,8 +4320,10 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (!result && (getContext().getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) { // On TVs, if the app doesn't implement search, we want to launch assist. + Bundle args = new Bundle(); + args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, event.getDeviceId()); return ((SearchManager)getContext().getSystemService(Context.SEARCH_SERVICE)) - .launchAssistAction(null, UserHandle.myUserId()); + .launchAssistAction(null, UserHandle.myUserId(), args); } return result; } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index efc38e2..3cc9c03 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -10663,7 +10663,7 @@ public final class ActivityManagerService extends ActivityManagerNative @Override public Bundle getAssistContextExtras(int requestType) { PendingAssistExtras pae = enqueueAssistContext(requestType, null, null, null, - UserHandle.getCallingUserId(), PENDING_ASSIST_EXTRAS_TIMEOUT); + UserHandle.getCallingUserId(), null, PENDING_ASSIST_EXTRAS_TIMEOUT); if (pae == null) { return null; } @@ -10686,11 +10686,11 @@ public final class ActivityManagerService extends ActivityManagerNative @Override public void requestAssistContextExtras(int requestType, IResultReceiver receiver) { enqueueAssistContext(requestType, null, null, receiver, UserHandle.getCallingUserId(), - PENDING_ASSIST_EXTRAS_LONG_TIMEOUT); + null, PENDING_ASSIST_EXTRAS_LONG_TIMEOUT); } private PendingAssistExtras enqueueAssistContext(int requestType, Intent intent, String hint, - IResultReceiver receiver, int userHandle, long timeout) { + IResultReceiver receiver, int userHandle, Bundle args, long timeout) { enforceCallingPermission(android.Manifest.permission.GET_TOP_ACTIVITY_INFO, "enqueueAssistContext()"); synchronized (this) { @@ -10709,6 +10709,9 @@ public final class ActivityManagerService extends ActivityManagerNative } PendingAssistExtras pae; Bundle extras = new Bundle(); + if (args != null) { + extras.putAll(args); + } extras.putString(Intent.EXTRA_ASSIST_PACKAGE, activity.packageName); extras.putInt(Intent.EXTRA_ASSIST_UID, activity.app.uid); pae = new PendingAssistExtras(activity, extras, intent, hint, receiver, userHandle); @@ -10794,8 +10797,9 @@ public final class ActivityManagerService extends ActivityManagerNative } } - public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle) { - return enqueueAssistContext(requestType, intent, hint, null, userHandle, + public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle, + Bundle args) { + return enqueueAssistContext(requestType, intent, hint, null, userHandle, args, PENDING_ASSIST_EXTRAS_TIMEOUT) != null; } diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 01fe6f5..6e52358 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -1204,7 +1204,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { launchHomeFromHotKey(); } - private void handleLongPressOnHome() { + private void handleLongPressOnHome(int deviceId) { if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { mHomeConsumed = true; performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); @@ -1212,7 +1212,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) { toggleRecentApps(); } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) { - launchAssistAction(); + launchAssistAction(null, deviceId); } } } @@ -2637,7 +2637,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { if (!keyguardOn) { - handleLongPressOnHome(); + handleLongPressOnHome(event.getDeviceId()); } } return -1; @@ -2717,7 +2717,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { mAssistKeyLongPressed = false; } else { if (!keyguardOn) { - launchAssistAction(); + launchAssistAction(null, event.getDeviceId()); } } } @@ -2779,7 +2779,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (down) { mPendingMetaAction = true; } else if (mPendingMetaAction) { - launchAssistAction(Intent.EXTRA_ASSIST_INPUT_HINT_KEYBOARD); + launchAssistAction(Intent.EXTRA_ASSIST_INPUT_HINT_KEYBOARD, event.getDeviceId()); } return -1; } @@ -3000,26 +3000,22 @@ public class PhoneWindowManager implements WindowManagerPolicy { } private void launchAssistAction() { - launchAssistAction(null); + 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); - Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) - .getAssistIntent(mContext, true, UserHandle.USER_CURRENT); - if (intent != null) { - if (hint != null) { - intent.putExtra(hint, true); - } - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_SINGLE_TOP - | Intent.FLAG_ACTIVITY_CLEAR_TOP); - try { - startActivityAsUser(intent, UserHandle.CURRENT); - } catch (ActivityNotFoundException e) { - Slog.w(TAG, "No activity to handle assist action.", e); - } + Bundle args = null; + if (deviceId > Integer.MIN_VALUE) { + args = new Bundle(); + args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, deviceId); } + ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) + .launchAssistAction(hint, UserHandle.myUserId(), args); } private void startActivityAsUser(Intent intent, UserHandle handle) { diff --git a/services/core/java/com/android/server/search/SearchManagerService.java b/services/core/java/com/android/server/search/SearchManagerService.java index 2b2b2ac..dd2286f 100644 --- a/services/core/java/com/android/server/search/SearchManagerService.java +++ b/services/core/java/com/android/server/search/SearchManagerService.java @@ -34,6 +34,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.database.ContentObserver; import android.os.Binder; +import android.os.Bundle; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; @@ -264,7 +265,7 @@ public class SearchManagerService extends ISearchManager.Stub { } @Override - public boolean launchAssistAction(String hint, int userHandle) { + public boolean launchAssistAction(String hint, int userHandle, Bundle args) { ComponentName comp = getAssistIntent(userHandle); if (comp == null) { return false; @@ -275,7 +276,7 @@ public class SearchManagerService extends ISearchManager.Stub { intent.setComponent(comp); IActivityManager am = ActivityManagerNative.getDefault(); return am.launchAssistIntent(intent, ActivityManager.ASSIST_CONTEXT_BASIC, hint, - userHandle); + userHandle, args); } catch (RemoteException e) { } finally { Binder.restoreCallingIdentity(ident); |