diff options
| -rw-r--r-- | core/api/system-current.txt | 2 | ||||
| -rw-r--r-- | telephony/java/android/telephony/data/DataCallResponse.java | 12 | ||||
| -rw-r--r-- | telephony/java/android/telephony/data/DataService.java | 34 |
3 files changed, 31 insertions, 17 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 6019ab56dea7..8e8afebd4833 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -11962,7 +11962,7 @@ package android.telephony.data { method @NonNull public android.telephony.data.DataCallResponse.Builder setMtuV4(int); method @NonNull public android.telephony.data.DataCallResponse.Builder setMtuV6(int); method @NonNull public android.telephony.data.DataCallResponse.Builder setPcscfAddresses(@NonNull java.util.List<java.net.InetAddress>); - method @NonNull public android.telephony.data.DataCallResponse.Builder setPduSessionId(int); + method @NonNull public android.telephony.data.DataCallResponse.Builder setPduSessionId(@IntRange(from=android.telephony.data.DataCallResponse.PDU_SESSION_ID_NOT_SET, to=15) int); method @NonNull public android.telephony.data.DataCallResponse.Builder setProtocolType(int); method @NonNull public android.telephony.data.DataCallResponse.Builder setRetryDurationMillis(long); method @NonNull public android.telephony.data.DataCallResponse.Builder setSliceInfo(@Nullable android.telephony.data.SliceInfo); diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java index a76422977cb6..ffe5399e406b 100644 --- a/telephony/java/android/telephony/data/DataCallResponse.java +++ b/telephony/java/android/telephony/data/DataCallResponse.java @@ -18,6 +18,7 @@ package android.telephony.data; import android.annotation.IntDef; +import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; @@ -29,6 +30,7 @@ import android.telephony.DataFailCause; import android.telephony.data.ApnSetting.ProtocolType; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.util.Preconditions; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -812,11 +814,19 @@ public final class DataCallResponse implements Parcelable { /** * Set pdu session id. + * <p/> + * The id must be between 1 and 15 when linked to a pdu session. If no pdu session + * exists for the current data call, the id must be set to {@link PDU_SESSION_ID_NOT_SET}. * * @param pduSessionId Pdu Session Id of the data call. * @return The same instance of the builder. */ - public @NonNull Builder setPduSessionId(int pduSessionId) { + public @NonNull Builder setPduSessionId( + @IntRange(from = PDU_SESSION_ID_NOT_SET, to = 15) int pduSessionId) { + Preconditions.checkArgument(pduSessionId >= PDU_SESSION_ID_NOT_SET, + "pduSessionId must be greater than or equal to" + PDU_SESSION_ID_NOT_SET); + Preconditions.checkArgument(pduSessionId <= 15, + "pduSessionId must be less than or equal to 15."); mPduSessionId = pduSessionId; return this; } diff --git a/telephony/java/android/telephony/data/DataService.java b/telephony/java/android/telephony/data/DataService.java index f5f29c65b7cd..048b3297a1b4 100644 --- a/telephony/java/android/telephony/data/DataService.java +++ b/telephony/java/android/telephony/data/DataService.java @@ -41,6 +41,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * Base class of data service. Services that extend DataService must register the service in @@ -284,11 +285,11 @@ public abstract class DataService extends Service { * * Any resources being transferred cannot be released while a * handover is underway. - * + * <p/> * If a handover was unsuccessful, then the framework calls * {@link DataService#cancelHandover}. The target transport retains ownership over any of * the resources being transferred. - * + * <p/> * If a handover was successful, the framework calls {@link DataService#deactivateDataCall} * with reason {@link DataService.REQUEST_REASON_HANDOVER}. The target transport now owns * the transferred resources and is responsible for releasing them. @@ -299,21 +300,27 @@ public abstract class DataService extends Service { * @hide */ public void startHandover(int cid, @NonNull DataServiceCallback callback) { + Objects.requireNonNull(callback, "callback cannot be null"); // The default implementation is to return unsupported. - if (callback != null) { - Log.d(TAG, "startHandover: " + cid); - callback.onHandoverStarted(DataServiceCallback.RESULT_ERROR_UNSUPPORTED); - } else { - Log.e(TAG, "startHandover: " + cid + ", callback is null"); - } + Log.d(TAG, "startHandover: " + cid); + callback.onHandoverStarted(DataServiceCallback.RESULT_ERROR_UNSUPPORTED); } /** * Indicates that a handover was cancelled after a call to * {@link DataService#startHandover}. This is called on the source transport. - * + * <p/> * Since the handover was unsuccessful, the source transport retains ownership over any of * the resources being transferred and is still responsible for releasing them. + * <p/> + * The handover can be cancelled up until either: + * <ul><li> + * The handover was successful after receiving a successful response from + * {@link DataService#setupDataCall} on the target transport. + * </li><li> + * The data call on the source transport was lost. + * </li> + * </ul> * * @param cid The identifier of the data call which is provided in {@link DataCallResponse} * @param callback The result callback for this request. @@ -321,13 +328,10 @@ public abstract class DataService extends Service { * @hide */ public void cancelHandover(int cid, @NonNull DataServiceCallback callback) { + Objects.requireNonNull(callback, "callback cannot be null"); // The default implementation is to return unsupported. - if (callback != null) { - Log.d(TAG, "cancelHandover: " + cid); - callback.onHandoverCancelled(DataServiceCallback.RESULT_ERROR_UNSUPPORTED); - } else { - Log.e(TAG, "cancelHandover: " + cid + ", callback is null"); - } + Log.d(TAG, "cancelHandover: " + cid); + callback.onHandoverCancelled(DataServiceCallback.RESULT_ERROR_UNSUPPORTED); } /** |