Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a90c92a1 authored by Justin Koh's avatar Justin Koh Committed by Android Git Automerger
Browse files

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

* commit '86903699':
  Start RecognitionActivity with an upswipe gesture.
parents c4241766 86903699
Loading
Loading
Loading
Loading
+2 −22
Original line number Diff line number Diff line
@@ -240,28 +240,8 @@ public class SearchManagerService extends ISearchManager.Stub {
    @Override
    public ComponentName getAssistIntent(int userHandle) {
        try {
            if (userHandle != UserHandle.getCallingUserId()) {
                // Requesting a different user, make sure that they have the permission
                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;
                }
            }
            userHandle = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
                    Binder.getCallingUid(), userHandle, true, false, "getAssistIntent", null);
            IPackageManager pm = AppGlobals.getPackageManager();
            Intent assistIntent = new Intent(Intent.ACTION_ASSIST);
            ResolveInfo info =
+23 −9
Original line number Diff line number Diff line
@@ -16,13 +16,15 @@

package android.view;

import android.app.SearchManager;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Handler.Callback;
import android.os.Message;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.util.Log;

/**
@@ -30,6 +32,8 @@ import android.util.Log;
 * 
 * @see ViewRootImpl
 */

//TODO: Make this class an internal class of ViewRootImpl.java
class SimulatedTrackball {

    private static final String TAG = "SimulatedTrackball";
@@ -43,7 +47,6 @@ class SimulatedTrackball {
    private static final int MSG_FLICK = 313;
    // TODO: Pass touch slop from the input device
    private static final int TOUCH_SLOP = 30;

    // The position of the previous touchpad event
    private float mLastTouchpadXPosition;
    private float mLastTouchpadYPosition;
@@ -59,6 +62,8 @@ class SimulatedTrackball {
    // Did the swipe begin in a valid region
    private boolean mEdgeSwipePossible;

    private final Context mContext;

    // How quickly keys were sent;
    private int mKeySendRateMs = 0;
    private int mLastKeySent;
@@ -92,7 +97,7 @@ class SimulatedTrackball {
    // How quickly the repeated events die off
    private float mFlickDecay;

    public SimulatedTrackball() {
    public SimulatedTrackball(Context context) {
        mDistancePerTick = SystemProperties.getInt("persist.vr_dist_tick", 64);
        mDistancePerTickSquared = mDistancePerTick * mDistancePerTick;
        mMaxRepeatDelay = SystemProperties.getInt("persist.vr_repeat_delay", 300);
@@ -102,6 +107,8 @@ class SimulatedTrackball {
                "persist.sys.vr_flick_decay", "1.3"));
        mTouchSlop = TOUCH_SLOP;
        mTouchSlopSquared = mTouchSlop * mTouchSlop;

        mContext = context;
    }

    private final Handler mHandler = new Handler(true /*async*/) {
@@ -167,12 +174,19 @@ class SimulatedTrackball {
                if (event.getY() < (event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax()
                        * .5) && mEdgeSwipePossible) {
                    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 {
                        viewroot.mView.getContext().startActivity(intent);
                            mContext.startActivity(intent);
                        } 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
+2 −1
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ public final class ViewRootImpl implements ViewParent,
    final TrackballAxis mTrackballAxisX = new TrackballAxis();
    final TrackballAxis mTrackballAxisY = new TrackballAxis();

    final SimulatedTrackball mSimulatedTrackball = new SimulatedTrackball();
    final SimulatedTrackball mSimulatedTrackball;

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

    /**