Android

字数 1337 · 2020-07-06

#android

Debug

multi device

1
2
adb devices
adb -s 192.168.56.107:5555 shell

wireless

Android 11+

developer options > Enable Wireless debugging

adb pair ipaddr:port

adb connect ipaddr:port

adb disconnect

https://developer.android.com/studio/command-line/adb#connect-to-a-device-over-wi-fi-android-11+

host

1
2
3
4
5
6
adb shell
mount -o rw,remount /system
vi /system/etc/hosts
mount -o ro,remount /system
nslookup your-site.com # check if it works
exit
1
2
emulator -list-avds
emulator @p3xl_29 -dns-server 172.26.222.226
1
2
3
4
emulator @p3xl_27 -writable-system
mount -o rw,remount /system
echo "172.26.202.206 my.dev.com" >> /system/etc/hosts
mount -o ro,remount /system

ip

1
2
3
4
5
# ip
ip -4 addr
# gateway
ip route get 8.8.8.8
# 8.8.8.8 via 172.26.203.254 (<- gateway) ...

versions

1
2
3
4
adb shell getprop ro.build.version.release 
# 10
adb shell getprop ro.build.version.sdk 
# 29

codename

1
2
3
4
adb shell getprop ro.product.name
#> poplar
adb shell getprop ro.product.model
#> G8341

https://www.techlatest.in/android-device-codenames/

adb

1
2
3
4
# output the package name from the current foreground app
adbcurrent() {
  adb shell "dumpsys activity activities | grep mResumedActivity" | perl -pe 's/.+(com.+?)\/.*/$1/'
}

pm

1
2
3
4
5
6
7
8
# list all packages
pm list packages
# disabled packages only
pm list packages -d
# path
pm path <package>
# dump info
pm dump <package>

dumpsys

1
2
3
4
5
# To dump all services
dumpsys

# dump specific serivce
dumpsys <SERVICE>

output struct:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Currently running services:
  # list
  # of
  # running
  # services
----------------------------
DUMP OF SERVICE wifi # service 1
# dump
# info
--------- 0.002s was the duration of dumpsys wifi, ending at: YYYY-MM-DD HH:mm:ss # time used
----------------------------
DUMP OF SERVICE user: # service 2
# dump
# info
--------- 0.003s was the duration of dumpsys user, ending at: YYYY-MM-DD HH:mm:ss # time used
----------------------------
# ...
# other
# services
# ...

battery

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Current Battery Service state:
  AC powered: true
  USB powered: false
  Wireless powered: false
  Max charging current: 850000
  Max charging voltage: 5000000
  Charge counter: 3062382
  status: 2 // [1/2/3/4/5] - [Unknown/Charging/Discharging/Notcharging/Full]
  health: 2 // 1:unknown 2:good 3:overheat 4:dead 5:overVoltage 6:unspecified 7: cold
  present: true // true 表示已安装电池
  level: 88 // 电池百分比
  scale: 100 // maximum value of level
  voltage: 4229 // 电池电压 4.229V
  temperature: 290 // 电池温度 29 摄氏度
  technology: Li-ion
1
2
3
4
5
6
# 设置电池为充电状态
adb shell dumpsys battery set status 2
# 恢复实际状态
adb shell dumpsys battery reset
# 设置电量百分比为 0(会导致手机关机)
adb shell dumpsys battery set level 0

package

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Database versions:
  // ...

Verifiers:
  // ...

Intent Filter Verifier:
  // ...

Libraries:
  //...

Features:
  android.hardware.sensor.proximity
  android.hardware.sensor.accelerometer
  // ...

Activity Resolver Table:
  Full MIME Types:
    // ...
  Base MIME Types:
    // ...
  Wild MIME Types:
    // ...
  Schemes:
    // ...
  Non-Data Actions:
    // ...
  MIME Typed Actions:
    // ...
Receiver Resolver Table:
  // ...
Service Resolver Table:
  // ...
Provider Resolver Table:
  // ...
Preferred Activities User 0:
  // ...
App verification status:
  // ...
App linkages for user 0:
  // ...
Permissions:
  // ...
AppOp Permissions:
  // ...
  AppOp Permission android.permission.PACKAGE_USAGE_STATS:
    // ...
  // ...
Registered ContentProviders:
  // ...
ContentProvider Authorities:
  // ...
Key Set Manager:
  // ...
Packages:
  // ...
Hidden system packages:
  // ...
Queries:
  // ...
Shared users:
  // ...
Package Changes:
  // ...
Frozen packages:
  // ...
Loaded volumes:
  // ...
Service permissions:
  // ...
Dexopt state:
  // ...
Compiler stats:
  // ...
Settings parse messages:
// ...

Package warning messages:
// ...

// ...

APEX session state:
  // ...
Active APEX packages:
  // ...
Inactive APEX packages:
  // ...
Factory APEX packages:
  // ...

Scrcpy

Display and control your Android device.

https://github.com/Genymobile/scrcpy

apktool

jadx

jadx-gui - 直接打开 apk 即可

https://github.com/skylot/jadx

dex2jar

jd-gui

API Level

API Level Android Version
30 11
29 10
28 9
27 8.1
26 8.0
25 7.1
24 7.0
23 6.0
22 5.1
21 5.0
20 4.4W
19 4.4
18 4.3
17 4.2
16 4.1
15 4.0.3
14 4.0
13 3.2
12 3.1
11 3.0
10 2.3.3
9 2.3