Apple uses Cryptographic Erasure. This means that new firmware image is first downloaded from Apple and then restored on the device. In this process, the old encryption keys are deleted and overwritten by the system. The operating system gets renewed and totally new encrypted file system is created over the old encrypted file system.
Android does a traditional overwrite of all storage and a factory reset after it, thus new firmware is not needed.