(Ffos Gecko & Gaia) OTA-Back to Updateprompt

Source: Internet
Author: User

When download is finished, it is back to updateprompt, because you need to prompt user download to complete, confirm apply.

1. updateprompt.showupdatedownloaded

Showupdatedownloaded:functionup_showupdatedownloaded (aupdate, abackground) {if( This. _systemupdatelistener) {       This. _systemupdatelistener.onupdateready (); } Else {       This. _ispendingupdateready =true; }    //The update has been downloaded and staged. We Send the update-downloaded    //event right away. After the user have been idle for a while, we send the    //Update-prompt-restart event, increasing the chances that we can apply the    //update quietly without user intervention.    This  . Sendupdateevent ("update-downloaded", aupdate); if(Services.idle.idleTime >= This. Applyidletimeout) {       This. Showapplyprompt (aupdate); return; } Let Applyidletimeoutseconds= This. applyidletimeout/1000; //We Haven ' t been idle long enough, so register an observerLog ("Update is ready to apply, registering idle timeout of" +Applyidletimeoutseconds+ "seconds before prompting.");  This. _update =aupdate;  This. Waitforidle (); },

2. Systemupdatable.handleevent

     Case ' update-downloaded ':      thisfalse;      updatemanager.downloaded (this);       This  . showapplyprompt (detail.isosupdate);        break;

3. Systemupdatable.showapplyprompt

//isosupdate comes from Gecko ' s update object passed in the Mozchromeevent//And is a expected to being true in the case of a update package that gets applied//In recovery mode (FOTA). We want to show the battery warning//Case as described in bug 959195SystemUpdatable.prototype.showApplyPrompt =function(isosupdate) {varBatterylevel = window.navigator.battery.level * 100; //Get battery Status   This. Getbatterypercentagethreshold (). Then (function(threshold) { This. showingapplyprompt =true; if(Isosupdate && Batterylevel <threshold) {       This. Showapplypromptbatterynok (threshold); } Else {      //battery sufficient case, prompt apply       This. Showapplypromptbatteryok (); }}.bind ( This));};

4. Systemupdatable.showapplypromptbatteryok

SystemUpdatable.prototype.showApplyPromptBatteryOk =function() {  //Update 'll be completed after restart   This. Forgetknownupdate (); varCancel ={title:' Later ', Callback: This. Declineinstallwait.bind ( This)  }; varConfirm ={title:' Installnow ', Callback: This. Acceptinstall.bind ( This), recommend:true  }; Service.request (' Utilitytray:hide ');
//Popup confirmation dialog, when confirm upgrade, call Acceptinstall function service.request ( ' showcustomdialog ', ' Systemupdateready ', ' Wanttoinstallnow ' , Cancel, confirm);};

5. Systemupdatable.acceptinstall

SystemUpdatable.prototype.acceptInstall =function() {service.request (' Hidecustomdialog '); //Display a splash-screen so the user knows an update is being applied  varSplash = document.createelement (' form '); Splash.id= ' System-update-splash '; [' label ', ' Divider ', ' Icon '].foreach (function(name) {varChild = document.createelement (' div '); Child.id=name;  Splash.appendchild (child);  }); Splash.firstChild.setAttribute (' Data-l10n-id ', ' systemupdate '); varScreen = document.getElementById (' Screen ');  Screen.appendchild (Splash);  This. _dispatchevent ('Update-prompt-apply-result‘, ‘Restart‘);};

6. Updateprompt.handleevent

       Case "Update-prompt-apply-result":        this. Handleapplypromptresult (detail);         break;

7. Updateprompt.handleapplypromptresult

Handleapplypromptresult:functionUp_handleapplypromptresult (adetail) {if( This. _applyprompttimer) {       This. _applyprompttimer.cancel ();  This. _applyprompttimer =NULL; }    Switch(adetail.result) {//Battery not okay, don't wait for idle to Re-prompt       Case"Low-battery":         Break;  Case"Wait":        //Wait until the user is idle before prompting to apply the update         This. Waitforidle ();  Break; Case   ' restart ':  this. Finishupdate ();  This. _update =NULL;  Break; }  },

8. Updateprompt.finishupdate

Here are two cases, one is gota, only need to restart the B2G process, there is a kind of fota, call Updateservice to complete the work of apply.

Finishupdate:functionup_finishupdate () {if(! This. _update.isosupdate) {      //Standard Gecko+gaia updates would just need to restart the process
This . restartprocess (); return; } Try{ Services.aus.applyOsUpdate ( This . _update); } Catch(e) { This. _update.errorcode =cr.ns_error_failure; This. Showupdateerror ( This. _update); } },

(Ffos Gecko & Gaia) OTA-Back to Updateprompt

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.