Android命令行工具使用总结

前一篇:学习总结

1.手机信息获取
adb shell getprop ro.product.model //获取手机model

adb shell getprop ro.build.version.release //获取手机Android大版本

adb shell getprop ro.product.brand //获取手机厂商

2.输入法
adb shell ime list -s //获取已经安装的输入法

adb shell settings get secure default_input_method //获取当前输入法

3.应用

# dumpsys window windows | grep com.ss.android.ugc.aweme //获取apk的MainActivity窗口信息
Window #16 Window{d8dbcb u0 com.ss.android.ugc.aweme/com.ss.android.ugc.aweme.main.MainActivity}:
#
# am start -W com.ss.android.ugc.aweme/com.ss.android.ugc.aweme.main.MainActivity //启动应用,成功
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.ss.android.ugc.aweme/.main.MainActivity }
Status: ok
LaunchState: COLD

am start -W 包名/启动名
示例:
am start -W com.yly.drawpic/.MainActivity  //实测并不行!!
解释:
TotalTime:app自身启动时间
WaitTime:系统启动应用时间

4.电池
adb shell dumpsys battery unplug //断电,但是插着adb电量并不会下降。但是插着串口桌面和低电流都没有变化。

adb shell dumpsys battery set level x //设置电池电量,测试会触发x电量时的反应。

adb shell dumpsys battery reset //重置

5. 应用

# dumpsys window | grep  mCurrentFocus 获取前台应用包名和Activity

6. 查看前台包名

查看前台包名和运行的activity:# dumpsys window | grep mCurrentFocus
查看前台包名:# am monitor //实时显示

7.查看屏幕刷新率

# while(true); do dumpsys SurfaceFlinger |grep refresh-rate; sleep 1; done

8. 查看背光

# cat /sys/class/leds/lcd-backlight/brightness

9. busybox工具包

优点:集成的工具多,Arm64中适应多平台。缺点: 输入命令tab键不能自动补全

# ./busybox --help
BusyBox v1.31.0 (2019-06-10 15:54:51 CEST) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

Usage: busybox [function [arguments]...]
   or: busybox --list[-full]
   or: busybox --show SCRIPT
   or: busybox --install [-s] [DIR]
   or: function [arguments]...

        BusyBox is a multi-call binary that combines many common Unix
        utilities into a single executable.  Most people will create a
        link to busybox for each function they wish to use and BusyBox
        will act like whatever it was invoked as.

Currently defined functions:
        [, [[, acpid, add-shell, addgroup, adduser, adjtimex, arch, arp, arping, ash, awk, base64, basename, bc, beep, blkdiscard, blkid, blockdev, bootchartd, brctl, bunzip2,
        bzcat, bzip2, cal, cat, chat, chattr, chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, conspy, cp, cpio, crond, crontab, cryptpw,
        cttyhack, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, dpkg, dpkg-deb, du,
        dumpkmap, dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid, ether-wake, expand, expr, factor, fakeidentd, fallocate, false, fatattr, fbset, fbsplash, fdflush,
        fdformat, fdisk, fgconsole, fgrep, find, findfs, flock, fold, free, freeramdisk, fsck, fsck.minix, fsfreeze, fstrim, fsync, ftpd, ftpget, ftpput, fuser, getopt, getty,
        grep, groups, gunzip, gzip, halt, hd, hdparm, head, hexdump, hexedit, hostid, hostname, httpd, hush, hwclock, i2cdetect, i2cdump, i2cget, i2cset, i2ctransfer, id,
        ifconfig, ifdown, ifenslave, ifplugd, ifup, inetd, init, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, ipneigh, iproute, iprule, iptunnel,
        kbd_mode, kill, killall, killall5, klogd, last, less, link, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup, lpd, lpq, lpr,
        ls, lsattr, lsmod, lsof, lspci, lsscsi, lsusb, lzcat, lzma, lzop, makedevs, makemime, man, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mkfs.ext2,
        mkfs.minix, mkfs.vfat, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mt, mv, nameif, nanddump, nandwrite, nbd-client, nc, netstat,
        nice, nl, nmeter, nohup, nologin, nproc, nsenter, nslookup, ntpd, nuke, od, openvt, partprobe, passwd, paste, patch, pgrep, pidof, ping, ping6, pipe_progress,
        pivot_root, pkill, pmap, popmaildir, poweroff, powertop, printenv, printf, ps, pscan, pstree, pwd, pwdx, raidautorun, rdate, rdev, readahead, readlink, readprofile,
        realpath, reboot, reformime, remove-shell, renice, reset, resize, resume, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, rtcwake, run-init, run-parts, runlevel, runsv,
        runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setarch, setconsole, setfattr, setfont, setkeycodes, setlogcons, setpriv, setserial, setsid, setuidgid, sh,
        sha1sum, sha256sum, sha3sum, sha512sum, showkey, shred, shuf, slattach, sleep, smemcap, softlimit, sort, split, ssl_client, start-stop-daemon, stat, strings, stty, su,
        sulogin, sum, sv, svc, svlogd, svok, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, taskset, tc, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd,
        time, timeout, top, touch, tr, traceroute, traceroute6, true, truncate, ts, tty, ttysize, tunctl, ubiattach, ubidetach, ubimkvol, ubirename, ubirmvol, ubirsvol,
        ubiupdatevol, udhcpc, udhcpc6, udhcpd, udpsvd, uevent, umount, uname, unexpand, uniq, unix2dos, unlink, unlzma, unshare, unxz, unzip, uptime, users, usleep, uudecode,
        uuencode, vconfig, vi, vlock, volname, w, wall, watch, watchdog, wc, wget, which, who, whoami, whois, xargs, xxd, xz, xzcat, yes, zcat, zcip

 

posted on 2020-04-25 22:05  Hello-World3  阅读(1276)  评论(0编辑  收藏  举报

导航