From b9bacba8035a09dd09d8919b985f25dad637c9f6 Mon Sep 17 00:00:00 2001 From: sewookseo Date: Mon, 7 Mar 2022 12:17:39 +0000 Subject: [PATCH] Support QosCallback for UDP socket : validate Do validate() before sending QosCallback to App. If validate fails, notify error to App & tear down QosCallback internally. Bug: 203146631 Test: atest & verified on LTE test equipment Change-Id: I05e28b10b816381a191272c85b3b178204d835d7 --- .../QosCallbackAgentConnection.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/service/src/com/android/server/connectivity/QosCallbackAgentConnection.java b/service/src/com/android/server/connectivity/QosCallbackAgentConnection.java index 534dbe7699..e682026aa8 100644 --- a/service/src/com/android/server/connectivity/QosCallbackAgentConnection.java +++ b/service/src/com/android/server/connectivity/QosCallbackAgentConnection.java @@ -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); }