(Ffos Gecko & Gaia) OTA-Back to Gaia Layer

Source: Internet
Author: User

The Updatemanager in Systemapp, as the communication bridge between Gaia and Gecko, receives the ' Gecko ' event updateprompt sends in Update-available.

1. Updatemanager.handleevent

var detail = evt.detail; if (Detail.type && Detail.type = = = 'update-available') {
//systemupdatable is new when Updatemanager is initialized, there is only one systemupdatable in Updatemanager.
This . systemupdatable.size = detail.size; This . Systemupdatable.rememberknownupdate ();
//Added to the Updatesqueue queue in Updatemanager.
this. Addtoupdatesqueue (
this. systemupdatable);}

2. Updatemanager.addtoupdatesqueue

Logic is relatively simple, after doing some check, push to Updatesqueue, then render UI.

Addtoupdatesqueue:functionUm_addtoupdatesqueue (updatable) {if( This. _downloading) {        return; }      if(Updatable.app &&updatable.app.installState!== ' Installed ') {        return; }      if(Updatable.app && This. Updatableapps.indexof (Updatable) = = =-1) {        return; }      varAlreadythere = This. Updatesqueue.some (functionlookup (u) {return(U.app = = =Updatable.app);      }); if(alreadythere) {return; }       This. Updatesqueue.push (updatable); if( This. _notificationtimeout = = =NULL) {         This. _notificationtimeout =SetTimeout ( This. Displaynotificationandtoaster.bind ( This),           This.      Notification_buffering_timeout); }       This. render (); },

3. Trigger the Download

Updatemanager is a Gaia layer that does some UI-related actions when it initializes, such as the bind and listen of the download button.

this. Downloadbutton = document.getElementById (' Updates-download-button ');  This this. Requestdownloads.bind (this);

The launch of the download is divided into the following steps:

(1) updatemanager.requestdownloads

function um_requestdownloads (evt) {  evt.preventdefault ();
//through DataConnection to download
ifthis. Downloadviadataconnectionbutton) { This true ; This . Startdownloads (); Else { this. Promptordownload (); }},

(2) Updatemanager.promptordownload

 promptordownload: function   um_ Promptordownload () { var  self = this
    < span> if  (Self.downloadDialog.dataset.online = = ' false ' ) {self.showpromptnoconnection ();       return  ; //Check WiFi   if   (s Elf._wifiavailable ()) {self._starteddownloadusingdataconnection  = false self.startdownloads ();        return  ; } ...}  

(3) Updatemanager.startdownloads

Startdownloads:functionum_startdownloads () { This. DownloadViaDataConnectionDialog.classList.remove (' Visible ');  This. _closedownloaddialog (); Service.request (' Utilitytray:show '); varCheckvalues = {}; varDialog = This. downloaddialoglist; varcheckboxes = Dialog.queryselectorall (' input[type= ' checkbox "] ');  for(vari = 0; i < checkboxes.length; i++) {        varCheckBox =Checkboxes[i]; Checkvalues[checkbox.dataset.position]=checkbox.checked; }
//Traverse Updatesqueue
This . Updatesqueue.foreach (function(updatable, index) { // the user opte Dout of the downloadif (Updatable.app &&! ) Checkvalues[index]) { return; } updatable.download (); }); This. _downloadedbytes = 0; This. render (); },

(4) Systemupdatable.download ()

Code Location: Gaia/apps/system/js/updatable.js

By walking back to the Updatemanager, added to Downloadsqueue, and sent a ' update-available-result '

SystemUpdatable.prototype.download =function() {  if( This. Downloading) {    return; }   This. downloading =true;  This. paused =false; Updatemanager.addtodownloadsqueue ( This  );  This. Progress = 0; This  . _dispatchevent (' Update-available-result ', ' Download ');};

(5) Updatemanager.addtodownloadsqueue

Addtodownloadsqueue:functionUm_addtodownloadsqueue (updatable) {if(Updatable.app && This. Updatableapps.indexof (Updatable) = = =-1) {        return; }      varAlreadythere = This. Downloadsqueue.some (functionlookup (u) {return(U.app = = =Updatable.app);      }); if(alreadythere) {return; }      This  . Downloadsqueue.push (updatable); if( This. downloadsqueue.length = = 1) {         This. _downloading =true; Service.request (' Incdownloads ');  This. _wifilock = Navigator.requestwakelock (' WiFi ');  This. Displaynotificationifhidden ();  This. render (); }    },

4. Trigger Download 2

After reading the analysis of ' 3 ', it seems that the tune has not triggered any download.

Looking back at the beginning of this article, from receiving the ' update-available ' start, and finally just to Updateprompt returned a ' update-available-result '.

In fact, Updatemanager and updateprompt are through this event to communicate, Updatemanager will do some UI-related operations, the actual action will be given to updateprompt to forward and implement.

(1) updateprompt---update-xxx---> Updatemanager

(2) Updatemanager---update-xxx-result---> updateprompt

(Ffos Gecko & Gaia) OTA-Back to Gaia Layer

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.