Loading src/com/android/settings/ApnSettings.java +64 −3 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceScreen; import android.telephony.CarrierConfigManager; import android.telephony.ServiceState; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -91,6 +92,8 @@ public class ApnSettings extends RestrictedSettingsFragment implements private static final int MVNO_TYPE_INDEX = 4; private static final int MVNO_MATCH_DATA_INDEX = 5; private static final int RO_INDEX = 6; private static final int BEARER_INDEX = 7; private static final int BEARER_BITMASK_INDEX = 8; private static final int MENU_NEW = Menu.FIRST; private static final int MENU_RESTORE = Menu.FIRST + 1; Loading Loading @@ -334,8 +337,8 @@ public class ApnSettings extends RestrictedSettingsFragment implements Log.d(TAG, "where---" + where); Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] { "_id", "name", "apn", "type", "mvno_type", "mvno_match_data", "read_only"}, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER); "_id", "name", "apn", "type", "mvno_type", "mvno_match_data", "read_only", "bearer", "bearer_bitmask"}, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER); if (cursor != null) { IccRecords r = null; Loading Loading @@ -365,7 +368,22 @@ public class ApnSettings extends RestrictedSettingsFragment implements if (!TextUtils.isEmpty(localizedName)) { name = localizedName; } int bearer = cursor.getInt(BEARER_INDEX); int bearerBitMask = cursor.getInt(BEARER_BITMASK_INDEX); int fullBearer = bearer | bearerBitMask; int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId() : SubscriptionManager.INVALID_SUBSCRIPTION_ID; int radioTech = networkTypeToRilRidioTechnology(TelephonyManager.getDefault() .getDataNetworkType(subId)); if (!ServiceState.bitmaskHasTech(fullBearer, radioTech) && (bearer != 0 || bearerBitMask != 0)) { // In OOS, show APN with bearer as default if ((radioTech != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) || (bearer == 0 && radioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)) { cursor.moveToNext(); continue; } } ApnPreference pref = new ApnPreference(getPrefContext()); pref.setApnReadOnly(readOnly); Loading Loading @@ -417,6 +435,49 @@ public class ApnSettings extends RestrictedSettingsFragment implements return false; } private int networkTypeToRilRidioTechnology(int nt) { switch(nt) { case TelephonyManager.NETWORK_TYPE_GPRS: return ServiceState.RIL_RADIO_TECHNOLOGY_GPRS; case TelephonyManager.NETWORK_TYPE_EDGE: return ServiceState.RIL_RADIO_TECHNOLOGY_EDGE; case TelephonyManager.NETWORK_TYPE_UMTS: return ServiceState.RIL_RADIO_TECHNOLOGY_UMTS; case TelephonyManager.NETWORK_TYPE_HSDPA: return ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA; case TelephonyManager.NETWORK_TYPE_HSUPA: return ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA; case TelephonyManager.NETWORK_TYPE_HSPA: return ServiceState.RIL_RADIO_TECHNOLOGY_HSPA; case TelephonyManager.NETWORK_TYPE_CDMA: return ServiceState.RIL_RADIO_TECHNOLOGY_IS95B; case TelephonyManager.NETWORK_TYPE_1xRTT: return ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT; case TelephonyManager.NETWORK_TYPE_EVDO_0: return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0; case TelephonyManager.NETWORK_TYPE_EVDO_A: return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A; case TelephonyManager.NETWORK_TYPE_EVDO_B: return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B; case TelephonyManager.NETWORK_TYPE_EHRPD: return ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD; case TelephonyManager.NETWORK_TYPE_LTE: return ServiceState.RIL_RADIO_TECHNOLOGY_LTE; case TelephonyManager.NETWORK_TYPE_HSPAP: return ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP; case TelephonyManager.NETWORK_TYPE_GSM: return ServiceState.RIL_RADIO_TECHNOLOGY_GSM; case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA; case TelephonyManager.NETWORK_TYPE_IWLAN: return ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN; case TelephonyManager.NETWORK_TYPE_LTE_CA: return ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA; default: return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; } } public static String getLocalizedName(Context context, Cursor cursor, int index) { // If can find a localized name, replace the APN name with it String resName = cursor.getString(index); Loading Loading
src/com/android/settings/ApnSettings.java +64 −3 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.support.v7.preference.Preference; import android.support.v7.preference.PreferenceGroup; import android.support.v7.preference.PreferenceScreen; import android.telephony.CarrierConfigManager; import android.telephony.ServiceState; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -91,6 +92,8 @@ public class ApnSettings extends RestrictedSettingsFragment implements private static final int MVNO_TYPE_INDEX = 4; private static final int MVNO_MATCH_DATA_INDEX = 5; private static final int RO_INDEX = 6; private static final int BEARER_INDEX = 7; private static final int BEARER_BITMASK_INDEX = 8; private static final int MENU_NEW = Menu.FIRST; private static final int MENU_RESTORE = Menu.FIRST + 1; Loading Loading @@ -334,8 +337,8 @@ public class ApnSettings extends RestrictedSettingsFragment implements Log.d(TAG, "where---" + where); Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] { "_id", "name", "apn", "type", "mvno_type", "mvno_match_data", "read_only"}, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER); "_id", "name", "apn", "type", "mvno_type", "mvno_match_data", "read_only", "bearer", "bearer_bitmask"}, where.toString(), null, Telephony.Carriers.DEFAULT_SORT_ORDER); if (cursor != null) { IccRecords r = null; Loading Loading @@ -365,7 +368,22 @@ public class ApnSettings extends RestrictedSettingsFragment implements if (!TextUtils.isEmpty(localizedName)) { name = localizedName; } int bearer = cursor.getInt(BEARER_INDEX); int bearerBitMask = cursor.getInt(BEARER_BITMASK_INDEX); int fullBearer = bearer | bearerBitMask; int subId = mSubscriptionInfo != null ? mSubscriptionInfo.getSubscriptionId() : SubscriptionManager.INVALID_SUBSCRIPTION_ID; int radioTech = networkTypeToRilRidioTechnology(TelephonyManager.getDefault() .getDataNetworkType(subId)); if (!ServiceState.bitmaskHasTech(fullBearer, radioTech) && (bearer != 0 || bearerBitMask != 0)) { // In OOS, show APN with bearer as default if ((radioTech != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) || (bearer == 0 && radioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)) { cursor.moveToNext(); continue; } } ApnPreference pref = new ApnPreference(getPrefContext()); pref.setApnReadOnly(readOnly); Loading Loading @@ -417,6 +435,49 @@ public class ApnSettings extends RestrictedSettingsFragment implements return false; } private int networkTypeToRilRidioTechnology(int nt) { switch(nt) { case TelephonyManager.NETWORK_TYPE_GPRS: return ServiceState.RIL_RADIO_TECHNOLOGY_GPRS; case TelephonyManager.NETWORK_TYPE_EDGE: return ServiceState.RIL_RADIO_TECHNOLOGY_EDGE; case TelephonyManager.NETWORK_TYPE_UMTS: return ServiceState.RIL_RADIO_TECHNOLOGY_UMTS; case TelephonyManager.NETWORK_TYPE_HSDPA: return ServiceState.RIL_RADIO_TECHNOLOGY_HSDPA; case TelephonyManager.NETWORK_TYPE_HSUPA: return ServiceState.RIL_RADIO_TECHNOLOGY_HSUPA; case TelephonyManager.NETWORK_TYPE_HSPA: return ServiceState.RIL_RADIO_TECHNOLOGY_HSPA; case TelephonyManager.NETWORK_TYPE_CDMA: return ServiceState.RIL_RADIO_TECHNOLOGY_IS95B; case TelephonyManager.NETWORK_TYPE_1xRTT: return ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT; case TelephonyManager.NETWORK_TYPE_EVDO_0: return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_0; case TelephonyManager.NETWORK_TYPE_EVDO_A: return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_A; case TelephonyManager.NETWORK_TYPE_EVDO_B: return ServiceState.RIL_RADIO_TECHNOLOGY_EVDO_B; case TelephonyManager.NETWORK_TYPE_EHRPD: return ServiceState.RIL_RADIO_TECHNOLOGY_EHRPD; case TelephonyManager.NETWORK_TYPE_LTE: return ServiceState.RIL_RADIO_TECHNOLOGY_LTE; case TelephonyManager.NETWORK_TYPE_HSPAP: return ServiceState.RIL_RADIO_TECHNOLOGY_HSPAP; case TelephonyManager.NETWORK_TYPE_GSM: return ServiceState.RIL_RADIO_TECHNOLOGY_GSM; case TelephonyManager.NETWORK_TYPE_TD_SCDMA: return ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA; case TelephonyManager.NETWORK_TYPE_IWLAN: return ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN; case TelephonyManager.NETWORK_TYPE_LTE_CA: return ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA; default: return ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN; } } public static String getLocalizedName(Context context, Cursor cursor, int index) { // If can find a localized name, replace the APN name with it String resName = cursor.getString(index); Loading