diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-04-05 18:57:33 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-04-05 19:33:11 -0700 |
commit | ac14351e16e1258f1cb54e2bf772b8be004eb2b8 (patch) | |
tree | 55c22fe8e19d35764f00a6ffad899e4fd2c4ccd0 /cmds/input | |
parent | 030711c39b6093024d784c1c3d7566bd5a3e3489 (diff) | |
download | frameworks_base-ac14351e16e1258f1cb54e2bf772b8be004eb2b8.zip frameworks_base-ac14351e16e1258f1cb54e2bf772b8be004eb2b8.tar.gz frameworks_base-ac14351e16e1258f1cb54e2bf772b8be004eb2b8.tar.bz2 |
Move some APIs from window manager to input manager.
Simplified input injection API down to just one call.
Removed all input state reading API. It was only used by the
window manager policy and required a permission that applications
could not obtain. READ_INPUT_STATE is now unused and deprecated.
Change-Id: I41278141586ddee9468cae0fb59ff0dced6cbc00
Diffstat (limited to 'cmds/input')
-rwxr-xr-x | cmds/input/src/com/android/commands/input/Input.java | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/cmds/input/src/com/android/commands/input/Input.java b/cmds/input/src/com/android/commands/input/Input.java index c4c3b8a..3037881 100755 --- a/cmds/input/src/com/android/commands/input/Input.java +++ b/cmds/input/src/com/android/commands/input/Input.java @@ -16,11 +16,12 @@ package com.android.commands.input; +import android.hardware.input.InputManager; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.util.Log; -import android.view.IWindowManager; +import android.view.InputDevice; import android.view.KeyCharacterMap; import android.view.KeyEvent; import android.view.MotionEvent; @@ -33,8 +34,6 @@ import android.view.MotionEvent; public class Input { private static final String TAG = "Input"; - private IWindowManager mWindowManager; - /** * Command-line entry point. * @@ -44,13 +43,6 @@ public class Input { (new Input()).run(args); } - private IWindowManager getWindowManager() { - if (mWindowManager == null) { - mWindowManager = (IWindowManager.Stub.asInterface(ServiceManager.getService("window"))); - } - return mWindowManager; - } - private void run(String[] args) { if (args.length < 1) { showUsage(); @@ -127,8 +119,10 @@ public class Input { private void sendKeyEvent(int keyCode) { long now = SystemClock.uptimeMillis(); - injectKeyEvent(new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keyCode, 0)); - injectKeyEvent(new KeyEvent(now, now, KeyEvent.ACTION_UP, keyCode, 0)); + injectKeyEvent(new KeyEvent(now, now, KeyEvent.ACTION_DOWN, keyCode, 0, 0, + KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD)); + injectKeyEvent(new KeyEvent(now, now, KeyEvent.ACTION_UP, keyCode, 0, 0, + KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD)); } private void sendTap(float x, float y) { @@ -150,23 +144,14 @@ public class Input { } private void injectKeyEvent(KeyEvent event) { - try { - Log.i(TAG, "InjectKeyEvent: " + event); - getWindowManager().injectKeyEvent(event, true); - } catch (RemoteException ex) { - Log.i(TAG, "RemoteException", ex); - } + Log.i(TAG, "InjectKeyEvent: " + event); + InputManager.injectInputEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); } private void injectPointerEvent(MotionEvent event) { - try { - Log.i("Input", "InjectPointerEvent: " + event); - getWindowManager().injectPointerEvent(event, true); - } catch (RemoteException ex) { - Log.i(TAG, "RemoteException", ex); - } finally { - event.recycle(); - } + event.setSource(InputDevice.SOURCE_TOUCHSCREEN); + Log.i("Input", "InjectPointerEvent: " + event); + InputManager.injectInputEvent(event, InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH); } private static final float lerp(float a, float b, float alpha) { @@ -174,7 +159,7 @@ public class Input { } private void showUsage() { - System.err.println("usage: input [text|keyevent]"); + System.err.println("usage: input ..."); System.err.println(" input text <string>"); System.err.println(" input keyevent <key code>"); System.err.println(" input tap <x> <y>"); |