Just because it uses Linux does not mean it is like Linux
ADB
Install apk
adb install /path/to/app.apk
Downgrade APK
adb install -d /path/to/app.apk
Install with rollback posibility
pm install --enable-rollback /path/to/app.apk
Rollback a package
pm rollback-app <package_name>
Spawn shell
adb shell
Screen recording
screenrecord /storage/self/primary/screenrecord.mp4
Screen capture
screencap /storage/self/primary/capture.png
Download file
adb pull /storage/self/primary/capture.png
Backup
adb backup -all
adb backup -apk -shared -all -f backup_file.ab
-apk
will backup all apps.-noapk
(the default) will not backup apps.-shared
will backup data from the SD card.-noshared
(the default) will not backup the SD card.-all
will backup system data and app data but not the apps themselves.
Restore
adb restore backup_file.ab
Package Manager
List all packages.
pm list packages | sort
pm list packages --show-versioncode | grep ...
Disable package
pm disable <package_name>
pm disable-user --user 0 com.samsung.android.themestore
Uninstall package
Uninstall.
pm uninstall <package_name>
pm uninstall org.mariotaku.twidere
Uninstall as root.
pm uninstall -k --user 0 <apk>
pm list packages | grep -i -E 'facebook|microsoft' | cut -f 2 -d ':' | while read -r apk ; do pm uninstall --user 0 $apk ; done
-k
: keep the data and cache directories after package removal.
Download apk from package
Get the package name. In this case org.mariotaku.twidere
.
pm list packages | grep <app>
pm list packages | grep twidere
---
package:org.mariotaku.twidere
Get the location of said package. In this case /data/app/org.mariotaku.twidere-VA1Xh4MQ6h5lLACl4imt4w==/base.apk
.
pm path org.mariotaku.twidere
---
package:/data/app/org.mariotaku.twidere-VA1Xh4MQ6h5lLACl4imt4w==/base.apk
Download the apk file. Downloads as base.apk
.
adb pull /data/app/org.mariotaku.twidere-VA1Xh4MQ6h5lLACl4imt4w==/base.apk
Listening ports
cat /proc/net/tcp
Explanation from
Decoding the data in /proc/net/tcp:
Linux 5.x /proc/net/tcp
Linux 6.x /proc/PID/net/tcp
Given a socket:
$ ls -l /proc/24784/fd/11
lrwx------ 1 jkstill dba 64 Dec 4 16:22 /proc/24784/fd/11 -> socket:[15907701]
Find the address
$ head -1 /proc/24784/net/tcp; grep 15907701 /proc/24784/net/tcp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
46: 010310AC:9C4C 030310AC:1770 01 0100000150:00000000 01:00000019 00000000 1000 0 54165785 4 cd1e6040 25 4 27 3 -1
46: 010310AC:9C4C 030310AC:1770 01
| | | | | |--> connection state
| | | | |------> remote TCP port number
| | | |-------------> remote IPv4 address
| | |--------------------> local TCP port number
| |---------------------------> local IPv4 address
|----------------------------------> number of entry
00000150:00000000 01:00000019 00000000
| | | | |--> number of unrecovered RTO timeouts
| | | |----------> number of jiffies until timer expires
| | |----------------> timer_active (see below)
| |----------------------> receive-queue
|-------------------------------> transmit-queue
1000 0 54165785 4 cd1e6040 25 4 27 3 -1
| | | | | | | | | |--> slow start size threshold,
| | | | | | | | | or -1 if the treshold
| | | | | | | | | is >= 0xFFFF
| | | | | | | | |----> sending congestion window
| | | | | | | |-------> (ack.quick<<1)|ack.pingpong
| | | | | | |---------> Predicted tick of soft clock
| | | | | | (delayed ACK control data)
| | | | | |------------> retransmit timeout
| | | | |------------------> location of socket in memory
| | | |-----------------------> socket reference count
| | |-----------------------------> inode
| |----------------------------------> unanswered 0-window probes
|---------------------------------------------> uid
timer_active:
0 no timer is pending
1 retransmit-timer is pending
2 another timer (e.g. delayed ack or keepalive) is pending
3 this is a socket in TIME_WAIT state. Not all field will contain data.
4 zero window probe timer is pending
==========================================
Perl script to decode the address
#!/usr/bin/perl
my $hexip=$ARGV[0];
my $hexport=$ARGV[1];
print "hex: $hexip\n";
my @ip = map hex($_), ( $hexip =~ m/../g );
my $ip = join('.',reverse(@ip));
my $port = hex($hexport);
print "IP: $ip PORT: $port\n";
==========================================
$ hexip.pl 030310AC 1770
hex: 030310AC
IP: 172.16.3.3 PORT: 6000
Wireless debugging in Android 11+
- Activate Settings > Developer options > Wireless debugging > Enable > Pairing code
- Pair with ip
10.0.0.2
port34567
and code000000
.
adb pair 10.0.0.2:34567 000000
- Connect. The port changes because ... android
adb connect 10.0.0.2:45678
- Change the port the device listens on (resets on reboot)
adb tcpip 5555
Seems to work wether you have USB debugging and/or Wireless debugging enabled. 5. Connect again
adb connect 10.0.0.2
Edit build.prop
Only if you are root. Source
service.adb.tls.port=5555
service.adb.tcp.port=5555
# To keep adb over wifi always on
persist.adb.tls_server.enable=1