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:
OverSu 2026-09-30 23:13:03 +02:00
commit b38dea0597
25901 changed files with 9982925 additions and 369 deletions

View file

@ -0,0 +1,342 @@
/* global DsdsSettings, IccHandlerForCarrierSettings */
define(function(require) {
'use strict';
var LazyLoader = require('shared/lazy_loader');
/**
* Singleton object that handles some cell and data settings.
*/
var Carrier = (function() {
var DATA_KEY = 'ril.data.enabled';
var DATA_ROAMING_KEY = 'ril.data.roaming_enabled';
var _settings;
var _mobileConnections;
var _iccManager;
/** mozMobileConnection instance the panel settings rely on */
var _mobileConnection = null;
/** Flag */
var _restartingDataConnection = false;
var _elements = {
detailHeader:
document.querySelector('#carrier-detail gaia-header h1'),
carrierInfo:
document.querySelector('#carrier .carrier-info'),
advancedSettings:
document.querySelector('#carrier .carrier-advancedSettings'),
advancedSettingsList:
document.querySelectorAll('#carrier .carrier-advancedSettings li'),
simSettings:
document.querySelector('#carrier .carrier-simSettings'),
dataToggle:
document.querySelector('#menuItem-enableDataCall gaia-switch'),
dataRoamingToggle:
document.querySelector('#menuItem-enableDataRoaming gaia-switch'),
desc:
document.getElementById('dataNetwork-desc')
};
/**
* Init function.
*/
function cs_init() {
_settings = window.navigator.mozSettings;
_mobileConnections = window.navigator.mozMobileConnections;
_iccManager = window.navigator.mozIccManager;
if (!_settings || !_mobileConnections || !_iccManager) {
return;
}
// Get the mozMobileConnection instace for this ICC card.
_mobileConnection = _mobileConnections[
DsdsSettings.getIccCardIndexForCellAndDataSettings()
];
if (!_mobileConnection) {
return;
}
// Show carrier name.
cs_showCarrierName();
// Set the navigation correctly when on a multi ICC card device.
cs_initIccsUI();
cs_initDataToggles();
window.addEventListener('panelready', function(e) {
// Get the mozMobileConnection instace for this ICC card.
_mobileConnection = _mobileConnections[
DsdsSettings.getIccCardIndexForCellAndDataSettings()
];
if (!_mobileConnection) {
return;
}
var currentHash = e.detail.current;
if (currentHash === '#carrier') {
// Show carrier name.
cs_showCarrierName();
return;
} else if (currentHash === '#carrier-detail') {
document.l10n.setAttributes(
_elements.detailHeader,
'simSettingsWithIndex',
{ index: DsdsSettings.getIccCardIndexForCellAndDataSettings() + 1 });
}
if (!currentHash.startsWith('#carrier-')) {
return;
}
});
}
function cs_initIccsUI() {
var isMultiSim = DsdsSettings.getNumberOfIccSlots() > 1;
if (isMultiSim) {
LazyLoader.load([
'/js/panels/carrier/carrier_iccs.js'
], function() {
IccHandlerForCarrierSettings.init();
});
}
_elements.carrierInfo.hidden = isMultiSim;
_elements.advancedSettings.hidden = isMultiSim;
_elements.simSettings.hidden = !isMultiSim;
}
function cs_initDataToggles() {
function updateDataRoamingToggle(dataEnabled) {
if (dataEnabled) {
_elements.dataRoamingToggle.disabled = false;
} else {
_elements.dataRoamingToggle.disabled = true;
_elements.dataRoamingToggle.checked = false;
_elements.dataRoamingToggle.dispatchEvent(new Event('change'));
}
}
function getDataEnabled() {
return new Promise(function(resolve, reject) {
var transaction = _settings.createLock();
var req = transaction.get(DATA_KEY);
req.onsuccess = function() {
resolve(req.result[DATA_KEY]);
};
req.onerror = function() {
resolve(false);
};
});
}
var isSimCardInserted = Array.prototype.some.call(
navigator.mozMobileConnections,
function(connection) {
return connection.iccId;
}
);
if (!isSimCardInserted) {
_elements.dataToggle.disabled = true;
_elements.dataRoamingToggle.disabled = true;
Array.prototype.forEach.call(_elements.advancedSettingsList,
(element) => {
element.setAttribute('aria-disabled', true);
}
);
}
getDataEnabled().then(function(dataEnabled) {
dataEnabled = isSimCardInserted && dataEnabled;
updateDataRoamingToggle(dataEnabled);
});
// We need to disable data roaming when data connection is disabled.
_settings.addObserver(DATA_KEY, function observerCb(event) {
_elements.dataToggle.checked = event.settingValue;
if (_restartingDataConnection) {
return;
}
updateDataRoamingToggle(event.settingValue);
});
// Init warnings the user sees before enabling data calls and roaming.
// The function also registers handlers for the changes of the toggles.
cs_initWarning(DATA_KEY,
_elements.dataToggle,
isSimCardInserted,
'dataConnection-warning-head',
'dataConnection-warning-message');
cs_initWarning(DATA_ROAMING_KEY,
_elements.dataRoamingToggle,
isSimCardInserted,
'dataRoaming-warning-head',
'dataRoaming-warning-message');
}
/**
* Show the carrier name in the ICC card.
*/
function cs_showCarrierName() {
if (DsdsSettings.getNumberOfIccSlots() > 1) {
// We don't do anything here when the device support dsds.
return;
}
var iccCard = _iccManager.getIccById(_mobileConnection.iccId);
var network = _mobileConnection.voice.network;
var iccInfo = iccCard && iccCard.iccInfo;
var carrier = network ? (network.shortName || network.longName) : null;
if (carrier && iccInfo && iccInfo.isDisplaySpnRequired && iccInfo.spn) {
if (iccInfo.isDisplayNetworkNameRequired && carrier !== iccInfo.spn) {
carrier = carrier + ' ' + iccInfo.spn;
} else {
carrier = iccInfo.spn;
}
}
if (iccCard) {
_elements.desc.textContent = carrier;
} else {
_elements.desc.setAttribute('data-l10n-id', 'noSimCard');
}
}
/**
* Init a warning dialog.
*
* @param {String} settingKey The key of the setting.
* @param {Object} input The input element.
* @param {Boolean} isSimCardInserted
* True if there is a SIM card inserted, otherwise.
* @param {String} l10n id of the title.
* @param {String} l10n id of the message.
*/
function cs_initWarning(settingKey,
input,
isSimCardInserted,
titleL10nId,
messageL10nId) {
var warningDialogEnabledKey = settingKey + '.warningDialog.enabled';
/**
* Figure out whether the warning is enabled or not.
*
* @param {Function} callback Callback function to be called once the
* work is done.
*/
function getWarningEnabled(callback) {
var request = _settings.createLock().get(warningDialogEnabledKey);
request.onsuccess = function onSuccessHandler() {
var warningEnabled = request.result[warningDialogEnabledKey];
if (warningEnabled === null) {
warningEnabled = true;
}
if (callback) {
callback(warningEnabled);
}
};
}
/**
* Set the value of the setting into the settings database.
*
* @param {Boolean} state State to be stored.
*/
function setState(state) {
var cset = {};
cset[settingKey] = !!state;
_settings.createLock().set(cset);
}
function getState(callback) {
var request = _settings.createLock().get(settingKey);
request.onsuccess = function onSuccessHandler() {
if (callback) {
callback(request.result[settingKey]);
}
};
}
function setWarningDialogState(state) {
var cset = {};
cset[warningDialogEnabledKey] = !!state;
_settings.createLock().set(cset);
}
/**
* Helper function. Handler to be called once the user click on the
* accept button form the warning dialog.
*/
function onSubmit() {
setWarningDialogState(false);
setState(true);
input.checked = true;
}
/**
* Helper function. Handler to be called once the user click on the
* cancel button form the warning dialog.
*/
function onReset() {
setWarningDialogState(true);
setState(false);
input.checked = false;
}
// Initialize the state of the input.
getState(function(enabled) {
input.checked = isSimCardInserted && enabled;
// Register an observer to monitor setting changes.
input.addEventListener('change', function() {
var enabled = this.checked;
getWarningEnabled(function getWarningEnabledCb(warningEnabled) {
if (warningEnabled) {
if (enabled) {
require(['modules/dialog_service'], function(DialogService) {
DialogService.confirm(messageL10nId, {
title: titleL10nId,
submitButton: 'turnOn',
cancelButton: 'notNow'
}).then(function(result) {
var type = result.type;
if (type === 'submit') {
onSubmit();
} else {
onReset();
}
});
});
}
} else {
setState(enabled);
}
});
});
});
// Initialize the visibility of the warning message.
getWarningEnabled(function getWarningEnabledCb(warningEnabled) {
if (warningEnabled) {
var request = _settings.createLock().get(settingKey);
request.onsuccess = function onSuccessCb() {
var enabled = false;
if (request.result[settingKey] !== undefined) {
enabled = request.result[settingKey];
}
if (enabled) {
setWarningDialogState(false);
}
};
}
});
}
return {
init: cs_init
};
})();
return Carrier;
});

