Anyone has a modified version of ADB sendevent file??

automated warm hole

Registered Member
Joined
Aug 19, 2020
Messages
62
Reaction score
17
Standard sendevent is slow as fuck when you use getevent to record a real human swipe and then play it, each sendevent only accepts 3 parameters only so you end up having to use 300 commands for a swipe, invoking shell and sendevent hundreds of times makes it really really slow.

Anyone has a modified version of sendevent class so you can pass the arguments in multiple pairs of three?
 
lol looks like we are on the same page, looking for this myself.
 
lol looks like we are on the same page, looking for this myself.
I'll let you know if I find it, right now the biggest lead I have is this: https://github.com/rils/ARP/

As stated in the description this tool does exactly that, it has a modified version of sendevent.c in order to accept as many arguments as you give and only opens the input file once. I've looked through the folders but can't find the custom class, I haven't learn C yet so maybe is because of that, If you have any luck with this please create a thread or post it here because I fear we are many who are looking for this.
 
I'll let you know if I find it, right now the biggest lead I have is this: https://github.com/rils/ARP/

As stated in the description this tool does exactly that, it has a modified version of sendevent.c in order to accept as many arguments as you give and only opens the input file once. I've looked through the folders but can't find the custom class, I haven't learn C yet so maybe is because of that, If you have any luck with this please create a thread or post it here because I fear we are many who are looking for this.
lol looks like we are on the same page, looking for this myself.
Just to be clear, I didn't express myself very good, you are looking to do as the modified sendevent right? This tool does it, however I need to implement it into my own coded bot which I assume is what you're also doing.

default sendevent

sendevent /dev/input/event1 3 47 0

sendevent /dev/input/event1 3 57 13578

sendevent /dev/input/event1 1 330 1

sendevent /dev/input/event1 1 325 1

Modified sendevent

/data/local/tmp/mysendevent /dev/input/event1 3 47 0 3 57 13578 1 330 1 1 325 1
 
Here is the java class that the program I mentioned earlier uses, it has a couple of sendevent methods, reading from this app's documentation the input to those methods seems to be a .mel or .mes file, don't know what those are but I'll run some tests later. I don't even know if this java class sendevent method will work as intended just by using this class or if other code is needed.
package com.ours.tester;

import java.io.FileWriter;
import java.util.Date;
import java.text.SimpleDateFormat;
import com.android.ddmlib.MultiLineReceiver;
import com.android.ddmlib.SyncException;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import com.android.ddmlib.ShellCommandUnresponsiveException;
import com.android.ddmlib.AdbCommandRejectedException;
import com.android.ddmlib.TimeoutException;
import com.android.ddmlib.IShellOutputReceiver;
import com.android.ddmlib.Log;
import java.io.File;
import java.nio.file.Paths;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.AndroidDebugBridge;

