Skip to content

Latest commit

 

History

History
298 lines (251 loc) · 10.1 KB

File metadata and controls

298 lines (251 loc) · 10.1 KB

Android development cheat sheet

multiplatform apps from a single codebase

connect phone to a computer ( Linux )

for reading links like: mtp://motorola_moto_g52_xxxxxx Settings -> Connected devices -> USB

  • Use USB for: File Transfer
  • Optional: USB controlled by connected device

PC software for managing Android device

Odin

Odin for Linux

  1. install heimdall
    ubuntu_version=$(lsb_release -rs | cut -d. -f1)
    if [ "$ubuntu_version" -ge 22 ]; then 
        sudo apt install heimdall-flash heimdall-flash-frontend
        heimdall print-pit
    fi
  2. download release of JOdin3 and run JOdin3CASUAL
    soft; mkdir odin3; cd odin3
    wget https://github.com/GameTheory-/jodin3/releases/download/v1.0/Jodin3.zip
    unzip Jodin3.zip
    ls -la Jodin3/JOdin3CASUAL

Android Debug Bridge creates a connection (bridge) between the device and computer. should be activated:

  1. developer mode Settings -> About phone -> build number -> type 5 times on it
  2. USB debug Settings -> find word "develop" -> activate "USB debugging"

adb install via Debian APT

sudo apt -y install adb
adb version
adb devices

copy files

adb push test.apk /sdcard
adb pull /sdcard/demo.mp4 e:\

restart device in recovery mode

adb reboot
adb reboot recovery

list of all applications/packages

adb shell pm list packages -f
# list of all installed applications with name of packages
adb shell pm list packages -f | awk -F '.apk=' '{printf "%-60s | %s\n", $2, $1}' | sort
# list of all non-system/installed applications
# | grep -v "package:/system" | grep -v "package:/vendor" | grep -v "package:/product" | grep -v "package:/apex"
adb shell pm list packages -f | awk -F '.apk=' '{printf "%-60s | %s\n", $2, $1}' | grep "package:/data/app/" | sort

# package_name=org.mozilla.firefox
# x-www-browser https://play.google.com/store/search?q=${package_name}&c=apps

# adb shell; 
# pm list packages -f

permission by package

PACKAGE_NAME=com.google.android.youtube
adb shell dumpsys package $PACKAGE_NAME | grep -i permission | grep -i granted=true

list of all permissions

adb shell pm list permissions

list of all features

adb shell pm list features
# print one file from OS
adb shell cat /proc/cpuinfo

# https://source.android.com/docs/core/architecture/bootloader/locking_unlocking
adb shell getprop | grep oem
adb shell getprop sys.oem_unlock_allowed
adb shell setprop sys.oem_unlock_allowed 1
# dmesg -wH

list of all settings

adb shell service list
adb shell settings list --user current secure 
adb shell settings get secure location_providers_allowed
adb shell settings get secure enabled_accessibility_services

send keyboard event

adb shell input keyevent KEYCODE_HOME

# KEYCODE_A: A
# KEYCODE_B: B
# KEYCODE_ENTER: Enter
# KEYCODE_SPACE: Space
# KEYCODE_BACK: Back button
# KEYCODE_HOME: Home button

works only in "bootloader" or "fastboot" or "download" mode. boot your Android device into the bootloader mode

fastboot install via Debian APT

sudo apt -y install fastboot
fastboot version

check connected phone

sudo apt install adb 

adb devices

lsusb
# Bus 001 Device 013: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy A5 (MTP)

fix issue with root:root usb access

ls -l /dev/bus/usb/001/013
# crw-rw-r--+ 1 root plugdev 189, 10 Mai 21 13:50 /dev/bus/usb/001/011

# if group is root, not a plugdev
sudo vim /etc/udev/rules.d/51-android.rules
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0660", GROUP="plugdev", SYMLINK+="android%n"

sudo service udev status

decompilation, opening Android apk

download latest release

GIT_ACCOUNT=skylot
GIT_PROJECT=jadx
version=`wget -v https://github.com/${GIT_ACCOUNT}/${GIT_PROJECT}/releases/latest/download/$GIT_RELEASE_ARTIFACT 2>&1 | grep following | awk '{print $2}' | awk -F '/' '{print $8}'`
GIT_RELEASE_ARTIFACT=jadx-${version:1}.zip
wget -v https://github.com/${GIT_ACCOUNT}/${GIT_PROJECT}/releases/latest/download/$GIT_RELEASE_ARTIFACT

