B2G/gaia/apps/system/js/operator_variant/operator_variant.js
// Store APN settings for the first carrier matching the mcc/mnc info.
Store APN settings for the first carrier matching the mcc/mnc info.
Store APN settings for the first carrier matching the mcc / mnc info .
function applyOperatorVariantSettings(result) {
    var apnPrefNames = {
      'default': {
        'ril.data.carrier': 'carrier',
        'ril.data.apn': 'apn',
        'ril.data.user': 'user',
        'ril.data.passwd': 'password',
        'ril.data.httpProxyHost': 'proxy',
        'ril.data.httpProxyPort': 'port',
        'ril.data.authtype': 'authtype'
      },
      'supl': {
        'ril.supl.carrier': 'carrier',
        'ril.supl.apn': 'apn',
        'ril.supl.user': 'user',
        'ril.supl.passwd': 'password',
        'ril.supl.httpProxyHost': 'proxy',
        'ril.supl.httpProxyPort': 'port',
        'ril.supl.authtype': 'authtype'
      },
      'mms': {
        'ril.mms.carrier': 'carrier',
        'ril.mms.apn': 'apn',
        'ril.mms.user': 'user',
        'ril.mms.passwd': 'password',
        'ril.mms.httpProxyHost': 'proxy',
        'ril.mms.httpProxyPort': 'port',
        'ril.mms.mmsc': 'mmsc',
        'ril.mms.mmsproxy': 'mmsproxy',
        'ril.mms.mmsport': 'mmsport',
        'ril.mms.authtype': 'authtype'
      },
      'operatorvariant': {
        'ril.iccInfo.mbdn': 'voicemail',
        'ril.sms.strict7BitEncoding.enabled': 'enableStrict7BitEncodingForSms',
        'ril.cellbroadcast.searchlist': 'cellBroadcastSearchList',
        'dom.mms.operatorSizeLimitation': 'operatorSizeLimitation'
      }
    };
    var booleanPrefNames = [
      'ril.sms.strict7BitEncoding.enabled'
    ];
    const AUTH_TYPES = ['none', 'pap', 'chap', 'papOrChap'];
    const DEFAULT_MMS_SIZE_LIMITATION = 300 * 1024;
    var transaction = settings.createLock();
    for (var type in apnPrefNames) {
      var apn = {};
      for (var i = 0; i < result.length; i++) {
        if (result[i] && result[i].type.indexOf(type) != -1) {
          apn = result[i];
          break;
        }
      }
      var prefNames = apnPrefNames[type];
      for (var key in prefNames) {
        var name = apnPrefNames[type][key];
        var item = {};
        switch (name) {
          case 'authtype':
            item[key] = apn[name] ? AUTH_TYPES[apn[name]] : 'notDefined';
            break;
          case 'operatorSizeLimitation':
            item[key] = +apn[name] || DEFAULT_MMS_SIZE_LIMITATION;
            break;
          default:
            if (booleanPrefNames.indexOf(key) !== -1) {
              item[key] = apn[name] || false;
            } else {
              item[key] = apn[name] || '';
            }
            break;
        }
        transaction.set(item);
      }
    }
    transaction.set({
      'operatorvariant.mcc': iccSettings.mcc,
      'operatorvariant.mnc': iccSettings.mnc
    });
  }
function applyOperatorVariantSettings ( result ) { var apnPrefNames = { 'default' : { 'ril.data.carrier' : 'carrier' , 'ril.data.apn' : 'apn' , 'ril.data.user' : 'user' , 'ril.data.passwd' : 'password' , 'ril.data.httpProxyHost' : 'proxy' , 'ril.data.httpProxyPort' : 'port' , 'ril.data.authtype' : 'authtype' } , 'supl' : { 'ril.supl.carrier' : 'carrier' , 'ril.supl.apn' : 'apn' , 'ril.supl.user' : 'user' , 'ril.supl.passwd' : 'password' , 'ril.supl.httpProxyHost' : 'proxy' , 'ril.supl.httpProxyPort' : 'port' , 'ril.supl.authtype' : 'authtype' } , 'mms' : { 'ril.mms.carrier' : 'carrier' , 'ril.mms.apn' : 'apn' , 'ril.mms.user' : 'user' , 'ril.mms.passwd' : 'password' , 'ril.mms.httpProxyHost' : 'proxy' , 'ril.mms.httpProxyPort' : 'port' , 'ril.mms.mmsc' : 'mmsc' , 'ril.mms.mmsproxy' : 'mmsproxy' , 'ril.mms.mmsport' : 'mmsport' , 'ril.mms.authtype' : 'authtype' } , 'operatorvariant' : { 'ril.iccInfo.mbdn' : 'voicemail' , 'ril.sms.strict7BitEncoding.enabled' : 'enableStrict7BitEncodingForSms' , 'ril.cellbroadcast.searchlist' : 'cellBroadcastSearchList' , 'dom.mms.operatorSizeLimitation' : 'operatorSizeLimitation' } } ; var booleanPrefNames = [ 'ril.sms.strict7BitEncoding.enabled' ] ; const AUTH_TYPES = [ 'none' , 'pap' , 'chap' , 'papOrChap' ] ; const DEFAULT_MMS_SIZE_LIMITATION = 300 * 1024 ; var transaction = settings . createLock ( ) ; for ( var type in apnPrefNames ) { var apn = { } ; for ( var i = 0 ; i < result . length ; i ++ ) { if ( result [ i ] && result [ i ] . type . indexOf ( type ) != - 1 ) { apn = result [ i ] ; break ; } } var prefNames = apnPrefNames [ type ] ; for ( var key in prefNames ) { var name = apnPrefNames [ type ] [ key ] ; var item = { } ; switch ( name ) { case 'authtype' : item [ key ] = apn [ name ] ? AUTH_TYPES [ apn [ name ] ] : 'notDefined' ; break ; case 'operatorSizeLimitation' : item [ key ] = + apn [ name ] || DEFAULT_MMS_SIZE_LIMITATION ; break ; default : if ( booleanPrefNames . indexOf ( key ) !== - 1 ) { item [ key ] = apn [ name ] || false ; } else { item [ key ] = apn [ name ] || '' ; } break ; } transaction . set ( item ) ; } } transaction . set ( { 'operatorvariant.mcc' : iccSettings . mcc , 'operatorvariant.mnc' : iccSettings . mnc } ) ; }
Store APN settings for the first carrier matching the mcc/mnc info.
Store APN settings for the first carrier matching the mcc / mnc info .
// store relevant APN settings // load values from the AUTH_TYPES // all other keys default to empty strings // store the current mcc/mnc info in the settings