Dump input device file using getevent tool on Android
I have a rooted Android 7 phone and I would like to dump unix input event files. Using adb I could do it using the following command:
adb shell getevent -t /dev/input/event7 > recorded_touch_events.txt
This will dump the event7 file into recorded_touch_events.txt. But this only works when the phone is connected by usb cable with the PC. Using Android I can dump files with the following code:
th = new Thread(new Runnable(){
private Process exec;
@Override
public void run() {
try {
exec = Runtime.getRuntime().exec(new String{"su","-c","getevent -t /dev/input/event7"});
InputStreamReader is = new InputStreamReader(
exec.getInputStream());
String s;
BufferedReader br = new BufferedReader(is);
while(((s = br.readLine()) != null) && run){
// write line to text file
}
is.close();
exec.destroy();
} catch (IOException e) {
e.printStackTrace();
}
}
In this way, I could store every read line in a text file.
Are there other approaches (probably faster ones) for directly dumping the event file?
android unix adb
add a comment |
I have a rooted Android 7 phone and I would like to dump unix input event files. Using adb I could do it using the following command:
adb shell getevent -t /dev/input/event7 > recorded_touch_events.txt
This will dump the event7 file into recorded_touch_events.txt. But this only works when the phone is connected by usb cable with the PC. Using Android I can dump files with the following code:
th = new Thread(new Runnable(){
private Process exec;
@Override
public void run() {
try {
exec = Runtime.getRuntime().exec(new String{"su","-c","getevent -t /dev/input/event7"});
InputStreamReader is = new InputStreamReader(
exec.getInputStream());
String s;
BufferedReader br = new BufferedReader(is);
while(((s = br.readLine()) != null) && run){
// write line to text file
}
is.close();
exec.destroy();
} catch (IOException e) {
e.printStackTrace();
}
}
In this way, I could store every read line in a text file.
Are there other approaches (probably faster ones) for directly dumping the event file?
android unix adb
add a comment |
I have a rooted Android 7 phone and I would like to dump unix input event files. Using adb I could do it using the following command:
adb shell getevent -t /dev/input/event7 > recorded_touch_events.txt
This will dump the event7 file into recorded_touch_events.txt. But this only works when the phone is connected by usb cable with the PC. Using Android I can dump files with the following code:
th = new Thread(new Runnable(){
private Process exec;
@Override
public void run() {
try {
exec = Runtime.getRuntime().exec(new String{"su","-c","getevent -t /dev/input/event7"});
InputStreamReader is = new InputStreamReader(
exec.getInputStream());
String s;
BufferedReader br = new BufferedReader(is);
while(((s = br.readLine()) != null) && run){
// write line to text file
}
is.close();
exec.destroy();
} catch (IOException e) {
e.printStackTrace();
}
}
In this way, I could store every read line in a text file.
Are there other approaches (probably faster ones) for directly dumping the event file?
android unix adb
I have a rooted Android 7 phone and I would like to dump unix input event files. Using adb I could do it using the following command:
adb shell getevent -t /dev/input/event7 > recorded_touch_events.txt
This will dump the event7 file into recorded_touch_events.txt. But this only works when the phone is connected by usb cable with the PC. Using Android I can dump files with the following code:
th = new Thread(new Runnable(){
private Process exec;
@Override
public void run() {
try {
exec = Runtime.getRuntime().exec(new String{"su","-c","getevent -t /dev/input/event7"});
InputStreamReader is = new InputStreamReader(
exec.getInputStream());
String s;
BufferedReader br = new BufferedReader(is);
while(((s = br.readLine()) != null) && run){
// write line to text file
}
is.close();
exec.destroy();
} catch (IOException e) {
e.printStackTrace();
}
}
In this way, I could store every read line in a text file.
Are there other approaches (probably faster ones) for directly dumping the event file?
android unix adb
android unix adb
asked Nov 12 at 17:40
machinery
1,59232650
1,59232650
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
getevent
is used to print input events out in human readable form. For example during interactive debug session. You do not need to use getevent
for just dumping or any other computer processing task. Just open and read the input file. The event record format is very simple.
Is it true that the event record file will be newly created (i.e. blank file) after restarting the device? So what I assume that you propose is just dumping the event record file before restarting the phone. Can I use afterwards getevent on the dumped file?
– machinery
Nov 13 at 9:33
The input event file is not a regular file (like all other files under/dev
). You can not just copy it before restarting the phone - you need to be reading it at the time of the input event occurring in order to capture it (the same as when usinggetevent
by the way).
– Alex P.
Nov 13 at 13:38
Thanks for the answer. Is directly dumping /dev/input/event7 faster than also applying getevent? If I directly dump /dev/input/event7, how can I afterwards transform the records into a format as I would get when applying getevent?
– machinery
Dec 10 at 22:24
add a comment |
Certainly No, you are doing it right.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267396%2fdump-input-device-file-using-getevent-tool-on-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
getevent
is used to print input events out in human readable form. For example during interactive debug session. You do not need to use getevent
for just dumping or any other computer processing task. Just open and read the input file. The event record format is very simple.
Is it true that the event record file will be newly created (i.e. blank file) after restarting the device? So what I assume that you propose is just dumping the event record file before restarting the phone. Can I use afterwards getevent on the dumped file?
– machinery
Nov 13 at 9:33
The input event file is not a regular file (like all other files under/dev
). You can not just copy it before restarting the phone - you need to be reading it at the time of the input event occurring in order to capture it (the same as when usinggetevent
by the way).
– Alex P.
Nov 13 at 13:38
Thanks for the answer. Is directly dumping /dev/input/event7 faster than also applying getevent? If I directly dump /dev/input/event7, how can I afterwards transform the records into a format as I would get when applying getevent?
– machinery
Dec 10 at 22:24
add a comment |
getevent
is used to print input events out in human readable form. For example during interactive debug session. You do not need to use getevent
for just dumping or any other computer processing task. Just open and read the input file. The event record format is very simple.
Is it true that the event record file will be newly created (i.e. blank file) after restarting the device? So what I assume that you propose is just dumping the event record file before restarting the phone. Can I use afterwards getevent on the dumped file?
– machinery
Nov 13 at 9:33
The input event file is not a regular file (like all other files under/dev
). You can not just copy it before restarting the phone - you need to be reading it at the time of the input event occurring in order to capture it (the same as when usinggetevent
by the way).
– Alex P.
Nov 13 at 13:38
Thanks for the answer. Is directly dumping /dev/input/event7 faster than also applying getevent? If I directly dump /dev/input/event7, how can I afterwards transform the records into a format as I would get when applying getevent?
– machinery
Dec 10 at 22:24
add a comment |
getevent
is used to print input events out in human readable form. For example during interactive debug session. You do not need to use getevent
for just dumping or any other computer processing task. Just open and read the input file. The event record format is very simple.
getevent
is used to print input events out in human readable form. For example during interactive debug session. You do not need to use getevent
for just dumping or any other computer processing task. Just open and read the input file. The event record format is very simple.
edited Nov 13 at 13:01
answered Nov 13 at 2:25
Alex P.
19.8k1366117
19.8k1366117
Is it true that the event record file will be newly created (i.e. blank file) after restarting the device? So what I assume that you propose is just dumping the event record file before restarting the phone. Can I use afterwards getevent on the dumped file?
– machinery
Nov 13 at 9:33
The input event file is not a regular file (like all other files under/dev
). You can not just copy it before restarting the phone - you need to be reading it at the time of the input event occurring in order to capture it (the same as when usinggetevent
by the way).
– Alex P.
Nov 13 at 13:38
Thanks for the answer. Is directly dumping /dev/input/event7 faster than also applying getevent? If I directly dump /dev/input/event7, how can I afterwards transform the records into a format as I would get when applying getevent?
– machinery
Dec 10 at 22:24
add a comment |
Is it true that the event record file will be newly created (i.e. blank file) after restarting the device? So what I assume that you propose is just dumping the event record file before restarting the phone. Can I use afterwards getevent on the dumped file?
– machinery
Nov 13 at 9:33
The input event file is not a regular file (like all other files under/dev
). You can not just copy it before restarting the phone - you need to be reading it at the time of the input event occurring in order to capture it (the same as when usinggetevent
by the way).
– Alex P.
Nov 13 at 13:38
Thanks for the answer. Is directly dumping /dev/input/event7 faster than also applying getevent? If I directly dump /dev/input/event7, how can I afterwards transform the records into a format as I would get when applying getevent?
– machinery
Dec 10 at 22:24
Is it true that the event record file will be newly created (i.e. blank file) after restarting the device? So what I assume that you propose is just dumping the event record file before restarting the phone. Can I use afterwards getevent on the dumped file?
– machinery
Nov 13 at 9:33
Is it true that the event record file will be newly created (i.e. blank file) after restarting the device? So what I assume that you propose is just dumping the event record file before restarting the phone. Can I use afterwards getevent on the dumped file?
– machinery
Nov 13 at 9:33
The input event file is not a regular file (like all other files under
/dev
). You can not just copy it before restarting the phone - you need to be reading it at the time of the input event occurring in order to capture it (the same as when using getevent
by the way).– Alex P.
Nov 13 at 13:38
The input event file is not a regular file (like all other files under
/dev
). You can not just copy it before restarting the phone - you need to be reading it at the time of the input event occurring in order to capture it (the same as when using getevent
by the way).– Alex P.
Nov 13 at 13:38
Thanks for the answer. Is directly dumping /dev/input/event7 faster than also applying getevent? If I directly dump /dev/input/event7, how can I afterwards transform the records into a format as I would get when applying getevent?
– machinery
Dec 10 at 22:24
Thanks for the answer. Is directly dumping /dev/input/event7 faster than also applying getevent? If I directly dump /dev/input/event7, how can I afterwards transform the records into a format as I would get when applying getevent?
– machinery
Dec 10 at 22:24
add a comment |
Certainly No, you are doing it right.
add a comment |
Certainly No, you are doing it right.
add a comment |
Certainly No, you are doing it right.
Certainly No, you are doing it right.
answered Nov 12 at 18:00
Disney Program
1194
1194
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53267396%2fdump-input-device-file-using-getevent-tool-on-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown