Android operation commands

Source: Internet
Author: User

ADB (Android Debug Bridge) Description: The following commands must have the root permission to be successfully executed to quickly start the dos window to execute adb: 1. add the path of adb.exe to the system environment variable. 2. enter the C: \ WINDOWS \ system32directory directory and find cmd.exe. right-click the menu "send to"-> desktop shortcut. On the desktop, right-click "shortcut to cmd.exe"-> "properties"-> "shortcut" Page-> highlight the cursor "shortcut"-> press the custom shortcut key (for example: ctrl + Alt + Z) in any situation, press Ctrl + Alt + Z to start the dos window and execute the adb command ----------- view the device connection status series ----------- adb get-serialno to get the device ID and serial number serialNumberadb devices to query those connected to the current computer devices (including simulators and mobile phones ), output Format: [serialNumber] [state] adb get-state to view the current status of the simulator/facility. description: serial number [serialNumber]-A string created by adb. This string uses its own control port.
 
  
-
  
   
Uniquely identifies a simulator/device instance. Example of a serial number: emulator-5554 ----------- send a command to the device series ----------- adb [-d |-e |-s
   
    
]
    -D. Send the command to the usb-connected device-e. Send the command to the simulator device-s.
    
     
Send commands to a specified device, such as starting the mobile phone device shell: adb-d shell adb forward
      
      
        Publish port. You can set any port number as the request port from the host to the simulator or device. For example, adb forward tcp: 5555 tcp: 8000adb reboot restart mobile phone adb remount system partition to read/write partition adb kill-server terminate adb service process adb start-server restart adb service process adb root restart adb service adb wait -for-device: run the command to record the available jdwp information of the specified facility in the adb command server before the simulator/device connection. you can use forward jdwp:
       
         Port ing information to connect to the specified JDWP process. For example: adb forward tcp: 8000 jdwp: 472 jdb-attach localhost: 8000 adb shell am command can start the application adb shell input text
        
          Input text to the device (text box where the cursor is located) adb shell input keyevent
         
           Send a key event to the device. For example, when editing a text message, enter adb shell input text "hello" in the text box and send the key value back to Home: adb shell input keyevent 3event_code reference view/KeyEvent. in java, KEYCODE _ * public static final int KEYCODE_SOFT_LEFT = 1; public static final int KEYCODE_SOFT_RIGHT = 2; public static final int KEYCODE_HOME = 3; public static final int KEYCODE_BACK = 4; public static final int KEYCODE_CALL = 5; public static final int KEYCODE_ENDCALL = 6; ----------- installation and uninstallation series ----------- adb install [-l] [-r]
          
            -Push this package file to the device and install it ('-l' means forward-lock the app) ('-R' means reinstall the app, keeping its data) adb uninstall [-k]
           
             -Remove this app package from the device ('-k' means keep the data and cache directories) such as: adb install d: \ hello.apk adb unstall com. huawei. hello Note: if the "-r" option is used to reinstall the apk, it is installed in the/data/local/tmp/directory. After the phone is restarted, the original apk is used. ----------- file operation series ----------- adb push
             
             
               -Copy file/dir to deviceadb pull
               
               
                 -Copy file/dir from device ----------- basic linux shell command series ----------- adb shell [command] ls list files and folders under the directory cd switch directory rm Delete directory and file cat View file Content ps you can view the process and run ps-x [PID] to view the status of a single process. You can see that the maximum usage of that process is su switched to the root user kill [pid] To kill a process chmod 777.
                
                  You can log on to a Linux server and view the help manual in shell. man
                 ----------- Viewing system status and Information Series ----------- adb shell procrank query memory usage of various processes adb shell service list View services Information adb shell cat/proc/meminfo view current memory situation adb shell cat/ proc/cpuinfo view CPU information (hardware) adb shell cat/proc/iomem view IO memory partition adb shell getprop list all system attributes adb shell getprop | findstr "gsm" list attributes containing gsm adb shell setprop
                  
                  
                    Modify the system attribute adb shell sqlite3 and execute SQL statements to view database information. The specific usage is to be investigated --------- Log Series --------- adb logcat [
                   
                     ]-View device log1 ~~~~~~~~~~~ View available log Buffer: adb logcat-B radio-view information about the buffer. adb logcat-B events-view the Event-related buffer. adb logcat-B main-view major log buffer zone 2 ~~~~~~~~~~~ Filter log output: the filter statement describes the tag in the following format: priority ..., tag indicates a label, and priority indicates the lowest level of the label report. adb logcat *: W indicates that the priority is warning or higher. log information adb logcat ActivityManager: I MyApp: D *: the S log label is a brief identifier of the original information of the system component. (For example, "View" is to View the system tag ). the priority has the following sets, which are arranged smoothly from low to high: V-Verbose (lowest priority) D-DebugI-InfoW-WarningE-ErrorF-FatalS-Silent (highest priority, on which nothing is ever printed) If you run logcat on your computer, you can also set the environment variable ANDROID_LOG_TAGS for the remote adbshell: enter a parameter to set the default Filter export ANDROID_LOG_TAGS = "ActivityManager: I MyApp: D *: S "Note that if the ANDROID_LOG_TAGS filter runs logcat through a remote shell or runs the simulator/device using the adb shell logcat, logs cannot be output. 3 ~~~~~~~~ ~~~ Control log output format: log information includes many metadata fields, including tags and priorities. You can modify the log output format to display a specific metadata domain. You can use the-v option to obtain information about formatted output logs. brief-Display priority/tag and PID of originating process (the default format ). process-Display PID only. tag-Display the priority/tag only. thread-Display process: thread and priority/tag only. raw-Display the raw log message, with no other metadata fields. time-Display the date, invocation time, priority/tag, and PID of the originating process. long-Display all metadata fields and separate messages with a blank lines. when logcat is started, you can use the-v option to specify the output format: [adb] logcat [-v
                    
                      ] The following is the log format generated using thread: the adb logcat-v thread must be noted that you only have the-v option to specify the output format option.4 ~~~~~~~~~~~ Logcat command list-B
                     
                       Load an available log buffer for viewing, such as event and radio. The default value is main. For details, see Viewing Alternative Log Buffers.-c to clearly view the Log on the screen.-d to output the Log to the screen.-f
                      
                        Specify
                       
                         By default, it is the specified log buffer output by stdout.-g, and exits after the output.-n
                        
                          Set the maximum number of logs
                         
                           . The default value is 4, which must be used with the-r option. -R
                          
                            Each
                           
                             The default value is 16. You must use.-s with the-f option to set the default filtering level to silent.-v.
                            
                              Set the log input format. The default format is brief. You Need To Know More supported formats, see Controlling Log Output Format adb bugreport-return all information from the device that shocould be stored in a bug report. adb shell dmesg queries information about the kernel buffer adb shell dumpstate, such as process information, memory information, and whether the process is abnormal, the log of the kernnel and other adb shell dumpcrashadb shell dumpsys queries the status of all services ----------- other --------- the simulator uses the image sdcard to use the mksdcard tool in the SDK to create a FAT32 disk image and load it when the simulator starts. Create an image like this :? Mksdcard
                              
                              
                                For example, if I want to create a 64 m SD card simulated file, the file path is in D: \ workspace \ sdcard. img mksdcard 64000000 D: \ workspace \ sdcard. imgEmulator-sdcard D: \ workspace \ sdcard. img or configure the startup parameters in the open run dialog box of the eclipse run menu. # Top Usage: top [-m max_procs] [-n iterations] [-d delay] [-s sort_column] [-t] [-h]-m num Maximum number of processes to display. -n num Updates to show before exiting. -d num Seconds to wait between updates. -s col Column to sort by (cpu, vss, rss, thr ). -t Show threads instead of processes. -h Display this help screen. * ******** simple selection ********************** selection by list ** * *****-A all processes-C by command name-N negate selection-G by real group ID (supports names) -a all w/tty handle T session leaders-U by real user ID (supports names) -d all privileges t session leaders-g by session OR by valid tive group name-e all processes-p by process IDT all processes on this terminal-s processes in the sessions givena all w/tty, including other users-t by ttyg OBSOLETE -- D O not use-u by valid tive user ID (supports names) r only running processes U processes for specified usersx processes w/o controlling ttys t by tty *********** output format ********* * *********** long options *************-o, o user-defined-f full -- Group -- User -- pid -- cols -- ppid-j, j job control s signal -- group -- user -- sid -- rows -- info-O, O preloaded-o v virtual memory -- cumulative -- format -- d Eselect-l, l long u user-oriented -- sort -- tty -- forest -- version-F extra full X registers -- heading -- no-heading -- context ********* misc options * * *******-V, V show version L list format codes f ASCII art forest-m, m,-L,-T, H threads S children in sum-y change-l format-M, Z security data c true command name-c scheduling class-w, w wide output n numeric WCHAN, UID-H process hierarchynetstat-ano view Network The network connection status displays the Protocol statistics and the current TCP/IP network connection. NETSTAT [-a] [-B] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval ]-a displays all connection and listening ports. -B shows the executable components that contain each connection or listening port. In some cases, it is known that the executable component has multiple independent components, and in these cases, the component sequence that includes creating a connection or listening port is displayed. In this case, the executable component name is in the [] at the bottom, and the component called by the component is at the top until the TCP/IP part. Note that this option may take a long time and may fail if you do not have sufficient permissions. -E displays Ethernet statistics. This option can be combined with the-s option. -N: the address and port number are displayed in numbers. -O displays the ID of the process associated with each connection. -P proto indicates the connection of the Protocol specified by proto. proto can be one of the following protocols: TCP, UDP, TCPv6, or UDPv6. If used with the-s option to display statistics by Protocol, proto can be one of the following protocols: IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6. -R shows the route table. -S displays statistics by protocol. By default, statistics of IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6 are displayed. The-p option is used to specify a subset of default conditions. When used together with option-B, components that contain connection or listening ports are displayed for All executable components. Interval re-displays the selected statistics. The pause interval between each display (in seconds ). Press CTRL + C to stop displaying statistics again. If omitted, netstat displays the current configuration information (only once) pmusage: pm [list | path | install | uninstall] pm list packages [-f] pm list permission-groups pm list permissions [-g] [-f] [-d] [-u] [GROUP] pm list instrumentation [-f] [TARGET-PACKAGE] pm list features pm path PACKAGE pm install [-l] [-r] [-t] [-I INSTALLER_PACKAGE_NAME] PATH pm uninstall [-k] PACKAGE pm enable PACKAGE_OR_COMPONENT pm disable PACKAGE_OR_COMPONENTThe list Packages command prints all packages. options:-f: see their associated file. the list permission-groups command prints all knownpermission groups. the list permissions command prints all knownpermissions, optionally only those in GROUP. options:-g: organize by group. -f: print all information. -s: short summary. -d: only list dangerous permissions. -u: list only the permissions users will see. the List instrumentation command prints all instrumentations, or only those that target a specified package. options:-f: see their associated file. the list features command prints all features of the system. the path command prints the path to. apk of a package. the install command installa package to the system. options:-l: install the package with FORWARD_LOCK. -r: reinstall an exisiting app, Keeping its data. -t: allow test. apks to be installed. -I: specify the installer package name. the uninstall command removes a package from the system. options:-k: keep the data and cache directories around. after the package removal. the enable and disable commands change the enabled state ofa given package or component (written as "package/class "). check whether stdout and stderr are in the default status. The Android system has stdout and stderr (System. out and System. err) output to/dev/null. In the process of running Dalvik VM, a System can back up log files. In this case, the system uses stdout and stderr and priority I. to record the log information. In this way, specify the output path, stop the running simulator/device, and remotely enter the log by using the setprop command $ adb shell stop $ adb shell setprop log. redirect-stdio true $ adb shell start system is retained until you disable the simulator/device. You can add/data/local. prop can use the default UI/software test program Monkey on the simulator/device. When the Monkey program is running on the simulator or device, when a gesture or a system-level event occurs, it generates a random pulse, so you can use Monkey to load the software you developed with a random repetition method. the simplest method is to use the following command to use Monkey. This command will start your software and trigger 500 events. $ adb shell monkey-v-p your. package. for more information about the Monkey command in name 500, you can view the UI/Application Exerciser Monkey documentation page.
                              
                             
                            
                           
                          
                         
                        
                       
                      
                     
                    
                   
                  
                 
                
               
              
             
            
           
          
         
        
       
      
     
    
   
  
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.