This analysis is already at an end, and in Updateprompt, the Updateservice applyosupdate function is called.
1. Updateservice.applyosupdate
This function is very simple, that is, after getting to Update.zip, call the recovery service to complete the update.
Applyosupdate:functionaus_applyosupdate (aupdate) {if(!aupdate.isosupdate | | aupdate.state! =state_applied) {Aupdate.statustext= "Fota-state-error"; Throwcr.ns_error_failure; } aupdate.queryinterface (Ci.nsiwritablepropertybag); Let Osapplytodir= Aupdate.getproperty ("Osapplytodir"); if(!Osapplytodir) {LOG ("Updateservice:applyosupdate-error:osapplytodir isn't defined" + "in the nsiupdate!"); Pingstateandstatuscodes (Aupdate,false, state_failed+ ": " +fota_file_operation_error); Handleupdatefailure (Aupdate, fota_file_operation_error); return; } //Get the final update.zipletupdatefile = cc["@mozilla. Org/file/local;1"].createinstance (Ci.nsifile); Updatefile.initwithpath (Osapplytodir + "/update.zip"); if(!updatefile.exists ()) {LOG ("Updateservice:applyosupdate-error:os update is not found at" +Updatefile.path); Pingstateandstatuscodes (Aupdate,false, state_failed+ ": " +fota_file_operation_error); Handleupdatefailure (Aupdate, fota_file_operation_error); return; } writestatusfile (Getupdatesdir (), Aupdate.state=state_applied_os); LOG ("Updateservice:applyosupdate-rebooting into Recovery to apply" + "FOTA Update:" +Updatefile.path); Try{Let recoveryservice = cc["@mozilla. Org/recovery-service;1" ]. GetService (Ci.nsirecoveryservice); Recoveryservice.installfotaupdate (Updatefile.path); } Catch(e) {LOG ("Updateservice:applyosupdate-error:couldn ' t reboot into Recovery" + "to apply FOTA Update" +Updatefile.path); Pingstateandstatuscodes (Aupdate,false, state_failed+ ": " +fota_recovery_error); Writestatusfile (Getupdatesdir (), Aupdate.state=state_applied); Handleupdatefailure (Aupdate, fota_recovery_error); } },
2. "@mozilla. Org/recovery-service;1"
This service is not analyzed here, very simple, just a simple package for the librecovery.so, familiar with the Android OTA students can understand.
(Ffos Gecko & Gaia) OTA-Key to apply