Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce614e30 authored by Cody Kesting's avatar Cody Kesting Committed by Gerrit Code Review
Browse files

Merge "Use VCN policy API in Telephony."

parents 95b42008 fac847e7
Loading
Loading
Loading
Loading
+19 −20
Original line number Original line Diff line number Diff line
@@ -40,8 +40,8 @@ import android.net.RouteInfo;
import android.net.SocketKeepalive;
import android.net.SocketKeepalive;
import android.net.TelephonyNetworkSpecifier;
import android.net.TelephonyNetworkSpecifier;
import android.net.vcn.VcnManager;
import android.net.vcn.VcnManager;
import android.net.vcn.VcnManager.VcnUnderlyingNetworkPolicyListener;
import android.net.vcn.VcnManager.VcnNetworkPolicyListener;
import android.net.vcn.VcnUnderlyingNetworkPolicy;
import android.net.vcn.VcnNetworkPolicyResult;
import android.os.AsyncResult;
import android.os.AsyncResult;
import android.os.HandlerExecutor;
import android.os.HandlerExecutor;
import android.os.Message;
import android.os.Message;
@@ -332,8 +332,8 @@ public class DataConnection extends StateMachine {
    PendingIntent mReconnectIntent = null;
    PendingIntent mReconnectIntent = null;


    /** Class used to track VCN-defined Network policies for this DcNetworkAgent. */
    /** Class used to track VCN-defined Network policies for this DcNetworkAgent. */
    private final VcnUnderlyingNetworkPolicyListener mVcnPolicyListener =
    private final VcnNetworkPolicyListener mVcnPolicyListener =
            new DataConnectionVcnUnderlyingNetworkPolicyListener();
            new DataConnectionVcnNetworkPolicyListener();


    // ***** Event codes for driving the state machine, package visible for Dcc
    // ***** Event codes for driving the state machine, package visible for Dcc
    static final int BASE = Protocol.BASE_DATA_CONNECTION;
    static final int BASE = Protocol.BASE_DATA_CONNECTION;
@@ -1769,13 +1769,13 @@ public class DataConnection extends StateMachine {
     * <p>Determining if the Network is VCN-managed requires polling VcnManager.
     * <p>Determining if the Network is VCN-managed requires polling VcnManager.
     */
     */
    private boolean isVcnManaged(NetworkCapabilities networkCapabilities) {
    private boolean isVcnManaged(NetworkCapabilities networkCapabilities) {
        VcnUnderlyingNetworkPolicy networkPolicy =
        VcnNetworkPolicyResult policyResult =
                mVcnManager.getUnderlyingNetworkPolicy(networkCapabilities, getLinkProperties());
                mVcnManager.applyVcnNetworkPolicy(networkCapabilities, getLinkProperties());


        // if the Network does have capability NOT_VCN_MANAGED, return false to indicate it's not
        // if the Network does have capability NOT_VCN_MANAGED, return false to indicate it's not
        // VCN-managed
        // VCN-managed
        return !networkPolicy
        return !policyResult
                .getMergedNetworkCapabilities()
                .getNetworkCapabilities()
                .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED);
                .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED);
    }
    }


