am 86903699: Merge "Start RecognitionActivity with an upswipe gesture." into jb-mr1-aah-dev

* commit '86903699692a0b3229062da2995d829629e64e7b':
  Start RecognitionActivity with an upswipe gesture.
This commit is contained in:
Justin Koh
2012-12-19 11:46:34 -08:00
committed by Android Git Automerger
3 changed files with 27 additions and 32 deletions

View File

@ -240,28 +240,8 @@ public class SearchManagerService extends ISearchManager.Stub {
@Override @Override
public ComponentName getAssistIntent(int userHandle) { public ComponentName getAssistIntent(int userHandle) {
try { try {
if (userHandle != UserHandle.getCallingUserId()) { userHandle = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
// Requesting a different user, make sure that they have the permission Binder.getCallingUid(), userHandle, true, false, "getAssistIntent", null);
if (ActivityManager.checkComponentPermission(
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
Binder.getCallingUid(), -1, true)
== PackageManager.PERMISSION_GRANTED) {
// Translate to the current user id, if caller wasn't aware
if (userHandle == UserHandle.USER_CURRENT) {
long identity = Binder.clearCallingIdentity();
userHandle = ActivityManagerNative.getDefault().getCurrentUser().id;
Binder.restoreCallingIdentity(identity);
}
} else {
String msg = "Permission Denial: "
+ "Request to getAssistIntent for " + userHandle
+ " but is calling from user " + UserHandle.getCallingUserId()
+ "; this requires "
+ android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
Slog.w(TAG, msg);
return null;
}
}
IPackageManager pm = AppGlobals.getPackageManager(); IPackageManager pm = AppGlobals.getPackageManager();
Intent assistIntent = new Intent(Intent.ACTION_ASSIST); Intent assistIntent = new Intent(Intent.ACTION_ASSIST);
ResolveInfo info = ResolveInfo info =

View File

@ -16,13 +16,15 @@
package android.view; package android.view;
import android.app.SearchManager;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Handler; import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message; import android.os.Message;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.os.UserHandle;
import android.util.Log; import android.util.Log;
/** /**
@ -30,6 +32,8 @@ import android.util.Log;
* *
* @see ViewRootImpl * @see ViewRootImpl
*/ */
//TODO: Make this class an internal class of ViewRootImpl.java
class SimulatedTrackball { class SimulatedTrackball {
private static final String TAG = "SimulatedTrackball"; private static final String TAG = "SimulatedTrackball";
@ -43,7 +47,6 @@ class SimulatedTrackball {
private static final int MSG_FLICK = 313; private static final int MSG_FLICK = 313;
// TODO: Pass touch slop from the input device // TODO: Pass touch slop from the input device
private static final int TOUCH_SLOP = 30; private static final int TOUCH_SLOP = 30;
// The position of the previous touchpad event // The position of the previous touchpad event
private float mLastTouchpadXPosition; private float mLastTouchpadXPosition;
private float mLastTouchpadYPosition; private float mLastTouchpadYPosition;
@ -59,6 +62,8 @@ class SimulatedTrackball {
// Did the swipe begin in a valid region // Did the swipe begin in a valid region
private boolean mEdgeSwipePossible; private boolean mEdgeSwipePossible;
private final Context mContext;
// How quickly keys were sent; // How quickly keys were sent;
private int mKeySendRateMs = 0; private int mKeySendRateMs = 0;
private int mLastKeySent; private int mLastKeySent;
@ -92,7 +97,7 @@ class SimulatedTrackball {
// How quickly the repeated events die off // How quickly the repeated events die off
private float mFlickDecay; private float mFlickDecay;
public SimulatedTrackball() { public SimulatedTrackball(Context context) {
mDistancePerTick = SystemProperties.getInt("persist.vr_dist_tick", 64); mDistancePerTick = SystemProperties.getInt("persist.vr_dist_tick", 64);
mDistancePerTickSquared = mDistancePerTick * mDistancePerTick; mDistancePerTickSquared = mDistancePerTick * mDistancePerTick;
mMaxRepeatDelay = SystemProperties.getInt("persist.vr_repeat_delay", 300); mMaxRepeatDelay = SystemProperties.getInt("persist.vr_repeat_delay", 300);
@ -102,6 +107,8 @@ class SimulatedTrackball {
"persist.sys.vr_flick_decay", "1.3")); "persist.sys.vr_flick_decay", "1.3"));
mTouchSlop = TOUCH_SLOP; mTouchSlop = TOUCH_SLOP;
mTouchSlopSquared = mTouchSlop * mTouchSlop; mTouchSlopSquared = mTouchSlop * mTouchSlop;
mContext = context;
} }
private final Handler mHandler = new Handler(true /*async*/) { private final Handler mHandler = new Handler(true /*async*/) {
@ -167,12 +174,19 @@ class SimulatedTrackball {
if (event.getY() < (event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax() if (event.getY() < (event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax()
* .5) && mEdgeSwipePossible) { * .5) && mEdgeSwipePossible) {
mEdgeSwipePossible = false; mEdgeSwipePossible = false;
Intent intent = new Intent("android.search.action.GLOBAL_SEARCH");
intent.addCategory("android.intent.category.DEFAULT"); Intent intent =
((SearchManager)mContext.getSystemService(Context.SEARCH_SERVICE))
.getAssistIntent(mContext, UserHandle.USER_CURRENT_OR_SELF);
if (intent != null) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try { try {
viewroot.mView.getContext().startActivity(intent); mContext.startActivity(intent);
} catch (ActivityNotFoundException e) { } catch (ActivityNotFoundException e){
Log.e(TAG,"Search activity not found."); Log.e(TAG, "Could not start search activity");
}
} else {
Log.e(TAG, "Could not find a search activity");
} }
} }
// Find the difference in position between the two most recent // Find the difference in position between the two most recent

View File

@ -144,7 +144,7 @@ public final class ViewRootImpl implements ViewParent,
final TrackballAxis mTrackballAxisX = new TrackballAxis(); final TrackballAxis mTrackballAxisX = new TrackballAxis();
final TrackballAxis mTrackballAxisY = new TrackballAxis(); final TrackballAxis mTrackballAxisY = new TrackballAxis();
final SimulatedTrackball mSimulatedTrackball = new SimulatedTrackball(); final SimulatedTrackball mSimulatedTrackball;
int mLastJoystickXDirection; int mLastJoystickXDirection;
int mLastJoystickYDirection; int mLastJoystickYDirection;
@ -385,6 +385,7 @@ public final class ViewRootImpl implements ViewParent,
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mAttachInfo.mScreenOn = powerManager.isScreenOn(); mAttachInfo.mScreenOn = powerManager.isScreenOn();
loadSystemProperties(); loadSystemProperties();
mSimulatedTrackball = new SimulatedTrackball(context);
} }
/** /**