forked from alicfeng/mobileGroupControlSystem
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAdbRecord.php
47 lines (39 loc) · 967 Bytes
/
AdbRecord.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Created by PhpStorm.
* User: alicfeng
* Date: 2018/11/25
* Time: 上午11:00
*/
class AdbRecord
{
const ADB_PATH = '/usr/local/bin/adb';
private $device = null;
public function __construct($device)
{
$this->device = $device;
}
public function record()
{
$descriptorspec = array(
0 => STDIN,
1 => STDOUT,
2 => STDERR
);
$command = self::ADB_PATH . ' -s ' . $this->device . ' shell getevent';
$process = proc_open($command, $descriptorspec, $pipes);
var_dump($pipes);
if (is_resource($process)) {
// fwrite($pipes[0], 'content');
while ($ret = fgets($pipes[1])) {
echo '' . $ret;
}
while ($ret = fgets($pipes[2])) {
echo '' . $ret;
}
}
// pclose($process);
}
}
$h = new AdbRecord('6L5D5P5PWS7SGAFA');
$h->record();