Loading src/java/com/android/internal/telephony/PhoneInternalInterface.java +1 −0 Original line number Diff line number Diff line Loading @@ -205,6 +205,7 @@ public interface PhoneInternalInterface { static final String REASON_RELEASED_BY_CONNECTIVITY_SERVICE = "releasedByConnectivityService"; static final String REASON_DATA_ENABLED_OVERRIDE = "dataEnabledOverride"; static final String REASON_IWLAN_DATA_SERVICE_DIED = "iwlanDataServiceDied"; static final String REASON_VCN_REQUESTED_TEARDOWN = "vcnRequestedTeardown"; // Reasons for Radio being powered off int RADIO_POWER_REASON_USER = 0; Loading src/java/com/android/internal/telephony/dataconnection/DataConnection.java +78 −5 Original line number Diff line number Diff line Loading @@ -39,7 +39,11 @@ import android.net.ProxyInfo; import android.net.RouteInfo; import android.net.SocketKeepalive; import android.net.TelephonyNetworkSpecifier; import android.net.vcn.VcnManager; import android.net.vcn.VcnManager.VcnUnderlyingNetworkPolicyListener; import android.net.vcn.VcnUnderlyingNetworkPolicy; import android.os.AsyncResult; import android.os.HandlerExecutor; import android.os.Message; import android.os.PersistableBundle; import android.os.SystemClock; Loading Loading @@ -285,6 +289,7 @@ public class DataConnection extends StateMachine { private Phone mPhone; private DataServiceManager mDataServiceManager; private VcnManager mVcnManager; private final int mTransportType; private LinkProperties mLinkProperties = new LinkProperties(); private int mPduSessionId; Loading Loading @@ -326,6 +331,9 @@ public class DataConnection extends StateMachine { private final Map<ApnContext, ConnectionParams> mApnContexts = new ConcurrentHashMap<>(); PendingIntent mReconnectIntent = null; /** Class used to track VCN-defined Network policies for this DcNetworkAgent. */ private final VcnUnderlyingNetworkPolicyListener mVcnPolicyListener = new DataConnectionVcnUnderlyingNetworkPolicyListener(); // ***** Event codes for driving the state machine, package visible for Dcc static final int BASE = Protocol.BASE_DATA_CONNECTION; Loading Loading @@ -738,6 +746,7 @@ public class DataConnection extends StateMachine { mPhone = phone; mDct = dct; mDataServiceManager = dataServiceManager; mVcnManager = mPhone.getContext().getSystemService(VcnManager.class); mTransportType = dataServiceManager.getTransportType(); mDcTesterFailBringUpAll = failBringUpAll; mDcController = dcc; Loading Loading @@ -1754,13 +1763,32 @@ public class DataConnection extends StateMachine { mUnmeteredOverride); result.setCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED, !mIsSuspended); result.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); result.setAdministratorUids(mAdministratorUids); // Check for VCN-specified Network policy before returning NetworkCapabilities result.setCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED, !isVcnManaged(result)); return result; } /** * Returns whether the Network represented by this DataConnection is VCN-managed. * * <p>Determining if the Network is VCN-managed requires polling VcnManager. */ private boolean isVcnManaged(NetworkCapabilities networkCapabilities) { VcnUnderlyingNetworkPolicy networkPolicy = mVcnManager.getUnderlyingNetworkPolicy(networkCapabilities, getLinkProperties()); // if the Network does have capability NOT_VCN_MANAGED, return false to indicate it's not // VCN-managed return !networkPolicy .getMergedNetworkCapabilities() .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); } /** @return {@code true} if validation is required, {@code false} otherwise. */ public boolean isValidationRequired() { final NetworkCapabilities nc = getNetworkCapabilities(); Loading Loading @@ -2570,6 +2598,11 @@ public class DataConnection extends StateMachine { + ", mUnmeteredUseOnly = " + mUnmeteredUseOnly); } // Always register a VcnUnderlyingNetworkPolicyListener, regardless of whether this is a // handover or new Network. mVcnManager.addVcnUnderlyingNetworkPolicyListener( new HandlerExecutor(getHandler()), mVcnPolicyListener); if (mConnectionParams != null && mConnectionParams.mRequestType == REQUEST_TYPE_HANDOVER) { // If this is a data setup for handover, we need to reuse the existing network agent Loading Loading @@ -2620,10 +2653,21 @@ public class DataConnection extends StateMachine { updateLinkPropertiesHttpProxy(); mNetworkAgent = new DcNetworkAgent(DataConnection.this, mPhone, mScore, configBuilder.build(), provider, mTransportType); VcnUnderlyingNetworkPolicy policy = mVcnManager.getUnderlyingNetworkPolicy( getNetworkCapabilities(), getLinkProperties()); if (policy.isTeardownRequested()) { tearDownAll( Phone.REASON_VCN_REQUESTED_TEARDOWN, DcTracker.RELEASE_TYPE_DETACH, null /* onCompletedMsg */); } else { // All network agents start out in CONNECTING mode, but DcNetworkAgents are // created when the network is already connected. Hence, send the connected // notification immediately. mNetworkAgent.markConnected(); } // The network agent is always created with NOT_SUSPENDED capability, but the // network might be already out of service (or voice call is ongoing) just right Loading Loading @@ -2676,6 +2720,8 @@ public class DataConnection extends StateMachine { mCid, mApnSetting.getApnTypeBitmask(), RilDataCall.State.DISCONNECTED); mDataCallSessionStats.onDataCallDisconnected(); mVcnManager.removeVcnUnderlyingNetworkPolicyListener(mVcnPolicyListener); mPhone.getCarrierPrivilegesTracker().unregisterCarrierPrivilegesListener(getHandler()); } Loading Loading @@ -3681,5 +3727,32 @@ public class DataConnection extends StateMachine { pw.println(); pw.flush(); } /** * Class used to track VCN-defined Network policies for this DataConnection. * * <p>MUST be registered with the associated DataConnection's Handler. */ private class DataConnectionVcnUnderlyingNetworkPolicyListener implements VcnUnderlyingNetworkPolicyListener { @Override public void onPolicyChanged() { // Poll the current underlying Network policy from VcnManager and send to NetworkAgent. final NetworkCapabilities networkCapabilities = getNetworkCapabilities(); VcnUnderlyingNetworkPolicy policy = mVcnManager.getUnderlyingNetworkPolicy( networkCapabilities, getLinkProperties()); if (policy.isTeardownRequested()) { tearDownAll( Phone.REASON_VCN_REQUESTED_TEARDOWN, DcTracker.RELEASE_TYPE_DETACH, null /* onCompletedMsg */); } if (mNetworkAgent != null) { mNetworkAgent.sendNetworkCapabilities(networkCapabilities, DataConnection.this); } } } } tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java +6 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import android.location.LocationManager; import android.net.ConnectivityManager; import android.net.Network; import android.net.Uri; import android.net.vcn.VcnManager; import android.net.wifi.WifiManager; import android.os.BatteryManager; import android.os.Bundle; Loading Loading @@ -266,6 +267,8 @@ public class ContextFixture implements TestFixture<Context> { return mSystemConfigManager; case Context.KEYGUARD_SERVICE: return mKeyguardManager; case Context.VCN_MANAGEMENT_SERVICE: return mVcnManager; case Context.BATTERY_STATS_SERVICE: case Context.DISPLAY_SERVICE: case Context.POWER_SERVICE: Loading Loading @@ -309,6 +312,8 @@ public class ContextFixture implements TestFixture<Context> { return Context.UI_MODE_SERVICE; } else if (serviceClass == KeyguardManager.class) { return Context.KEYGUARD_SERVICE; } else if (serviceClass == VcnManager.class) { return Context.VCN_MANAGEMENT_SERVICE; } return super.getSystemServiceName(serviceClass); } Loading Loading @@ -656,6 +661,7 @@ public class ContextFixture implements TestFixture<Context> { private final PowerWhitelistManager mPowerWhitelistManager = mock(PowerWhitelistManager.class); private final LocationManager mLocationManager = mock(LocationManager.class); private final KeyguardManager mKeyguardManager = mock(KeyguardManager.class); private final VcnManager mVcnManager = mock(VcnManager.class); private final ContentProvider mContentProvider = spy(new FakeContentProvider()); Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,9 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.net.NetworkCapabilities; import android.net.vcn.VcnManager; import android.net.vcn.VcnUnderlyingNetworkPolicy; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; Loading Loading @@ -336,6 +339,7 @@ public abstract class TelephonyTest { protected CarrierConfigManager mCarrierConfigManager; protected UserManager mUserManager; protected KeyguardManager mKeyguardManager; protected VcnManager mVcnManager; protected SimulatedCommands mSimulatedCommands; protected ContextFixture mContextFixture; protected Context mContext; Loading Loading @@ -477,6 +481,7 @@ public abstract class TelephonyTest { (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); mVcnManager = mContext.getSystemService(VcnManager.class); //mTelephonyComponentFactory doReturn(mTelephonyComponentFactory).when(mTelephonyComponentFactory).inject(anyString()); Loading Loading @@ -658,6 +663,12 @@ public abstract class TelephonyTest { doReturn(2).when(mWifiManager).calculateSignalLevel(anyInt()); doReturn(4).when(mWifiManager).getMaxSignalLevel(); doAnswer(invocation -> { NetworkCapabilities nc = invocation.getArgument(0); return new VcnUnderlyingNetworkPolicy( false /* isTearDownRequested */, nc); }).when(mVcnManager).getUnderlyingNetworkPolicy(any(), any()); //SIM doReturn(1).when(mTelephonyManager).getSimCount(); doReturn(1).when(mTelephonyManager).getPhoneCount(); Loading tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.times; Loading Loading @@ -386,6 +387,7 @@ public class DataConnectionTest extends TelephonyTest { verify(mSimulatedCommandsVerifier, times(1)) .registerForLceInfo(any(Handler.class), eq(DataConnection.EVENT_LINK_CAPACITY_CHANGED), eq(null)); verify(mVcnManager, atLeastOnce()).getUnderlyingNetworkPolicy(any(), any()); ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class); verify(mSimulatedCommandsVerifier, times(1)).setupDataCall( Loading Loading
src/java/com/android/internal/telephony/PhoneInternalInterface.java +1 −0 Original line number Diff line number Diff line Loading @@ -205,6 +205,7 @@ public interface PhoneInternalInterface { static final String REASON_RELEASED_BY_CONNECTIVITY_SERVICE = "releasedByConnectivityService"; static final String REASON_DATA_ENABLED_OVERRIDE = "dataEnabledOverride"; static final String REASON_IWLAN_DATA_SERVICE_DIED = "iwlanDataServiceDied"; static final String REASON_VCN_REQUESTED_TEARDOWN = "vcnRequestedTeardown"; // Reasons for Radio being powered off int RADIO_POWER_REASON_USER = 0; Loading
src/java/com/android/internal/telephony/dataconnection/DataConnection.java +78 −5 Original line number Diff line number Diff line Loading @@ -39,7 +39,11 @@ import android.net.ProxyInfo; import android.net.RouteInfo; import android.net.SocketKeepalive; import android.net.TelephonyNetworkSpecifier; import android.net.vcn.VcnManager; import android.net.vcn.VcnManager.VcnUnderlyingNetworkPolicyListener; import android.net.vcn.VcnUnderlyingNetworkPolicy; import android.os.AsyncResult; import android.os.HandlerExecutor; import android.os.Message; import android.os.PersistableBundle; import android.os.SystemClock; Loading Loading @@ -285,6 +289,7 @@ public class DataConnection extends StateMachine { private Phone mPhone; private DataServiceManager mDataServiceManager; private VcnManager mVcnManager; private final int mTransportType; private LinkProperties mLinkProperties = new LinkProperties(); private int mPduSessionId; Loading Loading @@ -326,6 +331,9 @@ public class DataConnection extends StateMachine { private final Map<ApnContext, ConnectionParams> mApnContexts = new ConcurrentHashMap<>(); PendingIntent mReconnectIntent = null; /** Class used to track VCN-defined Network policies for this DcNetworkAgent. */ private final VcnUnderlyingNetworkPolicyListener mVcnPolicyListener = new DataConnectionVcnUnderlyingNetworkPolicyListener(); // ***** Event codes for driving the state machine, package visible for Dcc static final int BASE = Protocol.BASE_DATA_CONNECTION; Loading Loading @@ -738,6 +746,7 @@ public class DataConnection extends StateMachine { mPhone = phone; mDct = dct; mDataServiceManager = dataServiceManager; mVcnManager = mPhone.getContext().getSystemService(VcnManager.class); mTransportType = dataServiceManager.getTransportType(); mDcTesterFailBringUpAll = failBringUpAll; mDcController = dcc; Loading Loading @@ -1754,13 +1763,32 @@ public class DataConnection extends StateMachine { mUnmeteredOverride); result.setCapability(NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED, !mIsSuspended); result.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); result.setAdministratorUids(mAdministratorUids); // Check for VCN-specified Network policy before returning NetworkCapabilities result.setCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED, !isVcnManaged(result)); return result; } /** * Returns whether the Network represented by this DataConnection is VCN-managed. * * <p>Determining if the Network is VCN-managed requires polling VcnManager. */ private boolean isVcnManaged(NetworkCapabilities networkCapabilities) { VcnUnderlyingNetworkPolicy networkPolicy = mVcnManager.getUnderlyingNetworkPolicy(networkCapabilities, getLinkProperties()); // if the Network does have capability NOT_VCN_MANAGED, return false to indicate it's not // VCN-managed return !networkPolicy .getMergedNetworkCapabilities() .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED); } /** @return {@code true} if validation is required, {@code false} otherwise. */ public boolean isValidationRequired() { final NetworkCapabilities nc = getNetworkCapabilities(); Loading Loading @@ -2570,6 +2598,11 @@ public class DataConnection extends StateMachine { + ", mUnmeteredUseOnly = " + mUnmeteredUseOnly); } // Always register a VcnUnderlyingNetworkPolicyListener, regardless of whether this is a // handover or new Network. mVcnManager.addVcnUnderlyingNetworkPolicyListener( new HandlerExecutor(getHandler()), mVcnPolicyListener); if (mConnectionParams != null && mConnectionParams.mRequestType == REQUEST_TYPE_HANDOVER) { // If this is a data setup for handover, we need to reuse the existing network agent Loading Loading @@ -2620,10 +2653,21 @@ public class DataConnection extends StateMachine { updateLinkPropertiesHttpProxy(); mNetworkAgent = new DcNetworkAgent(DataConnection.this, mPhone, mScore, configBuilder.build(), provider, mTransportType); VcnUnderlyingNetworkPolicy policy = mVcnManager.getUnderlyingNetworkPolicy( getNetworkCapabilities(), getLinkProperties()); if (policy.isTeardownRequested()) { tearDownAll( Phone.REASON_VCN_REQUESTED_TEARDOWN, DcTracker.RELEASE_TYPE_DETACH, null /* onCompletedMsg */); } else { // All network agents start out in CONNECTING mode, but DcNetworkAgents are // created when the network is already connected. Hence, send the connected // notification immediately. mNetworkAgent.markConnected(); } // The network agent is always created with NOT_SUSPENDED capability, but the // network might be already out of service (or voice call is ongoing) just right Loading Loading @@ -2676,6 +2720,8 @@ public class DataConnection extends StateMachine { mCid, mApnSetting.getApnTypeBitmask(), RilDataCall.State.DISCONNECTED); mDataCallSessionStats.onDataCallDisconnected(); mVcnManager.removeVcnUnderlyingNetworkPolicyListener(mVcnPolicyListener); mPhone.getCarrierPrivilegesTracker().unregisterCarrierPrivilegesListener(getHandler()); } Loading Loading @@ -3681,5 +3727,32 @@ public class DataConnection extends StateMachine { pw.println(); pw.flush(); } /** * Class used to track VCN-defined Network policies for this DataConnection. * * <p>MUST be registered with the associated DataConnection's Handler. */ private class DataConnectionVcnUnderlyingNetworkPolicyListener implements VcnUnderlyingNetworkPolicyListener { @Override public void onPolicyChanged() { // Poll the current underlying Network policy from VcnManager and send to NetworkAgent. final NetworkCapabilities networkCapabilities = getNetworkCapabilities(); VcnUnderlyingNetworkPolicy policy = mVcnManager.getUnderlyingNetworkPolicy( networkCapabilities, getLinkProperties()); if (policy.isTeardownRequested()) { tearDownAll( Phone.REASON_VCN_REQUESTED_TEARDOWN, DcTracker.RELEASE_TYPE_DETACH, null /* onCompletedMsg */); } if (mNetworkAgent != null) { mNetworkAgent.sendNetworkCapabilities(networkCapabilities, DataConnection.this); } } } }
tests/telephonytests/src/com/android/internal/telephony/ContextFixture.java +6 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ import android.location.LocationManager; import android.net.ConnectivityManager; import android.net.Network; import android.net.Uri; import android.net.vcn.VcnManager; import android.net.wifi.WifiManager; import android.os.BatteryManager; import android.os.Bundle; Loading Loading @@ -266,6 +267,8 @@ public class ContextFixture implements TestFixture<Context> { return mSystemConfigManager; case Context.KEYGUARD_SERVICE: return mKeyguardManager; case Context.VCN_MANAGEMENT_SERVICE: return mVcnManager; case Context.BATTERY_STATS_SERVICE: case Context.DISPLAY_SERVICE: case Context.POWER_SERVICE: Loading Loading @@ -309,6 +312,8 @@ public class ContextFixture implements TestFixture<Context> { return Context.UI_MODE_SERVICE; } else if (serviceClass == KeyguardManager.class) { return Context.KEYGUARD_SERVICE; } else if (serviceClass == VcnManager.class) { return Context.VCN_MANAGEMENT_SERVICE; } return super.getSystemServiceName(serviceClass); } Loading Loading @@ -656,6 +661,7 @@ public class ContextFixture implements TestFixture<Context> { private final PowerWhitelistManager mPowerWhitelistManager = mock(PowerWhitelistManager.class); private final LocationManager mLocationManager = mock(LocationManager.class); private final KeyguardManager mKeyguardManager = mock(KeyguardManager.class); private final VcnManager mVcnManager = mock(VcnManager.class); private final ContentProvider mContentProvider = spy(new FakeContentProvider()); Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,9 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.net.NetworkCapabilities; import android.net.vcn.VcnManager; import android.net.vcn.VcnUnderlyingNetworkPolicy; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; Loading Loading @@ -336,6 +339,7 @@ public abstract class TelephonyTest { protected CarrierConfigManager mCarrierConfigManager; protected UserManager mUserManager; protected KeyguardManager mKeyguardManager; protected VcnManager mVcnManager; protected SimulatedCommands mSimulatedCommands; protected ContextFixture mContextFixture; protected Context mContext; Loading Loading @@ -477,6 +481,7 @@ public abstract class TelephonyTest { (CarrierConfigManager) mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE); mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); mVcnManager = mContext.getSystemService(VcnManager.class); //mTelephonyComponentFactory doReturn(mTelephonyComponentFactory).when(mTelephonyComponentFactory).inject(anyString()); Loading Loading @@ -658,6 +663,12 @@ public abstract class TelephonyTest { doReturn(2).when(mWifiManager).calculateSignalLevel(anyInt()); doReturn(4).when(mWifiManager).getMaxSignalLevel(); doAnswer(invocation -> { NetworkCapabilities nc = invocation.getArgument(0); return new VcnUnderlyingNetworkPolicy( false /* isTearDownRequested */, nc); }).when(mVcnManager).getUnderlyingNetworkPolicy(any(), any()); //SIM doReturn(1).when(mTelephonyManager).getSimCount(); doReturn(1).when(mTelephonyManager).getPhoneCount(); Loading
tests/telephonytests/src/com/android/internal/telephony/dataconnection/DataConnectionTest.java +2 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.times; Loading Loading @@ -386,6 +387,7 @@ public class DataConnectionTest extends TelephonyTest { verify(mSimulatedCommandsVerifier, times(1)) .registerForLceInfo(any(Handler.class), eq(DataConnection.EVENT_LINK_CAPACITY_CHANGED), eq(null)); verify(mVcnManager, atLeastOnce()).getUnderlyingNetworkPolicy(any(), any()); ArgumentCaptor<DataProfile> dpCaptor = ArgumentCaptor.forClass(DataProfile.class); verify(mSimulatedCommandsVerifier, times(1)).setupDataCall( Loading