Merge "Remove @hide CollectionUtils in QosCallbackTracker"

This commit is contained in:
Treehugger Robot
2021-03-04 04:22:18 +00:00
committed by Gerrit Code Review

View File

@@ -29,7 +29,7 @@ import android.os.IBinder;
import android.telephony.data.EpsBearerQosSessionAttributes; import android.telephony.data.EpsBearerQosSessionAttributes;
import android.util.Log; import android.util.Log;
import com.android.internal.util.CollectionUtils; import com.android.net.module.util.CollectionUtils;
import com.android.server.ConnectivityService; import com.android.server.ConnectivityService;
import java.util.ArrayList; import java.util.ArrayList;
@@ -156,12 +156,13 @@ public class QosCallbackTracker {
private void handleUnregisterCallback(@NonNull final IBinder binder, private void handleUnregisterCallback(@NonNull final IBinder binder,
final boolean sendToNetworkAgent) { final boolean sendToNetworkAgent) {
final QosCallbackAgentConnection agentConnection = final int connIndex =
CollectionUtils.find(mConnections, c -> c.getBinder().equals(binder)); CollectionUtils.indexOf(mConnections, c -> c.getBinder().equals(binder));
if (agentConnection == null) { if (connIndex < 0) {
logw("handleUnregisterCallback: agentConnection is null"); logw("handleUnregisterCallback: no matching agentConnection");
return; return;
} }
final QosCallbackAgentConnection agentConnection = mConnections.get(connIndex);
if (DBG) { if (DBG) {
log("handleUnregisterCallback: unregister " log("handleUnregisterCallback: unregister "
@@ -226,10 +227,10 @@ public class QosCallbackTracker {
* @param network the network that was released * @param network the network that was released
*/ */
public void handleNetworkReleased(@Nullable final Network network) { public void handleNetworkReleased(@Nullable final Network network) {
final List<QosCallbackAgentConnection> connections = // Iterate in reverse order as agent connections will be removed when unregistering
CollectionUtils.filter(mConnections, ac -> ac.getNetwork().equals(network)); for (int i = mConnections.size() - 1; i >= 0; i--) {
final QosCallbackAgentConnection agentConnection = mConnections.get(i);
for (final QosCallbackAgentConnection agentConnection : connections) { if (!agentConnection.getNetwork().equals(network)) continue;
agentConnection.sendEventQosCallbackError( agentConnection.sendEventQosCallbackError(
QosCallbackException.EX_TYPE_FILTER_NETWORK_RELEASED); QosCallbackException.EX_TYPE_FILTER_NETWORK_RELEASED);
@@ -247,15 +248,14 @@ public class QosCallbackTracker {
@NonNull final String logPrefix, @NonNull final String logPrefix,
@NonNull final AgentConnectionAction action) { @NonNull final AgentConnectionAction action) {
mConnectivityServiceHandler.post(() -> { mConnectivityServiceHandler.post(() -> {
final QosCallbackAgentConnection ac = final int acIndex = CollectionUtils.indexOf(mConnections,
CollectionUtils.find(mConnections,
c -> c.getAgentCallbackId() == qosCallbackId); c -> c.getAgentCallbackId() == qosCallbackId);
if (ac == null) { if (acIndex == -1) {
loge(logPrefix + ": " + qosCallbackId + " missing callback id"); loge(logPrefix + ": " + qosCallbackId + " missing callback id");
return; return;
} }
action.execute(ac); action.execute(mConnections.get(acIndex));
}); });
} }