@@ -2588,9 +2588,9 @@ public class DataConnection extends StateMachine {
                        + ", mUnmeteredUseOnly = " + mUnmeteredUseOnly);
                        + ", mUnmeteredUseOnly = " + mUnmeteredUseOnly);
            }
            }


            // Always register a VcnUnderlyingNetworkPolicyListener, regardless of whether this is a
            // Always register a VcnNetworkPolicyListener, regardless of whether this is a handover
            // handover or new Network.
            // or new Network.
            mVcnManager.addVcnUnderlyingNetworkPolicyListener(
            mVcnManager.addVcnNetworkPolicyListener(
                    new HandlerExecutor(getHandler()), mVcnPolicyListener);
                    new HandlerExecutor(getHandler()), mVcnPolicyListener);


            if (mConnectionParams != null
            if (mConnectionParams != null
@@ -2644,10 +2644,10 @@ public class DataConnection extends StateMachine {
                mNetworkAgent = new DcNetworkAgent(DataConnection.this, mPhone, mScore,
                mNetworkAgent = new DcNetworkAgent(DataConnection.this, mPhone, mScore,
                        configBuilder.build(), provider, mTransportType);
                        configBuilder.build(), provider, mTransportType);


                VcnUnderlyingNetworkPolicy policy =
                VcnNetworkPolicyResult policyResult =
                        mVcnManager.getUnderlyingNetworkPolicy(
                        mVcnManager.applyVcnNetworkPolicy(
                                getNetworkCapabilities(), getLinkProperties());
                                getNetworkCapabilities(), getLinkProperties());
                if (policy.isTeardownRequested()) {
                if (policyResult.isTeardownRequested()) {
                    tearDownAll(
                    tearDownAll(
                            Phone.REASON_VCN_REQUESTED_TEARDOWN,
                            Phone.REASON_VCN_REQUESTED_TEARDOWN,
                            DcTracker.RELEASE_TYPE_DETACH,
                            DcTracker.RELEASE_TYPE_DETACH,
@@ -2706,7 +2706,7 @@ public class DataConnection extends StateMachine {
                    mCid, mApnSetting.getApnTypeBitmask(), RilDataCall.State.DISCONNECTED);
                    mCid, mApnSetting.getApnTypeBitmask(), RilDataCall.State.DISCONNECTED);
            mDataCallSessionStats.onDataCallDisconnected();
            mDataCallSessionStats.onDataCallDisconnected();


            mVcnManager.removeVcnUnderlyingNetworkPolicyListener(mVcnPolicyListener);
            mVcnManager.removeVcnNetworkPolicyListener(mVcnPolicyListener);


            mPhone.getCarrierPrivilegesTracker().unregisterCarrierPrivilegesListener(getHandler());
            mPhone.getCarrierPrivilegesTracker().unregisterCarrierPrivilegesListener(getHandler());
        }
        }
@@ -3716,16 +3716,15 @@ public class DataConnection extends StateMachine {
     *
     *
     * <p>MUST be registered with the associated DataConnection's Handler.
     * <p>MUST be registered with the associated DataConnection's Handler.
     */
     */
    private class DataConnectionVcnUnderlyingNetworkPolicyListener
    private class DataConnectionVcnNetworkPolicyListener implements VcnNetworkPolicyListener {
            implements VcnUnderlyingNetworkPolicyListener {
        @Override
        @Override
        public void onPolicyChanged() {
        public void onPolicyChanged() {
            // Poll the current underlying Network policy from VcnManager and send to NetworkAgent.
            // Poll the current underlying Network policy from VcnManager and send to NetworkAgent.
            final NetworkCapabilities networkCapabilities = getNetworkCapabilities();
            final NetworkCapabilities networkCapabilities = getNetworkCapabilities();
            VcnUnderlyingNetworkPolicy policy =
            VcnNetworkPolicyResult policyResult =
                    mVcnManager.getUnderlyingNetworkPolicy(
                    mVcnManager.applyVcnNetworkPolicy(
                            networkCapabilities, getLinkProperties());
                            networkCapabilities, getLinkProperties());
            if (policy.isTeardownRequested()) {
            if (policyResult.isTeardownRequested()) {
                tearDownAll(
                tearDownAll(
                        Phone.REASON_VCN_REQUESTED_TEARDOWN,
                        Phone.REASON_VCN_REQUESTED_TEARDOWN,
                        DcTracker.RELEASE_TYPE_DETACH,
                        DcTracker.RELEASE_TYPE_DETACH,
+3 −3
Original line number Original line Diff line number Diff line
@@ -43,7 +43,7 @@ import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import android.net.NetworkCapabilities;
import android.net.vcn.VcnManager;
import android.net.vcn.VcnManager;
import android.net.vcn.VcnUnderlyingNetworkPolicy;
import android.net.vcn.VcnNetworkPolicyResult;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Build;
@@ -649,9 +649,9 @@ public abstract class TelephonyTest {


        doAnswer(invocation -> {
        doAnswer(invocation -> {
            NetworkCapabilities nc = invocation.getArgument(0);
            NetworkCapabilities nc = invocation.getArgument(0);
            return new VcnUnderlyingNetworkPolicy(
            return new VcnNetworkPolicyResult(
                    false /* isTearDownRequested */, nc);
                    false /* isTearDownRequested */, nc);
        }).when(mVcnManager).getUnderlyingNetworkPolicy(any(), any());
        }).when(mVcnManager).applyVcnNetworkPolicy(any(), any());


        //SIM
        //SIM
        doReturn(1).when(mTelephonyManager).getSimCount();
        doReturn(1).when(mTelephonyManager).getSimCount();
+1 −1
Original line number Original line Diff line number Diff line
@@ -389,7 +389,7 @@ public class DataConnectionTest extends TelephonyTest {
                .registerForLceInfo(any(Handler.class),
                .registerForLceInfo(any(Handler.class),
                        eq(DataConnection.EVENT_LINK_CAPACITY_CHANGED), eq(null));
                        eq(DataConnection.EVENT_LINK_CAPACITY_CHANGED), eq(null));
        verify(mVcnManager, atLeastOnce())
        verify(mVcnManager, atLeastOnce())
                .getUnderlyingNetworkPolicy(
                .applyVcnNetworkPolicy(
                        argThat(caps ->
                        argThat(caps ->
                                caps.hasCapability(
                                caps.hasCapability(
                                        NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED)),
                                        NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED)),