当前位置:网站首页>ADB utility commands (network package, log, tuning related)

ADB utility commands (network package, log, tuning related)

2022-07-07 10:34:00 Zouch

background

Recently, I went on a business trip on the site of CAAC , I am responsible for sdk Development , The Bureau outsourced the integration to colleagues in Beijing sdk Development and application , Later, I found that there are some problems in the application that need to be solved . I am Party B again , Came to the bureau to analyze the problem on site , Then feedback and solve .

But later sdk It didn't move , Some optimizations are applications ( There is a memory leak ) What needs to be done , Set top box performance may also have a certain impact .

Some practical ones are available on site adb command , Record here , Convenient for myself and my classmates to use in the future .


command

- Connect to the set top box

adb connect [ The set-top box ip]

- View connected devices

adb devices

- Disconnect a set-top box

adb disconnect [ The set-top box ip]
or
adb disconnect [ Virtual machine name ]

- Disconnect all devices

adb disconnect

- obtain root jurisdiction

adb root

- Mount file system

adb remount

When you want to go to mobile devices push Show no permission when file , Try the following instructions :
adb root
adb remount

If there is a hint read-only Words , You can continue to try to execute the command :
adb root
adb disable-verity

adb reboot Restart and then adb remount that will do .

When you want to push When entering a folder under a specific path, you can use : adb shell mount -o rw,remount / route / route

notes :adb remount Is equivalent to adb shell mount -o rw,remount,rw /system

- Grab network packets

( stay cmd The directory where the window executes the command is placed tcpdump file , Used when grabbing bags )

 Insert picture description here
 Insert picture description here

adb shell tcpdump -i any -p -s 0 -w /data/data/capture.pcap

Composite key : ctrl + C You can stop capturing packets .

- Pull the network package to this computer cmd Execute the command current directory

adb pull /data/data/capture.pcap

- Delete the network package in the device

adb shell
rm /data/data/capture.pcap

- Get set-top box device information

adb shell getprop

- according to uri see contentProvider Middle table information

adb shell content query --uri [ Tabular uri]

 Example :
adb shell content query --uri content://stbauthinfo/authentication

give the result as follows :

Row: 0 _id=131, name=epg_server, value=http://183.224.21.144:33200
Row: 1 _id=132, name=refreshTime, value=915738
Row: 2 _id=133, name=licence, value=1
Row: 3 _id=134, name=Password, value=969256
Row: 4 _id=135, name=username, value=dsw1878700035901
Row: 5 _id=136, name=user_token, value=tj3kkvhyh0d4yS-StkL2k8844
Row: 6 _id=137, name=platform, value=YNYDHW
Row: 7 _id=138, name=userGroup, value=0
Row: 8 _id=139, name=platformType, value=1
Row: 9 _id=140, name=g_token, value=ee422c5fcf70dda06b3fb295d39ef8b0f5aca34ed45bcb4c
Row: 10 _id=141, name=isSW, value=0

- Open the application according to the package name and startup class name

adb shell am start -n [pkgId]/[launchClassName]

 Example :
adb shell am start -n com.utstar.smartTV/yanhua.tv.activity.Dispatcher

- Set the system parameters of application runtime

adb shell setprop [ Custom parameters  key] [ The parameter to be set corresponds to  value]

 Example :
adb shell setprop debug.ottsdk.config 1

notes : After the device restarts , The set parameter value will be invalid ; But restarting the application will not fail .

- Kill the application process according to the package name

adb shell am force-stop [pkgId]

Be careful : Sometimes it may not be successful .

Because in android8.1 In the code of the system :

if (app.persistent && !evenPersistent) {
    
// we don't kill persistent processes
continue;
}

Application android:persistent=“true”,true Don't let force-stop, Of course, the process also exists .

So if you want to force killing, you can do this : Find the application process id, And then by order kill -9 [ process id] You can force the killing process .

- The name of the process is grep Command filter output “com.gitv.tv.launcher” Information about the process

adb shell top | grep com.gitv.tv.launcher

For more related commands, please read adb shell top command .

- Empty ( eliminate )Android Medium logcat buffer

adb logcat -c

It is recommended to crawl logs , Execute the command once .
Prevent fetching redundant logs , Ensure the accuracy of log capture , It is convenient to analyze the positioning problem .