View file

@ -0,0 +1,261 @@
/* global DsdsSettings */
'use strict';
/**
* Singleton object that helps to populate and manage the 'Select a SIM card'
* panel in the cell and data settings panel.
*/
window.IccHandlerForCarrierSettings = (function() {
/** Card state mapping const. */
var CARDSTATE_MAPPING = {
'pinRequired' : 'simCardLockedMsg',
'pukRequired' : 'simCardLockedMsg',
'permanentBlocked': 'simCardBlockedMsg',
'networkLocked' : 'simLockedPhone',
'serviceProviderLocked' : 'simLockedPhone',
'corporateLocked' : 'simLockedPhone',
'network1Locked' : 'simLockedPhone',
'network2Locked' : 'simLockedPhone',
'hrpdNetworkLocked' : 'simLockedPhone',
'ruimCorporateLocked' : 'simLockedPhone',
'ruimServiceProviderLocked' : 'simLockedPhone',
'unknown' : 'unknownSimCardState',
'illegal' : 'simCardIllegal',
'absent' : 'noSimCard',
'null' : 'simCardNotReady',
'ready': ''
};
var DATA_TYPE_MAPPING = {
'lte' : '4G LTE',
'ehrpd': '4G CDMA',
'hspa+': '3.5G HSPA+',
'hsdpa': '3.5G HSDPA',
'hsupa': '3.5G HSDPA',
'hspa' : '3.5G HSDPA',
'evdo0': 'EVDO',
'evdoa': 'EVDO',
'evdob': 'EVDO',
'1xrtt': '1xRTT',
'umts' : '3G UMTS',
'edge' : '2G EDGE',
'is95a': '1xRTT',
'is95b': '1xRTT',
'gprs' : '2G GPRS'
};
var _settings = window.navigator.mozSettings;
var _iccManager = window.navigator.mozIccManager;
var _mobileConnections = null;
/** Array of menu item ids. */
var _menuItemIds = ['menuItem-carrier-sim1', 'menuItem-carrier-sim2'];
/** Array of menu item descriptions. */
var _menuItemDescriptions = [];
/**
* Init function.
*/
function ihfcs_init() {
_mobileConnections = window.navigator.mozMobileConnections;
if (!_settings || !_mobileConnections || !_iccManager) {
return;
}
if (DsdsSettings.getNumberOfIccSlots() === 1) {
return;
}
function addListeners(iccId) {
var eventHandler = ihfcs_showICCCardDetails.bind(null, iccId);
var iccCard = _iccManager.getIccById(iccId);
if (!iccCard) {
return;
}
iccCard.addEventListener('cardstatechange', eventHandler);
var mobileConnection = ihfcs_getMobileConnectionFromIccId(iccId);
if (!mobileConnection) {
return;
}
mobileConnection.addEventListener('datachange', eventHandler);
mobileConnection.addEventListener('radiostatechange', eventHandler);
}
_menuItemIds.forEach(function forEachFunction(id) {
var selector = document.getElementById(id);
_menuItemDescriptions[_menuItemIds.indexOf(id)] =
selector.querySelector('small');
});
_menuItemIds.forEach(function forEachFunction(id) {
var selector = document.getElementById(id);
var element = selector.querySelector('a');
element.addEventListener('click', function eventListenerHandler() {
DsdsSettings.setIccCardIndexForCellAndDataSettings(
_menuItemIds.indexOf(id)
);
});
});
var numberOfIccCards = _mobileConnections.length;
for (var i = 0; i < numberOfIccCards; i++) {
var mobileConnection = _mobileConnections[i];
if (!mobileConnection.iccId) {
// TODO: this could mean there is no ICC card or the ICC card is
// locked. If locked we would need to figure out how to check the
// current card state.
ihfcs_disableItems(_menuItemIds[i], true);
continue;
}
ihfcs_showICCCardDetails(mobileConnection.iccId);
addListeners(mobileConnection.iccId);
}
_iccManager.addEventListener('iccdetected',
function iccDetectedHandler(evt) {
var iccId = evt.iccId;
ihfcs_showICCCardDetails(iccId);
addListeners(iccId);
});
_iccManager.addEventListener('iccundetected',
function iccUndetectedHandler(evt) {
var iccId = evt.iccId;
var eventHandler = ihfcs_showICCCardDetails.bind(null, iccId);
var mobileConnection = ihfcs_getMobileConnectionFromIccId(iccId);
if (!mobileConnection) {
return;
}
mobileConnection.removeEventListener('datachange', eventHandler);
mobileConnection.removeEventListener('radiostatechange', eventHandler);
});
}
/**
* Show some details (card state or carrier) of the ICC card.
*
* @param {String} iccId ICC id.
*/
function ihfcs_showICCCardDetails(iccId) {
var iccCardIndex = ihfcs_getIccCardIndex(iccId);
var desc = _menuItemDescriptions[iccCardIndex];
desc.style.fontStyle = 'italic';
var mobileConnection = ihfcs_getMobileConnectionFromIccId(iccId);
if (!mobileConnection) {
desc.textContent = '';
desc.removeAttribute('data-l10n-id');
ihfcs_disableItems(_menuItemIds[iccCardIndex], true);
return;
}
if (mobileConnection.radioState !== 'enabled') {
// Airplane is enabled. Well, radioState property could be changing but
// let's disable the items during the transitions also.
desc.setAttribute('data-l10n-id', CARDSTATE_MAPPING['null']);
ihfcs_disableItems(_menuItemIds[iccCardIndex], true);
return;
}
if (mobileConnection.radioState === 'enabled') {
desc.textContent = '';
desc.removeAttribute('data-l10n-id');
ihfcs_disableItems(_menuItemIds[iccCardIndex], false);
}
var iccCard = _iccManager.getIccById(iccId);
if (!iccCard) {
desc.textContent = '';
desc.removeAttribute('data-l10n-id');
ihfcs_disableItems(_menuItemIds[iccCardIndex], true);
return;
}
var cardState = iccCard.cardState;
if (cardState !== 'ready') {
desc.setAttribute('data-l10n-id',
CARDSTATE_MAPPING[cardState || 'null']);
ihfcs_disableItems(_menuItemIds[iccCardIndex], true);
return;
}
desc.style.fontStyle = 'normal';
var network = mobileConnection.voice.network;
var iccInfo = iccCard.iccInfo;
var carrier = network ? (network.shortName || network.longName) : null;
if (carrier && iccInfo && iccInfo.isDisplaySpnRequired && iccInfo.spn) {
if (iccInfo.isDisplayNetworkNameRequired && carrier !== iccInfo.spn) {
carrier = carrier + ' ' + iccInfo.spn;
} else {
carrier = iccInfo.spn;
}
}
desc.textContent = carrier;
var dataType = (mobileConnection.data.connected &&
mobileConnection.data.type) ?
DATA_TYPE_MAPPING[mobileConnection.data.type] :
'';
if (dataType) {
desc.textContent += ' - ' + dataType;
}
ihfcs_disableItems(_menuItemIds[iccCardIndex], false);
}
/**
* Disable the items listed in the panel in order to avoid user interaction.
*
* @param {String} id Element id from the element to disable.
* @param {Boolean} disable This flag tells the function what to do.
*/
function ihfcs_disableItems(id, disable) {
var element = document.getElementById(id);
if (disable) {
element.setAttribute('aria-disabled', true);
} else {
element.removeAttribute('aria-disabled');
}
}
/**
* Helper function. Return the index of the ICC card given the ICC code in the
* ICC card.
*
* @param {String} iccId The iccId code form the ICC card.
*
* @return {Numeric} The index.
*/
function ihfcs_getIccCardIndex(iccId) {
for (var i = 0; i < _mobileConnections.length; i++) {
if (_mobileConnections[i].iccId === iccId) {
return i;
}
}
return -1;
}
/**
* Helper function. Return the mozMobileConnection for the ICC card given the
* ICC code in the ICC card.
*
* @param {String} iccId The iccId code form the ICC card.
*
* @return {mozMobileConnection} mozMobileConnection object.
*/
function ihfcs_getMobileConnectionFromIccId(iccId) {
for (var i = 0; i < _mobileConnections.length; i++) {
if (_mobileConnections[i].iccId === iccId) {
return _mobileConnections[i];
}
}
return null;
}
return {
init: ihfcs_init
};
})();

View file

@ -0,0 +1,18 @@
/**
* Used to show Cellular and Data panel
*/
define(function(require) {
'use strict';
var SettingsPanel = require('modules/settings_panel');
var Carrier = require('panels/carrier/carrier');
return function ctor_media_storage_panel() {
return SettingsPanel({
onInit: function() {
//XXX should further refactor the panel
Carrier.init();
}
});
};
});