adb/shell команды

всё относительно мобильных гаджетов и приложений

Модераторы: Olej, adminn, vikos

Правила форума
Все сообщения не по теме форума будут, без каких либо уведомлений, удаляться, а их авторы - убираться из регистрации.
Язык сообщений - исключительно русский.
Аватара пользователя
Olej
Писатель
Сообщения: 21338
Зарегистрирован: 24 сен 2011, 14:22
Откуда: Харьков
Контактная информация:

adb/shell команды

Непрочитанное сообщение Olej » 28 мар 2017, 16:22

Всякие полезные возможности по USB подключению...

Код: Выделить всё

[olej@dell 26]$ export ANDROID_SERIAL=0123456789ABCDEF

[olej@dell 26]$ echo $ANDROID_SERIAL
0123456789ABCDEF

[olej@dell 26]$ adb shell ls -l /sdcard/*
drwxrwx--x root     sdcard_r          2017-02-27 14:59 app
-rw-rw---- root     sdcard_r        0 2016-11-22 20:35 c487313678cbcbde
...
и т.д.

Аватара пользователя
Olej
Писатель
Сообщения: 21338
Зарегистрирован: 24 сен 2011, 14:22
Откуда: Харьков
Контактная информация:

Re: adb/shell команды

Непрочитанное сообщение Olej » 28 мар 2017, 16:28

Скриншот экрана Android в любое время (очень нужно для иллюстраций):

Код: Выделить всё

[olej@dell 26]$ adb shell screencap -p /sdcard/1.png
Теперь перегружаем сохранённый файл в Linux:

Код: Выделить всё

[olej@dell 28]$ adb pull /sdcard/1.png
[100%] /sdcard/1.png

[olej@dell 28]$ ls -l
итого 48
-rw-r--r-- 1 olej olej 46459 мар 28 16:19 1.png
1.png

Код: Выделить всё

[olej@dell 28]$ adb shell screencap --help
screencap: invalid option -- -
usage: screencap [-hp] [-d display-id] [FILENAME]
   -h: this message
   -p: save the file as a png.
   -d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.

Аватара пользователя
Olej
Писатель
Сообщения: 21338
Зарегистрирован: 24 сен 2011, 14:22
Откуда: Харьков
Контактная информация:

Re: adb/shell команды

Непрочитанное сообщение Olej » 28 мар 2017, 16:37

Запись видео с экрана Android:

Код: Выделить всё

[olej@dell 28]$ adb shell screenrecord /sdcard/v1.mp4
The max width/height supported by codec is 1280x720
^C

[olej@dell 28]$ adb shell ls -l /sdcard/v1.mp4
-rw-rw---- root     sdcard_r  4100604 2010-01-01 03:58 v1.mp4
Перегоняем на Linux:

Код: Выделить всё

[olej@dell 28]$ adb pull /sdcard/v1.mp4
[100%] /sdcard/v1.mp4

[olej@dell 28]$ ls -l *.mp4
-rw-r--r-- 1 olej olej 4100604 мар 28 16:32 v1.mp4

[olej@dell 28]$ file v1.mp4 
v1.mp4: ISO Media, MP4 v2 [ISO 14496-14]
Вложения
v1.mp4
(3.91 МБ) 5042 скачивания
v1.png

Аватара пользователя
Olej
Писатель
Сообщения: 21338
Зарегистрирован: 24 сен 2011, 14:22
Откуда: Харьков
Контактная информация:

Re: adb/shell команды

Непрочитанное сообщение Olej » 28 мар 2017, 16:43

Olej писал(а):Запись видео с экрана Android:

Код: Выделить всё

[olej@dell 28]$ adb shell screenrecord --help
Usage: screenrecord [options] <filename>

Android screenrecord v1.2.  Records the device's display to a .mp4 file.

Options:
--size WIDTHxHEIGHT
    Set the video size, e.g. "1280x720".  Default is the device's main
    display resolution (if supported), 1280x720 if not.  For best results,
    use a size supported by the AVC encoder.
--bit-rate RATE
    Set the video bit rate, in bits per second.  Value may be specified as
    bits or megabits, e.g. '4000000' is equivalent to '4M'.  Default 4Mbps.
--bugreport
    Add additional information, such as a timestamp overlay, that is helpful
    in videos captured to illustrate bugs.
--time-limit TIME
    Set the maximum recording time, in seconds.  Default / maximum is 180.
--verbose
    Display interesting information on stdout.
--help
    Show this message.

Recording continues until Ctrl-C is hit or the time limit is reached.

Аватара пользователя
Olej
Писатель
Сообщения: 21338
Зарегистрирован: 24 сен 2011, 14:22
Откуда: Харьков
Контактная информация:

Re: adb/shell команды

Непрочитанное сообщение Olej » 28 мар 2017, 16:59

Olej писал(а):

Код: Выделить всё

[olej@dell 28]$ adb shell screencap --help
screencap: invalid option -- -
usage: screencap [-hp] [-d display-id] [FILENAME]
   -h: this message
   -p: save the file as a png.
   -d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
Непонятно, что это за IMG формат получается, если без -p или имя файла без .png:

Код: Выделить всё

[olej@dell 28]$ adb shell screencap /sdcard/1

[olej@dell 28]$ adb pull /sdcard/1
[100%] /sdcard/1

[olej@dell 28]$ file 1
1: data

[olej@dell 28]$ ls -l 1*
-rw-r--r-- 1 olej olej 2457612 мар 28 16:53 1
-rw-r--r-- 1 olej olej   46459 мар 28 16:19 1.png
Возможно это сырые (RAW) отсчёты?

Аватара пользователя
Olej
Писатель
Сообщения: 21338
Зарегистрирован: 24 сен 2011, 14:22
Откуда: Харьков
Контактная информация:

Re: adb/shell команды

Непрочитанное сообщение Olej » 28 мар 2017, 17:11

Olej писал(а):

Код: Выделить всё

[olej@dell 28]$ adb shell screencap --help
screencap: invalid option -- -
usage: screencap [-hp] [-d display-id] [FILENAME]
   -h: this message
   -p: save the file as a png.
   -d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
Непонятно, что это за IMG формат получается, если без -p или имя файла без .png:
А вот так - вывод на STDOUT, но STDOUT Linux терминала adb !:

Код: Выделить всё

[olej@dell 28]$ adb shell screencap -p > 2.png

[olej@dell 28]$ file 2.png 
2.png: data

[olej@dell 28]$ file 1.png 
1.png: PNG image data, 600 x 1024, 8-bit/color RGBA, non-interlaced
Но структура так сохранённого PNG-файла каким-то образом нарушается!

Аватара пользователя
Olej
Писатель
Сообщения: 21338
Зарегистрирован: 24 сен 2011, 14:22
Откуда: Харьков
Контактная информация:

Re: adb/shell команды

Непрочитанное сообщение Olej » 28 мар 2017, 17:18

Код: Выделить всё

[olej@dell 28]$ adb shell busybox --help
BusyBox v1.21.1 (2013-07-08 10:26:30 CDT) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2012.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

Usage: busybox [function [arguments]...]
   or: busybox --list[-full]
   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, arp, arping, ash,
	awk, base64, basename, beep, blkid, blockdev, bootchartd, brctl,
	bunzip2, bzcat, bzip2, cal, cat, catv, 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, du, dumpkmap,
	dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid, ether-wake,
	expand, expr, fakeidentd, false, fbset, fbsplash, fdflush, fdformat,
	fdisk, fgconsole, fgrep, find, findfs, flock, fold, free, freeramdisk,
	fsck, fsck.minix, fsync, ftpd, ftpget, ftpput, fuser, getopt, getty,
	grep, groups, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostid,
	hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifenslave,
	ifplugd, ifup, inetd, init, insmod, install, ionice, iostat, ip,
	ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel,
	kbd_mode, kill, killall, killall5, klogd, last, less, linux32, linux64,
	linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread,
	losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat,
	lzma, lzop, lzopcat, 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, nmeter, nohup, nslookup, ntpd, od,
	openvt, passwd, 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, rev, rm, rmdir, rmmod, route, rpm,
	rpm2cpio, rtcwake, run-parts, runlevel, runsv, runsvdir, rx, script,
	scriptreplay, sed, sendmail, seq, setarch, setconsole, setfont,
	setkeycodes, setlogcons, setserial, setsid, setuidgid, sh, sha1sum,
	sha256sum, sha3sum, sha512sum, showkey, slattach, sleep, smemcap,
	softlimit, sort, split, start-stop-daemon, stat, strings, stty, su,
	sulogin, sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl,
	syslogd, tac, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp,
	tftpd, time, timeout, top, touch, tr, traceroute, traceroute6, true,
	tty, ttysize, tunctl, udhcpc, udhcpd, udpsvd, umount, uname, unexpand,
	uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, users, usleep,
	uudecode, uuencode, vconfig, vi, vlock, volname, wall, watch, watchdog,
	wc, wget, which, who, whoami, whois, xargs, xz, xzcat, yes, zcat, zcip
Это реализация внутренней команды busybox:

Код: Выделить всё

[olej@dell 28]$ adb shell busybox ifconfig --help
BusyBox v1.21.1 (2013-07-08 10:26:30 CDT) multi-call binary.

Usage: ifconfig [-a] interface [address]

Configure a network interface

	[add ADDRESS[/PREFIXLEN]]
	[del ADDRESS[/PREFIXLEN]]
	[[-]broadcast [ADDRESS]] [[-]pointopoint [ADDRESS]]
	[netmask ADDRESS] [dstaddr ADDRESS]
	[outfill NN] [keepalive NN]
	[hw ether|infiniband ADDRESS] [metric NN] [mtu NN]
	[[-]trailers] [[-]arp] [[-]allmulti]
	[multicast] [[-]promisc] [txqueuelen NN] [[-]dynamic]
	[mem_start NN] [io_addr NN] [irq NN]
	[up|down] ...

Код: Выделить всё

[olej@dell 28]$ adb shell busybox ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:124 errors:0 dropped:0 overruns:0 frame:0
          TX packets:124 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:9974 (9.7 KiB)  TX bytes:9974 (9.7 KiB)

Код: Выделить всё

[olej@dell 28]$ adb shell busybox ifconfig -a
ccmni0    Link encap:Ethernet  HWaddr 9A:F3:85:D4:1D:6D  
          NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:8 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ccmni1    Link encap:Ethernet  HWaddr B6:AD:8B:7A:41:78  
          NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:8 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ccmni2    Link encap:Ethernet  HWaddr DE:7B:5C:9F:A6:49  
          NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:8 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ifb0      Link encap:Ethernet  HWaddr 86:8D:ED:9E:03:55  
          BROADCAST NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:32 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ifb1      Link encap:Ethernet  HWaddr 8A:3E:66:AA:97:83  
          BROADCAST NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:32 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ip6tnl0   Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          NOARP  MTU:1452  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:124 errors:0 dropped:0 overruns:0 frame:0
          TX packets:124 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:9974 (9.7 KiB)  TX bytes:9974 (9.7 KiB)

sit0      Link encap:IPv6-in-IPv4  
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

tunl0     Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          NOARP  MTU:0  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
А это - реализация той же команды, но как отдельной утилиты (исполнимого файла):

Код: Выделить всё

[olej@dell 28]$ adb shell ifconfig lo
lo: ip 127.0.0.1 mask 255.0.0.0 flags [up loopback running]

[olej@dell 28]$ adb shell busybox which ifconfig
/system/bin/ifconfig

Ответить

Вернуться в «Android»

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 4 гостя