初始化

This commit is contained in:
2025-07-30 13:39:32 +08:00
commit d1f2452b28
253 changed files with 32087 additions and 0 deletions

33
docs/Devtools.md Normal file
View File

@@ -0,0 +1,33 @@
# Devtools
Forward and proxy a WebKit debug-socket from an android device to your browser
## How it works
### Server
1. Find devtools sockets: `adb shell 'grep -a devtools_remote /proc/net/unix'`
2. For each socket request `/json` and `/json/version`
3. Replace websocket address in response with our hostname
4. Combine all data and send to a client
### Client
Though each debuggable page explicitly specifies `devtoolsFrontendUrl` it is
possible that provided version of devtools frontend will not work in your
browser. To ensure that you will be able to debug webpage/webview, client
creates three links:
- `inspect` - this is a link provided by a remote browser in the answer for
`/json` request (only WebSocket address is changed). When this link points to
a local version of devtools (bundled with debuggable browser) you will not able
to open it, because only WebSocket forwarding is implemented at the moment.
- `bundled` - link to a version of devtools bundled with your (chromium based)
browser without specifying revision or version of the remote target. You will
get same link in the `chrome://inspect` page of Chromium browser.
e.g. `devtools://devtools/bundled/inspector.html?ws=<WebSocketAddress>`
- `remote` - link to a bundled devtools but with specified revision and version
of remote target. This link is visible only when original link in
`devtoolsFrontendUrl` contains revision. You will get same link in the
`chrome://inspect` page of Chrome browser.
e.g. `devtools://devtools/remote/serve_rev/@<Revision>/inspector.html?remoteVersion=<Version>&remoteFrontend=true&ws=<WebSocketAddress>`
**You can't open two last links with click or `open link in new tab`.**
You must copy link and open it manually. This is browser restriction.

46
docs/debug.md Normal file
View File

@@ -0,0 +1,46 @@
### Client
1. Build dev version (will include source maps):
> npm run dist:dev
2. Run from `dist` directory:
> npm run start
3. Use the browser's built-in developer tools or your favorite IDE.
### Node.js server
1. `npm run dist:dev`
2. `cd dist`
3. `node --inspect-brk ./index.js`
__HINT__: you might want to set `DEBUG` environment variable (see [debug](https://github.com/visionmedia/debug)):
> DEBUG=* node --inspect-brk ./index.js
### Android server (`scrcpy-server.jar`)
Source code is available [here](https://github.com/NetrisTV/scrcpy/tree/feature/websocket-server)
__HINT__: you might want to build a dev version.
To debug the server:
1. start node server
2. kill server from UI (click button with cross and PID number).
3. upload server package to a device:
> adb push server/build/outputs/apk/debug/server-debug.apk /data/local/tmp/scrcpy-server.jar
4. setup port forwarding:
> adb forward tcp:5005 tcp:5005
5. connect to device with adb shell:
> adb shell
6.1. for Android 8 and below run this in adb shell (single line):
> CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process -agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address=5005 / com.genymobile.scrcpy.Server 1.17-ws5 DEBUG web 8886
6.2. for Android 9 and above:
> CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process -XjdwpProvider:internal -XjdwpOptions:transport=dt_socket,suspend=y,server=y,address=5005 / com.genymobile.scrcpy.Server 1.17-ws5 web DEBUG 8886
7. Open project (scrcpy, not ws-scrcpy) in Android Studio, create `Remote` Debug configuration with:
> Host: localhost, Port: 5005
Connect the debugger to the remote server on the device.

30
docs/scheme.md Normal file
View File

@@ -0,0 +1,30 @@
```
+--------------------------+ +------------------------------+
| Android device | | Server |
| | | |
| +----------------------+ | | +--------------------------+ |
| | adb | | Run scrcpy | | adb (client) | |
| | |<---------------| | |
| | (usb/tcp) | | | | | |
| +----------------------+ | | +--------------------------+ |
| | | |
| +----------------------+ | | +--------------------------+ |
| | scrcpy | | | | nodejs | |
| | | | | | | |
----| (ws://0.0.0.0:8886/) | | | | (http://0.0.0.0:8000/) |----
| | +----------------------+ | | +--------------------------+ | |
| +--------------------------+ +------------------------------+ |
| |
| |
| |
| |
| |
| HTTP: |
| +------------------------------+ < static (html, js...)|
|Web-socket: | Client | |
|< Input events | | Web-socket: |
|> Video stream | +--------------------------+ | < Device list |
-------------------| Web-browser |-----------------------------
| +--------------------------+ |
+------------------------------+
```