Loading src/java/com/android/internal/telephony/data/DataNetwork.java +4 −2 Original line number Diff line number Diff line Loading @@ -1355,8 +1355,10 @@ public class DataNetwork extends StateMachine { // suggested to de-register and re-register the network agent if it is needed to // add/remove immutable capabilities. logl("updateNetworkCapabilities: Immutable capabilities changed. Re-create the " + "network agent."); mNetworkAgent.unregister(); + "network agent. Attempted to change from " + mNetworkCapabilities + " to " + nc); // Abandon the network agent because we are going to create a new one. mNetworkAgent.abandon(); // Update the capabilities first so the new network agent would be created with the // new capabilities. mNetworkCapabilities = nc; Loading src/java/com/android/internal/telephony/data/TelephonyNetworkAgent.java +42 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,12 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess /** This is the id from {@link NetworkAgent#register()}. */ private final int mId; /** * Indicates if this network agent is abandoned. if {@code true}, it ignores the * @link NetworkAgent#onNetworkUnwanted()} calls from connectivity service. */ private boolean mAbandoned = false; /** * The callbacks that are used to pass information to {@link DataNetwork} and * {@link QosCallbackTracker}. Loading Loading @@ -163,6 +169,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess */ @Override public void onNetworkUnwanted() { if (mAbandoned) { log("The agent is already abandoned. Ignored onNetworkUnwanted."); return; } mDataNetwork.tearDown(DataNetwork.TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED); } Loading @@ -186,6 +196,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess @Override public void onValidationStatus(@android.telephony.Annotation.ValidationStatus int status, @Nullable Uri redirectUri) { if (mAbandoned) { log("The agent is already abandoned. Ignored onValidationStatus."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onValidationStatus(status, redirectUri))); } Loading @@ -212,6 +226,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess @Override public void onStartSocketKeepalive(int slot, @NonNull Duration interval, @NonNull KeepalivePacketData packet) { if (mAbandoned) { log("The agent is already abandoned. Ignored onStartSocketKeepalive."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onStartSocketKeepalive(slot, interval, packet))); } Loading @@ -224,6 +242,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess */ @Override public void onStopSocketKeepalive(int slot) { if (mAbandoned) { log("The agent is already abandoned. Ignored onStopSocketKeepalive."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onStopSocketKeepalive(slot))); } Loading @@ -236,6 +258,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess */ @Override public void onQosCallbackRegistered(final int qosCallbackId, final @NonNull QosFilter filter) { if (mAbandoned) { log("The agent is already abandoned. Ignored onQosCallbackRegistered."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onQosCallbackRegistered(qosCallbackId, filter))); } Loading @@ -250,6 +276,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess */ @Override public void onQosCallbackUnregistered(final int qosCallbackId) { if (mAbandoned) { log("The agent is already abandoned. Ignored onQosCallbackUnregistered."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onQosCallbackUnregistered(qosCallbackId))); } Loading Loading @@ -285,6 +315,18 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess super.sendQosSessionLost(qosCallbackId, sessionId, qosSessionType); } /** * Abandon the network agent. This is used for telephony to re-create the network agent when * immutable capabilities got changed, where telephony calls {@link NetworkAgent#unregister()} * and then create another network agent with new capabilities. Abandon this network agent * allowing it ignore the subsequent {@link #onNetworkUnwanted()} invocation caused by * {@link NetworkAgent#unregister()}. */ public void abandon() { mAbandoned = true; unregister(); } /** * Register the callback for receiving information from {@link TelephonyNetworkAgent}. * Loading Loading
src/java/com/android/internal/telephony/data/DataNetwork.java +4 −2 Original line number Diff line number Diff line Loading @@ -1355,8 +1355,10 @@ public class DataNetwork extends StateMachine { // suggested to de-register and re-register the network agent if it is needed to // add/remove immutable capabilities. logl("updateNetworkCapabilities: Immutable capabilities changed. Re-create the " + "network agent."); mNetworkAgent.unregister(); + "network agent. Attempted to change from " + mNetworkCapabilities + " to " + nc); // Abandon the network agent because we are going to create a new one. mNetworkAgent.abandon(); // Update the capabilities first so the new network agent would be created with the // new capabilities. mNetworkCapabilities = nc; Loading
src/java/com/android/internal/telephony/data/TelephonyNetworkAgent.java +42 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,12 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess /** This is the id from {@link NetworkAgent#register()}. */ private final int mId; /** * Indicates if this network agent is abandoned. if {@code true}, it ignores the * @link NetworkAgent#onNetworkUnwanted()} calls from connectivity service. */ private boolean mAbandoned = false; /** * The callbacks that are used to pass information to {@link DataNetwork} and * {@link QosCallbackTracker}. Loading Loading @@ -163,6 +169,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess */ @Override public void onNetworkUnwanted() { if (mAbandoned) { log("The agent is already abandoned. Ignored onNetworkUnwanted."); return; } mDataNetwork.tearDown(DataNetwork.TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED); } Loading @@ -186,6 +196,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess @Override public void onValidationStatus(@android.telephony.Annotation.ValidationStatus int status, @Nullable Uri redirectUri) { if (mAbandoned) { log("The agent is already abandoned. Ignored onValidationStatus."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onValidationStatus(status, redirectUri))); } Loading @@ -212,6 +226,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess @Override public void onStartSocketKeepalive(int slot, @NonNull Duration interval, @NonNull KeepalivePacketData packet) { if (mAbandoned) { log("The agent is already abandoned. Ignored onStartSocketKeepalive."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onStartSocketKeepalive(slot, interval, packet))); } Loading @@ -224,6 +242,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess */ @Override public void onStopSocketKeepalive(int slot) { if (mAbandoned) { log("The agent is already abandoned. Ignored onStopSocketKeepalive."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onStopSocketKeepalive(slot))); } Loading @@ -236,6 +258,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess */ @Override public void onQosCallbackRegistered(final int qosCallbackId, final @NonNull QosFilter filter) { if (mAbandoned) { log("The agent is already abandoned. Ignored onQosCallbackRegistered."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onQosCallbackRegistered(qosCallbackId, filter))); } Loading @@ -250,6 +276,10 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess */ @Override public void onQosCallbackUnregistered(final int qosCallbackId) { if (mAbandoned) { log("The agent is already abandoned. Ignored onQosCallbackUnregistered."); return; } mTelephonyNetworkAgentCallbacks.forEach(callback -> callback.invokeFromExecutor( () -> callback.onQosCallbackUnregistered(qosCallbackId))); } Loading Loading @@ -285,6 +315,18 @@ public class TelephonyNetworkAgent extends NetworkAgent implements NotifyQosSess super.sendQosSessionLost(qosCallbackId, sessionId, qosSessionType); } /** * Abandon the network agent. This is used for telephony to re-create the network agent when * immutable capabilities got changed, where telephony calls {@link NetworkAgent#unregister()} * and then create another network agent with new capabilities. Abandon this network agent * allowing it ignore the subsequent {@link #onNetworkUnwanted()} invocation caused by * {@link NetworkAgent#unregister()}. */ public void abandon() { mAbandoned = true; unregister(); } /** * Register the callback for receiving information from {@link TelephonyNetworkAgent}. * Loading