来自 PC 的 Android phone 上的 运行 命令
Run command on Android phone from PC
我在 Andorid phone 上使用网络共享来与我的 PC 共享互联网连接。
有时我需要一个新的 IP 地址,为此我切换到飞行模式,然后禁用它并获得一个新的 IP。我正在寻找一种从我的电脑上完成这个技巧的方法。
所以我需要 运行 在我的 phone 上从我的 PC 上执行一个命令,我完全不知道该怎么做,如果我需要 root 我的 android 设备。
谢谢!
使用 ADB(无需 root)
// Open Wifi settings screen
adb shell am start -a android.settings.WIRELESS_SETTINGS
// Call key down event
adb shell input keyevent 20
// Call key click event to turn off wifi
adb shell input keyevent 23
// Key click again to turn on wifi
adb shell input keyevent 23
// Get the ip address
adb shell ip route
使用 SVC(需要 root)
// Disable Wifi
adb shell su -c 'svc wifi disable'
// Enable Wifi
adb shell su -c 'svc wifi enable'
// Get the ip address
adb shell ip route
我在 Andorid phone 上使用网络共享来与我的 PC 共享互联网连接。 有时我需要一个新的 IP 地址,为此我切换到飞行模式,然后禁用它并获得一个新的 IP。我正在寻找一种从我的电脑上完成这个技巧的方法。 所以我需要 运行 在我的 phone 上从我的 PC 上执行一个命令,我完全不知道该怎么做,如果我需要 root 我的 android 设备。
谢谢!
使用 ADB(无需 root)
// Open Wifi settings screen
adb shell am start -a android.settings.WIRELESS_SETTINGS
// Call key down event
adb shell input keyevent 20
// Call key click event to turn off wifi
adb shell input keyevent 23
// Key click again to turn on wifi
adb shell input keyevent 23
// Get the ip address
adb shell ip route
使用 SVC(需要 root)
// Disable Wifi
adb shell su -c 'svc wifi disable'
// Enable Wifi
adb shell su -c 'svc wifi enable'
// Get the ip address
adb shell ip route