yore
Android uses A/B partitions for updating. You have 2 system slots, and you always switch between them on updates.
Afaik:
- You are in Slot A. Slot B has the same content as Slot A.
- You do an update, the system updater downloads only the differences between the new image and slot A (I think. @GrapheneOS It could also use slot B but more on that later)
- The system updater has downloaded the update and now writes the complete (local + diff) system to the inactive slot B
- The checksums of the update are verified to be correct
- Maybe more steps I skipped
- You get a reboot prompt
If you reboot, the bootloader automatically boots into slot B. This contains the new system.
In an early boot stage, system apps (afaik) are optimized. Afaik this means they are re-precompiled onto the new libraries.
Android apps are mostly Java, which can be dynamically compiled or precompiled. Precompilation takes more time once, but should be faster afterwards.
This avoids the Javascript JIT compilation at runtime, which is a security benefit because JIT is a major attack vector for exploits.
So the system apps are recompiled and you can login.
Afterwards the user apps are recompiled the same, on a typical "gotta try everything" setup this takes quite a while.
You get prompted to restart all those apps, which kills the processes so you need to restart them.
After the new system runs for some time, it is proven to work. Now, afaik, it is copied to the inactive slot A, possibly to prevent malicious rollbacks.
Then the whole cycle repeats once a new update is pushed.
Afaik this is different from stock Android in many cases:
- Playstore precompiles only often used areas of apps, for speed purposes. There is no precompilation of everything, so JIT could be exploited
- the system apps may also not be precompiled that extensively, but I could be wrong here
- there is no "kill running apps" prompt to make sure apps are using the latest libraries