Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
85
gaia/apps/settings/js/telephony_settings.js
Executable file
85
gaia/apps/settings/js/telephony_settings.js
Executable file
|
|
@ -0,0 +1,85 @@
|
|||
/* global DsdsSettings, TelephonyItemsHandler, AirplaneModeHelper */
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Singleton object (base object) that handle listener and events on mozIcc
|
||||
* objects in order to handle telephony-related menu items in the root panel.
|
||||
*/
|
||||
window.TelephonySettingHelper = (function() {
|
||||
var _iccManager;
|
||||
var _mobileConnections;
|
||||
|
||||
var _iccId;
|
||||
|
||||
/**
|
||||
* Init function.
|
||||
*/
|
||||
function tsh_init() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
_iccManager = window.navigator.mozIccManager;
|
||||
_mobileConnections = window.navigator.mozMobileConnections;
|
||||
|
||||
if (!_mobileConnections || !_iccManager) {
|
||||
return resolve();
|
||||
}
|
||||
|
||||
var idleObserver = {
|
||||
time: 3,
|
||||
onidle: function() {
|
||||
navigator.removeIdleObserver(idleObserver);
|
||||
|
||||
DsdsSettings.init();
|
||||
|
||||
TelephonyItemsHandler.init();
|
||||
TelephonyItemsHandler.handleItems();
|
||||
|
||||
AirplaneModeHelper.addEventListener('statechange',
|
||||
TelephonyItemsHandler.handleItems);
|
||||
|
||||
tsh_addListeners();
|
||||
|
||||
_iccManager.addEventListener('iccdetected',
|
||||
function iccDetectedHandler(evt) {
|
||||
if (_mobileConnections[0].iccId &&
|
||||
(_mobileConnections[0].iccId === evt.iccId)) {
|
||||
TelephonyItemsHandler.handleItems();
|
||||
tsh_addListeners();
|
||||
}
|
||||
});
|
||||
|
||||
_iccManager.addEventListener('iccundetected',
|
||||
function iccUndetectedHandler(evt) {
|
||||
if (_iccId === evt.iccId) {
|
||||
_mobileConnections[0].removeEventListener('datachange',
|
||||
TelephonyItemsHandler.handleItems);
|
||||
}
|
||||
});
|
||||
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
navigator.addIdleObserver(idleObserver);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add listeners.
|
||||
*/
|
||||
function tsh_addListeners() {
|
||||
_mobileConnections[0].addEventListener('datachange',
|
||||
TelephonyItemsHandler.handleItems);
|
||||
_iccId = _mobileConnections[0].iccId;
|
||||
|
||||
var iccCard = _iccManager.getIccById(_iccId);
|
||||
if (!iccCard) {
|
||||
return;
|
||||
}
|
||||
iccCard.addEventListener('cardstatechange',
|
||||
TelephonyItemsHandler.handleItems);
|
||||
}
|
||||
|
||||
// Public API.
|
||||
return {
|
||||
init: tsh_init
|
||||
};
|
||||
})();
|
||||
Loading…
Reference in a new issue