From 7d8a77dad6c3d4be5bbe072165a224b806dd65d7 Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Fri, 23 Oct 2020 17:12:15 -0700 Subject: [PATCH] Added global retry support The retry timer suggested by the network will persist accross network requests. Also changed the retry timer to a 64-bit value to be consistent with types used in Android time APIs. Test: FrameworksTelephonytests Fix: 159672248 Change-Id: I632d4dc07fb545fa04eb3aefb0ff3270ee8f6ff8 --- api/system-current.txt | 7 ++- non-updatable-api/system-current.txt | 7 ++- .../telephony/data/DataCallResponse.java | 48 ++++++++++++++++--- 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index c932718bc55cc..5b27cf6ac3a71 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -12030,7 +12030,8 @@ package android.telephony.data { method public int getMtuV6(); method @NonNull public java.util.List getPcscfAddresses(); method public int getProtocolType(); - method public int getSuggestedRetryTime(); + method public long getRetryIntervalMillis(); + method @Deprecated public int getSuggestedRetryTime(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; field public static final int HANDOVER_FAILURE_MODE_DO_FALLBACK = 1; // 0x1 @@ -12042,6 +12043,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 RETRY_INTERVAL_UNDEFINED = -1; // 0xffffffff } public static final class DataCallResponse.Builder { @@ -12060,7 +12062,8 @@ package android.telephony.data { method @NonNull public android.telephony.data.DataCallResponse.Builder setMtuV6(int); method @NonNull public android.telephony.data.DataCallResponse.Builder setPcscfAddresses(@NonNull java.util.List); method @NonNull public android.telephony.data.DataCallResponse.Builder setProtocolType(int); - method @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int); + method @NonNull public android.telephony.data.DataCallResponse.Builder setRetryIntervalMillis(long); + method @Deprecated @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int); } public final class DataProfile implements android.os.Parcelable { diff --git a/non-updatable-api/system-current.txt b/non-updatable-api/system-current.txt index b2d13f908b615..d65bd5b6c4994 100644 --- a/non-updatable-api/system-current.txt +++ b/non-updatable-api/system-current.txt @@ -10885,7 +10885,8 @@ package android.telephony.data { method public int getMtuV6(); method @NonNull public java.util.List getPcscfAddresses(); method public int getProtocolType(); - method public int getSuggestedRetryTime(); + method public long getRetryIntervalMillis(); + method @Deprecated public int getSuggestedRetryTime(); method public void writeToParcel(android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; field public static final int HANDOVER_FAILURE_MODE_DO_FALLBACK = 1; // 0x1 @@ -10897,6 +10898,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 RETRY_INTERVAL_UNDEFINED = -1; // 0xffffffff } public static final class DataCallResponse.Builder { @@ -10915,7 +10917,8 @@ package android.telephony.data { method @NonNull public android.telephony.data.DataCallResponse.Builder setMtuV6(int); method @NonNull public android.telephony.data.DataCallResponse.Builder setPcscfAddresses(@NonNull java.util.List); method @NonNull public android.telephony.data.DataCallResponse.Builder setProtocolType(int); - method @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int); + method @NonNull public android.telephony.data.DataCallResponse.Builder setRetryIntervalMillis(long); + method @Deprecated @NonNull public android.telephony.data.DataCallResponse.Builder setSuggestedRetryTime(int); } public final class DataProfile implements android.os.Parcelable { diff --git a/telephony/java/android/telephony/data/DataCallResponse.java b/telephony/java/android/telephony/data/DataCallResponse.java index 41381c59482b0..3e2a6eec37c47 100644 --- a/telephony/java/android/telephony/data/DataCallResponse.java +++ b/telephony/java/android/telephony/data/DataCallResponse.java @@ -109,8 +109,14 @@ public final class DataCallResponse implements Parcelable { */ public static final int HANDOVER_FAILURE_MODE_NO_FALLBACK_RETRY_SETUP_NORMAL = 3; + /** + * Indicates that data retry interval is not specified. Platform can determine when to + * perform data setup appropriately. + */ + public static final int RETRY_INTERVAL_UNDEFINED = -1; + private final @DataFailureCause int mCause; - private final int mSuggestedRetryTime; + private final long mSuggestedRetryTime; private final int mId; private final @LinkStatus int mLinkStatus; private final @ProtocolType int mProtocolType; @@ -172,7 +178,7 @@ public final class DataCallResponse implements Parcelable { mHandoverFailureMode = HANDOVER_FAILURE_MODE_LEGACY; } - private DataCallResponse(@DataFailureCause int cause, int suggestedRetryTime, int id, + private DataCallResponse(@DataFailureCause int cause, long suggestedRetryTime, int id, @LinkStatus int linkStatus, @ProtocolType int protocolType, @Nullable String interfaceName, @Nullable List addresses, @Nullable List dnsAddresses, @Nullable List gatewayAddresses, @@ -202,7 +208,7 @@ public final class DataCallResponse implements Parcelable { @VisibleForTesting public DataCallResponse(Parcel source) { mCause = source.readInt(); - mSuggestedRetryTime = source.readInt(); + mSuggestedRetryTime = source.readLong(); mId = source.readInt(); mLinkStatus = source.readInt(); mProtocolType = source.readInt(); @@ -229,8 +235,22 @@ public final class DataCallResponse implements Parcelable { /** * @return The suggested data retry time in milliseconds. + * + * @deprecated Use {@link #getRetryIntervalMillis()} instead. */ - public int getSuggestedRetryTime() { return mSuggestedRetryTime; } + @Deprecated + public int getSuggestedRetryTime() { + return (int) mSuggestedRetryTime; + } + + /** + * @return The network suggested data retry interval in milliseconds. {@code Long.MAX_VALUE} + * indicates data retry should not occur. {@link #RETRY_INTERVAL_UNDEFINED} indicates network + * did not suggest any retry interval. + */ + public long getRetryIntervalMillis() { + return mSuggestedRetryTime; + } /** * @return The unique id of the data connection. @@ -382,7 +402,7 @@ public final class DataCallResponse implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mCause); - dest.writeInt(mSuggestedRetryTime); + dest.writeLong(mSuggestedRetryTime); dest.writeInt(mId); dest.writeInt(mLinkStatus); dest.writeInt(mProtocolType); @@ -446,7 +466,7 @@ public final class DataCallResponse implements Parcelable { public static final class Builder { private @DataFailureCause int mCause; - private int mSuggestedRetryTime; + private long mSuggestedRetryTime = RETRY_INTERVAL_UNDEFINED; private int mId; @@ -494,9 +514,23 @@ public final class DataCallResponse implements Parcelable { * * @param suggestedRetryTime The suggested data retry time in milliseconds. * @return The same instance of the builder. + * + * @deprecated Use {@link #setRetryIntervalMillis(long)} instead. */ + @Deprecated public @NonNull Builder setSuggestedRetryTime(int suggestedRetryTime) { - mSuggestedRetryTime = suggestedRetryTime; + mSuggestedRetryTime = (long) suggestedRetryTime; + return this; + } + + /** + * Set the network suggested data retry interval. + * + * @param retryIntervalMillis The suggested data retry interval in milliseconds. + * @return The same instance of the builder. + */ + public @NonNull Builder setRetryIntervalMillis(long retryIntervalMillis) { + mSuggestedRetryTime = retryIntervalMillis; return this; }