Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 446afac1 authored by Glen Kuhne's avatar Glen Kuhne
Browse files

Add FailureReason to WifiConfiguration

Added a new field that caches extra details about connection failures so
that they may be surfaced in the UI.

Bug: 62915994
Test: Manual...
Change-Id: I6e7860df4ea755e72fbdd4b6bf514338f2f1de80
parent 3698fc8e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@
    <!-- Summary for Connected wifi network without internet -->
    <string name="wifi_connected_no_internet">Connected, no Internet</string>

    <!-- Summary for networks failing to connect due to association rejection status 17, AP full -->
    <string name="wifi_ap_unable_to_handle_new_sta">Access point temporarily full</string>

    <!-- Speed label for very slow network speed -->
    <string name="speed_label_very_slow">Very Slow</string>
    <!-- Speed label for slow network speed -->
+11 −1
Original line number Diff line number Diff line
@@ -721,7 +721,17 @@ public class AccessPoint implements Comparable<AccessPoint> {
            summary.append(mContext.getString(R.string.wifi_not_in_range));
        } else { // In range, not disabled.
            if (config != null) { // Is saved network
                // Last attempt to connect to this failed. Show reason why
                switch (config.recentFailure.getAssociationStatus()) {
                    case WifiConfiguration.RecentFailure.STATUS_AP_UNABLE_TO_HANDLE_NEW_STA:
                        summary.append(mContext.getString(
                                R.string.wifi_ap_unable_to_handle_new_sta));
                        break;
                    default:
                        // "Saved"
                        summary.append(mContext.getString(R.string.wifi_remembered));
                        break;
                }
            }
        }

+52 −8
Original line number Diff line number Diff line
@@ -418,12 +418,6 @@ public class WifiConfiguration implements Parcelable {
     */
    public String defaultGwMacAddress;

    /**
     * @hide
     * last failure
     */
    public String lastFailure;

    /**
     * @hide
     * last time we connected, this configuration had validated internet access
@@ -1415,6 +1409,53 @@ public class WifiConfiguration implements Parcelable {
     */
    private NetworkSelectionStatus mNetworkSelectionStatus = new NetworkSelectionStatus();

    /**
     * @hide
     * This class is intended to store extra failure reason information for the most recent
     * connection attempt, so that it may be surfaced to the settings UI
     */
    public static class RecentFailure {

        /**
         * No recent failure, or no specific reason given for the recent connection failure
         */
        public static final int NONE = 0;
        /**
         * Connection to this network recently failed due to Association Rejection Status 17
         * (AP is full)
         */
        public static final int STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17;
        /**
         * Association Rejection Status code (NONE for success/non-association-rejection-fail)
         */
        private int mAssociationStatus = NONE;

        /**
         * @param status the association status code for the recent failure
         */
        public void setAssociationStatus(int status) {
            mAssociationStatus = status;
        }
        /**
         * Sets the RecentFailure to NONE
         */
        public void clear() {
            mAssociationStatus = NONE;
        }
        /**
         * Get the recent failure code
         */
        public int getAssociationStatus() {
            return mAssociationStatus;
        }
    }

    /**
     * @hide
     * RecentFailure member
     */
    final public RecentFailure recentFailure = new RecentFailure();

    /**
     * @hide
     * @return network selection status
@@ -1705,7 +1746,8 @@ public class WifiConfiguration implements Parcelable {
                sbuf.append('\n');
            }
        }

        sbuf.append("recentFailure: ").append("Association Rejection code: ")
                .append(recentFailure.getAssociationStatus()).append("\n");
        return sbuf.toString();
    }

@@ -2029,7 +2071,6 @@ public class WifiConfiguration implements Parcelable {
                visibility = new Visibility(source.visibility);
            }

            lastFailure = source.lastFailure;
            didSelfAdd = source.didSelfAdd;
            lastConnectUid = source.lastConnectUid;
            lastUpdateUid = source.lastUpdateUid;
@@ -2053,6 +2094,7 @@ public class WifiConfiguration implements Parcelable {
            creationTime = source.creationTime;
            updateTime = source.updateTime;
            shared = source.shared;
            recentFailure.setAssociationStatus(source.recentFailure.getAssociationStatus());
        }
    }

@@ -2119,6 +2161,7 @@ public class WifiConfiguration implements Parcelable {
        dest.writeInt(noInternetAccessExpected ? 1 : 0);
        dest.writeInt(shared ? 1 : 0);
        dest.writeString(mPasspointManagementObjectTree);
        dest.writeInt(recentFailure.getAssociationStatus());
    }

    /** Implement the Parcelable interface {@hide} */
@@ -2186,6 +2229,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());
                return config;
            }