您的位置:首页 > 运维架构 > Shell

ADB SHELL 你值得拥有

2016-05-28 17:53 531 查看
摘要:

ANDROID ADB很强大,记住一些ADB命令有助于提高工作效率

主要内容:

ADB Debugging:

1 adb devices(Prints a list of all attached emulator/device)

2 adb forward(forward socket connections)

usage:adb forward local remote

3 adb kill-server(terminates the adb server process)

Wireless:

1 adb connect(use ADB over Wi-Fi)

2 adb usb(restarting ADB in USB mode)

Package Manager:

1 adb install(Pushes an Android application (specified as a full path to an .apk file) to an emulator/device)

2 adb uninstall(Removes a package from the emulator/device)

3 adb shell pm list packages(Prints all packages, optionally only those whose package name contains the text in FILTER)

4 adb shell pm path(Print the path to the APK of the given PACKAGE)

usage : adb shell pm path com.android.phone

5 adb shell pm clear(Deletes all data associated with a package)

usage : adb shell pm clear com.test.abc

File Manager:

1 adb pull(Download a specified file from an emulator/device to your computer)

usage : adb pull /sdcard/demo.mp4 e:\

2 adb push(Upload a specified file from your computer to an emulator/device)

usage : adb push d:\test.apk /sdcard

3 adb shell ls(list directory contents)

4 adb shell cd(change directory)

5 adb shell rm(remove files or directories)

6 adb shell mkdir(make directories)

7 adb shell touch(create empty file or change file timestamps)

8 adb shell pwd(print current working directory location)

9 adb shell cp(copy files and directories)

10 adb shell mv(move or rename files)

Network:

1 adb shell netstat(network statistics)

2 adb shell ping(test the connection and latency between two network connection)

3 adb shell netcfg(configure and manage network connections via profiles)

4 adb shell ip(show, manipulate routing, devices, policy routing and tunnels)

Logcat:

1 adb logcat(Prints log data to the screen)

2 adb shell dumpsys(dumps system data)

usage : adb shell dumpsys battery

3 adb shell dumpstate(dumps state)

usage : adb shell dumpstate > state.logs dumps state to a file

Screenshot:

1 adb shell screencap(taking a screenshot of a device display.)

usage :

adb shell screencap /sdcard/screen.png

download the file from the device : adb pull /sdcard/screen.png

2 adb shell screenrecord(recording the display of devices running Android 4.4 (API level 19) and higher.)

usage :

adb shell screenrecord /sdcard/demo.mp4

System:

1 adb root(restarts the adbd daemon with root permissions)

2 adb sideload(flashing/restoring Android update.zip packages)

3 adb shell ps(print process status)

4 adb shell top(display top CPU processes)

5 adb shell getprop(get property via the android property service)

6 adb shell setprop(set property service)

Android_adb shell am/pm示例:

1.adb shell am start [options] INTENT

作用:启动一个activity

举例:adb shell am start -a com.lt.test.action.SECOND

举例:adb shell am start -n com.lt.test/.MyActivity

2.adb shell am startservice [options] INTENT

作用:启动一个service

举例:adb shell am startservice -a com.lt.test.action.ONESERVICE

举例:adb shell am startservice -n com.lt.test/.MyService

3.adb shell am force-stop PACKAGE

作用:强制关闭一个应用程序

举例:adb shell am force-stop com.lt.test

4.adb shell am broadcast [options] INTENT

作用:发送一个广播

举例:adb shell am broadcast -a “action_finish” (发送一个广播去关闭一个activity)

举例:adb shell am broadcast -a android.intent.action.MASTER_CLEAR(恢复出厂设置的方法,会清除内存所有内容)

5.adb shell pm list packages [options] INTENT

作用:列举出所有包含INTENT的package

举例:adb shell pm list packages com.lt

总结:

ANDROID ADB对Android自动化帮助很大,比如:

adb shell am start -n 包名/Activity


直接进入相应APP的Activity页面,不然进行一系列的前置步骤

备注:

手机中相应APP的Activity获取方法:

1.开启Activity监控:adb logcat ActivityManager:I *:s

2.手机or模拟器进行相应的页面,就可显示该页面Activity

如下图:



参考文献:

http://adbshell.com/commands/adb-shell-ls

本人利用Bootstrap + EasyUI + Django开发网站:http://www.xuyangting.com/ 欢迎来访

欢迎加QQ群 -> 阳台测试 -> 239547991(群号)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  adb-shell shell