Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
- // Jad home page: http://www.kpdus.com/jad.html
- // Decompiler options: packimports(3)
- package com.android.commands.input;
- import android.hardware.input.InputManager;
- import android.os.SystemClock;
- import android.util.Log;
- import android.view.*;
- import java.io.PrintStream;
- import java.util.*;
- public class Input
- {
- public Input()
- {
- }
- private int getInputDeviceId(int i)
- {
- int ai[] = InputDevice.getDeviceIds();
- int j = ai.length;
- for(int k = 0; k < j; k++)
- {
- int l = ai[k];
- if(InputDevice.getDevice(l).supportsSource(i))
- return l;
- }
- return 0;
- }
- private static final int getSource(int i, int j)
- {
- if(i == 0)
- i = j;
- return i;
- }
- private void injectKeyEvent(KeyEvent keyevent)
- {
- Log.i("Input", (new StringBuilder()).append("injectKeyEvent: ").append(keyevent).toString());
- InputManager.getInstance().injectInputEvent(keyevent, 2);
- }
- private void injectMotionEvent(int i, int j, long l, float f, float f1, float f2)
- {
- MotionEvent motionevent = MotionEvent.obtain(l, l, j, f, f1, f2, 1.0F, 0, 1.0F, 1.0F, getInputDeviceId(i), 0);
- motionevent.setSource(i);
- Log.i("Input", (new StringBuilder()).append("injectMotionEvent: ").append(motionevent).toString());
- InputManager.getInstance().injectInputEvent(motionevent, 2);
- }
- private static final float lerp(float f, float f1, float f2)
- {
- return (f1 - f) * f2 + f;
- }
- public static void main(String args[])
- {
- (new Input()).run(args);
- }
- private void run(String as[])
- {
- int i;
- int j;
- String s1;
- int k;
- if(as.length < 1)
- {
- showUsage();
- return;
- }
- i = 0;
- String s = as[0];
- j = 0;
- s1 = s;
- if(SOURCES.containsKey(s))
- {
- j = ((Integer)SOURCES.get(s)).intValue();
- i = 1;
- s1 = as[1];
- }
- k = as.length - i;
- if(!s1.equals("text")) goto _L2; else goto _L1
- _L1:
- boolean flag;
- int l;
- int i1;
- if(k == 2)
- try
- {
- sendText(getSource(j, 257), as[i + 1]);
- return;
- }
- // Misplaced declaration of an exception variable
- catch(String as[]) { }
- goto _L3
- _L2:
- if(!s1.equals("keyevent")) goto _L5; else goto _L4
- _L4:
- if(k < 2) goto _L3; else goto _L6
- _L6:
- flag = "--longpress".equals(as[i + 1]);
- if(flag)
- i += 2;
- else
- i++;
- l = getSource(j, 257);
- if(k <= i) goto _L3; else goto _L7
- _L7:
- if(i >= k)
- break; /* Loop/switch isn't completed */
- i1 = KeyEvent.keyCodeFromString(as[i]);
- j = i1;
- if(i1 != 0)
- break MISSING_BLOCK_LABEL_202;
- StringBuilder stringbuilder = JVM INSTR new #47 <Class StringBuilder>;
- stringbuilder.StringBuilder();
- j = KeyEvent.keyCodeFromString(stringbuilder.append("KEYCODE_").append(as[i]).toString());
- sendKeyEvent(l, j, flag);
- i++;
- if(true) goto _L7; else goto _L8
- _L8:
- return;
- _L5:
- if(!s1.equals("tap")) goto _L10; else goto _L9
- _L9:
- if(k != 3) goto _L3; else goto _L11
- _L11:
- sendTap(getSource(j, 4098), Float.parseFloat(as[i + 1]), Float.parseFloat(as[i + 2]));
- return;
- _L10:
- if(!s1.equals("swipe")) goto _L13; else goto _L12
- _L12:
- i1 = -1;
- l = getSource(j, 4098);
- j = i1;
- k;
- JVM INSTR tableswitch 5 6: default 320
- // 5 361
- // 6 351;
- goto _L3 _L14 _L15
- _L3:
- System.err.println((new StringBuilder()).append("Error: Invalid arguments for command: ").append(s1).toString());
- showUsage();
- return;
- _L15:
- j = Integer.parseInt(as[i + 5]);
- _L14:
- sendSwipe(l, Float.parseFloat(as[i + 1]), Float.parseFloat(as[i + 2]), Float.parseFloat(as[i + 3]), Float.parseFloat(as[i + 4]), j);
- return;
- _L13:
- if(!s1.equals("draganddrop")) goto _L17; else goto _L16
- _L16:
- i1 = -1;
- l = getSource(j, 4098);
- j = i1;
- k;
- JVM INSTR tableswitch 5 6: default 452
- // 5 455
- // 6 496;
- goto _L3 _L18 _L19
- _L18:
- sendDragAndDrop(l, Float.parseFloat(as[i + 1]), Float.parseFloat(as[i + 2]), Float.parseFloat(as[i + 3]), Float.parseFloat(as[i + 4]), j);
- return;
- _L19:
- j = Integer.parseInt(as[i + 5]);
- if(true) goto _L18; else goto _L17
- _L17:
- if(!s1.equals("press")) goto _L21; else goto _L20
- _L20:
- i = getSource(j, 0x10004);
- if(k != 1) goto _L3; else goto _L22
- _L22:
- sendTap(i, 0.0F, 0.0F);
- return;
- _L21:
- if(!s1.equals("roll")) goto _L24; else goto _L23
- _L23:
- j = getSource(j, 0x10004);
- if(k != 3) goto _L3; else goto _L25
- _L25:
- sendMove(j, Float.parseFloat(as[i + 1]), Float.parseFloat(as[i + 2]));
- return;
- _L24:
- if(!s1.equals("tmode")) goto _L27; else goto _L26
- _L26:
- if(as.length <= 1) goto _L29; else goto _L28
- _L28:
- as = as[1];
- if(!as.equals("glove_off")) goto _L31; else goto _L30
- _L30:
- InputManager.getInstance().switchTouchSensitiveMode(false);
- System.err.println("glove off!\n");
- _L29:
- return;
- _L31:
- if(!as.equals("glove_on")) goto _L33; else goto _L32
- _L32:
- InputManager.getInstance().switchTouchSensitiveMode(true);
- System.err.println("glove on!\n");
- goto _L29
- _L33:
- if(!as.equals("stylus_off")) goto _L35; else goto _L34
- _L34:
- InputManager.getInstance().switchTouchStylusMode(false);
- System.err.println("stylus off!\n");
- goto _L29
- _L35:
- if(!as.equals("stylus_on")) goto _L37; else goto _L36
- _L36:
- InputManager.getInstance().switchTouchStylusMode(true);
- System.err.println("stylus on!\n");
- goto _L29
- _L37:
- if(!as.equals("wakeup_off")) goto _L39; else goto _L38
- _L38:
- InputManager.getInstance().switchTouchWakeupMode(false);
- System.err.println("wakeup gesture off!\n");
- goto _L29
- _L39:
- if(!as.equals("wakeup_on")) goto _L41; else goto _L40
- _L40:
- InputManager.getInstance().switchTouchWakeupMode(true);
- System.err.println("wakeup gesture on!\n");
- goto _L29
- _L41:
- if(!as.equals("cover_off")) goto _L43; else goto _L42
- _L42:
- InputManager.getInstance().switchTouchCoverMode(false);
- System.err.println("cover gesture off!\n");
- goto _L29
- _L43:
- if(!as.equals("cover_on")) goto _L29; else goto _L44
- _L44:
- InputManager.getInstance().switchTouchCoverMode(true);
- System.err.println("cover gesture on!\n");
- goto _L29
- _L27:
- as = System.err;
- StringBuilder stringbuilder1 = JVM INSTR new #47 <Class StringBuilder>;
- stringbuilder1.StringBuilder();
- as.println(stringbuilder1.append("Error: Unknown command: ").append(s1).toString());
- showUsage();
- return;
- }
- private void sendDragAndDrop(int i, float f, float f1, float f2, float f3, int j)
- {
- int k = j;
- if(j < 0)
- k = 300;
- injectMotionEvent(i, 0, SystemClock.uptimeMillis(), f, f1, 1.0F);
- long l;
- long l1;
- long l2;
- try
- {
- Thread.sleep(ViewConfiguration.getLongPressTimeout());
- }
- catch(InterruptedException interruptedexception)
- {
- throw new RuntimeException(interruptedexception);
- }
- l = SystemClock.uptimeMillis();
- l1 = k;
- for(l2 = l; l2 < l + l1; l2 = SystemClock.uptimeMillis())
- {
- float f4 = (float)(l2 - l) / (float)k;
- injectMotionEvent(i, 2, l2, lerp(f, f2, f4), lerp(f1, f3, f4), 1.0F);
- }
- injectMotionEvent(i, 1, l2, f2, f3, 0.0F);
- }
- private void sendKeyEvent(int i, int j, boolean flag)
- {
- long l = SystemClock.uptimeMillis();
- injectKeyEvent(new KeyEvent(l, l, 0, j, 0, 0, -1, 0, 0, i));
- if(flag)
- injectKeyEvent(new KeyEvent(l, l, 0, j, 1, 0, -1, 0, 128, i));
- injectKeyEvent(new KeyEvent(l, l, 1, j, 0, 0, -1, 0, 0, i));
- }
- private void sendMove(int i, float f, float f1)
- {
- injectMotionEvent(i, 2, SystemClock.uptimeMillis(), f, f1, 0.0F);
- }
- private void sendSwipe(int i, float f, float f1, float f2, float f3, int j)
- {
- int k = j;
- if(j < 0)
- k = 300;
- long l = SystemClock.uptimeMillis();
- injectMotionEvent(i, 0, l, f, f1, 1.0F);
- long l1 = k;
- long l2;
- for(l2 = l; l2 < l + l1; l2 = SystemClock.uptimeMillis())
- {
- float f4 = (float)(l2 - l) / (float)k;
- injectMotionEvent(i, 2, l2, lerp(f, f2, f4), lerp(f1, f3, f4), 1.0F);
- }
- injectMotionEvent(i, 1, l2, f2, f3, 0.0F);
- }
- private void sendTap(int i, float f, float f1)
- {
- long l = SystemClock.uptimeMillis();
- injectMotionEvent(i, 0, l, f, f1, 1.0F);
- injectMotionEvent(i, 1, l, f, f1, 0.0F);
- }
- private void sendText(int i, String s)
- {
- s = new StringBuffer(s);
- boolean flag = false;
- int l;
- for(int j = 0; j < s.length(); j = l + 1)
- {
- boolean flag1 = flag;
- l = j;
- if(flag)
- {
- flag = false;
- flag1 = flag;
- l = j;
- if(s.charAt(j) == 's')
- {
- s.setCharAt(j, ' ');
- l = j - 1;
- s.deleteCharAt(l);
- flag1 = flag;
- }
- }
- flag = flag1;
- if(s.charAt(l) == '%')
- flag = true;
- }
- s = s.toString().toCharArray();
- s = KeyCharacterMap.load(-1).getEvents(s);
- for(int k = 0; k < s.length; k++)
- {
- KeyEvent keyevent = s[k];
- if(i != keyevent.getSource())
- keyevent.setSource(i);
- injectKeyEvent(keyevent);
- }
- }
- private void showUsage()
- {
- System.err.println("Usage: input [<source>] <command> [<arg>...]");
- System.err.println();
- System.err.println("The sources are: ");
- String s;
- for(Iterator iterator = SOURCES.keySet().iterator(); iterator.hasNext(); System.err.println((new StringBuilder()).append(" ").append(s).toString()))
- s = (String)iterator.next();
- System.err.println();
- System.err.println("The commands and default sources are:");
- System.err.println(" text <string> (Default: touchscreen)");
- System.err.println(" keyevent [--longpress] <key code number or name> ... (Default: keyboard)");
- System.err.println(" tap <x> <y> (Default: touchscreen)");
- System.err.println(" swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)");
- System.err.println(" draganddrop <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen)");
- System.err.println(" press (Default: trackball)");
- System.err.println(" roll <dx> <dy> (Default: trackball)");
- System.err.println(" tmode <tmode>");
- }
- private static final String INVALID_ARGUMENTS = "Error: Invalid arguments for command: ";
- private static final Map SOURCES = new HashMap() {
- {
- put("keyboard", Integer.valueOf(257));
- put("dpad", Integer.valueOf(513));
- put("gamepad", Integer.valueOf(1025));
- put("touchscreen", Integer.valueOf(4098));
- put("mouse", Integer.valueOf(8194));
- put("stylus", Integer.valueOf(16386));
- put("trackball", Integer.valueOf(0x10004));
- put("touchpad", Integer.valueOf(0x100008));
- put("touchnavigation", Integer.valueOf(0x200000));
- put("joystick", Integer.valueOf(0x1000010));
- }
- }
- ;
- private static final String TAG = "Input";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement