Restore Gaia settings and media workflows, extend native network adapters, and align the APK payload. Generate French/English changelogs and website entries from the simplified JSON source. Validation: shared JS and Tundra unit tests; desktop workflows and persistence; signed APK payload parity; Sargo RAM and installed startup with boot readback. Android runtime qualification is recorded separately.
17 lines
No EOL
13 KiB
JavaScript
17 lines
No EOL
13 KiB
JavaScript
|
|
define('panels/simcard_manager/sim_ui_model',['require'],function(require){'use strict';var SimUIModel=function(cardIndex){this._cardIndex=cardIndex;this._enabled=false;this._absent=false;this._locked=false;this._defaultName={id:'simWithIndex',args:{index:this._cardIndex+1}};this._name=this._defaultName;this._number='';this._operator=null;};SimUIModel.prototype={getInfo:function(){var keys=['enabled','absent','locked','name','number','operator'];var info={};keys.forEach(function(key){info[key]=this['_'+key];}.bind(this));return info;},setState:function(key,options){switch(key){case'nosim':this._enabled=false;this._absent=true;this._locked=false;this._number='';this._operator={id:'noSimCard'};this._name=this._defaultName;break;case'locked':this._enabled=false;this._absent=false;this._locked=true;this._number='';this._operator={id:'sim-pin-locked'};this._name=this._defaultName;break;case'blocked':this._enabled=true;this._absent=true;this._locked=false;this._number='';this._operator=null;this._name={id:'noSimCard'};break;case'normal':this._enabled=true;this._absent=false;this._locked=false;this._number=options.number;if(options.operator){this._operator={text:options.operator};}else{this._operator={id:'no-operator'};}
|
|
this._name=this._defaultName;break;}}};return function ctor_simUIModel(cardIndex){return new SimUIModel(cardIndex);};});define('panels/simcard_manager/simcard_manager',['require','shared/sanitizer','shared/sim_settings_helper','shared/airplane_mode_helper','shared/mobile_operator','panels/simcard_manager/sim_ui_model'],function(require){'use strict';var l10n=document.l10n;var Sanitizer=require('shared/sanitizer');var SimSettingsHelper=require('shared/sim_settings_helper');var AirplaneModeHelper=require('shared/airplane_mode_helper');var MobileOperator=require('shared/mobile_operator');var SimUIModel=require('panels/simcard_manager/sim_ui_model');var SimCardManager=function(elements){this._elements=elements;this._simcards=[];this._isAirplaneMode=false;};SimCardManager.prototype={init:function scm_init(){this._elements.outgoingCallSelect.addEventListener('change',this);this._elements.outgoingMessagesSelect.addEventListener('change',this);this._addOutgoingDataSelectEvent();this._addVoiceChangeEventOnConns();this._addCardStateChangeEventOnIccs();this._addLocalizedChangeEventOnIccs();SimSettingsHelper.observe('outgoingData',this._outgoingDataChangeEvent.bind(this));this._addAirplaneModeChangeEvent();this._isAirplaneMode=AirplaneModeHelper.getStatus()==='enabled'?true:false;this._initSimCardsInfo();this._initSimCardManagerUI();},simItemView:function({simIndex}){return Sanitizer.escapeHTML`<li class="sim-card sim-card-${simIndex}">
|
|
<div class="sim-card-icon"></div>
|
|
<div class="information-container">
|
|
<p class="sim-card-name"></p>
|
|
<p class="sim-card-operator"></p>
|
|
<bdi class="sim-card-number"></bdi>
|
|
</div>
|
|
</li>`;},_initSimCardsInfo:function scm__initSimCardsInfo(){var conns=window.navigator.mozMobileConnections;for(var cardIndex=0;cardIndex<conns.length;cardIndex++){var conn=conns[cardIndex];var iccId=conn.iccId;var simcard=SimUIModel(cardIndex);this._simcards.push(simcard);this._updateCardState(cardIndex,iccId);}},handleEvent:function scm_handlEvent(evt){var cardIndex=evt.target.value;if(cardIndex===SimSettingsHelper.EMPTY_OPTION_VALUE){return;}
|
|
switch(evt.target){case this._elements.outgoingCallSelect:SimSettingsHelper.setServiceOnCard('outgoingCall',cardIndex);break;case this._elements.outgoingMessagesSelect:SimSettingsHelper.setServiceOnCard('outgoingMessages',cardIndex);break;}},_outgoingDataChangeEvent:function scm__outgoingDataChangeEvent(cardIndex){this._elements.outgoingDataSelect.value=cardIndex;},_addOutgoingDataSelectEvent:function scm__addOutgoingDataSelectEvent(){var prevCardIndex;var newCardIndex;this._elements.outgoingDataSelect.addEventListener('focus',function(){prevCardIndex=this.selectedIndex;newCardIndex=this.selectedIndex;});this._elements.outgoingDataSelect.addEventListener('blur',function(){newCardIndex=this.selectedIndex;if(prevCardIndex!==newCardIndex){l10n.formatValue('change-outgoing-data-confirm').then(value=>{var wantToChange=window.confirm(value);if(wantToChange){SimSettingsHelper.setServiceOnCard('outgoingData',newCardIndex);}else{this.selectedIndex=prevCardIndex;}});}});},_getSimCardsCount:function scm__getSimCardsCount(){return this._simcards.length;},_getSimCardInfo:function scm__getSimCardInfo(cardIndex){return this._simcards[cardIndex].getInfo();},_getSimCard:function scm__getSimCard(cardIndex){return this._simcards[cardIndex];},_updateSimCardsUI:function scm__updateSimCardsUI(){this._simcards.forEach(function(simcard,cardIndex){this._updateSimCardUI(cardIndex);}.bind(this));},_updateSimCardUI:function scm__updateSimCardUI(cardIndex){var simcardInfo=this._getSimCardInfo(cardIndex);var selectors=['name','number','operator'];var cardSelector='.sim-card-'+cardIndex;var cardDom=this._elements.simCardContainer.querySelector(cardSelector);cardDom.classList.toggle('absent',simcardInfo.absent);cardDom.classList.toggle('locked',simcardInfo.locked);cardDom.classList.toggle('enabled',simcardInfo.enabled);cardDom.classList.toggle('with-number',!!simcardInfo.number);selectors.forEach(function(selector){var targetSelector=cardSelector+' .sim-card-'+selector;var element=this._elements.simCardContainer.querySelector(targetSelector);if(selector==='number'){element.textContent=simcardInfo[selector];}else{var l10nObj=simcardInfo[selector];if(l10nObj.id){l10n.setAttributes(element,l10nObj.id,l10nObj.args);}else{element.removeAttribute('data-l10n-id');element.textContent=l10nObj.text;}}}.bind(this));},_initSimCardManagerUI:function scm__initSimCardManagerUI(){this._initSimCardsUI();this._updateSelectOptionsUI();this._updateSimCardsUI();this._updateSimSettingsUI();},_initSimCardsUI:function scm__initSimCardsUI(){var simItemHTMLs=[];this._simcards.forEach(function(simcard,index){simItemHTMLs.push(this.simItemView({simIndex:index.toString()}));}.bind(this));this._elements.simCardContainer.innerHTML=simItemHTMLs.join('');},_updateSimSettingsUI:function scm__updateSimSettingsUI(){var firstCardInfo=this._simcards[0].getInfo();var secondCardInfo=(this._simcards[1]?this._simcards[1].getInfo():{absent:true});var hidden=firstCardInfo.absent&&secondCardInfo.absent||this._isAirplaneMode;this._elements.simSettingsHeader.hidden=hidden;this._elements.simSettingsList.hidden=hidden;},_updateSelectOptionsUI:function scm__updateSelectOptionsUI(){var firstCardInfo=this._simcards[0].getInfo();var secondCardInfo=(this._simcards[1]?this._simcards[1].getInfo():{absent:true});if(!firstCardInfo.absent&&!secondCardInfo.absent){SimSettingsHelper.getCardIndexFrom('outgoingCall',function(cardIndex){this._updateSelectOptionUI('outgoingCall',cardIndex,this._elements.outgoingCallSelect);}.bind(this));SimSettingsHelper.getCardIndexFrom('outgoingMessages',function(cardIndex){this._updateSelectOptionUI('outgoingMessages',cardIndex,this._elements.outgoingMessagesSelect);}.bind(this));SimSettingsHelper.getCardIndexFrom('outgoingData',function(cardIndex){this._updateSelectOptionUI('outgoingData',cardIndex,this._elements.outgoingDataSelect);}.bind(this));}else{var selectedCardIndex;if(firstCardInfo.absent&&secondCardInfo.absent){selectedCardIndex=0;}else{selectedCardIndex=firstCardInfo.absent?1:0;}
|
|
this._elements.outgoingCallSelect.disabled=true;this._elements.outgoingMessagesSelect.disabled=true;this._elements.outgoingDataSelect.disabled=true;this._updateSelectOptionUI('outgoingCall',selectedCardIndex,this._elements.outgoingCallSelect);this._updateSelectOptionUI('outgoingMessages',selectedCardIndex,this._elements.outgoingMessagesSelect);this._updateSelectOptionUI('outgoingData',selectedCardIndex,this._elements.outgoingDataSelect);}},_updateSelectOptionUI:function scm__updateSelectOptionUI(storageKey,selectedCardIndex,selectDOM){while(selectDOM.firstChild){selectDOM.removeChild(selectDOM.firstChild);}
|
|
this._simcards.forEach(function(simcard,index){var simcardInfo=simcard.getInfo();var option=document.createElement('option');option.value=index;if(simcardInfo.absent){option.value=SimSettingsHelper.EMPTY_OPTION_VALUE;option.text=SimSettingsHelper.EMPTY_OPTION_TEXT;}else{if(simcardInfo.name.id){l10n.setAttributes(option,simcardInfo.name.id,simcardInfo.name.args);}else{option.text=simcardInfo.name.text;}}
|
|
if(index==selectedCardIndex){option.selected=true;}
|
|
selectDOM.add(option);});if(storageKey==='outgoingCall'||storageKey==='outgoingMessages'){var option=document.createElement('option');option.value=SimSettingsHelper.ALWAYS_ASK_OPTION_VALUE;option.setAttribute('data-l10n-id','sim-manager-always-ask');if(SimSettingsHelper.ALWAYS_ASK_OPTION_VALUE===selectedCardIndex){option.selected=true;}
|
|
selectDOM.add(option);}},_isSimCardLocked:function scm__isSimCardLocked(cardState){var lockedState=['pinRequired','pukRequired','networkLocked','serviceProviderLocked','corporateLocked','network1Locked','network2Locked','hrpdNetworkLocked','ruimCorporateLocked','ruimServiceProviderLocked'];return lockedState.indexOf(cardState)!==-1;},_isSimCardBlocked:function scm__isSimCardBlocked(cardState){var uselessState=['permanentBlocked'];return uselessState.indexOf(cardState)!==-1;},_addVoiceChangeEventOnConns:function scm__addVoiceChangeEventOnConns(){var conns=window.navigator.mozMobileConnections;for(var i=0;i<conns.length;i++){var iccId=conns[i].iccId;conns[i].addEventListener('voicechange',this._updateCardStateWithUI.bind(this,i,iccId));}},_addCardStateChangeEventOnIccs:function scm__addCardStateChangeEventOnIccs(){var conns=window.navigator.mozMobileConnections;var iccManager=window.navigator.mozIccManager;for(var i=0;i<conns.length;i++){var iccId=conns[i].iccId;var icc=iccManager.getIccById(iccId);if(icc){this._addChangeEventOnIccByIccId(iccId);}}},_addLocalizedChangeEventOnIccs:function scm__addLocalizedChangeEventOnIccs(){var conns=window.navigator.mozMobileConnections;document.addEventListener('DOMRetranslated',function(){for(var i=0;i<conns.length;i++){var iccId=conns[i].iccId;this._updateCardStateWithUI(i,iccId);}}.bind(this));},_addChangeEventOnIccByIccId:function scm__addChangeEventOnIccByIccId(iccId){var self=this;var icc=window.navigator.mozIccManager.getIccById(iccId);if(icc){icc.addEventListener('cardstatechange',function(){var cardIndex=self._getCardIndexByIccId(iccId);self._updateCardStateWithUI(cardIndex,iccId);if(self._isSimCardBlocked(icc.cardState)){self._updateSelectOptionsUI();}});}},_addAirplaneModeChangeEvent:function scm__addAirplaneModeChangeEvent(){var self=this;AirplaneModeHelper.addEventListener('statechange',function(state){if(state==='enabled'||state==='disabled'){var enabled=(state==='enabled')?true:false;self._isAirplaneMode=enabled;self._updateCardsState();self._updateSimCardsUI();self._updateSimSettingsUI();}});},_updateCardsState:function scm__updateCardsState(){var conns=window.navigator.mozMobileConnections;for(var cardIndex=0;cardIndex<conns.length;cardIndex++){var iccId=conns[cardIndex].iccId;this._updateCardState(cardIndex,iccId);}},_updateCardState:function scm__updateCardState(cardIndex,iccId){var iccManager=window.navigator.mozIccManager;var conn=window.navigator.mozMobileConnections[cardIndex];var simcard=this._simcards[cardIndex];if(!iccId||this._isAirplaneMode){simcard.setState('nosim');}else{var icc=iccManager.getIccById(iccId);var iccInfo=icc.iccInfo;var cardState=icc.cardState;var operatorInfo=MobileOperator.userFacingInfo(conn);if(this._isSimCardLocked(cardState)){simcard.setState('locked');}else if(this._isSimCardBlocked(cardState)){simcard.setState('blocked');}else{simcard.setState('normal',{number:iccInfo.msisdn||iccInfo.mdn||'',operator:operatorInfo.operator});}}},_updateCardStateWithUI:function scm__updateCardStateWithUI(cardIndex,iccId){this._updateCardState(cardIndex,iccId);this._updateSimCardUI(cardIndex);this._updateSimSettingsUI();},_getCardIndexByIccId:function scm__getCardIndexByIccId(iccId){var conns=window.navigator.mozMobileConnections;var cardIndex;for(var i=0;i<conns.length;i++){if(conns[i].iccId==iccId){cardIndex=i;}}
|
|
return cardIndex;}};return SimCardManager;});define('panels/simcard_manager/panel',['require','modules/settings_panel','panels/simcard_manager/simcard_manager'],function(require){'use strict';var SettingsPanel=require('modules/settings_panel');var SimCardManager=require('panels/simcard_manager/simcard_manager');return function ctor_sim_manager_panel(){return SettingsPanel({onInit:function(panel){var simcardManager=new SimCardManager({simCardContainer:panel.querySelector('.sim-card-container'),simSettingsHeader:panel.querySelector('.sim-manager-settings-header'),simSettingsList:panel.querySelector('.sim-manager-select-list'),outgoingCallSelect:panel.querySelector('.sim-manager-outgoing-call-select'),outgoingMessagesSelect:panel.querySelector('.sim-manager-outgoing-messages-select'),outgoingDataSelect:panel.querySelector('.sim-manager-outgoing-data-select'),});simcardManager.init();}});};}); |