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

Commit 8301f05c authored by David Su's avatar David Su Committed by Android (Google) Code Review
Browse files

Merge changes from topics "api-review-getNetworkSelectionStatus",...

Merge changes from topics "api-review-getNetworkSelectionStatus", "api-review-networkselectiondisabled-max"

* changes:
  SettingsLib: Hide NETWORK_SELECTION_DISABLED_MAX
  Wifi: Hide NETWORK_SELECTION_DISABLED_MAX
  Migrate to getNetworkSelectionStatus()
parents 3ef03023 8257d962
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -7571,13 +7571,12 @@ package android.net.wifi {
  @Deprecated public static class WifiConfiguration.NetworkSelectionStatus {
    method @Deprecated public int getDisableReasonCounter(int);
    method @Deprecated public long getDisableTime();
    method @Deprecated public static int getMaxNetworkSelectionDisableReason();
    method @Deprecated @Nullable public static String getNetworkDisableReasonString(int);
    method @Deprecated public int getNetworkSelectionDisableReason();
    method @Deprecated public int getNetworkSelectionStatus();
    method @Deprecated @NonNull public String getNetworkStatusString();
    method @Deprecated public boolean hasEverConnected();
    method @Deprecated public boolean isNetworkEnabled();
    method @Deprecated public boolean isNetworkPermanentlyDisabled();
    field @Deprecated public static final int DISABLED_ASSOCIATION_REJECTION = 1; // 0x1
    field @Deprecated public static final int DISABLED_AUTHENTICATION_FAILURE = 2; // 0x2
    field @Deprecated public static final int DISABLED_AUTHENTICATION_NO_CREDENTIALS = 5; // 0x5
@@ -7588,7 +7587,6 @@ package android.net.wifi {
    field @Deprecated public static final int DISABLED_NONE = 0; // 0x0
    field @Deprecated public static final int DISABLED_NO_INTERNET_PERMANENT = 6; // 0x6
    field @Deprecated public static final int DISABLED_NO_INTERNET_TEMPORARY = 4; // 0x4
    field @Deprecated public static final int NETWORK_SELECTION_DISABLED_MAX = 10; // 0xa
    field @Deprecated public static final int NETWORK_SELECTION_ENABLED = 0; // 0x0
    field @Deprecated public static final int NETWORK_SELECTION_PERMANENTLY_DISABLED = 2; // 0x2
    field @Deprecated public static final int NETWORK_SELECTION_TEMPORARY_DISABLED = 1; // 0x1
+9 −2
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.settingslib.wifi;

import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_PERMANENTLY_DISABLED;

import android.annotation.IntDef;
import android.annotation.MainThread;
import android.annotation.Nullable;
@@ -1144,11 +1147,15 @@ public class AccessPoint implements Comparable<AccessPoint> {
                    mInfo != null ? mInfo.getRequestingPackageName() : null));
        } else { // not active
            if (mConfig != null && mConfig.hasNoInternetAccess()) {
                int messageID = mConfig.getNetworkSelectionStatus().isNetworkPermanentlyDisabled()
                int messageID =
                        mConfig.getNetworkSelectionStatus().getNetworkSelectionStatus()
                                == NETWORK_SELECTION_PERMANENTLY_DISABLED
                        ? R.string.wifi_no_internet_no_reconnect
                        : R.string.wifi_no_internet;
                summary.append(mContext.getString(messageID));
            } else if (mConfig != null && !mConfig.getNetworkSelectionStatus().isNetworkEnabled()) {
            } else if (mConfig != null
                    && (mConfig.getNetworkSelectionStatus().getNetworkSelectionStatus()
                            != NETWORK_SELECTION_ENABLED)) {
                WifiConfiguration.NetworkSelectionStatus networkStatus =
                        mConfig.getNetworkSelectionStatus();
                switch (networkStatus.getNetworkSelectionDisableReason()) {
+14 −10
Original line number Diff line number Diff line
@@ -16,9 +16,13 @@

package com.android.settingslib.wifi;

import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED;
import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.getMaxNetworkSelectionDisableReason;

import android.content.Context;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.NetworkSelectionStatus;
import android.net.wifi.WifiInfo;
import android.os.SystemClock;

@@ -41,7 +45,9 @@ public class WifiUtils {
            summary.append(" f=" + Integer.toString(info.getFrequency()));
        }
        summary.append(" " + getVisibilityStatus(accessPoint));
        if (config != null && !config.getNetworkSelectionStatus().isNetworkEnabled()) {
        if (config != null
                && (config.getNetworkSelectionStatus().getNetworkSelectionStatus()
                        != NETWORK_SELECTION_ENABLED)) {
            summary.append(" (" + config.getNetworkSelectionStatus().getNetworkStatusString());
            if (config.getNetworkSelectionStatus().getDisableTime() > 0) {
                long now = System.currentTimeMillis();
@@ -58,15 +64,13 @@ public class WifiUtils {
        }

        if (config != null) {
            WifiConfiguration.NetworkSelectionStatus networkStatus =
                    config.getNetworkSelectionStatus();
            for (int index = WifiConfiguration.NetworkSelectionStatus.DISABLED_NONE;
                    index < WifiConfiguration.NetworkSelectionStatus
                            .NETWORK_SELECTION_DISABLED_MAX; index++) {
                if (networkStatus.getDisableReasonCounter(index) != 0) {
                    summary.append(" " + WifiConfiguration.NetworkSelectionStatus
                            .getNetworkDisableReasonString(index) + "="
                            + networkStatus.getDisableReasonCounter(index));
            NetworkSelectionStatus networkStatus = config.getNetworkSelectionStatus();
            for (int reason = 0; reason <= getMaxNetworkSelectionDisableReason(); reason++) {
                if (networkStatus.getDisableReasonCounter(reason) != 0) {
                    summary.append(" ")
                            .append(NetworkSelectionStatus.getNetworkDisableReasonString(reason))
                            .append("=")
                            .append(networkStatus.getDisableReasonCounter(reason));
                }
            }
        }
+5 −3
Original line number Diff line number Diff line
@@ -465,6 +465,8 @@ public class AccessPointTest {
        WifiConfiguration.NetworkSelectionStatus status =
                mock(WifiConfiguration.NetworkSelectionStatus.class);
        when(configuration.getNetworkSelectionStatus()).thenReturn(status);
        when(status.getNetworkSelectionStatus()).thenReturn(
                WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_TEMPORARY_DISABLED);
        when(status.getNetworkSelectionDisableReason()).thenReturn(
                WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD);
        AccessPoint ap = new AccessPoint(mContext, configuration);
@@ -1370,13 +1372,13 @@ public class AccessPointTest {
    public void testOsuAccessPointSummary_showsProvisioningUpdates() {
        OsuProvider provider = createOsuProvider();
        Context spyContext = spy(new ContextWrapper(mContext));
        AccessPoint osuAccessPoint = new AccessPoint(spyContext, provider,
                mScanResults);
        when(spyContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mMockWifiManager);
        Map<OsuProvider, PasspointConfiguration> osuProviderConfigMap = new HashMap<>();
        osuProviderConfigMap.put(provider, null);
        when(spyContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mMockWifiManager);
        when(mMockWifiManager.getMatchingPasspointConfigsForOsuProviders(
                Collections.singleton(provider))).thenReturn(osuProviderConfigMap);
        AccessPoint osuAccessPoint = new AccessPoint(spyContext, provider,
                mScanResults);

        osuAccessPoint.setListener(mMockAccessPointListener);

+33 −3
Original line number Diff line number Diff line
@@ -1301,9 +1301,33 @@ public class WifiConfiguration implements Parcelable {
        public static final int DISABLED_BY_WRONG_PASSWORD = 8;
        /** This network is disabled because service is not subscribed. */
        public static final int DISABLED_AUTHENTICATION_NO_SUBSCRIPTION = 9;
        /** All other disable reasons should be strictly less than this value. */
        /**
         * All other disable reasons should be strictly less than this value.
         * @hide
         */
        public static final int NETWORK_SELECTION_DISABLED_MAX = 10;

        /**
         * Get an integer that is equal to the maximum integer value of all the
         * DISABLED_* reasons
         * e.g. {@link #DISABLED_NONE}, {@link #DISABLED_ASSOCIATION_REJECTION}, etc.
         *
         * All DISABLED_* constants will be contiguous in the range
         * 0, 1, 2, 3, ..., getMaxNetworkSelectionDisableReasons()
         *
         * <br />
         * For example, this can be used to iterate through all the network selection
         * disable reasons like so:
         * <pre>{@code
         * for (int reason = 0; reason <= getMaxNetworkSelectionDisableReasons(); reason++) {
         *     ...
         * }
         * }</pre>
         */
        public static int getMaxNetworkSelectionDisableReason() {
            return NETWORK_SELECTION_DISABLED_MAX - 1;
        }

        /**
         * Contains info about disable reasons.
         * @hide
@@ -1706,7 +1730,10 @@ public class WifiConfiguration implements Parcelable {
            return mStatus;
        }

        /** True if the current network is enabled to join network selection, false otherwise. */
        /**
         * True if the current network is enabled to join network selection, false otherwise.
         * @hide
         */
        public boolean isNetworkEnabled() {
            return mStatus == NETWORK_SELECTION_ENABLED;
        }
@@ -1719,7 +1746,10 @@ public class WifiConfiguration implements Parcelable {
            return mStatus == NETWORK_SELECTION_TEMPORARY_DISABLED;
        }

        /** True if the current network is permanently disabled, false otherwise. */
        /**
         * True if the current network is permanently disabled, false otherwise.
         * @hide
         */
        public boolean isNetworkPermanentlyDisabled() {
            return mStatus == NETWORK_SELECTION_PERMANENTLY_DISABLED;
        }
Loading