From e5e923aaa3040bb0de9e7a9e6843bddf851ebf1a Mon Sep 17 00:00:00 2001 From: xshu Date: Tue, 20 Oct 2020 20:25:58 -0700 Subject: [PATCH] API support for more recent failure statuses Added new failure statuses and the ability to last update timestamp. Bug: 155697192 Test: atest android.net.wifi Change-Id: I46d20f2804601eb7efd3712928fd5c4727b17fb4 --- api/system-current.txt | 3 + wifi/api/system-current.txt | 3 + .../android/net/wifi/WifiConfiguration.java | 65 ++++++++++++++++--- 3 files changed, 63 insertions(+), 8 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 1404f7e1c554b..b3221760cbb86 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -7361,8 +7361,11 @@ package android.net.wifi { field @Deprecated public static final int RANDOMIZATION_NONE = 0; // 0x0 field @Deprecated public static final int RANDOMIZATION_PERSISTENT = 1; // 0x1 field @Deprecated public static final int RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA = 17; // 0x11 + field @Deprecated public static final int RECENT_FAILURE_DISCONNECTION_AP_BUSY = 1004; // 0x3ec field @Deprecated public static final int RECENT_FAILURE_MBO_OCE_DISCONNECT = 1001; // 0x3e9 field @Deprecated public static final int RECENT_FAILURE_NONE = 0; // 0x0 + field @Deprecated public static final int RECENT_FAILURE_POOR_CHANNEL_CONDITIONS = 1003; // 0x3eb + field @Deprecated public static final int RECENT_FAILURE_REFUSED_TEMPORARILY = 1002; // 0x3ea field @Deprecated public boolean allowAutojoin; field @Deprecated public int carrierId; field @Deprecated public String creatorName; diff --git a/wifi/api/system-current.txt b/wifi/api/system-current.txt index 98cb849084d42..84215a6d5e67c 100644 --- a/wifi/api/system-current.txt +++ b/wifi/api/system-current.txt @@ -332,8 +332,11 @@ package android.net.wifi { field @Deprecated public static final int RANDOMIZATION_NONE = 0; // 0x0 field @Deprecated public static final int RANDOMIZATION_PERSISTENT = 1; // 0x1 field @Deprecated public static final int RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA = 17; // 0x11 + field @Deprecated public static final int RECENT_FAILURE_DISCONNECTION_AP_BUSY = 1004; // 0x3ec field @Deprecated public static final int RECENT_FAILURE_MBO_OCE_DISCONNECT = 1001; // 0x3e9 field @Deprecated public static final int RECENT_FAILURE_NONE = 0; // 0x0 + field @Deprecated public static final int RECENT_FAILURE_POOR_CHANNEL_CONDITIONS = 1003; // 0x3eb + field @Deprecated public static final int RECENT_FAILURE_REFUSED_TEMPORARILY = 1002; // 0x3ea field @Deprecated public boolean allowAutojoin; field @Deprecated public int carrierId; field @Deprecated public String creatorName; diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 7c2556d8cffd4..21c6c1bc70f56 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -2050,27 +2050,42 @@ public class WifiConfiguration implements Parcelable { */ @RecentFailureReason private int mAssociationStatus = RECENT_FAILURE_NONE; + private long mLastUpdateTimeSinceBootMillis; /** * @param status the association status code for the recent failure */ - public void setAssociationStatus(@RecentFailureReason int status) { + public void setAssociationStatus(@RecentFailureReason int status, + long updateTimeSinceBootMs) { mAssociationStatus = status; + mLastUpdateTimeSinceBootMillis = updateTimeSinceBootMs; } /** * Sets the RecentFailure to NONE */ public void clear() { mAssociationStatus = RECENT_FAILURE_NONE; + mLastUpdateTimeSinceBootMillis = 0; } /** - * Get the recent failure code. One of {@link #RECENT_FAILURE_NONE} or - * {@link #RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA}. + * Get the recent failure code. One of {@link #RECENT_FAILURE_NONE}, + * {@link #RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA}, + * {@link #RECENT_FAILURE_MBO_OCE_DISCONNECT}, + * {@link #RECENT_FAILURE_REFUSED_TEMPORARILY}, + * {@link #RECENT_FAILURE_POOR_CHANNEL_CONDITIONS}. + * {@link #RECENT_FAILURE_DISCONNECTION_AP_BUSY} */ @RecentFailureReason public int getAssociationStatus() { return mAssociationStatus; } + + /** + * Get the timestamp the failure status is last updated, in milliseconds since boot. + */ + public long getLastUpdateTimeSinceBootMillis() { + return mLastUpdateTimeSinceBootMillis; + } } /** @@ -2087,7 +2102,11 @@ public class WifiConfiguration implements Parcelable { @IntDef(prefix = "RECENT_FAILURE_", value = { RECENT_FAILURE_NONE, RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA, - RECENT_FAILURE_MBO_OCE_DISCONNECT}) + RECENT_FAILURE_MBO_OCE_DISCONNECT, + RECENT_FAILURE_REFUSED_TEMPORARILY, + RECENT_FAILURE_POOR_CHANNEL_CONDITIONS, + RECENT_FAILURE_DISCONNECTION_AP_BUSY + }) public @interface RecentFailureReason {} /** @@ -2111,13 +2130,40 @@ public class WifiConfiguration implements Parcelable { @SystemApi public static final int RECENT_FAILURE_MBO_OCE_DISCONNECT = 1001; + /** + * Failed to connect because the association is rejected by the AP. + * IEEE 802.11 association status code 30. + * @hide + */ + @SystemApi + public static final int RECENT_FAILURE_REFUSED_TEMPORARILY = 1002; + + /** + * Failed to connect because of excess frame loss and/or poor channel conditions. + * IEEE 802.11 association status code 34. + * @hide + */ + @SystemApi + public static final int RECENT_FAILURE_POOR_CHANNEL_CONDITIONS = 1003; + + /** + * Disconnected by the AP because the AP can't handle all the associated stations. + * IEEE 802.11 disconnection reason code 5. + * @hide + */ + @SystemApi + public static final int RECENT_FAILURE_DISCONNECTION_AP_BUSY = 1004; + /** * Get the failure reason for the most recent connection attempt, or * {@link #RECENT_FAILURE_NONE} if there was no failure. * * Failure reasons include: * {@link #RECENT_FAILURE_AP_UNABLE_TO_HANDLE_NEW_STA} - * + * {@link #RECENT_FAILURE_MBO_OCE_DISCONNECT} + * {@link #RECENT_FAILURE_REFUSED_TEMPORARILY} + * {@link #RECENT_FAILURE_POOR_CHANNEL_CONDITIONS} + * {@link #RECENT_FAILURE_DISCONNECTION_AP_BUSY} * @hide */ @RecentFailureReason @@ -2453,7 +2499,8 @@ public class WifiConfiguration implements Parcelable { } } sbuf.append("recentFailure: ").append("Association Rejection code: ") - .append(recentFailure.getAssociationStatus()).append("\n"); + .append(recentFailure.getAssociationStatus()).append(", last update time: ") + .append(recentFailure.getLastUpdateTimeSinceBootMillis()).append("\n"); return sbuf.toString(); } @@ -2892,7 +2939,8 @@ public class WifiConfiguration implements Parcelable { numNoInternetAccessReports = source.numNoInternetAccessReports; noInternetAccessExpected = source.noInternetAccessExpected; shared = source.shared; - recentFailure.setAssociationStatus(source.recentFailure.getAssociationStatus()); + recentFailure.setAssociationStatus(source.recentFailure.getAssociationStatus(), + source.recentFailure.getLastUpdateTimeSinceBootMillis()); mRandomizedMacAddress = source.mRandomizedMacAddress; macRandomizationSetting = source.macRandomizationSetting; randomizedMacExpirationTimeMs = source.randomizedMacExpirationTimeMs; @@ -2969,6 +3017,7 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(shared ? 1 : 0); dest.writeString(mPasspointManagementObjectTree); dest.writeInt(recentFailure.getAssociationStatus()); + dest.writeLong(recentFailure.getLastUpdateTimeSinceBootMillis()); dest.writeParcelable(mRandomizedMacAddress, flags); dest.writeInt(macRandomizationSetting); dest.writeInt(osu ? 1 : 0); @@ -3045,7 +3094,7 @@ public class WifiConfiguration implements Parcelable { config.noInternetAccessExpected = in.readInt() != 0; config.shared = in.readInt() != 0; config.mPasspointManagementObjectTree = in.readString(); - config.recentFailure.setAssociationStatus(in.readInt()); + config.recentFailure.setAssociationStatus(in.readInt(), in.readLong()); config.mRandomizedMacAddress = in.readParcelable(null); config.macRandomizationSetting = in.readInt(); config.osu = in.readInt() != 0;