- see cpu Information

adb shell dumpsys cpuinfo

 Insert picture description here

- Check out the meminfo

adb shell cat /proc/meminfo

 Insert picture description here
The instructions are as follows :

MemTotal:         688576 kB      Total memory 
MemFree:          153736 kB      Free memory 
MemAvailable:     339884 kB      Available memory 
Buffers:              16 kB      The buffer size given to the file 
Cached:           267672 kB      Cache memory 
SwapCached:           36 kB      The size of the swap space used by the cache 
Active:           222900 kB      Cache page file size in active use 
Inactive:         123700 kB      Not often used to tell buffer memory file size 
Active(anon):      31800 kB      Active anonymous memory ( Memory allocated on the heap in the process , Yes, it is malloc Allocated memory )
Inactive(anon):    57272 kB      Inactive anonymous memory 
Active(file):     191100 kB      Active file Memory 
Inactive(file):    66428 kB     Inactive file Memory      
Unevictable:           0 kB     Memory pages that cannot be freed 
Mlocked:               0 kB    mlock() Memory size locked by system call 
SwapTotal:       2097148 kB     Total size of swap space 
SwapFree:        2096884 kB     Free swap space 
Dirty:                 0 kB     Waiting to be written back to disk size 
Writeback:             0 kB     The size being written back 
AnonPages:         78876 kB        The size of the unmapped page 
Mapped:            28556 kB     Device and file mapping size 
Shmem:             10160 kB     The size of shared memory that has been allocated 
Slab:             102916 kB     Kernel data structure cache size 
SReclaimable:      49616 kB     Recoverable slab Size 
SUnreclaim:        53300 kB     Non recyclable slab Size 
KernelStack:        4416 kB      kernel Memory consumed 
PageTables:         6028 kB       Manage the size of the index table for memory paging 
NFS_Unstable:          0 kB       Unstable page table size 
Bounce:                0 kB       Allocate a temporary... In low-end memory buffer As a jump , Copy the cache data in high-end memory to the memory consumed here 
WritebackTmp:          0 kB      USE Memory for temporary write back buffer 
CommitLimit:     2441436 kB       The total amount of memory that the system actually allocates 
Committed_AS:     308028 kB       The total amount of memory currently allocated 
VmallocTotal:   34359738367 kB    Virtual memory size 
VmallocUsed:      179588 kB     The size of virtual memory that has been used 
VmallocChunk:   34359310332 kB   malloc  The maximum logical contiguous memory size that can be allocated 
HardwareCorrupted:     0 kB       Total size of deleted memory pages ( When the system detects a hardware failure in memory )
AnonHugePages:      6144 kB       anonymous  HugePages  Number 
CmaTotal:              0 kB     Total continuous available memory 
CmaFree:               0 kB       Free continuous memory 
HugePages_Total:       0       reserve HugePages Total number of  
HugePages_Free:        0      Not yet allocated in the pool  HugePages  Number 
HugePages_Rsvd:        0         Represents the pool that has been allocated but not yet used by the application  HugePages  Number 
HugePages_Surp:        0       It's worth saying that when you start to configure 20 A big page , Now change the configuration to 16, Then this parameter will be displayed as 4, Generally, the configuration is not modified , The values are all 0
Hugepagesize:       2048 kB      The size of each large page 
DirectMap4k:      108416 kB    mapping TLB by 4kB The amount of memory 
DirectMap2M:      940032 kB    mapping TLB by 2M The amount of memory 
DirectMap1G:           0 kB      mapping TLB by 1G The amount of memory 

- Check the power information

adb shell dumpsys battery

 Insert picture description here

- Find the applied pid

adb shell 

top | grep [pkgId]

 Insert picture description here
Number in the first column 2185 Is the process of application pid

- Check the maximum memory limit of the application

adb shell 

getprop|grep heapgrowthlimit

 Insert picture description here

- Analyze the memory information of the application ( Is there a memory leak )

adb shell

dumpsys meminfo [pkgId/pid]

 Insert picture description here

Please read more detailed usage and memory analysis instructions :adb shell dumpsys meminfo Detailed explanation .


Technology never sleeps ! See you next time !

原网站

版权声明
本文为[Zouch ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070812405569.html