欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何在 fedora 上进行手机投屏

程序员文章站 2022-03-04 10:08:14
ENVGoogle pixel. android 10fedora 29 x86_64 workstation1 打开 Google pixel 的 USB 调试System > Build number > Tap 7 times 打开开发者选项然后打开 USB 调试.https://www.syncios.com/android/how-to-debug-google-pixel.html2 安装 adb使用命令行工具 sdk-manager$./sdk-manager "p...

ENV

Google pixel. android 10
fedora 29 x86_64 workstation

1 打开 Google pixel 的 USB 调试

System > Build number > Tap 7 times 打开开发者选项然后打开 USB 调试.
[1] https://www.syncios.com/android/how-to-debug-google-pixel.html

2 安装 adb

使用命令行工具 sdk-manager, 需要给 --sdk_root 指定一个当前用户有权限的目录

$./sdk-manager "platform-tools" --sdk_root=/home/software/androidsdk

[1] https://developer.android.google.cn/studio?hl=zh-cn
[2] https://developer.android.google.cn/studio/releases/platform-tools?hl=zh-cn

3 使用 adb 连接手机

用 USB 连接手机和电脑

$./adb devices
List of devices attached
XXxxXxxxxxxx	no permission

解决方法:
1 . 使用 lsusb

$lsusb
...
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 023: ID 0a5c:21f3 Broadcom Corp. 
Bus 001 Device 022: ID 2717:003b  
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 066: ID MYID:myid Google Inc. 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

2 . 在 /etc/udev/rules.d/ 下新建 51-android.rules 文件.

SUBSYSTEM=="usb", ATTRS{idVendor}=="MYID", ATTRS{idProduct}=="myid",MODE="0666"

权限设置为 sudo chmod a+x 51-android.rules

这时:

$./adb devices
List of devices attached
XXxxXxxxxxxx	unauthorized

只需要在手机上确认一下就可以正常 attach 手机了。

$./adb devices
List of devices attached
XXxxXxxxxxxx	device
3 使用网络连接手机

手机和电脑在同一个局域网.
使用手机 IP, 让手机监听端口 5555

$./adb tcpip 5555
$./adb connect 192.168.1.5:5555

查看

$./adb devices
List of devices attached
XXxxXxxxxxxx	device
192.168.1.5:5555 device

然后去掉 USB

$./adb devices
List of devices attached
192.168.1.5:5555 device

[1] https://blog.csdn.net/xiaxiangnanxp1989/article/details/8605611#commentBox

4 使用投屏软件 scrcpy

安装 snap
sudo dnf install snap
从 snap 安装 scrcpy
snap install scrcpy

指定安装的 adb 路径, 运行 scrcpy。 适用 WIFI 的折衷参数 --bit-rate 2M --max-size 800

$ ADB=/home/software/androidsdk/platform-tools/adb scrcpy --bit-rate 2M --max-size 800
INFO: scrcpy 1.14 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 57.0 MB/s (33142 bytes in 0.001s)
[server] INFO: Device: Google Pixel (Android 10)
INFO: OpenGL shaders: ENABLED
INFO: Created renderer: opengl
INFO: Renderer: opengl
INFO: OpenGL version: 3.0 Mesa 19.2.8
INFO: Trilinear filtering enabled
INFO: Initial texture: 448x800

如何在 fedora 上进行手机投屏

[1] https://imcn.me/html/y2017/29579.html
[2] https://segmentfault.com/a/1190000021390826?utm_source=tag-newest
[3] https://www.cnblogs.com/it-artical/p/9898470.html
[4] https://www.genymotion.com/blog/open-source-project-scrcpy-now-works-wirelessly/
[5] https://github.com/Genymobile/scrcpy
[6] https://github.com/Genymobile/scrcpy/issues/400

本文地址:https://blog.csdn.net/ppdouble/article/details/107133550