android ADB SHELL常用调试指令

目录

WIFI

NFC

蓝牙Bluetooth

GPS

恢复出厂设置

查看mac地址

获取系统软件版本号

获取IMEI号

指示灯/battery charger leds

按键事件模拟


  • WIFI

打开:svc wifi enable

关闭:svc wifi disable

查看当前状态:settings get global wifi_on

搜索wifi列表

  1. svc wifi enable
  2. wpa_cli -i wlan0 -p /data/misc/wifi/sockets/
  3. scan(搜索开始标志:CTRL-EVENT-SCAN-STARTED;结束标志:CTRL-EVENT-SCAN-RESULTS)
  4. scan_result
  5. add_network(add_network会返回一个ID,这个ID用于绑定对应的SSID,比如示例的ID 0.)
  6. set_network 0 ssid "WIFI-TEST"(SSID WIFI-TEST)
  7. set_network 0 key_mgmt WPA-PSK
  8. set_network 0 psk "12345678"(设置密码12345678)
  9. set_network 0 pairwise CCMP
  10. set_network 0 group CCMP
  11. 1set_network 0 proto WPA2
  12. enable_network 0
  13. select_network 0
  14. 链接结果

<3>CTRL-EVENT-STATE-CHANGE id=0 state=3 BSSID=00:00:00:00:00:00 SSID=WIFI-TEST
<3>CTRL-EVENT-SCAN-STARTED
<3>CTRL-EVENT-SCAN-RESULTS
<3>WPS-AP-AVAILABLE
<3>Trying to associate with SSID 'WIFI-TEST'
<3>CTRL-EVENT-STATE-CHANGE id=0 state=5 BSSID=00:00:00:00:00:00 SSID=WIFI-TEST
<3>CTRL-EVENT-STATE-CHANGE id=0 state=6 BSSID=00:00:00:00:00:00 SSID=WIFI-TEST
<3>Associated with a0:63:91:6f:a0:dd
<3>CTRL-EVENT-STATE-CHANGE id=0 state=7 BSSID=a0:63:91:6f:a0:dd SSID=WIFI-TEST
<3>CTRL-EVENT-STATE-CHANGE id=0 state=8 BSSID=a0:63:91:6f:a0:dd SSID=WIFI-TEST
<3>WPA: Key negotiation completed with a0:63:91:6f:a0:dd [PTK=CCMP GTK=CCMP]
<3>CTRL-EVENT-CONNECTED - Connection to a0:63:91:6f:a0:dd completed [id=0 id_str=]
<3>CTRL-EVENT-STATE-CHANGE id=0 state=9 BSSID=a0:63:91:6f:a0:dd SSID=WIFI-TEST

  • NFC

打开:svc nfc enable

关闭:svc nfc disable

  • 蓝牙Bluetooth

打开

service call bluetooth_manager 6

settings put global bluetooth_on 1

关闭

service call bluetooth_manager 8

settings put global bluetooth_on 0

查看当前状态(打开或者关闭)

settings get global bluetooth_on

  • GPS

打开:settings put secure location_providers_allowed +gps

关闭:settings put secure location_providers_allowed -gps

获取状态:settings get secure location_providers_allowed

结果为gps说明打开gps

  • 恢复出厂设置

adb shell am broadcast -a android.intent.action.MASTER_CLEAR

  • 查看mac地址

cat /sys/class/net/wlan0/address

  • 获取系统软件版本号

getprop | grep ro.build.display.id

  • 获取IMEI号

service call iphonesubinfo 1

  • 指示灯/battery charger leds

RED LED
亮:echo 1 > /sys/class/leds/red/brightness
灭:echo 0 > /sys/class/leds/red/brightness

GREEN LED
亮:echo 1 > /sys/class/leds/green/brightness
灭:echo 0 > /sys/class/leds/green/brightness

  • 按键事件模拟

sendevent /dev/input/event4 0001 003d 00000001
sendevent /dev/input/event4 0000 0000 00000000
sendevent /dev/input/event4 0001 003d 00000000
sendevent /dev/input/event4 0000 0000 00000000

sendevent /dev/input/event4 1 114 1
sendevent /dev/input/event4 0 0 0
sendevent /dev/input/event4 1 114 0
sendevent /dev/input/event4 0 0

你可能感兴趣的:(android,adb常用指令)