public class ADB
{
public static final String LOG_TAG = "mytester";
public String file_location;
public static boolean isStartNewLogFile;
private AndroidDebugBridge mAndroidDebugBridge;
public static IDevice[] mDevices;
public static IDevice mDevice;
public static FileOutputReceiver fReciever;
public static boolean isLogCancelled;
private static String myTesterEventScript_file;
static final String mySendEventAdbLocation = "/data/local/tmp/mysendevent";
public static final String mySendEventLocation;

static {
ADB.isStartNewLogFile = true;
ADB.isLogCancelled = false;
ADB.myTesterEventScript_file = "/data/local/tmp/myTesterEventScript.mes";
mySendEventLocation = String.valueOf(Paths.get("", new String[0]).toAbsolutePath().toString()) + File.separator + "mysendevent";
}

public boolean initialize() {
boolean success = true;
String adbLocation = System.getenv("ANDROID_HOME");
if (adbLocation != null) {
adbLocation = String.valueOf(adbLocation) + File.separator + "platform-tools";
}
if (success) {
if (adbLocation != null && adbLocation.length() != 0) {
adbLocation = String.valueOf(adbLocation) + File.separator + "adb";
}
else {
adbLocation = "adb";
}
System.out.println("adb path is " + adbLocation);
AndroidDebugBridge.init(false);
this.mAndroidDebugBridge = AndroidDebugBridge.createBridge(adbLocation, true);
if (this.mAndroidDebugBridge == null) {
success = false;
}
}
if (success) {
int count = 0;
while (!this.mAndroidDebugBridge.hasInitialDeviceList()) {
try {
Thread.sleep(100L);
++count;
}
catch (InterruptedException ex) {}
if (count > 100) {
success = false;
break;
}
}
}
if (!success) {
this.terminate();
}
return success;
}

public void terminate() {
AndroidDebugBridge.terminate();
}

public IDevice[] getDevices() {
IDevice[] devices = null;
if (this.mAndroidDebugBridge != null) {
devices = this.mAndroidDebugBridge.getDevices();
}
return devices;
}

public String[] adbDevices() {
ADB.mDevices = this.getDevices();
if (ADB.mDevices.length == 0) {
System.out.println("No connected devices!");
return null;
}
final String[] list = new String[ADB.mDevices.length + 1];
if (ADB.mDevices != null) {
for (int i = 0; i < ADB.mDevices.length; ++i) {
list = ADB.mDevices.toString();
}
ADB.mDevice = ADB.mDevices[0];
}
list[ADB.mDevices.length] = "All Devices";
return list;
}

public String getDeviceName() {
return ADB.mDevice.getName();
}

public IDevice getMyDevice() {
return ADB.mDevice;
}

public String shell(final String command) throws IOException {
Log.i("mytester", String.format("adb shell %s", command));
System.out.println("adb shell " + command);
final CollectingOutputReceiver receiver = new CollectingOutputReceiver((CollectingOutputReceiver)null);
try {
ADB.mDevice.executeShellCommand(command, (IShellOutputReceiver)receiver);
}
catch (TimeoutException e) {
e.printStackTrace();
}
catch (AdbCommandRejectedException e2) {
e2.printStackTrace();
}
catch (ShellCommandUnresponsiveException e3) {
e3.printStackTrace();
}
final String output = receiver.getOutput();
Log.i("mytester", String.format("Result: %s", output));
return output;
}

public FileOutputReceiver startlogGetEventToFile() {
ADB.isLogCancelled = false;
System.out.println("Start Logging...");
final String command = "getevent -t";
final FileOutputReceiver fReceiver = new FileOutputReceiver();
System.out.println("Before " + ADB.isStartNewLogFile);
try {
ADB.mDevice.executeShellCommand(command, (IShellOutputReceiver)fReceiver);
}
catch (TimeoutException e) {
e.printStackTrace();
}
catch (AdbCommandRejectedException e2) {
e2.printStackTrace();
}
catch (ShellCommandUnresponsiveException e3) {
e3.printStackTrace();
}
catch (IOException e4) {
e4.printStackTrace();
}
System.out.println("From startloggin " + ADB.isStartNewLogFile);
fReceiver.getOutputToFile();
fReceiver.flush();
fReceiver.isCancelled();
fReceiver.done();
return fReceiver;
}

public String stoplogGetEventToFile() {
ADB.isLogCancelled = true;
try {
Thread.sleep(1000L);
}
catch (InterruptedException e) {
e.printStackTrace();
}
ADB.isStartNewLogFile = true;
System.out.println("Stop: getevent logging done\n" + this.file_location);
return this.file_location;
}

public static boolean isStartNewLogFile() {
return ADB.isStartNewLogFile;
}

public void setStartNewLogFile(final boolean isStartNewLogFile) {
ADB.isStartNewLogFile = isStartNewLogFile;
}

public String resumelogGetEventToFile() {
ADB.isStartNewLogFile = false;
System.out.println("Resume getevent logging " + this.file_location);
this.startlogGetEventToFile();
return this.file_location;
}

public String pauselogGetEventToFile() {
ADB.isLogCancelled = true;
try {
Thread.sleep(1000L);
}
catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Pause: getevent logging done\n" + this.file_location);
return this.file_location;
}

public void runSendEventScript(final String mes_script_location) throws IOException {
final String cmd = "sh " + mes_script_location;
this.shell(cmd);
}

public void initmySendEvent() throws IOException {
final InputStream is = this.getClass().getClassLoader().getResourceAsStream("mysendevent");
FileOutputStream fos = null;
try {
fos = new FileOutputStream("mysendevent");
final byte[] buf = new byte[2048];
for (int r = is.read(buf); r != -1; r = is.read(buf)) {
fos.write(buf, 0, r);
}
}
finally {
if (fos != null) {
fos.close();
}
}
if (fos != null) {
fos.close();
}
this.adbPush(ADB.mySendEventLocation, "/data/local/tmp/mysendevent");
this.shell("chmod 777 /data/local/tmp/mysendevent");
}

public void convertPushPlayEventScript(final String mel_file_location, final boolean play_only) {
System.out.println("convertpushPlay" + mel_file_location);
try {
if (!play_only) {
final String mes_script_file = new Utils().convertgetEventToSendEvent(mel_file_location);
this.adbPush(mes_script_file, ADB.myTesterEventScript_file);
}
this.runSendEventScript(ADB.myTesterEventScript_file);
}
catch (IOException e) {
e.printStackTrace();
}
}

public void adbPush(final String src, final String dst) {
System.out.println("adb push: " + src + "to " + dst);
try {
ADB.mDevice.pushFile(src, dst);
}
catch (SyncException e) {
e.printStackTrace();
}
catch (IOException e2) {
e2.printStackTrace();
}
catch (AdbCommandRejectedException e3) {
e3.printStackTrace();
}
catch (TimeoutException e4) {
e4.printStackTrace();
}
}

private class CollectingOutputReceiver extends MultiLineReceiver
{
private StringBuffer mOutputBuffer;

private CollectingOutputReceiver() {
this.mOutputBuffer = new StringBuffer();
}

public String getOutput() {
return this.mOutputBuffer.toString();
}

public void processNewLines(final String[] lines) {
for (final String line : lines) {
this.mOutputBuffer.append(line);
this.mOutputBuffer.append("\n");
}
}

public boolean isCancelled() {
return false;
}
}

public class FileOutputReceiver extends MultiLineReceiver
{
private StringBuffer mOutputBuffer;

public FileOutputReceiver() {
this.mOutputBuffer = new StringBuffer();
}

public void getOutputToFile() {
if (ADB.isStartNewLogFile) {
ADB.this.file_location = String.valueOf(Paths.get("", new String[0]).toAbsolutePath().toString()) + File.separator + new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + "_events.mel";
System.out.println("New logging");
}
try {
final FileWriter fw = new FileWriter(ADB.this.file_location, true);
fw.write(this.mOutputBuffer.toString());
fw.close();
System.out.println("Written to file " + ADB.this.file_location);
}
catch (IOException e) {
System.out.println("Cant open file in this location: " + ADB.this.file_location);
e.printStackTrace();
}
}

public void processNewLines(final String[] lines) {
for (final String line : lines) {
this.mOutputBuffer.append(line);
this.mOutputBuffer.append("\n");
}
}

public boolean isCancelled() {
return ADB.isLogCancelled;
}
}
}
 
ok I see, I'll have a lot here in a bit. thank
 
Back
Top