/** Based on the operator, create a list of cdma data profiles. */ private void readNaiListFromDatabase() { String operator = getOperatorNumeric(); if (operator == null || operator.length() < 2) { loge("operatorNumeric invalid. Won't read database"); return; } log("Loading data profiles for operator = " + operator); String selection = "numeric = '" + operator + "'"; // query only enabled nai. // carrier_enabled : 1 means enabled nai, 0 disabled nai. selection += " and carrier_enabled = 1"; log("readNaiListFromDatabase: selection=" + selection); Cursor cursor = mPhone .getContext() .getContentResolver() .query(Telephony.Carriers.CONTENT_URI, null, selection, null, null); if (cursor != null) { if (cursor.getCount() > 0) { populateDataProfilesList(cursor); } cursor.close(); } }
CdmaDataProfileTracker(CDMAPhone phone) { mPhone = phone; mCdmaSsm = CdmaSubscriptionSourceManager.getInstance( phone.getContext(), phone.mCM, this, EVENT_LOAD_PROFILES, null); mOmhServicePriorityMap = new HashMap<String, Integer>(); sendMessage(obtainMessage(EVENT_LOAD_PROFILES)); log("SUPPORT_OMH: " + mIsOmhEnabled); }
/** * - Create the default profiles. - One for DUN and another for all the default profiles supported */ private void createDefaultDataProfiles() { log("Creating default profiles..."); String ipProto = SystemProperties.get(TelephonyProperties.PROPERTY_CDMA_IPPROTOCOL, "IP"); String roamingIpProto = SystemProperties.get(TelephonyProperties.PROPERTY_CDMA_ROAMING_IPPROTOCOL, "IP"); CdmaDataConnectionTracker cdmaDct = (CdmaDataConnectionTracker) (mPhone.mDataConnectionTracker); DataProfileCdma dp; dp = new DataProfileCdma( cdmaDct.apnTypeToId(Phone.APN_TYPE_DEFAULT), null, null, null, null, RILConstants.SETUP_DATA_AUTH_PAP_CHAP, mDefaultApnTypes, ipProto, roamingIpProto, mPhone.getServiceState().getRadioTechnology()); dp.setProfileId(RILConstants.DATA_PROFILE_DEFAULT); mDataProfilesList.add((DataProfile) dp); String[] types = {Phone.APN_TYPE_DUN}; dp = new DataProfileCdma( cdmaDct.apnTypeToId(Phone.APN_TYPE_DUN), null, null, null, null, RILConstants.SETUP_DATA_AUTH_PAP_CHAP, types, ipProto, roamingIpProto, mPhone.getServiceState().getRadioTechnology()); dp.setProfileId(RILConstants.DATA_PROFILE_TETHERED); mDataProfilesList.add((DataProfile) dp); }
public DataProfile getDataProfile(String serviceType) { DataProfile profile = null; // first try to get preferred APN String operator = getOperatorNumeric(); String selection = "numeric = '" + operator + "'"; // query only enabled nai. // carrier_enabled : 1 means enabled nai, 0 disabled nai. selection += " and carrier_enabled = 1"; Cursor cursor = mPhone .getContext() .getContentResolver() .query(PREFER_DEFAULT_APN_URI, null, selection, null, null); log( "getDataProfile operator:" + operator + " select:" + selection + " count:" + cursor.getCount()); if (cursor != null && cursor.getCount() > 0) { if (cursor.moveToFirst()) { do { String[] types = parseTypes(cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.TYPE))); DataProfile nai = new DataProfileCdma( cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers._ID)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NUMERIC)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.USER)), cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PASSWORD)), cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.AUTH_TYPE)), types, cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL)), cursor.getString( cursor.getColumnIndexOrThrow(Telephony.Carriers.ROAMING_PROTOCOL)), cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.BEARER))); if (nai.canHandleType(serviceType)) { cursor.close(); return nai; } } while (cursor.moveToNext()); } } if (cursor != null) cursor.close(); // Go through all the profiles to find one for (DataProfile dp : mDataProfilesList) { if (dp.canHandleType(serviceType)) { profile = dp; if (mIsOmhEnabled && dp.getDataProfileType() != DataProfile.DataProfileType.PROFILE_TYPE_OMH) { // OMH enabled - Keep looking for OMH profile continue; } break; } } return profile; }