-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
182 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# Android GetEvent | ||
# Android GetEvent V2 | ||
|
||
[English](README_en.md) | [中文](README.md) | ||
|
||
**通过Shizuku权限,读取触摸屏事件示例** [下载演示APP](https://github.com/lalakii/get_event/releases/) | ||
|
||
读取到的数据还需要解析,我只实现到这一步,有功能需求自行完善。 | ||
|
||
<img src="./video/demo.gif" width="300"/> | ||
<img src="./video/demo_v2.gif" width="300"/> | ||
|
||
## By lalaki.cn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# Android GetEvent | ||
# Android GetEvent V2 | ||
|
||
[中文](README.md) | [English](README_en.md) | ||
|
||
**Example of reading touch screen events with Shizuku privileges** [Download Sample App](https://github.com/lalakii/get_event/releases/) | ||
|
||
The read data still need to be parsed, I have only completed to this point, there are functional requirements to improve their own. | ||
|
||
<img src="./video/demo.gif" width="300"/> | ||
<img src="./video/demo_v2.gif" width="300"/> | ||
|
||
## By lalaki.cn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
app/src/main/aidl/cn/lalaki/touch_event/IGetEventService.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package cn.lalaki.touch_event; | ||
interface IGetEventService { | ||
void destroy() = 16777114; | ||
void getEvent(int port) = 2; | ||
} |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
47 changes: 47 additions & 0 deletions
47
app/src/main/java/cn/lalaki/touch_event/GetEventService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package cn.lalaki.touch_event; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.net.InetAddress; | ||
import java.net.Socket; | ||
|
||
public class GetEventService extends IGetEventService.Stub implements Runnable { | ||
private boolean isServiceRunning = true; | ||
private final ProcessBuilder builder = new ProcessBuilder(); | ||
private int port; | ||
|
||
@Override | ||
public void destroy() { | ||
isServiceRunning = false; | ||
} | ||
|
||
@Override | ||
public void getEvent(int port) { | ||
this.port = port; | ||
new Thread(this).start(); | ||
} | ||
|
||
/** | ||
* @noinspection BusyWait | ||
*/ | ||
@Override | ||
public void run() { | ||
while (isServiceRunning) { | ||
try (Socket socket = new Socket(InetAddress.getLocalHost(), port)) { | ||
String[] cmdline = {"getevent", "-t"}; | ||
InputStream in = builder.command(cmdline).start().getInputStream(); | ||
OutputStream out = socket.getOutputStream(); | ||
int ch; | ||
while (isServiceRunning) { | ||
ch = in.read(); | ||
if (ch == -1) { | ||
Thread.sleep(1); | ||
} else { | ||
out.write(ch); | ||
} | ||
} | ||
} catch (IOException | InterruptedException ignored) { | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.