forked from webadb/webadb.js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.html
56 lines (47 loc) · 1.26 KB
/
test.html
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
48
49
50
51
52
53
54
55
56
<html>
<head>
<script src="./webadb.js"></script>
<script>
let adb;
let webusb;
let init = async () => {
webusb = await Adb.open("WebUSB");
};
let connect = async () => {
if (webusb.isAdb()) {
try {
adb = null;
adb = await webusb.connectAdb("host::", () => {
console.log("Please check the screen of your " + webusb.device.productName + ".");
});
}
catch(error) {
console.error(error);
adb = null;
}
}
};
let disconnect = async () => {
webusb.close();
};
let pull = async (filename) => {
let sync = await adb.sync();
let content = await sync.pull(filename);
await sync.quit();
return content;
};
let test = async () => {
await init();
await connect();
let data = await pull('/sdcard/Movies/2018-01-04-21-17-20.mp4');
let a = document.createElement('a')
a.href = URL.createObjectURL(new Blob([data]));
a.download = "2018-01-04-21-17-20.mp4";
a.click();
await disconnect();
};
</script>
</head>
<body>
</body>
</html>