start gui

./bin/jadx-gui

adb usage

print all applications with full set of granted permissions

for each_app in `adb shell pm list packages -f | grep 'package:/data/app' | awk -F 'base.apk=' '{print $2}' | sort `; do
    echo ">>> $each_app"
    # each_app=com.google.android.youtube
    # adb shell pm dump $each_app | clipboard
    adb shell pm dump $each_app | awk '/runtime permissions:/,/disabledComponents:/ { if ($0 ~ /disabledComponents:/ || $0 ~ /enabledComponents:/) exit; else print }' | grep "granted=true"
    echo ""
done

Android test codes

Universal Android Secret Codes (2024–2025)

Secret Code Function
*#06# Show IMEI number
*#*#4636#*#* Phone info, battery info, usage stats, and Wi-Fi info
*#*#7780#*#* Factory reset (Soft reset – keeps OS)
*2767*3855# Full factory reset (Hard reset – erases everything)
*#*#7594#*#* Change power button behavior
*#*#34971539#*#* Camera firmware and details
*#*#232339#*#* Wireless LAN test
*#*#0842#*#* Vibration and backlight test
*#*#2664#*#* Touchscreen test
*#*#0588#*#* Proximity sensor test
*#*#0*#*#* LCD display test
*#*#7262626#*#* Field test (Network signal)
*#*#232331#*#* Bluetooth test
*#*#1472365#*#* GPS test
*#12580*369# Software and hardware information
*#9090# Diagnostic configuration
*#872564# USB logging control
*#9900# System dump mode (primarily Samsung)
*#301279# Network control (UMTS/GSM settings)

Samsung

Secret Code Function
*#0*# General test mode (LCD, vibration, sensors)
*#0228# Battery status
*#0283# Audio loopback test
*#1111# FTA software version
*#2222# FTA hardware version

Xiaomi / Redmi / POCO

Secret Code Function
*#*#6484#*#* Hardware test mode (CIT)
*#*#4636#*#* Usage and battery info
*#*#86583#*#* Disable VoLTE carrier check
*#*#86943#*#* Disable VoWiFi carrier check

OnePlus

Secret Code Function
*#808# Engineering Mode (Touchscreen, sensors, audio, etc.)
*#1234# Software version
*#*#4636#*#* Phone info and statistics

Realme / Oppo

Secret Code Function
*#899# Engineer mode
*#36446337# Hardware test
*#*#4636#*#* Battery and usage info

Vivo

Secret Code Function
*#558# Hardware test
*#*#4636#*#* Device & battery info

Motorola

Secret Code Function
*#*#2486#*#* CQATest – Hardware diagnostics
*#*#4636#*#* Phone & usage info

Android regular cleanup

## collect files
find .  -printf "%p %s %TY-%Tm-%Td %TH:%TM:%TS\n" > ~/phone.files

## consider files
cat ~/phone.files  | awk '{print $1}' | grep -v gallery_disk_cache/ | grep -v Pictures/Viber | grep -v DCIM/Camera

## print all files
cat ~/redmi-9t.files.txt | awk '{print $1}' | awk -F '/' '{for(i=1; i<NF; i++) printf "%s%s", $i, (i<NF-1 ? "/" : ""); print ""}' > ~/phone.files.txt.dirs

## move viber files
DEST=/media/$USER/DEFA-5D32
for each_file in `cat ~/phone.files  | awk '{print $1}' | grep Movies/Viber | grep mp4 `;do
    echo $each_file
    mv $each_file $DEST/Viber
done

Android hardware

phone specifications

external display

is possible to connect when Phone has "USB Type-C 3.1"

Android applications

WhatsApp

internal storage for documents

mtp://${YOUR_PHONE}/Internal%20shared%20storage/Android/media/com.whatsapp/WhatsApp/Media/WhatsApp%20Documents

Applications for managing phone remotely

  • Scrcpy ( SCReen CoPY )
  • Vysor ( aka Scrcpy )
  • AirDroid: remote access over the internet
  • TeamViewer QuickSupport

custom java applications