Flash android factory image

How to flash an android factory image and uninstall bloat packages without rooting the phone




Install package

pacman -Syu android-tools

Enable Developer Mode

Connect your phone to your computer.
Launch the Settings app > About phone
Tap build number seven times.


Enable USB Debugging

Settings > System > Developer options > enable USB Debugging
Authorize your computer connection on your phone when the prompt comes up on your phone,
if this is the first time you are connecting with this ADB computer.


Unlock bootloader

Settings > Developer Options > enable OEM unlocking
Reboot the phone into Fastboot mode.

adb reboot bootloader
fastboot flashing unlock

Vol up to select option on phone > press power button to confirm After reboot press power button to start.


Flash full Factory Image via Fastboot

Download the latest Factory Image

adb devices

Reboot the phone into Fastboot mode.

adb reboot bootloader
Info

Retain personal data by deleting the “-w” wipe attribute from the command within the script.
To avoid compatibility issues, a data wipe is recommended though.

./flash-all.sh

Once the script finishes, your device will reboot into the new OS.


Uninstall bloat packages

adb shell
pm list packages
Tip

Search for the package name in the url on Google Play Store

pm uninstall -k com.google.android.apps.youtube.music
pm uninstall -k --user 0 com.google.android.apps.youtube.music
pm uninstall -k com.google.android.youtube
pm uninstall -k --user 0 com.google.android.youtube
pm uninstall -k com.google.android.googlequicksearchbox
pm uninstall -k --user 0 com.google.android.googlequicksearchbox
pm uninstall -k com.google.android.gm
pm uninstall -k --user 0 com.google.android.gm
pm uninstall -k com.google.vr.apps.ornament
pm uninstall -k com.google.android.apps.wearables.maestro.companion
pm uninstall -k --user 0 com.google.android.apps.wearables.maestro.companion
pm uninstall -k --user 0 com.google.android.calendar
pm uninstall -k com.google.android.calendar
pm uninstall -k --user 0 com.android.chrome
pm uninstall -k com.android.chrome
pm uninstall -k --user 0 com.google.ar.core
pm uninstall -k com.google.ar.core
pm uninstall -k --user 0 com.google.android.videos
pm uninstall -k com.google.android.videos

Lock bootloader

Reboot the phone into Fastboot mode.

adb reboot bootloader
fastboot flashing lock

Vol up to select option on phone > press power button to confirm.
After reboot press power button to start.
Settings > Developer Options > disable OEM unlocking


Transfer media files

pacman -S mtpfs gvfs-mtp gvfs-gphoto2
/etc/fuse.conf

uncomment user_allow_other

Mount your device

mtpfs -o allow_other ~/mnt