Wednesday 8 October 2014

Collection of adb commands


 Here is a collection of adb commands 



1 Navigate To Home Screen  -->  "adb shell am start -a android.intent.action.MAIN -c android.intent.category.HOME"


2 Application Install  -->  "adb install TPLTRCU.apk"


3 Application Uninstall   -->  "adb uninstall com.tpltrcu"


4 To view apk properties  -->  "aapt dump badging <path-to-apk>"


5 To Remove the Default Launcher   -->  "adb shell rm        /system/app/Launcher3.apk"


6 Android Running Services  -->  "adb shell dumpsys activity services"


7 Android Version  -->  "adb shell getprop ro.build.version.release"


8 Android SDK Version  -->  "adb shell getprop ro.build.version.sdk"


9 Android properties  --> "adb shell getprop"


10 Date & Time  -->  "adb shell date"


11 Application Force-Stop  -->  "adb shell am force-stop <PACKAGE>"


12 Running Processes  -->  "adb shell ps"


13 ADB shell   -->  "adb shell"


14 Network status  -->  "adb shell netcfg"


15 To get a file  -->  "adb pull path_to_file"


16 To put a file  -->  "adb push sourcePath destinationPath"


17 To Change time Zone  -->  "adb shell setprop persist.sys.timezone "Asia/Kolkata""

        To find Time-Zone [http://en.wikipedia.org/wiki/List_of_tz_database_time_zones]

18 To take backups  -->  “adb backup -apk -shared -all”


19 To Restore  -->  “adb restore backup.ab”


20 To save logs from android   -->  “adb shell logcat > log.txt”


21 To check CPU usage  -->  “adb shell dumpsys cpuinfo”


22 To CheckMemory usage  -->  “adb shell dumpsys meminfo”


23 To Change Settings  -->  “adb shell am start -n com.android.settings/.Settings”


24 Bug Report Via ADB  -->  “adb bugreport > bug_report.txt”


25 Bug Report Parsing  -->  “java -jar chkbugreport.jar bug_report.txt”

        To get chkbugreport.jar [https://github.com/sonyxperiadev/ChkBugReport/downloads]

26 To Reboot the OS  -->  "adb shell reboot"


27 ADB Version  -->  "adb version"


28 To get Help  -->  "adb help"


29 To get Serial Number   -->  "adb get-serialno"


30 List of devices  -->  "adb devices"


31 To get running process  -->  "adb shell ps"


32 To print dump  -->  "adb shell dumpsys"


33 To start an Activity  -->  "adb shell am start PACKAGE_NAME/.ACTIVITY_NAME"


34 To save screenshot  -->  "adb shell screencap -p /mnt/image_name.png"


35 List of installed packages  -->  "adb shell pm list packages -f"


36    To make key event   -->  "adb shell input keyevent"




Logcat Options


If you want to control the format of each log entry is dumped, you need to use the "adb logcat -v <format>" option, which supports the following formats:


37    Display priority/tag and the PID of process issuing the message (the default format)  -->  "adb logcat -v     brief"


38    Display PID only  -->  "adb logcat -v process"


39    Display the priority/tag only   -->  "adb logcat -v tag" 


40    Display the raw log message, with no other metadata fields  -->  "adb logcat -v raw" 


41    Display the date, invocation time, priority/tag, and PID of the process issuing the message  -->  "adb logcat -v time"


42    Display the priority, tag, and the PID and TID of the thread issuing the message  -->  "adb logcat -v thread"


43    Display the date, invocation time, priority, tag, and the PID and TID of the thread issuing the message  

  -->"adb logcat -v threadtime"

 44   Display all metadata fields and separate messages with a blank lines  -->  "adb logcat -v long"



Key codes for adb command "input keyevent"


0 -->  "KEYCODE_UNKNOWN" 

1 -->  "KEYCODE_MENU" 
2 -->  "KEYCODE_SOFT_RIGHT" 
3 -->  "KEYCODE_HOME" 
4 -->  "KEYCODE_BACK" 
5 -->  "KEYCODE_CALL" 
6 -->  "KEYCODE_ENDCALL" 
7 -->  "KEYCODE_0" 
8 -->  "KEYCODE_1" 
9 -->  "KEYCODE_2" 
10 -->  "KEYCODE_3" 
11 -->  "KEYCODE_4" 
12 -->  "KEYCODE_5" 
13 -->  "KEYCODE_6" 
14 -->  "KEYCODE_7" 
15 -->  "KEYCODE_8" 
16 -->  "KEYCODE_9" 
17 -->  "KEYCODE_STAR" 
18 -->  "KEYCODE_POUND" 
19 -->  "KEYCODE_DPAD_UP" 
20 -->  "KEYCODE_DPAD_DOWN" 
21 -->  "KEYCODE_DPAD_LEFT" 
22 -->  "KEYCODE_DPAD_RIGHT" 
23 -->  "KEYCODE_DPAD_CENTER" 
24 -->  "KEYCODE_VOLUME_UP" 
25 -->  "KEYCODE_VOLUME_DOWN" 
26 -->  "KEYCODE_POWER" 
27 -->  "KEYCODE_CAMERA" 
28 -->  "KEYCODE_CLEAR" 
29 -->  "KEYCODE_A" 
30 -->  "KEYCODE_B" 
31 -->  "KEYCODE_C" 
32 -->  "KEYCODE_D" 
33 -->  "KEYCODE_E" 
34 -->  "KEYCODE_F" 
35 -->  "KEYCODE_G" 
36 -->  "KEYCODE_H" 
37 -->  "KEYCODE_I" 
38 -->  "KEYCODE_J" 
39 -->  "KEYCODE_K" 
40 -->  "KEYCODE_L" 
41 -->  "KEYCODE_M" 
42 -->  "KEYCODE_N" 
43 -->  "KEYCODE_O" 
44 -->  "KEYCODE_P" 
45 -->  "KEYCODE_Q" 
46 -->  "KEYCODE_R" 
47 -->  "KEYCODE_S" 
48 -->  "KEYCODE_T" 
49 -->  "KEYCODE_U" 
50 -->  "KEYCODE_V" 
51 -->  "KEYCODE_W" 
52 -->  "KEYCODE_X" 
53 -->  "KEYCODE_Y" 
54 -->  "KEYCODE_Z" 
55 -->  "KEYCODE_COMMA" 
56 -->  "KEYCODE_PERIOD" 
57 -->  "KEYCODE_ALT_LEFT" 
58 -->  "KEYCODE_ALT_RIGHT" 
59 -->  "KEYCODE_SHIFT_LEFT" 
60 -->  "KEYCODE_SHIFT_RIGHT" 
61 -->  "KEYCODE_TAB" 
62 -->  "KEYCODE_SPACE" 
63 -->  "KEYCODE_SYM" 
64 -->  "KEYCODE_EXPLORER" 
65 -->  "KEYCODE_ENVELOPE" 
66 -->  "KEYCODE_ENTER" 
67 -->  "KEYCODE_DEL" 
68 -->  "KEYCODE_GRAVE" 
69 -->  "KEYCODE_MINUS" 
70 -->  "KEYCODE_EQUALS" 
71 -->  "KEYCODE_LEFT_BRACKET" 
72 -->  "KEYCODE_RIGHT_BRACKET" 
73 -->  "KEYCODE_BACKSLASH" 
74 -->  "KEYCODE_SEMICOLON" 
75 -->  "KEYCODE_APOSTROPHE" 
76 -->  "KEYCODE_SLASH" 
77 -->  "KEYCODE_AT" 
78 -->  "KEYCODE_NUM" 
79 -->  "KEYCODE_HEADSETHOOK" 
80 -->  "KEYCODE_FOCUS" 
81 -->  "KEYCODE_PLUS" 
82 -->  "KEYCODE_MENU" 
83 -->  "KEYCODE_NOTIFICATION" 
84 -->  "KEYCODE_SEARCH" 
85 -->  "TAG_LAST_KEYCODE"