[Sony Xperia XZ1  Guides, News, & Discussion] GuestD0932:
Guide

Debloat XZ1 with ADB

WARNING: WORK IN PROGRESS​

Preamble

First of all it should be mentioned that in the worst case your device has to be reset to factory settings. All the bloatware you will "remove" in the following hours and days will still remain on the device. So it's not about freeing up storage, but about hiding unwanted functionality, potentially increasing battery life, and freeing up some memory. However, to completely remove pre-installed software from your device, you must have root privileges. I personally advise against "rooting" a new device that will still receive security updates for some time. In most cases the process of acquiring root privileges, or at least the subsequent operations on the device, will lead to a loss of warranty. But that is only my opinion. I am not aware of any case in which the use of ADB with user rights led to a loss of warranty.

Requirements

ADB (Android Debug Bridge)

Arch-based $ sudo pacman -Syu android-tools

Debian-based $ sudo apt-get install adb

Fedora-based $ sudo yum install android-tools

Windows/mac https://www.xda-developers.com/install-adb-windows-macos-linux/

Sony Xperia XZ1 (should also work for other Xperia devices with Oreo)

Stock firmware

No root privileges required

"USB debugging" enabled in developer options⁰

Time :rolleyes:

Background & Commands

Introduction

The android debug bridge provides the right tool to remove the bloatware: The included package manager (pm) will become your best friend for now. I strongly recommend reading the official documentation if you have any questions after reading this section.

Notes on style

Every line of code with a leading $ is followed by a command. So lines without that are command output. If there is code written in italics you should expect other output or modify the command according to your needs. The # is used for line comments.

Getting started

First of all you start an ADB shell. Since this shell is quite limited, all following commands can alternatively be executed directly by prefixing adb shell. This could be useful later e.g. for scripting.

$ adb shell

Gathering information

After the shell has started, you probably want to collect information about the installed bloatware. The first place you can do that is the package list. Note that the commands implicitly add --user 0 which is your main user or "admin". Also the pm list command will be replaced by cmd package in the future but is more handy right now.

$ pm list packages -s -d |sort [color="green"]# Sorted list of all disabled system packages[/color]
$ pm list packages -s -e |sort [color="green"]# Sorted list of all enabled system packages[/color]
$ pm list packages -s -u |sort [color="green"]# Sorted list of all system packages including uninstalled ones[/color]

To show only uninstalled packages you can use the following command outside the ADB shell.

grep -vf <(adb shell pm list packages -s |sort) <(adb shell pm list packages -s -u |sort)

If you don't know the exact package name, you can specify a filter behind pm list packages or work with dumpsys and grep. There are, however, nicer methods respectively apps that take away the manual name resolution.

$ pm list packages [i]sony[/i] [color="green"]# Shows only packages that have "sony" in their name[/color]
$ dumpsys |grep -i [i]gmail[/i] -C5 [color="red"]# This is totally slow and doesn't always work out[/color]

To really get a lot of information, like dependencies, about a certain package, the following command is suitable.

$ dumpsys package [i]com.package.name[/i] [color="green"]# Much to read[/color]
$ pm list packages -f -i -u [i]com.package.name[/i] [color="green"]# Show associated .apk file and installer[/color]

Providing a test environment

Since you don't have root rights¹, you can't disable/uninstall system packages system-wide. The only thing that can happen is that you remove a package for your main user, that makes your main account or other packages unusable, or that cannot be reinstalled. Then the only option is a factory reset, right? Narp:D. You won't believe it, but it's enough to create a new user as a test environment. A user can be removed easily and is isolated from the other users. So your new user – we lovingly call it "test" – sacrifices itself to save you the factory reset. Therefore you can also test without hesitation on a productive system. Of course this only works if you specify the corresponding user-id in the following commands.; nevertheless, I recommend a backup.

$ pm create-user [i]test[/i]
Success: created user id [i]10[/i]
$ pm list users [color="green"]# Just to verify that worked[/color]
Users:
UserInfo{0:[i]Hallmund Gautisson[/i]:13} running
UserInfo{[i]10[/i]:[i]test[/i]:0}

No risk… and fun

Now we come to the fun part, debloat the $#*! out of your phone. At this point you often have to decide: disable or uninstall. In general disabling a package leads to success in most cases. An uninstall is only recommended if the disable does not lead to the desired result and if at best the package can be reinstalled. The test environment is perfect to check this and to uncover possible side effects of removing a package.

$ pm disable-user --user [i]10 com.package.name[/i] [color="green"]# This should also be safe if it's done with your main user (0)[/color]
Package [i]com.package.name[/i] new state: disabled-user
$ pm uninstall -k --user [i]10 com.package.name[/i] [color="red"]# This could force you to perform a factory reset when applied to your main user (0)[/color]
Success

The -k option is used to keep the data and cache directories, as you are not allowed to remove them anyway.

Damn regrets

If a package has more destructive power than previously thought, or proves to be quite useful in retrospect, or if you have simply made a mistake with the name, it would be nice if you could simply undo what you did full of youthful recklessness. For deactivated packages this works very reliably. With uninstalled packages this is quite random. Sometimes packages that even exist in the Play Store cannot be reinstalled anymore² and the apparently deepest ingrained system app can be reinstalled without even a single error. To reinstall a system package you have to get the path to the associated .apk file using -f option in package list.

$ pm enable --user [i]10 com.package.name[/i] [color="green"]# To undo the disable command, works reliable[/color]
$ pm list packages -f -u [i]com.package.name[/i]
package:[i]/path/to/package.apk[/i]=[i]com.package.name[/i]
$ pm install -r --user [i]10 /path/to/package.apk [color="red"]# To undo the uninstall command, works flaky[/color][/i]
Success [color="red"]# Or Failure³[/color]

The -r option is used reinstall an existing package and keeping its data. You don't have any rights in the installation target directory anyway.

(Bloat)-Packages

Notes on style

All packages I have tested myself have green coloured names. Packages that appear in other debloat lists are coloured blue. Packages with a red name mean: better don't touch them. Abbreviations are R for packages that can be reinstalled, P for packages that are also available in the play store, U for packages that you can also disable in the app settings, and M for packages that are removed from my phone. At this point you are welcome to contribute, especially the effects of removing are often not clear and package descriptions are missing.

List of bloatware #1

List of bloatware #2

List of bloatware #3

A/N: I will try to complete this list in the next few days and add more descriptions. The following lists contain the packages currently disabled or uninstalled on my phone.

Disabled:

package:android.autoinstalls.config.sony.xperia

package:com.amazon.kindle

package:com.android.apps.tag

package:com.android.bluetoothmidiservice

package:com.android.bookmarkprovider

package:com.android.chrome

package:com.android.documentsui

package:com.android.dreams.basic

package:com.android.egg

package:com.android.facelock

package:com.android.hotwordenrollment.okgoogle

package:com.android.partnerbrowsercustomizations.chromeHomepage

package:com.android.providers.downloads.ui

package:com.android.providers.partnerbookmarks

package:com.google.android.apps.photos

package:com.google.android.apps.tachyon

package:com.google.android.apps.work.oobconfig

package:com.google.android.feedback

package:com.google.android.gm

package:com.google.android.marvin.talkback

package:com.google.android.music

package:com.google.android.partnersetup

package:com.google.android.printservice.recommendation

package:com.google.android.setupwizard

package:com.google.android.syncadapters.contacts

package:com.google.android.tts

package:com.google.android.videos

package:com.google.android.youtube

package:com.s.antivirus

package:com.sonyericsson.android.omacp

package:com.sonyericsson.crashmonitor

package:com.sonyericsson.devicemonitor

package:com.sonyericsson.idd.agent

package:com.sonyericsson.lockscreen.uxpnxt

package:com.sonyericsson.organizer

package:com.sonyericsson.providers.cnap

package:com.sonyericsson.setupwizard

package:com.sonyericsson.startupflagservice

package:com.sonyericsson.suquashi.soundpicker

package:com.sonyericsson.tetherentitlementcheck

package:com.sonyericsson.textinput.chinese

package:com.sonyericsson.unsupportedheadsetnotifier

package:com.sonyericsson.updatecenter

package:com.sonyericsson.usbux

package:com.sonyericsson.wappush

package:com.sonyericsson.xhs

package:com.sonymobile.advancedlogging

package:com.sonymobile.advancedwidget.clock

package:com.sonymobile.android.addoncamera.soundphoto

package:com.sonymobile.android.contacts

package:com.sonymobile.android.externalkeyboard

package:com.sonymobile.android.externalkeyboardjp

package:com.sonymobile.anondata

package:com.sonymobile.assist

package:com.sonymobile.assist.persistent

package:com.sonymobile.btidd

package:com.sonymobile.cameracommon.wearablebridge

package:com.sonymobile.coverapp2

package:com.sonymobile.crashmonitor.system

package:com.sonymobile.demoappchecker

package:com.sonymobile.deqp

package:com.sonymobile.deviceconfigtool

package:com.sonymobile.enterprise.service

package:com.sonymobile.entrance

package:com.sonymobile.exchange

package:com.sonymobile.googleanalyticsproxy

package:com.sonymobile.idd.permission.application_certificate

package:com.sonymobile.moviecreator.rmm

package:com.sonymobile.music.googlelyricsplugin

package:com.sonymobile.music.wikipediaplugin

package:com.sonymobile.music.youtubekaraokeplugin

package:com.sonymobile.music.youtubeplugin

package:com.sonymobile.phoneusage

package:com.sonymobile.pip

package:com.sonymobile.pobox

package:com.sonymobile.rcahandler

package:com.sonymobile.retaildemo

package:com.sonymobile.secureclockservice

package:com.sonymobile.sso

package:com.sonymobile.superstamina

package:com.sonymobile.support

package:com.sonymobile.susrescheck

package:com.sonymobile.synchub

package:com.sonymobile.updatecenter.config.autoinstall

package:com.sonymobile.updatecenter.config.latecmz

package:com.sonymobile.usm

package:com.sonymobile.xperialounge.services

package:com.sonymobile.xperiaservices

package:com.sonymobile.xperiatransfermobile

package:com.sonymobile.xperiaweather

package:com.sony.tvsideview.videoph

package:com.spotify.music

Uninstalled:

package:com.android.browser.res.overlay_305

package:com.facebook.appmanager

package:com.facebook.katana

package:com.facebook.services

package:com.facebook.system

package:com.sonyericsson.conversations.res.overlay_305

package:com.sonyericsson.trackid.res.overlay_305

package:com.sonymobile.themes.sou.cid18.black

package:com.sonymobile.themes.sou.cid19.silver

package:com.sonymobile.themes.sou.cid20.blue

package:com.sonymobile.themes.sou.cid21.pink

⁰) Go to "Settings" → "System" → "About phone" → Tap "Build number" seven times → Back → "Developer options" → Enable "USB debugging"

¹) As long as you do not run ADB with root, it should not be possible to modify packages system-wide.

²) You can install them from the store but not with the original APK; congratulations, you now have double the package data.

³) Mostly you will get either INSTALL_PARSE_FAILED_NO_CERTIFICATES or INSTALL_FAILED_INVALID_APK.