Home > Uncategorized > Missing Android manual

Missing Android manual

We all got Android devices without a proper manual so here are some basics I have learned over time…

It was taken from my internal notes so it’s not very pretty but I decided to share it so it can help more people.

Basic Paths

  • /system – system partition with read-only system
  • /data – data partition with user data
  • /data/data – application data (each app folder has to have u:object_r:app_data_file:s0:c512,c768 selinux context)
  • /data/user/0 – application data for user 0
  • /storage/emulated (/storage/self/primary) – internal flash memory, number folders for individual android users
  • /sdcard (/storage/self/primary) – internal flash memory for the current user (alias of /storage/emulated/0)
  • /storage/SOME-ID (or /mnt/media_rw/SOME-ID) – shared external SDCARd

Important files

  • /data/system/packages.xml – list of installed packages with their permissions and other metadata, includes package renames
  • /data/system/packages.list – list of installed packages in format “packageID UID isDebuggable PathToDataDirectory otherflags..”

Important Android Commands

  • pm – package manager:
      to list packages **pm list packages**
      to uninstall **pm uninstall package.id**
      to freeze/unfreeze **pm enable/disable package.id**
  • am – application manager, to force-stop app am force-stop package.id
  • dumpsys – dumps various system stuff, you can use dumpsys package package.id to dump various package info including installed version number
  • ime – input method manager. To list all keyboards and other input methods including disabled ones ime list -a, to enable input method ime enable package.id/somePath

Important Computer Commands

Normal debug mode

  • adb reboot recovery reboot into recovery (TWRP)
  • adb reboot bootloader reboot into fastboot mode
  • adb root – switch adb daemon on the phone to root by default
  • adb shell – access phone shell
  • adb install [-r] /path/to.apk – install apk, use -r to replace existing package
  • adb push /path/on/pc /path/on/phone – push local file/folder to a destination on the phone
  • adb pull /path/on/phone /target/path/on/pc – pull files/folders from the phone

Fastboot mode

  • fastboot flash recovery /path/to/recovery.img – flash recovery partition (can flash other partitions too)
  • fastboot boot /path/to/image.img – boot the image (image is abootimg – contains kernel, initramfs and potentially other partitions)
  • fastboot reboot – reboot normally
  • fastboot oem unlock / fastboot oem unlock-go – unlock bootloader (different for different vendors)

Remove fingerprint data after secure storage invalidation to allow removing old fingerprints and adding new ones

  • rm -rf /data/system/users/0/fpdata
  • (may not be needed) edit /data/system/users/0/settings_fingerprint.xml to remove fingerprint lines
  • restart Settings app and edit fingerprints

Firmware update

On Xiaomi (Qualcomm SoC) it is done by writing to the partitions directly, when selinux is disabled (e.g TWRP recovery).

package_extract_file(“firmware-update/cmnlib64.mbn”, “/dev/block/bootdevice/by-name/cmnlib64”);
package_extract_file(“firmware-update/cmnlib.mbn”, “/dev/block/bootdevice/by-name/cmnlib”);
package_extract_file(“firmware-update/rpm.mbn”, “/dev/block/bootdevice/by-name/rpm”);
package_extract_file(“firmware-update/tz.mbn”, “/dev/block/bootdevice/by-name/tz”);
package_extract_file(“firmware-update/emmc_appsboot.mbn”, “/dev/block/bootdevice/by-name/aboot”);
package_extract_file(“firmware-update/lksecapp.mbn”, “/dev/block/bootdevice/by-name/lksecapp”);
package_extract_file(“firmware-update/sbl1.mbn”, “/dev/block/bootdevice/by-name/sbl1”);
package_extract_file(“firmware-update/devcfg.mbn”, “/dev/block/bootdevice/by-name/devcfg”);
package_extract_file(“firmware-update/keymaster.mbn”, “/dev/block/bootdevice/by-name/keymaster”);

package_extract_file(“firmware-update/NON-HLOS.bin”, “/dev/block/bootdevice/by-name/modem”);
package_extract_file(“firmware-update/adspso.bin”, “/dev/block/bootdevice/by-name/dsp”);

.. this example script was taken from an official MIUI ROM http://en.miui.com/gid-23.html

Clear data of system packages after upgrading/downgrading system

(on device as root)

mv /data/data/com.android.chrome /data/data/_com.android.chrome
mv /data/user_de/0/com.android.chrome /data/user_de/0/_com.android.chrome
rm -rf /data/data/com.android.* /data/data/com.google.* /data/user_de/0/com.android.* /data/user_de/0/com.google.*
mv /data/data/_com.android.chrome /data/data/com.android.chrome
mv /data/user_de/0/_com.android.chrome /data/user_de/0/com.android.chrome

Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.

deadly laser