Loading src/java/com/android/internal/telephony/DisplayInfoController.java +4 −2 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ public class DisplayInfoController extends Handler { mTelephonyDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, false); false, false, false); mNetworkTypeController = new NetworkTypeController(phone, this, featureFlags); // EVENT_UPDATE will transition from DefaultState to the current state // and update the TelephonyDisplayInfo based on the current state. Loading @@ -132,7 +132,9 @@ public class DisplayInfoController extends Handler { TelephonyDisplayInfo newDisplayInfo = new TelephonyDisplayInfo( mNetworkTypeController.getDataNetworkType(), mNetworkTypeController.getOverrideNetworkType(), isRoaming()); isRoaming(), mPhone.getServiceStateTracker().getServiceState().isUsingNonTerrestrialNetwork(), mNetworkTypeController.getSatelliteConstrainedData()); if (!newDisplayInfo.equals(mTelephonyDisplayInfo)) { logl("TelephonyDisplayInfo changed from " + mTelephonyDisplayInfo + " to " + newDisplayInfo); Loading src/java/com/android/internal/telephony/NetworkTypeController.java +114 −0 Original line number Diff line number Diff line Loading @@ -22,7 +22,13 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkRequest; import android.os.AsyncResult; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.os.PersistableBundle; import android.os.PowerManager; Loading Loading @@ -233,6 +239,72 @@ public class NetworkTypeController extends StateMachine { private boolean mDoesPccListIndicateIdle = false; private boolean mInVoiceCall = false; private boolean mIsSatelliteConstrainedData = false; private boolean mIsSatelliteNetworkCallbackRegistered = false; private ConnectivityManager mConnectivityManager; private final ConnectivityManager.NetworkCallback mNetworkCallback = new ConnectivityManager.NetworkCallback() { @Override public void onAvailable(Network network) { log("On Available: " + network); if (network != null) { if (mConnectivityManager != null) { NetworkCapabilities capabilities = mConnectivityManager.getNetworkCapabilities(network); updateBandwidthConstrainedStatus(capabilities); } else { log("network is null"); } } } @Override public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) { log("onCapabilitiesChanged: " + network); if (network != null) { updateBandwidthConstrainedStatus(networkCapabilities); } else { log("network is null"); } } @Override public void onLost(Network network) { log("Network Lost"); if (mIsSatelliteConstrainedData) { mIsSatelliteConstrainedData = false; mDisplayInfoController.updateTelephonyDisplayInfo(); } } }; private boolean isBandwidthConstrainedCapabilitySupported(NetworkCapabilities capabilities) { // TODO (b/382002908: Remove try catch exception for // NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED & replace datautils with // NetworkCapabilities on api availability at mainline module) try { return capabilities.hasTransport( NetworkCapabilities.TRANSPORT_SATELLITE) && !capabilities.hasCapability(DataUtils.NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED); } catch (Exception ignored) { log("NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED not supported "); return false; } } private void updateBandwidthConstrainedStatus(NetworkCapabilities capabilities) { if (capabilities != null) { mIsSatelliteConstrainedData = isBandwidthConstrainedCapabilitySupported(capabilities); log("satellite constrained data status : " + mIsSatelliteConstrainedData); mDisplayInfoController.updateTelephonyDisplayInfo(); } else { log("capabilities is null"); } } /** * NetworkTypeController constructor. Loading Loading @@ -266,9 +338,42 @@ public class NetworkTypeController extends StateMachine { mServiceState = mPhone.getServiceStateTracker().getServiceState(); mPhysicalChannelConfigs = mPhone.getServiceStateTracker().getPhysicalChannelConfigList(); if(mFeatureFlags.carrierEnabledSatelliteFlag()) { registerForSatelliteNetwork(); } sendMessage(EVENT_INITIALIZE); } public synchronized void registerForSatelliteNetwork() { if (!mIsSatelliteNetworkCallbackRegistered) { mIsSatelliteNetworkCallbackRegistered = true; HandlerThread handlerThread = new HandlerThread("SatelliteDataUsageThread"); handlerThread.start(); Handler handler = new Handler(handlerThread.getLooper()); NetworkRequest.Builder builder = new NetworkRequest.Builder(); builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); // TODO (b/382002908: Remove try catch exception for // NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED & replace datautils with // NetworkCapabilities on api availability at mainline module) try { builder.removeCapability(DataUtils.NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED); } catch (Exception ignored) { log("NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED not supported "); } mConnectivityManager = (ConnectivityManager) mPhone.getContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (mConnectivityManager != null) { mConnectivityManager.registerBestMatchingNetworkCallback( builder.build(), mNetworkCallback, handler); } else { loge("network callback not registered"); } } } /** * @return The current override network type, used to create TelephonyDisplayInfo in * DisplayInfoController. Loading @@ -288,6 +393,15 @@ public class NetworkTypeController extends StateMachine { : nri.getAccessNetworkTechnology(); } /** * @return satellite bandwidth constrained connection status, used to create * TelephonyDisplayInfo in DisplayInfoController. * */ public boolean getSatelliteConstrainedData() { return mIsSatelliteConstrainedData; } /** * @return {@code true} if either the primary or secondary 5G icon timers are active, * and {@code false} if neither are. Loading tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -1044,7 +1044,8 @@ public class NetworkTypeControllerTest extends TelephonyTest { doReturn(new TelephonyDisplayInfo( mNetworkTypeController.getDataNetworkType(), mNetworkTypeController.getOverrideNetworkType(), false)).when(mDisplayInfoController).getTelephonyDisplayInfo(); false, false, false)) .when(mDisplayInfoController).getTelephonyDisplayInfo(); return null; }).when(mDisplayInfoController).updateTelephonyDisplayInfo(); mNetworkRegistrationInfo = new NetworkRegistrationInfo.Builder() Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -1344,7 +1344,7 @@ public class TelephonyRegistryTest extends TelephonyTest { TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, false); false, false, false); // Notify with invalid subId on default phone. Should NOT trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); Loading @@ -1371,11 +1371,11 @@ public class TelephonyRegistryTest extends TelephonyTest { TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, false); false, false, false); TelephonyDisplayInfo expectDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE, false); false, false, false); // Notify with invalid subId on default phone. Should NOT trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); Loading @@ -1398,11 +1398,11 @@ public class TelephonyRegistryTest extends TelephonyTest { TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, false); false, false, false); TelephonyDisplayInfo expectDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE, false); false, false, false); TelephonyCallback telephonyCallback2 = new TelephonyCallbackWrapper() { @Override public void onDisplayInfoChanged(TelephonyDisplayInfo displayInfoNotify) { Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -811,7 +811,7 @@ public abstract class TelephonyTest { doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_LTE).when(mServiceState) .getRilDataRadioTechnology(); doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, false)) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, false, false, false)) .when(mDisplayInfoController).getTelephonyDisplayInfo(); doReturn(mPhone).when(mCT).getPhone(); doReturn(mImsEcbm).when(mImsManager).getEcbmInterface(); Loading Loading
src/java/com/android/internal/telephony/DisplayInfoController.java +4 −2 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ public class DisplayInfoController extends Handler { mTelephonyDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, false); false, false, false); mNetworkTypeController = new NetworkTypeController(phone, this, featureFlags); // EVENT_UPDATE will transition from DefaultState to the current state // and update the TelephonyDisplayInfo based on the current state. Loading @@ -132,7 +132,9 @@ public class DisplayInfoController extends Handler { TelephonyDisplayInfo newDisplayInfo = new TelephonyDisplayInfo( mNetworkTypeController.getDataNetworkType(), mNetworkTypeController.getOverrideNetworkType(), isRoaming()); isRoaming(), mPhone.getServiceStateTracker().getServiceState().isUsingNonTerrestrialNetwork(), mNetworkTypeController.getSatelliteConstrainedData()); if (!newDisplayInfo.equals(mTelephonyDisplayInfo)) { logl("TelephonyDisplayInfo changed from " + mTelephonyDisplayInfo + " to " + newDisplayInfo); Loading
src/java/com/android/internal/telephony/NetworkTypeController.java +114 −0 Original line number Diff line number Diff line Loading @@ -22,7 +22,13 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkRequest; import android.os.AsyncResult; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.os.PersistableBundle; import android.os.PowerManager; Loading Loading @@ -233,6 +239,72 @@ public class NetworkTypeController extends StateMachine { private boolean mDoesPccListIndicateIdle = false; private boolean mInVoiceCall = false; private boolean mIsSatelliteConstrainedData = false; private boolean mIsSatelliteNetworkCallbackRegistered = false; private ConnectivityManager mConnectivityManager; private final ConnectivityManager.NetworkCallback mNetworkCallback = new ConnectivityManager.NetworkCallback() { @Override public void onAvailable(Network network) { log("On Available: " + network); if (network != null) { if (mConnectivityManager != null) { NetworkCapabilities capabilities = mConnectivityManager.getNetworkCapabilities(network); updateBandwidthConstrainedStatus(capabilities); } else { log("network is null"); } } } @Override public void onCapabilitiesChanged(Network network, NetworkCapabilities networkCapabilities) { log("onCapabilitiesChanged: " + network); if (network != null) { updateBandwidthConstrainedStatus(networkCapabilities); } else { log("network is null"); } } @Override public void onLost(Network network) { log("Network Lost"); if (mIsSatelliteConstrainedData) { mIsSatelliteConstrainedData = false; mDisplayInfoController.updateTelephonyDisplayInfo(); } } }; private boolean isBandwidthConstrainedCapabilitySupported(NetworkCapabilities capabilities) { // TODO (b/382002908: Remove try catch exception for // NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED & replace datautils with // NetworkCapabilities on api availability at mainline module) try { return capabilities.hasTransport( NetworkCapabilities.TRANSPORT_SATELLITE) && !capabilities.hasCapability(DataUtils.NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED); } catch (Exception ignored) { log("NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED not supported "); return false; } } private void updateBandwidthConstrainedStatus(NetworkCapabilities capabilities) { if (capabilities != null) { mIsSatelliteConstrainedData = isBandwidthConstrainedCapabilitySupported(capabilities); log("satellite constrained data status : " + mIsSatelliteConstrainedData); mDisplayInfoController.updateTelephonyDisplayInfo(); } else { log("capabilities is null"); } } /** * NetworkTypeController constructor. Loading Loading @@ -266,9 +338,42 @@ public class NetworkTypeController extends StateMachine { mServiceState = mPhone.getServiceStateTracker().getServiceState(); mPhysicalChannelConfigs = mPhone.getServiceStateTracker().getPhysicalChannelConfigList(); if(mFeatureFlags.carrierEnabledSatelliteFlag()) { registerForSatelliteNetwork(); } sendMessage(EVENT_INITIALIZE); } public synchronized void registerForSatelliteNetwork() { if (!mIsSatelliteNetworkCallbackRegistered) { mIsSatelliteNetworkCallbackRegistered = true; HandlerThread handlerThread = new HandlerThread("SatelliteDataUsageThread"); handlerThread.start(); Handler handler = new Handler(handlerThread.getLooper()); NetworkRequest.Builder builder = new NetworkRequest.Builder(); builder.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); // TODO (b/382002908: Remove try catch exception for // NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED & replace datautils with // NetworkCapabilities on api availability at mainline module) try { builder.removeCapability(DataUtils.NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED); } catch (Exception ignored) { log("NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED not supported "); } mConnectivityManager = (ConnectivityManager) mPhone.getContext() .getSystemService(Context.CONNECTIVITY_SERVICE); if (mConnectivityManager != null) { mConnectivityManager.registerBestMatchingNetworkCallback( builder.build(), mNetworkCallback, handler); } else { loge("network callback not registered"); } } } /** * @return The current override network type, used to create TelephonyDisplayInfo in * DisplayInfoController. Loading @@ -288,6 +393,15 @@ public class NetworkTypeController extends StateMachine { : nri.getAccessNetworkTechnology(); } /** * @return satellite bandwidth constrained connection status, used to create * TelephonyDisplayInfo in DisplayInfoController. * */ public boolean getSatelliteConstrainedData() { return mIsSatelliteConstrainedData; } /** * @return {@code true} if either the primary or secondary 5G icon timers are active, * and {@code false} if neither are. Loading
tests/telephonytests/src/com/android/internal/telephony/NetworkTypeControllerTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -1044,7 +1044,8 @@ public class NetworkTypeControllerTest extends TelephonyTest { doReturn(new TelephonyDisplayInfo( mNetworkTypeController.getDataNetworkType(), mNetworkTypeController.getOverrideNetworkType(), false)).when(mDisplayInfoController).getTelephonyDisplayInfo(); false, false, false)) .when(mDisplayInfoController).getTelephonyDisplayInfo(); return null; }).when(mDisplayInfoController).updateTelephonyDisplayInfo(); mNetworkRegistrationInfo = new NetworkRegistrationInfo.Builder() Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyRegistryTest.java +5 −5 Original line number Diff line number Diff line Loading @@ -1344,7 +1344,7 @@ public class TelephonyRegistryTest extends TelephonyTest { TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, false); false, false, false); // Notify with invalid subId on default phone. Should NOT trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); Loading @@ -1371,11 +1371,11 @@ public class TelephonyRegistryTest extends TelephonyTest { TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, false); false, false, false); TelephonyDisplayInfo expectDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE, false); false, false, false); // Notify with invalid subId on default phone. Should NOT trigger callback. mTelephonyRegistry.notifyDisplayInfoChanged(0, INVALID_SUBSCRIPTION_ID, displayInfo); Loading @@ -1398,11 +1398,11 @@ public class TelephonyRegistryTest extends TelephonyTest { TelephonyDisplayInfo displayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_ADVANCED, false); false, false, false); TelephonyDisplayInfo expectDisplayInfo = new TelephonyDisplayInfo( TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE, false); false, false, false); TelephonyCallback telephonyCallback2 = new TelephonyCallbackWrapper() { @Override public void onDisplayInfoChanged(TelephonyDisplayInfo displayInfoNotify) { Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -811,7 +811,7 @@ public abstract class TelephonyTest { doReturn(ServiceState.RIL_RADIO_TECHNOLOGY_LTE).when(mServiceState) .getRilDataRadioTechnology(); doReturn(new TelephonyDisplayInfo(TelephonyManager.NETWORK_TYPE_LTE, TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, false)) TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, false, false, false)) .when(mDisplayInfoController).getTelephonyDisplayInfo(); doReturn(mPhone).when(mCT).getPhone(); doReturn(mImsEcbm).when(mImsManager).getEcbmInterface(); Loading