Loading src/java/com/android/internal/telephony/ServiceStateTracker.java +28 −25 Original line number Diff line number Diff line Loading @@ -2098,32 +2098,15 @@ public class ServiceStateTracker extends Handler { int newFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN; if (physicalChannelConfigs != null) { for (PhysicalChannelConfig config : physicalChannelConfigs) { if (isNrPhysicalChannelConfig(config)) { // Update the frequency range of the NR parameters if there is an internet data // connection associate to this NR physical channel channel config. int[] contextIds = config.getContextIds(); for (int cid : contextIds) { if (mPhone.isUsingNewDataStack()) { if (mPhone.getDataNetworkController().isInternetNetwork(cid)) { newFrequencyRange = ServiceState.getBetterNRFrequencyRange( newFrequencyRange, config.getFrequencyRange()); break; } } else { DataConnection dc = mPhone.getDcTracker( AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .getDataConnectionByContextId(cid); if (dc != null && dc.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_INTERNET)) { if (isNrPhysicalChannelConfig(config) && isInternetPhysicalChannelConfig(config)) { // Update the NR frequency range if there is an internet data connection // associated with this NR physical channel channel config. newFrequencyRange = ServiceState.getBetterNRFrequencyRange( newFrequencyRange, config.getFrequencyRange()); break; } } } } } } boolean hasChanged = newFrequencyRange != ss.getNrFrequencyRange(); ss.setNrFrequencyRange(newFrequencyRange); Loading @@ -2138,7 +2121,8 @@ public class ServiceStateTracker extends Handler { boolean hasNrSecondaryServingCell = false; for (PhysicalChannelConfig config : configs) { if (isNrPhysicalChannelConfig(config) && config.getConnectionStatus() if (isNrPhysicalChannelConfig(config) && isInternetPhysicalChannelConfig(config) && config.getConnectionStatus() == PhysicalChannelConfig.CONNECTION_SECONDARY_SERVING) { hasNrSecondaryServingCell = true; break; Loading @@ -2146,7 +2130,7 @@ public class ServiceStateTracker extends Handler { } int oldNrState = regInfo.getNrState(); int newNrState = oldNrState; int newNrState; if (hasNrSecondaryServingCell) { newNrState = NetworkRegistrationInfo.NR_STATE_CONNECTED; } else { Loading @@ -2164,6 +2148,25 @@ public class ServiceStateTracker extends Handler { return config.getNetworkType() == TelephonyManager.NETWORK_TYPE_NR; } private boolean isInternetPhysicalChannelConfig(PhysicalChannelConfig config) { for (int cid : config.getContextIds()) { if (mPhone.isUsingNewDataStack()) { if (mPhone.getDataNetworkController().isInternetNetwork(cid)) { return true; } } else { DataConnection dc = mPhone.getDcTracker( AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .getDataConnectionByContextId(cid); if (dc != null && dc.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_INTERNET)) { return true; } } } return false; } /** * This combine PS registration states from cellular and IWLAN and generates the final data * reg state and rat for backward compatibility purpose. In reality there should be two separate Loading src/java/com/android/internal/telephony/data/DataConfigManager.java +34 −32 Original line number Diff line number Diff line Loading @@ -35,9 +35,9 @@ import android.telephony.Annotation.ApnType; import android.telephony.Annotation.NetCapability; import android.telephony.Annotation.NetworkType; import android.telephony.CarrierConfigManager; import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.data.ApnSetting; import android.text.TextUtils; Loading Loading @@ -623,13 +623,13 @@ public class DataConfigManager extends Handler { /** * Get whether the network type is unmetered from the carrier configs. * * @param networkType The network type to check meteredness for * @param serviceState The service state, used to determine NR state * @return Whether the carrier considers the given network type unmetered * @param displayInfo The {@link TelephonyDisplayInfo} to check meteredness for. * @param serviceState The {@link ServiceState}, used to determine roaming state. * @return Whether the carrier considers the given display info unmetered. */ public boolean isNetworkTypeUnmetered(@NetworkType int networkType, public boolean isNetworkTypeUnmetered(@NonNull TelephonyDisplayInfo displayInfo, @NonNull ServiceState serviceState) { String dataConfigNetworkType = getDataConfigNetworkType(networkType, serviceState); String dataConfigNetworkType = getDataConfigNetworkType(displayInfo); return serviceState.getDataRoaming() ? mRoamingUnmeteredNetworkTypes.contains(dataConfigNetworkType) : mUnmeteredNetworkTypes.contains(dataConfigNetworkType); Loading Loading @@ -686,14 +686,13 @@ public class DataConfigManager extends Handler { /** * Get the bandwidth estimate from the carrier config. * * @param networkType The network type to get the bandwidth for * @param serviceState The service state, used to determine NR state * @param displayInfo The {@link TelephonyDisplayInfo} to get the bandwidth for. * @return The pre-configured bandwidth estimate from carrier config. */ public @NonNull DataNetwork.NetworkBandwidth getBandwidthForNetworkType( @NetworkType int networkType, @NonNull ServiceState serviceState) { @NonNull TelephonyDisplayInfo displayInfo) { DataNetwork.NetworkBandwidth bandwidth = mBandwidthMap.get( getDataConfigNetworkType(networkType, serviceState)); getDataConfigNetworkType(displayInfo)); if (bandwidth != null) { return bandwidth; } Loading Loading @@ -804,15 +803,12 @@ public class DataConfigManager extends Handler { * The config string will have the following form, with values in bytes: * "read_min,read_default,read_max,write_min,write_default,write_max" * * @param networkType The network type. Note that {@link TelephonyManager#NETWORK_TYPE_LTE_CA} * can be used for LTE CA even though it's not a radio access technology. * @param serviceState The service state, used to determine NR state. * @return The TCP configuration string for the given network type or the default value from * config_tcp_buffers if unavailable. * @param displayInfo The {@link TelephonyDisplayInfo} to get the TCP config string for. * @return The TCP configuration string for the given display info or the default value from * {@code config_tcp_buffers} if unavailable. */ public @NonNull String getTcpConfigString(@NetworkType int networkType, @NonNull ServiceState serviceState) { String config = mTcpBufferSizeMap.get(getDataConfigNetworkType(networkType, serviceState)); public @NonNull String getTcpConfigString(@NonNull TelephonyDisplayInfo displayInfo) { String config = mTcpBufferSizeMap.get(getDataConfigNetworkType(displayInfo)); if (TextUtils.isEmpty(config)) { config = getDefaultTcpConfigString(); } Loading Loading @@ -882,26 +878,32 @@ public class DataConfigManager extends Handler { } /** * Get the data config network type based on the given network type and service state * Get the {@link DataConfigNetworkType} based on the given {@link TelephonyDisplayInfo}. * * @param networkType The network type * @param serviceState The service state, used to determine NR state * @return The equivalent data config network type * @param displayInfo The {@link TelephonyDisplayInfo} used to determine the type. * @return The equivalent {@link DataConfigNetworkType}. */ public static @NonNull @DataConfigNetworkType String getDataConfigNetworkType( @NetworkType int networkType, @NonNull ServiceState serviceState) { @NonNull TelephonyDisplayInfo displayInfo) { // TODO: Make method private once DataConnection is removed if ((networkType == TelephonyManager.NETWORK_TYPE_LTE || networkType == TelephonyManager.NETWORK_TYPE_LTE_CA) && (serviceState.getNrState() == NetworkRegistrationInfo.NR_STATE_CONNECTED)) { return serviceState.getNrFrequencyRange() == ServiceState.FREQUENCY_RANGE_MMWAVE ? DATA_CONFIG_NETWORK_TYPE_NR_NSA_MMWAVE : DATA_CONFIG_NETWORK_TYPE_NR_NSA; } else if (networkType == TelephonyManager.NETWORK_TYPE_NR && serviceState.getNrFrequencyRange() == ServiceState.FREQUENCY_RANGE_MMWAVE) { int networkType = displayInfo.getNetworkType(); switch (displayInfo.getOverrideNetworkType()) { case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED: if (networkType == TelephonyManager.NETWORK_TYPE_NR) { return DATA_CONFIG_NETWORK_TYPE_NR_SA_MMWAVE; } else { return DATA_CONFIG_NETWORK_TYPE_NR_NSA_MMWAVE; } case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA: return DATA_CONFIG_NETWORK_TYPE_NR_NSA; case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO: case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA: return DATA_CONFIG_NETWORK_TYPE_LTE_CA; case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE: default: return networkTypeToDataConfigNetworkType(networkType); } } /** Update handover rules from carrier config. */ private void updateHandoverRules() { Loading src/java/com/android/internal/telephony/data/DataNetwork.java +29 −42 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import android.telephony.PcoData; import android.telephony.PreciseDataConnectionState; import android.telephony.ServiceState; import android.telephony.SubscriptionPlan; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.data.ApnSetting; import android.telephony.data.DataCallResponse; Loading Loading @@ -548,6 +549,9 @@ public class DataNetwork extends StateMachine { /** The TCP buffer sizes config. */ private @NonNull String mTcpBufferSizes; /** The telephony display info. */ private @NonNull TelephonyDisplayInfo mTelephonyDisplayInfo; /** Whether {@link NetworkCapabilities#NET_CAPABILITY_TEMPORARILY_NOT_METERED} is supported. */ private boolean mTempNotMeteredSupported = false; Loading Loading @@ -840,6 +844,7 @@ public class DataNetwork extends StateMachine { mCid.put(AccessNetworkConstants.TRANSPORT_TYPE_WWAN, INVALID_CID); mCid.put(AccessNetworkConstants.TRANSPORT_TYPE_WLAN, INVALID_CID); mTcpBufferSizes = mDataConfigManager.getDefaultTcpConfigString(); mTelephonyDisplayInfo = mPhone.getDisplayInfoController().getTelephonyDisplayInfo(); for (TelephonyNetworkRequest networkRequest : networkRequestList) { networkRequest.setAttachedNetwork(DataNetwork.this); Loading Loading @@ -1402,6 +1407,9 @@ public class DataNetwork extends StateMachine { mFailCause = DataFailCause.LOST_CONNECTION; transitionTo(mDisconnectedState); break; case EVENT_DISPLAY_INFO_CHANGED: onDisplayInfoChanged(); break; default: return NOT_HANDLED; } Loading Loading @@ -2159,38 +2167,6 @@ public class DataNetwork extends StateMachine { updateNetworkCapabilities(); } /** * @return {@code true} if the device is connected to NR cell in 5G NSA mode, and the current * data network is using the NR cell. */ private boolean isNrConnected() { return mPhone.getServiceState().getNrState() == NetworkRegistrationInfo.NR_STATE_CONNECTED && mPhone.getServiceStateTracker().getNrContextIds().contains( mCid.get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)); } /** * Get the TCP buffer sizes config string. * * @return The TCP buffer sizes config used in {@link LinkProperties#setTcpBufferSizes(String)}. */ private @Nullable String getTcpConfig() { ServiceState ss = mPhone.getServiceState(); NetworkRegistrationInfo nrs = ss.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, mTransport); int networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN; if (nrs != null) { networkType = nrs.getAccessNetworkTechnology(); if (networkType == TelephonyManager.NETWORK_TYPE_LTE && nrs.isUsingCarrierAggregation()) { // Although LTE_CA is not a real RAT, but since LTE CA generally has higher speed // we use LTE_CA to get a different TCP config for LTE CA. networkType = TelephonyManager.NETWORK_TYPE_LTE_CA; } } return mDataConfigManager.getTcpConfigString(networkType, ss); } /** * Called when receiving setup data network response from the data service. * Loading Loading @@ -2457,7 +2433,7 @@ public class DataNetwork extends StateMachine { log("onBandwidthUpdated: downlinkBandwidthKbps=" + downlinkBandwidthKbps + ", uplinkBandwidthKbps=" + uplinkBandwidthKbps); NetworkBandwidth bandwidthFromConfig = mDataConfigManager.getBandwidthForNetworkType( getDataNetworkType(), mPhone.getServiceState()); mTelephonyDisplayInfo); if (downlinkBandwidthKbps == LinkCapacityEstimate.INVALID && bandwidthFromConfig != null) { // Fallback to carrier config. Loading @@ -2477,10 +2453,11 @@ public class DataNetwork extends StateMachine { } /** * Called when display info changed. This can happen when network types changed or override * types (5G NSA, 5G MMWAVE) changes. * Called when {@link TelephonyDisplayInfo} changed. This can happen when network types or * override network types (5G NSA, 5G MMWAVE) change. */ private void onDisplayInfoChanged() { mTelephonyDisplayInfo = mPhone.getDisplayInfoController().getTelephonyDisplayInfo(); updateBandwidthFromDataConfig(); updateTcpBufferSizes(); updateMeteredAndCongested(); Loading @@ -2495,8 +2472,7 @@ public class DataNetwork extends StateMachine { return; } log("updateBandwidthFromDataConfig"); mNetworkBandwidth = mDataConfigManager.getBandwidthForNetworkType( getDataNetworkType(), mPhone.getServiceState()); mNetworkBandwidth = mDataConfigManager.getBandwidthForNetworkType(mTelephonyDisplayInfo); updateNetworkCapabilities(); } Loading @@ -2505,7 +2481,7 @@ public class DataNetwork extends StateMachine { */ private void updateTcpBufferSizes() { log("updateTcpBufferSizes"); mTcpBufferSizes = getTcpConfig(); mTcpBufferSizes = mDataConfigManager.getTcpConfigString(mTelephonyDisplayInfo); LinkProperties linkProperties = new LinkProperties(mLinkProperties); linkProperties.setTcpBufferSizes(mTcpBufferSizes); if (!linkProperties.equals(mLinkProperties)) { Loading @@ -2519,7 +2495,17 @@ public class DataNetwork extends StateMachine { * Update the metered and congested values from carrier configs and subscription overrides */ private void updateMeteredAndCongested() { int networkType = isNrConnected() ? TelephonyManager.NETWORK_TYPE_NR : getDataNetworkType(); int networkType = mTelephonyDisplayInfo.getNetworkType(); switch (mTelephonyDisplayInfo.getOverrideNetworkType()) { case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED: case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA: networkType = TelephonyManager.NETWORK_TYPE_NR; break; case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO: case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA: networkType = TelephonyManager.NETWORK_TYPE_LTE_CA; break; } log("updateMeteredAndCongested: networkType=" + TelephonyManager.getNetworkTypeName(networkType)); boolean changed = false; Loading Loading @@ -3157,15 +3143,16 @@ public class DataNetwork extends StateMachine { pw.println("mDataAllowedReason=" + mDataAllowedReason); pw.println("mPduSessionId=" + mPduSessionId); pw.println("mDataProfile=" + mDataProfile); pw.println("mNetworkCapabilities" + mNetworkCapabilities); pw.println("mNetworkCapabilities=" + mNetworkCapabilities); pw.println("mLinkProperties=" + mLinkProperties); pw.println("mNetworkSliceInfo=" + mNetworkSliceInfo); pw.println("mNetworkBandwidth=" + mNetworkBandwidth); pw.println("mTcpBufferSizes=" + mTcpBufferSizes); pw.println("mTelephonyDisplayInfo=" + mTelephonyDisplayInfo); pw.println("mTempNotMeteredSupported=" + mTempNotMeteredSupported); pw.println("mTempNotMetered=" + mTempNotMetered); pw.println("mCongested=" + mCongested); pw.println("mSuspended" + mSuspended); pw.println("mSuspended=" + mSuspended); pw.println("mDataCallResponse=" + mDataCallResponse); pw.println("mFailCause=" + DataFailCause.toString(mFailCause)); pw.println("mAdministratorUids=" + Arrays.toString(mAdministratorUids)); Loading src/java/com/android/internal/telephony/dataconnection/DataConnection.java +1 −1 Original line number Diff line number Diff line Loading @@ -1584,7 +1584,7 @@ public class DataConnection extends StateMachine { private void updateLinkBandwidthsFromCarrierConfig(int rilRat) { String ratName = DataConfigManager.getDataConfigNetworkType( ServiceState.rilRadioTechnologyToNetworkType(rilRat), mPhone.getServiceState()); mPhone.getDisplayInfoController().getTelephonyDisplayInfo()); if (DBG) log("updateLinkBandwidthsFromCarrierConfig: " + ratName); Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +11 −3 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SubscriptionManager; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.TelephonyRegistryManager; import android.telephony.emergency.EmergencyNumber; Loading Loading @@ -707,6 +708,9 @@ public abstract class TelephonyTest { //Misc doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS).when(mServiceState). getRilDataRadioTechnology(); doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UMTS, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE)) .when(mDisplayInfoController).getTelephonyDisplayInfo(); doReturn(mPhone).when(mCT).getPhone(); doReturn(mImsEcbm).when(mImsManager).getEcbmInterface(); doReturn(mPhone).when(mInboundSmsHandler).getPhone(); Loading Loading @@ -885,9 +889,13 @@ public abstract class TelephonyTest { } TestableLooper.remove(TelephonyTest.this); if (mSimulatedCommands != null) { mSimulatedCommands.dispose(); } if (mContext != null) { SharedPreferences sharedPreferences = mContext.getSharedPreferences((String) null, 0); sharedPreferences.edit().clear().commit(); } restoreInstances(); TelephonyManager.enableServiceHandleCaching(); SubscriptionController.enableCaching(); Loading Loading
src/java/com/android/internal/telephony/ServiceStateTracker.java +28 −25 Original line number Diff line number Diff line Loading @@ -2098,32 +2098,15 @@ public class ServiceStateTracker extends Handler { int newFrequencyRange = ServiceState.FREQUENCY_RANGE_UNKNOWN; if (physicalChannelConfigs != null) { for (PhysicalChannelConfig config : physicalChannelConfigs) { if (isNrPhysicalChannelConfig(config)) { // Update the frequency range of the NR parameters if there is an internet data // connection associate to this NR physical channel channel config. int[] contextIds = config.getContextIds(); for (int cid : contextIds) { if (mPhone.isUsingNewDataStack()) { if (mPhone.getDataNetworkController().isInternetNetwork(cid)) { newFrequencyRange = ServiceState.getBetterNRFrequencyRange( newFrequencyRange, config.getFrequencyRange()); break; } } else { DataConnection dc = mPhone.getDcTracker( AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .getDataConnectionByContextId(cid); if (dc != null && dc.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_INTERNET)) { if (isNrPhysicalChannelConfig(config) && isInternetPhysicalChannelConfig(config)) { // Update the NR frequency range if there is an internet data connection // associated with this NR physical channel channel config. newFrequencyRange = ServiceState.getBetterNRFrequencyRange( newFrequencyRange, config.getFrequencyRange()); break; } } } } } } boolean hasChanged = newFrequencyRange != ss.getNrFrequencyRange(); ss.setNrFrequencyRange(newFrequencyRange); Loading @@ -2138,7 +2121,8 @@ public class ServiceStateTracker extends Handler { boolean hasNrSecondaryServingCell = false; for (PhysicalChannelConfig config : configs) { if (isNrPhysicalChannelConfig(config) && config.getConnectionStatus() if (isNrPhysicalChannelConfig(config) && isInternetPhysicalChannelConfig(config) && config.getConnectionStatus() == PhysicalChannelConfig.CONNECTION_SECONDARY_SERVING) { hasNrSecondaryServingCell = true; break; Loading @@ -2146,7 +2130,7 @@ public class ServiceStateTracker extends Handler { } int oldNrState = regInfo.getNrState(); int newNrState = oldNrState; int newNrState; if (hasNrSecondaryServingCell) { newNrState = NetworkRegistrationInfo.NR_STATE_CONNECTED; } else { Loading @@ -2164,6 +2148,25 @@ public class ServiceStateTracker extends Handler { return config.getNetworkType() == TelephonyManager.NETWORK_TYPE_NR; } private boolean isInternetPhysicalChannelConfig(PhysicalChannelConfig config) { for (int cid : config.getContextIds()) { if (mPhone.isUsingNewDataStack()) { if (mPhone.getDataNetworkController().isInternetNetwork(cid)) { return true; } } else { DataConnection dc = mPhone.getDcTracker( AccessNetworkConstants.TRANSPORT_TYPE_WWAN) .getDataConnectionByContextId(cid); if (dc != null && dc.getNetworkCapabilities().hasCapability( NetworkCapabilities.NET_CAPABILITY_INTERNET)) { return true; } } } return false; } /** * This combine PS registration states from cellular and IWLAN and generates the final data * reg state and rat for backward compatibility purpose. In reality there should be two separate Loading
src/java/com/android/internal/telephony/data/DataConfigManager.java +34 −32 Original line number Diff line number Diff line Loading @@ -35,9 +35,9 @@ import android.telephony.Annotation.ApnType; import android.telephony.Annotation.NetCapability; import android.telephony.Annotation.NetworkType; import android.telephony.CarrierConfigManager; import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.data.ApnSetting; import android.text.TextUtils; Loading Loading @@ -623,13 +623,13 @@ public class DataConfigManager extends Handler { /** * Get whether the network type is unmetered from the carrier configs. * * @param networkType The network type to check meteredness for * @param serviceState The service state, used to determine NR state * @return Whether the carrier considers the given network type unmetered * @param displayInfo The {@link TelephonyDisplayInfo} to check meteredness for. * @param serviceState The {@link ServiceState}, used to determine roaming state. * @return Whether the carrier considers the given display info unmetered. */ public boolean isNetworkTypeUnmetered(@NetworkType int networkType, public boolean isNetworkTypeUnmetered(@NonNull TelephonyDisplayInfo displayInfo, @NonNull ServiceState serviceState) { String dataConfigNetworkType = getDataConfigNetworkType(networkType, serviceState); String dataConfigNetworkType = getDataConfigNetworkType(displayInfo); return serviceState.getDataRoaming() ? mRoamingUnmeteredNetworkTypes.contains(dataConfigNetworkType) : mUnmeteredNetworkTypes.contains(dataConfigNetworkType); Loading Loading @@ -686,14 +686,13 @@ public class DataConfigManager extends Handler { /** * Get the bandwidth estimate from the carrier config. * * @param networkType The network type to get the bandwidth for * @param serviceState The service state, used to determine NR state * @param displayInfo The {@link TelephonyDisplayInfo} to get the bandwidth for. * @return The pre-configured bandwidth estimate from carrier config. */ public @NonNull DataNetwork.NetworkBandwidth getBandwidthForNetworkType( @NetworkType int networkType, @NonNull ServiceState serviceState) { @NonNull TelephonyDisplayInfo displayInfo) { DataNetwork.NetworkBandwidth bandwidth = mBandwidthMap.get( getDataConfigNetworkType(networkType, serviceState)); getDataConfigNetworkType(displayInfo)); if (bandwidth != null) { return bandwidth; } Loading Loading @@ -804,15 +803,12 @@ public class DataConfigManager extends Handler { * The config string will have the following form, with values in bytes: * "read_min,read_default,read_max,write_min,write_default,write_max" * * @param networkType The network type. Note that {@link TelephonyManager#NETWORK_TYPE_LTE_CA} * can be used for LTE CA even though it's not a radio access technology. * @param serviceState The service state, used to determine NR state. * @return The TCP configuration string for the given network type or the default value from * config_tcp_buffers if unavailable. * @param displayInfo The {@link TelephonyDisplayInfo} to get the TCP config string for. * @return The TCP configuration string for the given display info or the default value from * {@code config_tcp_buffers} if unavailable. */ public @NonNull String getTcpConfigString(@NetworkType int networkType, @NonNull ServiceState serviceState) { String config = mTcpBufferSizeMap.get(getDataConfigNetworkType(networkType, serviceState)); public @NonNull String getTcpConfigString(@NonNull TelephonyDisplayInfo displayInfo) { String config = mTcpBufferSizeMap.get(getDataConfigNetworkType(displayInfo)); if (TextUtils.isEmpty(config)) { config = getDefaultTcpConfigString(); } Loading Loading @@ -882,26 +878,32 @@ public class DataConfigManager extends Handler { } /** * Get the data config network type based on the given network type and service state * Get the {@link DataConfigNetworkType} based on the given {@link TelephonyDisplayInfo}. * * @param networkType The network type * @param serviceState The service state, used to determine NR state * @return The equivalent data config network type * @param displayInfo The {@link TelephonyDisplayInfo} used to determine the type. * @return The equivalent {@link DataConfigNetworkType}. */ public static @NonNull @DataConfigNetworkType String getDataConfigNetworkType( @NetworkType int networkType, @NonNull ServiceState serviceState) { @NonNull TelephonyDisplayInfo displayInfo) { // TODO: Make method private once DataConnection is removed if ((networkType == TelephonyManager.NETWORK_TYPE_LTE || networkType == TelephonyManager.NETWORK_TYPE_LTE_CA) && (serviceState.getNrState() == NetworkRegistrationInfo.NR_STATE_CONNECTED)) { return serviceState.getNrFrequencyRange() == ServiceState.FREQUENCY_RANGE_MMWAVE ? DATA_CONFIG_NETWORK_TYPE_NR_NSA_MMWAVE : DATA_CONFIG_NETWORK_TYPE_NR_NSA; } else if (networkType == TelephonyManager.NETWORK_TYPE_NR && serviceState.getNrFrequencyRange() == ServiceState.FREQUENCY_RANGE_MMWAVE) { int networkType = displayInfo.getNetworkType(); switch (displayInfo.getOverrideNetworkType()) { case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED: if (networkType == TelephonyManager.NETWORK_TYPE_NR) { return DATA_CONFIG_NETWORK_TYPE_NR_SA_MMWAVE; } else { return DATA_CONFIG_NETWORK_TYPE_NR_NSA_MMWAVE; } case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA: return DATA_CONFIG_NETWORK_TYPE_NR_NSA; case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO: case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA: return DATA_CONFIG_NETWORK_TYPE_LTE_CA; case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE: default: return networkTypeToDataConfigNetworkType(networkType); } } /** Update handover rules from carrier config. */ private void updateHandoverRules() { Loading
src/java/com/android/internal/telephony/data/DataNetwork.java +29 −42 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import android.telephony.PcoData; import android.telephony.PreciseDataConnectionState; import android.telephony.ServiceState; import android.telephony.SubscriptionPlan; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.data.ApnSetting; import android.telephony.data.DataCallResponse; Loading Loading @@ -548,6 +549,9 @@ public class DataNetwork extends StateMachine { /** The TCP buffer sizes config. */ private @NonNull String mTcpBufferSizes; /** The telephony display info. */ private @NonNull TelephonyDisplayInfo mTelephonyDisplayInfo; /** Whether {@link NetworkCapabilities#NET_CAPABILITY_TEMPORARILY_NOT_METERED} is supported. */ private boolean mTempNotMeteredSupported = false; Loading Loading @@ -840,6 +844,7 @@ public class DataNetwork extends StateMachine { mCid.put(AccessNetworkConstants.TRANSPORT_TYPE_WWAN, INVALID_CID); mCid.put(AccessNetworkConstants.TRANSPORT_TYPE_WLAN, INVALID_CID); mTcpBufferSizes = mDataConfigManager.getDefaultTcpConfigString(); mTelephonyDisplayInfo = mPhone.getDisplayInfoController().getTelephonyDisplayInfo(); for (TelephonyNetworkRequest networkRequest : networkRequestList) { networkRequest.setAttachedNetwork(DataNetwork.this); Loading Loading @@ -1402,6 +1407,9 @@ public class DataNetwork extends StateMachine { mFailCause = DataFailCause.LOST_CONNECTION; transitionTo(mDisconnectedState); break; case EVENT_DISPLAY_INFO_CHANGED: onDisplayInfoChanged(); break; default: return NOT_HANDLED; } Loading Loading @@ -2159,38 +2167,6 @@ public class DataNetwork extends StateMachine { updateNetworkCapabilities(); } /** * @return {@code true} if the device is connected to NR cell in 5G NSA mode, and the current * data network is using the NR cell. */ private boolean isNrConnected() { return mPhone.getServiceState().getNrState() == NetworkRegistrationInfo.NR_STATE_CONNECTED && mPhone.getServiceStateTracker().getNrContextIds().contains( mCid.get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)); } /** * Get the TCP buffer sizes config string. * * @return The TCP buffer sizes config used in {@link LinkProperties#setTcpBufferSizes(String)}. */ private @Nullable String getTcpConfig() { ServiceState ss = mPhone.getServiceState(); NetworkRegistrationInfo nrs = ss.getNetworkRegistrationInfo( NetworkRegistrationInfo.DOMAIN_PS, mTransport); int networkType = TelephonyManager.NETWORK_TYPE_UNKNOWN; if (nrs != null) { networkType = nrs.getAccessNetworkTechnology(); if (networkType == TelephonyManager.NETWORK_TYPE_LTE && nrs.isUsingCarrierAggregation()) { // Although LTE_CA is not a real RAT, but since LTE CA generally has higher speed // we use LTE_CA to get a different TCP config for LTE CA. networkType = TelephonyManager.NETWORK_TYPE_LTE_CA; } } return mDataConfigManager.getTcpConfigString(networkType, ss); } /** * Called when receiving setup data network response from the data service. * Loading Loading @@ -2457,7 +2433,7 @@ public class DataNetwork extends StateMachine { log("onBandwidthUpdated: downlinkBandwidthKbps=" + downlinkBandwidthKbps + ", uplinkBandwidthKbps=" + uplinkBandwidthKbps); NetworkBandwidth bandwidthFromConfig = mDataConfigManager.getBandwidthForNetworkType( getDataNetworkType(), mPhone.getServiceState()); mTelephonyDisplayInfo); if (downlinkBandwidthKbps == LinkCapacityEstimate.INVALID && bandwidthFromConfig != null) { // Fallback to carrier config. Loading @@ -2477,10 +2453,11 @@ public class DataNetwork extends StateMachine { } /** * Called when display info changed. This can happen when network types changed or override * types (5G NSA, 5G MMWAVE) changes. * Called when {@link TelephonyDisplayInfo} changed. This can happen when network types or * override network types (5G NSA, 5G MMWAVE) change. */ private void onDisplayInfoChanged() { mTelephonyDisplayInfo = mPhone.getDisplayInfoController().getTelephonyDisplayInfo(); updateBandwidthFromDataConfig(); updateTcpBufferSizes(); updateMeteredAndCongested(); Loading @@ -2495,8 +2472,7 @@ public class DataNetwork extends StateMachine { return; } log("updateBandwidthFromDataConfig"); mNetworkBandwidth = mDataConfigManager.getBandwidthForNetworkType( getDataNetworkType(), mPhone.getServiceState()); mNetworkBandwidth = mDataConfigManager.getBandwidthForNetworkType(mTelephonyDisplayInfo); updateNetworkCapabilities(); } Loading @@ -2505,7 +2481,7 @@ public class DataNetwork extends StateMachine { */ private void updateTcpBufferSizes() { log("updateTcpBufferSizes"); mTcpBufferSizes = getTcpConfig(); mTcpBufferSizes = mDataConfigManager.getTcpConfigString(mTelephonyDisplayInfo); LinkProperties linkProperties = new LinkProperties(mLinkProperties); linkProperties.setTcpBufferSizes(mTcpBufferSizes); if (!linkProperties.equals(mLinkProperties)) { Loading @@ -2519,7 +2495,17 @@ public class DataNetwork extends StateMachine { * Update the metered and congested values from carrier configs and subscription overrides */ private void updateMeteredAndCongested() { int networkType = isNrConnected() ? TelephonyManager.NETWORK_TYPE_NR : getDataNetworkType(); int networkType = mTelephonyDisplayInfo.getNetworkType(); switch (mTelephonyDisplayInfo.getOverrideNetworkType()) { case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED: case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA: networkType = TelephonyManager.NETWORK_TYPE_NR; break; case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO: case TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA: networkType = TelephonyManager.NETWORK_TYPE_LTE_CA; break; } log("updateMeteredAndCongested: networkType=" + TelephonyManager.getNetworkTypeName(networkType)); boolean changed = false; Loading Loading @@ -3157,15 +3143,16 @@ public class DataNetwork extends StateMachine { pw.println("mDataAllowedReason=" + mDataAllowedReason); pw.println("mPduSessionId=" + mPduSessionId); pw.println("mDataProfile=" + mDataProfile); pw.println("mNetworkCapabilities" + mNetworkCapabilities); pw.println("mNetworkCapabilities=" + mNetworkCapabilities); pw.println("mLinkProperties=" + mLinkProperties); pw.println("mNetworkSliceInfo=" + mNetworkSliceInfo); pw.println("mNetworkBandwidth=" + mNetworkBandwidth); pw.println("mTcpBufferSizes=" + mTcpBufferSizes); pw.println("mTelephonyDisplayInfo=" + mTelephonyDisplayInfo); pw.println("mTempNotMeteredSupported=" + mTempNotMeteredSupported); pw.println("mTempNotMetered=" + mTempNotMetered); pw.println("mCongested=" + mCongested); pw.println("mSuspended" + mSuspended); pw.println("mSuspended=" + mSuspended); pw.println("mDataCallResponse=" + mDataCallResponse); pw.println("mFailCause=" + DataFailCause.toString(mFailCause)); pw.println("mAdministratorUids=" + Arrays.toString(mAdministratorUids)); Loading
src/java/com/android/internal/telephony/dataconnection/DataConnection.java +1 −1 Original line number Diff line number Diff line Loading @@ -1584,7 +1584,7 @@ public class DataConnection extends StateMachine { private void updateLinkBandwidthsFromCarrierConfig(int rilRat) { String ratName = DataConfigManager.getDataConfigNetworkType( ServiceState.rilRadioTechnologyToNetworkType(rilRat), mPhone.getServiceState()); mPhone.getDisplayInfoController().getTelephonyDisplayInfo()); if (DBG) log("updateLinkBandwidthsFromCarrierConfig: " + ratName); Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +11 −3 Original line number Diff line number Diff line Loading @@ -76,6 +76,7 @@ import android.telephony.NetworkRegistrationInfo; import android.telephony.ServiceState; import android.telephony.SignalStrength; import android.telephony.SubscriptionManager; import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.telephony.TelephonyRegistryManager; import android.telephony.emergency.EmergencyNumber; Loading Loading @@ -707,6 +708,9 @@ public abstract class TelephonyTest { //Misc doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS).when(mServiceState). getRilDataRadioTechnology(); doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_UMTS, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE)) .when(mDisplayInfoController).getTelephonyDisplayInfo(); doReturn(mPhone).when(mCT).getPhone(); doReturn(mImsEcbm).when(mImsManager).getEcbmInterface(); doReturn(mPhone).when(mInboundSmsHandler).getPhone(); Loading Loading @@ -885,9 +889,13 @@ public abstract class TelephonyTest { } TestableLooper.remove(TelephonyTest.this); if (mSimulatedCommands != null) { mSimulatedCommands.dispose(); } if (mContext != null) { SharedPreferences sharedPreferences = mContext.getSharedPreferences((String) null, 0); sharedPreferences.edit().clear().commit(); } restoreInstances(); TelephonyManager.enableServiceHandleCaching(); SubscriptionController.enableCaching(); Loading