Does `pm uninstall` also automatically execute `force-stop` and `clear` on a non-rooted device? This is for non-rooted stock ROM's.
To get rid of one single app, I've been executing the following commands:
(Step 1) disable-user
(2) force-stop
(3) clear
(4) uninstall
(5) clear
Steps (1) and (2) first — otherwise, if I just execute (3) before them, the app will (more often than not) launch itself again and start accumulating app data.
At this point, I've achieved to make an app useless. It is not running (force stopped), it has no data saved (cleared) and will not launch itself without me knowing (disabled).
If I wish to take it further and entirely get rid of it, I can execute (4) to uninstall it.
Step (5), might seem redundant, but I tested myself several times on two different categories of apps. The first one is system apps (i.e., the Settings UI has the option to disable it greyed out) and the other is typical carrier bloatware (you can uninstall it from the UI yourself without ADB)
If you run steps (1)‐(5) on a system app, you will get &quot;success&quot; on all five. If you run all five on the carrier app, you will get &quot;success&quot; only in steps (1)-(4). In step (5), you will get &quot;app is not found&quot; (or some similar message) instead.
So I said, maybe an &quot;uninstalled&quot; system app is still accumulating app data, if I can run clear as many times as I wish after it's uninstalled and still get &quot;success&quot;. Is that the case?
As far as just disabling is concerned, I have verified steps (1)-(3) are necessary. But when it comes to uninstalling instead, are they redundant?
(i.e., does a simple uninstall also automatically execute force-stop and clear?)
force-stop
Uninstalling an app always kills all related processes. Keeping them running doesn't make any sense and can end up in an app crash. Therefore Android kills the app process(es) before uninstalling it.
clear
Clear data and cache directories is enabled by default. It is just the opposite if you want to uninstall the app but keeping data and cache you have to add the option -k to the uninstall command.
clear an system app after uninstall
System aps are located on the system partition which is by default read-only. Thus uninstalling an system app is not possible on a non-rooted device.
If you execute uninstall on a system app only the installed app updates on the user partition are removed and the system app itself is set to disabled. Clearing the data of an disabled app is possible therefore you don't get an error.