Loading core/java/android/service/gesture/IGestureService.aidl +5 −4 Original line number Diff line number Diff line package android.service.gesture; import android.app.PendingIntent; /** @hide */ interface IGestureService { /** * Register a listener for gesture sensor input. Gesture sensor input * is then converted into input events for system consumption. */ void setOnLongPressPendingIntent(in PendingIntent pendingIntent); void setOnDoubleClickPendingIntent(in PendingIntent pendingIntent); } services/java/com/android/server/gesture/GestureInputFilter.java +29 −15 Original line number Diff line number Diff line Loading @@ -15,13 +15,13 @@ */ package com.android.server.gesture; import android.app.PendingIntent; import android.app.PendingIntent.CanceledException; import android.content.Context; import android.content.Intent; import android.hardware.input.InputManager; import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.util.Slog; import android.view.Display; import android.view.GestureDetector; Loading @@ -30,13 +30,10 @@ import android.view.IInputFilter; import android.view.IInputFilterHost; import android.view.InputDevice; import android.view.InputEvent; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.OrientationEventListener; import android.view.ViewConfiguration; import android.view.WindowManager; import java.io.PrintWriter; /** Loading @@ -57,6 +54,8 @@ public class GestureInputFilter implements IInputFilter, GestureDetector.OnGestu private float mGesturePadWidth, mGesturePadHeight; private int mTouchSlop, mOrientation; private Context mContext; private PendingIntent mLongPressPendingIntent; private PendingIntent mDoubleClickPendingIntent; public GestureInputFilter(Context context) { mInputManager = InputManager.getInstance(); Loading Loading @@ -285,9 +284,13 @@ public class GestureInputFilter implements IInputFilter, GestureDetector.OnGestu @Override public void onLongPress(MotionEvent e) { Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF, null, null, null, 0, null, null); if (mLongPressPendingIntent != null) { try { mLongPressPendingIntent.send(); } catch (CanceledException e1) { e1.printStackTrace(); } } } @Override Loading @@ -303,17 +306,28 @@ public class GestureInputFilter implements IInputFilter, GestureDetector.OnGestu @Override public boolean onDoubleTap(MotionEvent e) { long now = SystemClock.uptimeMillis(); sendInputEvent(new KeyEvent(now, now, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_CAMERA, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD)); sendInputEvent(new KeyEvent(now, now, KeyEvent.ACTION_UP,KeyEvent.KEYCODE_CAMERA, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD)); if (mDoubleClickPendingIntent != null) { try { mDoubleClickPendingIntent.send(); return true; } catch (CanceledException e1) { e1.printStackTrace(); } } return false; } @Override public boolean onDoubleTapEvent(MotionEvent e) { return false; } public void setOnLongPressPendingIntent(PendingIntent pendingIntent) { mLongPressPendingIntent = pendingIntent; } public void setOnDoubleClickPendingIntent(PendingIntent pendingIntent) { mDoubleClickPendingIntent = pendingIntent; } } services/java/com/android/server/gesture/GestureService.java +9 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.gesture; import android.Manifest; import android.app.PendingIntent; import android.content.Context; import android.os.Binder; import android.os.IBinder; Loading Loading @@ -51,4 +52,12 @@ public class GestureService extends IGestureService.Stub { mInputFilter = new GestureInputFilter(mContext); mInputManager.registerSecondaryInputFilter(mInputFilter); } public void setOnLongPressPendingIntent(PendingIntent pendingIntent) { mInputFilter.setOnLongPressPendingIntent(pendingIntent); } public void setOnDoubleClickPendingIntent(PendingIntent pendingIntent) { mInputFilter.setOnDoubleClickPendingIntent(pendingIntent); } } Loading
core/java/android/service/gesture/IGestureService.aidl +5 −4 Original line number Diff line number Diff line package android.service.gesture; import android.app.PendingIntent; /** @hide */ interface IGestureService { /** * Register a listener for gesture sensor input. Gesture sensor input * is then converted into input events for system consumption. */ void setOnLongPressPendingIntent(in PendingIntent pendingIntent); void setOnDoubleClickPendingIntent(in PendingIntent pendingIntent); }
services/java/com/android/server/gesture/GestureInputFilter.java +29 −15 Original line number Diff line number Diff line Loading @@ -15,13 +15,13 @@ */ package com.android.server.gesture; import android.app.PendingIntent; import android.app.PendingIntent.CanceledException; import android.content.Context; import android.content.Intent; import android.hardware.input.InputManager; import android.os.IBinder; import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.util.Slog; import android.view.Display; import android.view.GestureDetector; Loading @@ -30,13 +30,10 @@ import android.view.IInputFilter; import android.view.IInputFilterHost; import android.view.InputDevice; import android.view.InputEvent; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.OrientationEventListener; import android.view.ViewConfiguration; import android.view.WindowManager; import java.io.PrintWriter; /** Loading @@ -57,6 +54,8 @@ public class GestureInputFilter implements IInputFilter, GestureDetector.OnGestu private float mGesturePadWidth, mGesturePadHeight; private int mTouchSlop, mOrientation; private Context mContext; private PendingIntent mLongPressPendingIntent; private PendingIntent mDoubleClickPendingIntent; public GestureInputFilter(Context context) { mInputManager = InputManager.getInstance(); Loading Loading @@ -285,9 +284,13 @@ public class GestureInputFilter implements IInputFilter, GestureDetector.OnGestu @Override public void onLongPress(MotionEvent e) { Intent intent = new Intent(Intent.ACTION_CAMERA_BUTTON, null); mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF, null, null, null, 0, null, null); if (mLongPressPendingIntent != null) { try { mLongPressPendingIntent.send(); } catch (CanceledException e1) { e1.printStackTrace(); } } } @Override Loading @@ -303,17 +306,28 @@ public class GestureInputFilter implements IInputFilter, GestureDetector.OnGestu @Override public boolean onDoubleTap(MotionEvent e) { long now = SystemClock.uptimeMillis(); sendInputEvent(new KeyEvent(now, now, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_CAMERA, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD)); sendInputEvent(new KeyEvent(now, now, KeyEvent.ACTION_UP,KeyEvent.KEYCODE_CAMERA, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD)); if (mDoubleClickPendingIntent != null) { try { mDoubleClickPendingIntent.send(); return true; } catch (CanceledException e1) { e1.printStackTrace(); } } return false; } @Override public boolean onDoubleTapEvent(MotionEvent e) { return false; } public void setOnLongPressPendingIntent(PendingIntent pendingIntent) { mLongPressPendingIntent = pendingIntent; } public void setOnDoubleClickPendingIntent(PendingIntent pendingIntent) { mDoubleClickPendingIntent = pendingIntent; } }
services/java/com/android/server/gesture/GestureService.java +9 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.gesture; import android.Manifest; import android.app.PendingIntent; import android.content.Context; import android.os.Binder; import android.os.IBinder; Loading Loading @@ -51,4 +52,12 @@ public class GestureService extends IGestureService.Stub { mInputFilter = new GestureInputFilter(mContext); mInputManager.registerSecondaryInputFilter(mInputFilter); } public void setOnLongPressPendingIntent(PendingIntent pendingIntent) { mInputFilter.setOnLongPressPendingIntent(pendingIntent); } public void setOnDoubleClickPendingIntent(PendingIntent pendingIntent) { mInputFilter.setOnDoubleClickPendingIntent(pendingIntent); } }