Merge "Add support for pdu session id" am: 3798c10c1d

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1507547

Change-Id: Ib9106fba33057b9b49a58d6b1dcc7d95f296ce55
This commit is contained in:
Daniel Bright
2020-11-20 23:26:09 +00:00
committed by Automerger Merge Worker
7 changed files with 254 additions and 19 deletions

View File

@@ -10379,6 +10379,7 @@ package android.telephony.data {
method public int getMtuV4();
method public int getMtuV6();
method @NonNull public java.util.List<java.net.InetAddress> getPcscfAddresses();
method public int getPduSessionId();
method public int getProtocolType();
method public long getRetryIntervalMillis();
method @Deprecated public int getSuggestedRetryTime();
@@ -10393,6 +10394,7 @@ package android.telephony.data {
field public static final int LINK_STATUS_DORMANT = 1; // 0x1
field public static final int LINK_STATUS_INACTIVE = 0; // 0x0
field public static final int LINK_STATUS_UNKNOWN = -1; // 0xffffffff
field public static final int PDU_SESSION_ID_NOT_SET = 0; // 0x0
field public static final int RETRY_INTERVAL_UNDEFINED = -1; // 0xffffffff
}
@@ -10411,6 +10413,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 setProtocolType(int);
method @NonNull public android.telephony.data.DataCallResponse.Builder setRetryIntervalMillis(long);
method @Deprecated @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int);
@@ -10475,6 +10478,7 @@ package android.telephony.data {
public abstract class DataService.DataServiceProvider implements java.lang.AutoCloseable {
ctor public DataService.DataServiceProvider(int);
method public void cancelHandover(int, @NonNull android.telephony.data.DataServiceCallback);
method public abstract void close();
method public void deactivateDataCall(int, int, @Nullable android.telephony.data.DataServiceCallback);
method public final int getSlotIndex();
@@ -10483,11 +10487,15 @@ package android.telephony.data {
method public void setDataProfile(@NonNull java.util.List<android.telephony.data.DataProfile>, boolean, @NonNull android.telephony.data.DataServiceCallback);
method public void setInitialAttachApn(@NonNull android.telephony.data.DataProfile, boolean, @NonNull android.telephony.data.DataServiceCallback);
method public void setupDataCall(int, @NonNull android.telephony.data.DataProfile, boolean, boolean, int, @Nullable android.net.LinkProperties, @NonNull android.telephony.data.DataServiceCallback);
method public void setupDataCall(int, @NonNull android.telephony.data.DataProfile, boolean, boolean, int, @Nullable android.net.LinkProperties, @IntRange(from=0, to=15) int, @NonNull android.telephony.data.DataServiceCallback);
method public void startHandover(int, @NonNull android.telephony.data.DataServiceCallback);
}
public class DataServiceCallback {
method public void onDataCallListChanged(@NonNull java.util.List<android.telephony.data.DataCallResponse>);
method public void onDeactivateDataCallComplete(int);
method public void onHandoverCancelled(int);
method public void onHandoverStarted(int);
method public void onRequestDataCallListComplete(int, @NonNull java.util.List<android.telephony.data.DataCallResponse>);
method public void onSetDataProfileComplete(int);
method public void onSetInitialAttachApnComplete(int);

View File

@@ -114,6 +114,11 @@ public final class DataCallResponse implements Parcelable {
*/
public static final int RETRY_INTERVAL_UNDEFINED = -1;
/**
* Indicates that the pdu session id is not set.
*/
public static final int PDU_SESSION_ID_NOT_SET = 0;
private final @DataFailureCause int mCause;
private final long mSuggestedRetryTime;
private final int mId;
@@ -128,6 +133,7 @@ public final class DataCallResponse implements Parcelable {
private final int mMtuV4;
private final int mMtuV6;
private final @HandoverFailureMode int mHandoverFailureMode;
private final int mPduSessionId;
/**
* @param cause Data call fail cause. {@link DataFailCause#NONE} indicates no error.
@@ -175,6 +181,7 @@ public final class DataCallResponse implements Parcelable {
? new ArrayList<>() : new ArrayList<>(pcscfAddresses);
mMtu = mMtuV4 = mMtuV6 = mtu;
mHandoverFailureMode = HANDOVER_FAILURE_MODE_LEGACY;
mPduSessionId = PDU_SESSION_ID_NOT_SET;
}
private DataCallResponse(@DataFailureCause int cause, long suggestedRetryTime, int id,
@@ -182,7 +189,7 @@ public final class DataCallResponse implements Parcelable {
@Nullable String interfaceName, @Nullable List<LinkAddress> addresses,
@Nullable List<InetAddress> dnsAddresses, @Nullable List<InetAddress> gatewayAddresses,
@Nullable List<InetAddress> pcscfAddresses, int mtu, int mtuV4, int mtuV6,
@HandoverFailureMode int handoverFailureMode) {
@HandoverFailureMode int handoverFailureMode, int pduSessionId) {
mCause = cause;
mSuggestedRetryTime = suggestedRetryTime;
mId = id;
@@ -201,6 +208,7 @@ public final class DataCallResponse implements Parcelable {
mMtuV4 = mtuV4;
mMtuV6 = mtuV6;
mHandoverFailureMode = handoverFailureMode;
mPduSessionId = pduSessionId;
}
/** @hide */
@@ -224,6 +232,7 @@ public final class DataCallResponse implements Parcelable {
mMtuV4 = source.readInt();
mMtuV6 = source.readInt();
mHandoverFailureMode = source.readInt();
mPduSessionId = source.readInt();
}
/**
@@ -334,6 +343,13 @@ public final class DataCallResponse implements Parcelable {
return mHandoverFailureMode;
}
/**
* @return The pdu session id
*/
public int getPduSessionId() {
return mPduSessionId;
}
@NonNull
@Override
public String toString() {
@@ -353,6 +369,7 @@ public final class DataCallResponse implements Parcelable {
.append(" mtuV4=").append(getMtuV4())
.append(" mtuV6=").append(getMtuV6())
.append(" handoverFailureMode=").append(getHandoverFailureMode())
.append(" pduSessionId=").append(getPduSessionId())
.append("}");
return sb.toString();
}
@@ -383,14 +400,15 @@ public final class DataCallResponse implements Parcelable {
&& mMtu == other.mMtu
&& mMtuV4 == other.mMtuV4
&& mMtuV6 == other.mMtuV6
&& mHandoverFailureMode == other.mHandoverFailureMode;
&& mHandoverFailureMode == other.mHandoverFailureMode
&& mPduSessionId == other.mPduSessionId;
}
@Override
public int hashCode() {
return Objects.hash(mCause, mSuggestedRetryTime, mId, mLinkStatus, mProtocolType,
mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses, mPcscfAddresses,
mMtu, mMtuV4, mMtuV6, mHandoverFailureMode);
mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId);
}
@Override
@@ -414,6 +432,7 @@ public final class DataCallResponse implements Parcelable {
dest.writeInt(mMtuV4);
dest.writeInt(mMtuV6);
dest.writeInt(mHandoverFailureMode);
dest.writeInt(mPduSessionId);
}
public static final @android.annotation.NonNull Parcelable.Creator<DataCallResponse> CREATOR =
@@ -491,6 +510,8 @@ public final class DataCallResponse implements Parcelable {
private @HandoverFailureMode int mHandoverFailureMode = HANDOVER_FAILURE_MODE_LEGACY;
private int mPduSessionId = PDU_SESSION_ID_NOT_SET;
/**
* Default constructor for Builder.
*/
@@ -673,6 +694,17 @@ public final class DataCallResponse implements Parcelable {
return this;
}
/**
* Set pdu session id.
*
* @param pduSessionId Pdu Session Id of the data call.
* @return The same instance of the builder.
*/
public @NonNull Builder setPduSessionId(int pduSessionId) {
mPduSessionId = pduSessionId;
return this;
}
/**
* Build the DataCallResponse.
*
@@ -681,7 +713,7 @@ public final class DataCallResponse implements Parcelable {
public @NonNull DataCallResponse build() {
return new DataCallResponse(mCause, mSuggestedRetryTime, mId, mLinkStatus,
mProtocolType, mInterfaceName, mAddresses, mDnsAddresses, mGatewayAddresses,
mPcscfAddresses, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode);
mPcscfAddresses, mMtu, mMtuV4, mMtuV6, mHandoverFailureMode, mPduSessionId);
}
}
}

View File

@@ -17,6 +17,7 @@
package android.telephony.data;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
@@ -30,7 +31,7 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.telephony.AccessNetworkConstants;
import android.util.Log;
import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting;
@@ -104,6 +105,8 @@ public abstract class DataService extends Service {
private static final int DATA_SERVICE_REQUEST_REGISTER_DATA_CALL_LIST_CHANGED = 9;
private static final int DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED = 10;
private static final int DATA_SERVICE_INDICATION_DATA_CALL_LIST_CHANGED = 11;
private static final int DATA_SERVICE_REQUEST_START_HANDOVER = 12;
private static final int DATA_SERVICE_REQUEST_CANCEL_HANDOVER = 13;
private final HandlerThread mHandlerThread;
@@ -147,7 +150,7 @@ public abstract class DataService extends Service {
* the provided callback to notify the platform.
*
* @param accessNetworkType Access network type that the data call will be established on.
* Must be one of {@link AccessNetworkConstants.AccessNetworkType}.
* Must be one of {@link android.telephony.AccessNetworkConstants.AccessNetworkType}.
* @param dataProfile Data profile used for data call setup. See {@link DataProfile}
* @param isRoaming True if the device is data roaming.
* @param allowRoaming True if data roaming is allowed by the user.
@@ -158,10 +161,9 @@ public abstract class DataService extends Service {
* @param callback The result callback for this request.
*/
public void setupDataCall(int accessNetworkType, @NonNull DataProfile dataProfile,
boolean isRoaming, boolean allowRoaming,
@SetupDataReason int reason,
@Nullable LinkProperties linkProperties,
@NonNull DataServiceCallback callback) {
boolean isRoaming, boolean allowRoaming,
@SetupDataReason int reason, @Nullable LinkProperties linkProperties,
@NonNull DataServiceCallback callback) {
// The default implementation is to return unsupported.
if (callback != null) {
callback.onSetupDataCallComplete(DataServiceCallback.RESULT_ERROR_UNSUPPORTED,
@@ -169,6 +171,37 @@ public abstract class DataService extends Service {
}
}
/**
* Setup a data connection. The data service provider must implement this method to support
* establishing a packet data connection. When completed or error, the service must invoke
* the provided callback to notify the platform.
*
* @param accessNetworkType Access network type that the data call will be established on.
* Must be one of {@link android.telephony.AccessNetworkConstants.AccessNetworkType}.
* @param dataProfile Data profile used for data call setup. See {@link DataProfile}
* @param isRoaming True if the device is data roaming.
* @param allowRoaming True if data roaming is allowed by the user.
* @param reason The reason for data setup. Must be {@link #REQUEST_REASON_NORMAL} or
* {@link #REQUEST_REASON_HANDOVER}.
* @param linkProperties If {@code reason} is {@link #REQUEST_REASON_HANDOVER}, this is the
* link properties of the existing data connection, otherwise null.
* @param pduSessionId The pdu session id to be used for this data call.
* The standard range of values are 1-15 while 0 means no pdu session id
* was attached to this call. Reference: 3GPP TS 24.007 section
* 11.2.3.1b.
* @param callback The result callback for this request.
*/
public void setupDataCall(int accessNetworkType, @NonNull DataProfile dataProfile,
boolean isRoaming, boolean allowRoaming,
@SetupDataReason int reason,
@Nullable LinkProperties linkProperties,
@IntRange(from = 0, to = 15) int pduSessionId,
@NonNull DataServiceCallback callback) {
/* Call the old version since the new version isn't supported */
setupDataCall(accessNetworkType, dataProfile, isRoaming, allowRoaming, reason,
linkProperties, callback);
}
/**
* Deactivate a data connection. The data service provider must implement this method to
* support data connection tear down. When completed or error, the service must invoke the
@@ -223,6 +256,53 @@ public abstract class DataService extends Service {
}
}
/**
* Indicates that a handover has begun. This is called on the source transport.
*
* Any resources being transferred cannot be released while a
* handover is underway.
*
* If a handover was unsuccessful, then the framework calls
* {@link DataService#cancelHandover}. The target transport retains ownership over any of
* the resources being transferred.
*
* 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.
*
* @param cid The identifier of the data call which is provided in {@link DataCallResponse}
* @param callback The result callback for this request.
*/
public void startHandover(int cid, @NonNull DataServiceCallback callback) {
// 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");
}
}
/**
* Indicates that a handover was cancelled after a call to
* {@link DataService#startHandover}. This is called on the source transport.
*
* Since the handover was unsuccessful, the source transport retains ownership over any of
* the resources being transferred and is still responsible for releasing them.
*
* @param cid The identifier of the data call which is provided in {@link DataCallResponse}
* @param callback The result callback for this request.
*/
public void cancelHandover(int cid, @NonNull DataServiceCallback callback) {
// 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");
}
}
/**
* Get the active data call list.
*
@@ -278,16 +358,18 @@ public abstract class DataService extends Service {
public final boolean allowRoaming;
public final int reason;
public final LinkProperties linkProperties;
public final int pduSessionId;
public final IDataServiceCallback callback;
SetupDataCallRequest(int accessNetworkType, DataProfile dataProfile, boolean isRoaming,
boolean allowRoaming, int reason, LinkProperties linkProperties,
IDataServiceCallback callback) {
int pduSessionId, IDataServiceCallback callback) {
this.accessNetworkType = accessNetworkType;
this.dataProfile = dataProfile;
this.isRoaming = isRoaming;
this.allowRoaming = allowRoaming;
this.linkProperties = linkProperties;
this.reason = reason;
this.pduSessionId = pduSessionId;
this.callback = callback;
}
}
@@ -327,6 +409,16 @@ public abstract class DataService extends Service {
}
}
private static final class BeginCancelHandoverRequest {
public final int cid;
public final IDataServiceCallback callback;
BeginCancelHandoverRequest(int cid,
IDataServiceCallback callback) {
this.cid = cid;
this.callback = callback;
}
}
private static final class DataCallListChangedIndication {
public final List<DataCallResponse> dataCallList;
public final IDataServiceCallback callback;
@@ -377,7 +469,7 @@ public abstract class DataService extends Service {
serviceProvider.setupDataCall(setupDataCallRequest.accessNetworkType,
setupDataCallRequest.dataProfile, setupDataCallRequest.isRoaming,
setupDataCallRequest.allowRoaming, setupDataCallRequest.reason,
setupDataCallRequest.linkProperties,
setupDataCallRequest.linkProperties, setupDataCallRequest.pduSessionId,
(setupDataCallRequest.callback != null)
? new DataServiceCallback(setupDataCallRequest.callback)
: null);
@@ -438,6 +530,20 @@ public abstract class DataService extends Service {
loge("Failed to call onDataCallListChanged. " + e);
}
break;
case DATA_SERVICE_REQUEST_START_HANDOVER:
if (serviceProvider == null) break;
BeginCancelHandoverRequest bReq = (BeginCancelHandoverRequest) message.obj;
serviceProvider.startHandover(bReq.cid,
(bReq.callback != null)
? new DataServiceCallback(bReq.callback) : null);
break;
case DATA_SERVICE_REQUEST_CANCEL_HANDOVER:
if (serviceProvider == null) break;
BeginCancelHandoverRequest cReq = (BeginCancelHandoverRequest) message.obj;
serviceProvider.cancelHandover(cReq.cid,
(cReq.callback != null)
? new DataServiceCallback(cReq.callback) : null);
break;
}
}
}
@@ -506,11 +612,11 @@ public abstract class DataService extends Service {
@Override
public void setupDataCall(int slotIndex, int accessNetworkType, DataProfile dataProfile,
boolean isRoaming, boolean allowRoaming, int reason,
LinkProperties linkProperties, IDataServiceCallback callback) {
boolean isRoaming, boolean allowRoaming, int reason,
LinkProperties linkProperties, int pduSessionId, IDataServiceCallback callback) {
mHandler.obtainMessage(DATA_SERVICE_REQUEST_SETUP_DATA_CALL, slotIndex, 0,
new SetupDataCallRequest(accessNetworkType, dataProfile, isRoaming,
allowRoaming, reason, linkProperties, callback))
allowRoaming, reason, linkProperties, pduSessionId, callback))
.sendToTarget();
}
@@ -566,6 +672,29 @@ public abstract class DataService extends Service {
mHandler.obtainMessage(DATA_SERVICE_REQUEST_UNREGISTER_DATA_CALL_LIST_CHANGED,
slotIndex, 0, callback).sendToTarget();
}
@Override
public void startHandover(int slotIndex, int cid, IDataServiceCallback callback) {
if (callback == null) {
loge("startHandover: callback is null");
return;
}
BeginCancelHandoverRequest req = new BeginCancelHandoverRequest(cid, callback);
mHandler.obtainMessage(DATA_SERVICE_REQUEST_START_HANDOVER,
slotIndex, 0, req)
.sendToTarget();
}
@Override
public void cancelHandover(int slotIndex, int cid, IDataServiceCallback callback) {
if (callback == null) {
loge("cancelHandover: callback is null");
return;
}
BeginCancelHandoverRequest req = new BeginCancelHandoverRequest(cid, callback);
mHandler.obtainMessage(DATA_SERVICE_REQUEST_CANCEL_HANDOVER,
slotIndex, 0, req).sendToTarget();
}
}
private void log(String s) {

View File

@@ -79,7 +79,7 @@ public class DataServiceCallback {
* @param response Setup data call response.
*/
public void onSetupDataCallComplete(@ResultCode int result,
@Nullable DataCallResponse response) {
@Nullable DataCallResponse response) {
if (mCallback != null) {
try {
if (DBG) Rlog.d(TAG, "onSetupDataCallComplete");
@@ -156,7 +156,7 @@ public class DataServiceCallback {
* set it to an empty list.
*/
public void onRequestDataCallListComplete(@ResultCode int result,
@NonNull List<DataCallResponse> dataCallList) {
@NonNull List<DataCallResponse> dataCallList) {
if (mCallback != null) {
try {
mCallback.onRequestDataCallListComplete(result, dataCallList);
@@ -186,4 +186,66 @@ public class DataServiceCallback {
Rlog.e(TAG, "onDataCallListChanged: callback is null!");
}
}
/**
* Called to indicate result for the request {@link DataService#startHandover}.
*
* @param result The result code. Must be one of the {@link ResultCode}
*/
public void onHandoverStarted(@ResultCode int result) {
if (mCallback != null) {
try {
if (DBG) Rlog.d(TAG, "onHandoverStarted");
mCallback.onHandoverStarted(result);
} catch (RemoteException e) {
Rlog.e(TAG, "Failed to onHandoverStarted on the remote");
}
} else {
Rlog.e(TAG, "onHandoverStarted: callback is null!");
}
}
/**
* Called to indicate result for the request {@link DataService#cancelHandover}.
*
* @param result The result code. Must be one of the {@link ResultCode}
*/
public void onHandoverCancelled(@ResultCode int result) {
if (mCallback != null) {
try {
if (DBG) Rlog.d(TAG, "onHandoverCancelled");
mCallback.onHandoverCancelled(result);
} catch (RemoteException e) {
Rlog.e(TAG, "Failed to onHandoverCancelled on the remote");
}
} else {
Rlog.e(TAG, "onHandoverCancelled: callback is null!");
}
}
/**
* Get the result code as a string
*
* @param resultCode The result code. Must be one of the {@link ResultCode}
* @return the string representation
*
* @hide
*/
@NonNull
public static String resultCodeToString(@DataServiceCallback.ResultCode int resultCode) {
switch(resultCode) {
case RESULT_SUCCESS:
return "RESULT_SUCCESS";
case RESULT_ERROR_UNSUPPORTED:
return "RESULT_ERROR_UNSUPPORTED";
case RESULT_ERROR_INVALID_ARG:
return "RESULT_ERROR_INVALID_ARG";
case RESULT_ERROR_BUSY:
return "RESULT_ERROR_BUSY";
case RESULT_ERROR_ILLEGAL_STATE:
return "RESULT_ERROR_ILLEGAL_STATE";
default:
return "Missing case for result code=" + resultCode;
}
}
}

View File

@@ -29,7 +29,7 @@ oneway interface IDataService
void removeDataServiceProvider(int slotId);
void setupDataCall(int slotId, int accessNetwork, in DataProfile dataProfile, boolean isRoaming,
boolean allowRoaming, int reason, in LinkProperties linkProperties,
IDataServiceCallback callback);
int pduSessionId, IDataServiceCallback callback);
void deactivateDataCall(int slotId, int cid, int reason, IDataServiceCallback callback);
void setInitialAttachApn(int slotId, in DataProfile dataProfile, boolean isRoaming,
IDataServiceCallback callback);
@@ -38,4 +38,6 @@ oneway interface IDataService
void requestDataCallList(int slotId, IDataServiceCallback callback);
void registerForDataCallListChanged(int slotId, IDataServiceCallback callback);
void unregisterForDataCallListChanged(int slotId, IDataServiceCallback callback);
void startHandover(int slotId, int cid, IDataServiceCallback callback);
void cancelHandover(int slotId, int cid, IDataServiceCallback callback);
}

View File

@@ -30,4 +30,6 @@ oneway interface IDataServiceCallback
void onSetDataProfileComplete(int result);
void onRequestDataCallListComplete(int result, in List<DataCallResponse> dataCallList);
void onDataCallListChanged(in List<DataCallResponse> dataCallList);
void onHandoverStarted(int result);
void onHandoverCancelled(int result);
}

View File

@@ -517,7 +517,7 @@ public interface RILConstants {
int RIL_REQUEST_IS_NR_DUAL_CONNECTIVITY_ENABLED = 214;
int RIL_REQUEST_ALLOCATE_PDU_SESSION_ID = 215;
int RIL_REQUEST_RELEASE_PDU_SESSION_ID = 216;
int RIL_REQUEST_BEGIN_HANDOVER = 217;
int RIL_REQUEST_START_HANDOVER = 217;
int RIL_REQUEST_CANCEL_HANDOVER = 218;
/* Responses begin */