Skip to content

Instantly share code, notes, and snippets.

@saravr
Last active January 25, 2025 13:31
Show Gist options
  • Save saravr/9ea059979cb5bd96df712a96e87cb291 to your computer and use it in GitHub Desktop.
Save saravr/9ea059979cb5bd96df712a96e87cb291 to your computer and use it in GitHub Desktop.
android.tips
Increase adb buffer size
========================
adb logcat -b main -G 16M
adb logcat -g
Decode obfuscated trace
=======================
~/Library/Android/sdk/tools/proguard/bin/retrace.sh proguard.map <stacktracefile>
Doze mode
=========
adb shell dumpsys deviceidle enable
adb shell dumpsys deviceidle get light
adb shell dumpsys deviceidle get deep
adb shell dumpsys deviceidle disable
Android Auto
============
# in the phone: 1. Enable android auto developer mode
# in the phone: 2. In android auto setting, enable DHU (?)
cd ~/Library/Android/sdk/extras/google/auto
adb forward tcp:5277 tcp:5277
./desktop-head-unit
Dark/Light mode
===============
adb shell "cmd uimode night yes"
Profile HWUI rendering
======================
adb shell setprop debug.hwui.profile visual_bars
Get app details (like permissions, ...)
=======================================
adb shell dumpsys package <pkg-name>
Emulator network speed
======================
adb emu network speed gsm
adb emu network speed full
...gsm, hscsd, gprs, umts, edge, hsdpa, lte, evdo, full
Physical devices wifi on/off
============================
adb -s 17101JECB11327 shell svc wifi disable
adb -s 17101JECB11327 shell svc wifi enable
adb shell svc wifi disable
adb shell svc wifi enable
adb shell ifconfig wlan0 down # ???
adb shell ifconfig wlan0 up # ???
adb shell ping 8.8.8.8 # check connectivity
Check if my service is running
==============================
adb shell dumpsys activity services com.example.MyService | grep app=
Media
=====
adb shell dumpsys media_session
Android env clean
=================
killall java
killall gradle
killall $HOME/Library/Android/sdk/emulator/qemu/darwin-aarch64/qemu-system-aarch64
ps -ef | grep emu | cut -d" " -f4 | xargs kill -9
Screen recording / capture
==========================
adb shell screenrecord /sdcard/screenrecord.mp4
adb pull /sdcard/screenrecord.mp4
adb shell screencap /sdcard/screenshot.png
adb pull /sdcard/screenshot.png
# parameters:
# --size 1280x720
# --bit-rate 8000000 # default bit rate 4M
# --time-limit 60 # default time limit 3 mins
Install/uninstall
=================
adb uninstall -k com.example.app # -k to keep data
Connect/Wifi
============
adb shell ip route # find IP address
adb tcpip 5555
adb connect <device_ip>:5555
adb disconnect <device_ip>:5555
Grant permissions
=================
adb shell pm grant <package_name> <permission>
adb shell pm revoke <package_name> <permission>
Start/stop service
==================
adb shell am startservice com.acme.com/.BackupService
adb shell am stopservice com.acme.com/.BackupService
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment