The cost of complexity: Ansible AWX
May 05, 2024
Sanitize personal Android devices
Following an idea of Micheal Bazzel , I decided to write a short procedure to remove unwanted software from Android smartphones. It’s not only about cleaning the phone, it’s about privacy. My old approach required a rootable phone, this one doesn’t and doesn’t affect the warranty.
Uninstalled packages will be kept in the ROM, but they are removed from the running OS.
Be aware: you should not remove any software you suspect because you are probably making your phone unusable and only a hard reset will fix it.
Connect your phone
Install Android Debug Bridge (ADB) on your platform. The following commands work on Raspberry Pi OS:
sudo apt install android-tools-adb
Now enable USB Debugging mode. Go to Settings > About Phone > Software Information
and click 7 times on Build Number
, then go to Settings > Developer Options > Enable > USB Debugging
and enable it.
Connect the phone via USB cable to your computer and restart ADB:
adb kill-server
adb devices
- daemon not running; starting now at tcp:5037
- daemon started successfully
List of devices attached
520011a1a0123143 device
Let’s get the ID of the current user (usually 0):
adb shell pm list users
Users:
UserInfo{0:+39 333 000 1234:13} running
Now we can:
- list installed and uninstalled packages (
list packages
); - uninstall a package (
uninstall
); - disable a package (
pm disable-user
): - reinstall a package (
install-existing
); - enable a package (
enable
).
Android sanitization
Let’s find some unwanted packages, for example, let’s assume we want to remove some social networks apps:
adb shell pm list packages --user 0 | egrep -i "linkedin|microsoft" | cut -d ":" -f2 | sort
com.facebook.appmanager
com.facebook.katana
com.facebook.services
com.facebook.system
com.linkedin.android
Then uninstall them one by one:
adb shell pm uninstall -k --user 0 com.linkedin.android
Or, maybe, we want to script our task:
PKGS_TO_UNINSTALL=$(adb shell pm list packages --user 0 | egrep -i "linkedin|microsoft" | cut -d ":" -f2)
for P in $PKGS_TO_UNINSTALL; do adb shell pm uninstall -k --user 0 $P; done
Disabling an app marks it unavailable (which can easily be reverted), while uninstalling physically removes the app and all connected data from the device. The flag -k
keep the data and cache directories around after package removal.
Restoring a critical app
In my test I removed some critical apps. We can restore them without issues:
adb shell cmd package install-existing com.linkedin.android
adb shell pm enable com.linkedin.android
Finding app info
Besides some famous apps, on most of them, we have to find some additional information. I automated this long task by writing a simple Python scripts:
#!/usr/bin/env python3
import requests
from lxml.html import fromstring
with open('package_list.txt') as f:
lines = f.readlines()
print("Package,Name,Author,Category")
for line in lines:
package_name = line.strip()
package_title = 'N/A'
package_author = 'N/A'
package_category = 'N/A'
url = f'https://apkcombo.com/en/visionprovider/{package_name}/'
r = requests.get(url)
if r.status_code == 200:
tree = fromstring(r.content)
information_table = tree.xpath("//div[@class='information-table']").pop()
package_title = tree.findtext('.//title').split(' APK ')[0]
try:
package_author = information_table.xpath("//a[contains(@href,'developer')]")[0].text
except:
pass
try:
package_category = information_table.xpath("//a[contains(@href,'category')]")[3].text
except:
pass
print(f'{package_name},{package_title},{package_author},{package_category}')
We can now lookup app details for each installed app:
sudo apt install python3-pip
pip3 install lxml -U
adb shell pm list packages -u | cut -d":" -f2 > package_list.txt
./app_resolver.py > package_list.csv
Finding the uninstalled app
Finally, we want to save the list of uninstalled apps. If we used the above commands and flags, we can list installed packages, list installed and uninstalled packages, and compare them:
adb shell pm list packages > a
adb shell pm list packages -u > b
diff a b | grep "^>" | cut -d":" -f2 | sort
From my testing devices I removed:
Package | Name | Author | Category |
---|---|---|---|
com.android.email | HUAWEI Email | HUAWEI | Tools |
com.android.mediacenter | Huawei Music | Huawei Internet Services | Tools |
com.example.android.notepad | NotePad | Xiaomi Inc. | Tools |
com.facebook.appmanager | N/A | N/A | N/A |
com.facebook.katana | Meta Platforms | Inc. | |
com.facebook.services | Facebook Services | Samsung Electronics Co., Ltd. | Tools |
com.facebook.system | Facebook App Installer | Samsung Electronics Co., Ltd. | Tools |
com.google.android.apps.docs | Google Drive | Google LLC | Productivity |
com.google.android.apps.photos | Google Photos | Google LLC | Photography |
com.google.android.apps.tachyon | Google Duo | Google LLC | Communication |
com.google.android.music | Google Play Music | Google LLC | Music & Audio |
com.google.android.videos | Google TV | Google LLC | Video Players & Editors |
com.google.android.youtube | YouTube | Google LLC | Video Players & Editors |
com.huawei.android.mirrorshare | Wireless projection | HUAWEI | Tools |
com.huawei.android.totemweather | HUAWEI Weather | Huawei | Tools |
com.huawei.appmarket | Huawei AppGallery | Huawei | Tools |
com.huawei.compass | Huawei Compass | Uploader | Tools |
com.huawei.hidisk | Huawei File Manager | Huawei Internet Services | Tools |
com.huawei.hwdetectrepair | Smart diagnosis | Huawei Internet Service | Tools |
com.huawei.hwid | Huawei Mobile Services | Huawei Internet Services | Tools |
com.huawei.mirror | N/A | N/A | N/A |
com.huawei.phoneservice | HiCare | Huawei Internet Services | Tools |
com.huawei.search | HUAWEI HiSearch | HUAWEI | Tools |
com.huawei.systemmanager | HUAWEI Optimizer | HUAWEI | Tools |
com.huawei.vassistant | HiVoice | HUAWEI | Tools |
com.linkedin.android | Business | ||
com.microsoft.office.excel | Microsoft Excel | Microsoft Corporation | Productivity |
com.microsoft.office.powerpoint | Microsoft PowerPoint | Microsoft Corporation | Productivity |
com.microsoft.office.word | Microsoft Word | Microsoft Corporation | Productivity |
com.microsoft.skydrive | Microsoft OneDrive | Microsoft Corporation | Productivity |
com.microsoft.translator | Microsoft Translator | Microsoft Corporation | Productivity |
com.nuance.swype.emui | Swype for Huawei | Nuance Communications, Inc | Tools |
com.samsung.android.app.spage | Bixby Home | Samsung Electronics Co., Ltd. | Tools |
com.samsung.android.bbc.fileprovider | KnoxBBCProvider | Samsung Electronics Co., Ltd. | Tools |
com.samsung.android.lool | Samsung Device Care | Samsung Electronics Co., Ltd. | Tools |
com.samsung.knox.securefolder | Secure Folder | Samsung Electronics Co., Ltd. | Business |
com.samsung.android.scloud | Samsung Cloud | Samsung Electronics Co., Ltd. | Tools |
com.samsung.android.securitylogagent | SecurityLogAgent | Samsung Electronics Co., Ltd. | Tools |
com.samsung.android.visionintelligence | Bixby Vision | Samsung Electronics Co., Ltd. | Tools |
com.sec.android.app.samsungapps | Samsung Galaxy Store | Samsung Electronics Co. Ltd | Entertainment |
com.sec.enterprise.knox.shareddevice.keyguard | SharedDeviceKeyguard | Samsung Electronics Co., Ltd. | Tools |
com.sec.spp.push | Samsung Push Service | Samsung Electronics Co., Ltd. | Communication |
com.topjohnwu.magisk | Magisk | topjohnwu | Tools |
de.axelspringer.yana.zeropage | upday | upday GmbH & Co. KG | News & Magazines |
me.twrp.twrpapp | Official TWRP App | Team Win LLC | Tools |
Conclusions
I honestly hate bloatware. They impact my privacy by tracking and stealing data. I think that this is a good method to disable unwanted software. It’s not a perfect method because we will never know what exactly is installed in our phones, but it’s an easy and affordable method for many people.
There are other methods, but they are for advanced users.
References
- Android Sanitization
- How to Remove Samsung Bloatware without Root (ADB)
- Uninstall System Apps on Huawei and Honor Devices “Uninstall System Apps on Huawei and Honor Devices”)