Merge "Support QosCallback for UDP socket : validate"

This commit is contained in:
Sewook Seo 2022-05-06 20:46:46 +00:00 • committed by Gerrit Code Review
commit bffaff76e0

View file

@ -30,6 +30,8 @@ import android.telephony.data.EpsBearerQosSessionAttributes;
import android.telephony.data.NrQosSessionAttributes;
import android.util.Log;
import com.android.modules.utils.build.SdkLevel;
import java.util.Objects;
/**
@ -149,6 +151,7 @@ class QosCallbackAgentConnection implements IBinder.DeathRecipient {
void sendEventEpsQosSessionAvailable(final QosSession session,
final EpsBearerQosSessionAttributes attributes) {
if (!validateOrSendErrorAndUnregister()) return;
try {
if (DBG) log("sendEventEpsQosSessionAvailable: sending...");
mCallback.onQosEpsBearerSessionAvailable(session, attributes);
@ -159,6 +162,7 @@ class QosCallbackAgentConnection implements IBinder.DeathRecipient {
void sendEventNrQosSessionAvailable(final QosSession session,
final NrQosSessionAttributes attributes) {
if (!validateOrSendErrorAndUnregister()) return;
try {
if (DBG) log("sendEventNrQosSessionAvailable: sending...");
mCallback.onNrQosSessionAvailable(session, attributes);
@ -168,6 +172,7 @@ class QosCallbackAgentConnection implements IBinder.DeathRecipient {
}
void sendEventQosSessionLost(@NonNull final QosSession session) {
if (!validateOrSendErrorAndUnregister()) return;
try {
if (DBG) log("sendEventQosSessionLost: sending...");
mCallback.onQosSessionLost(session);
@ -185,6 +190,21 @@ class QosCallbackAgentConnection implements IBinder.DeathRecipient {
}
}
private boolean validateOrSendErrorAndUnregister() {
final int exceptionType = mFilter.validate();
if (exceptionType != EX_TYPE_FILTER_NONE) {
log("validation fail before sending QosCallback.");
// Error callback is returned from Android T to prevent any disruption of application
// running on Android S.
if (SdkLevel.isAtLeastT()) {
sendEventQosCallbackError(exceptionType);
mQosCallbackTracker.unregisterCallback(mCallback);
}
return false;
}
return true;
}
private static void log(@NonNull final String msg) {
Log.d(TAG, msg);
}