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

Commit 9926363b authored by Amin Shaikh's avatar Amin Shaikh Committed by android-build-merger
Browse files

Merge "Expose ScanResult#untrusted as a @SystemApi." am: a93e57f1 am: a3943850

am: 471093b5

Change-Id: I129d3abd329d9e00de1177ca39cf3ce0ff06946b
parents cca4e6d0 471093b5
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -25757,9 +25757,11 @@ package android.net {
  }
  public final class RecommendationResult implements android.os.Parcelable {
    ctor public RecommendationResult(android.net.wifi.WifiConfiguration);
    method public static android.net.RecommendationResult createDoNotConnectRecommendation();
    method public static android.net.RecommendationResult createConnectRecommendation(android.net.wifi.WifiConfiguration);
    method public int describeContents();
    method public android.net.wifi.WifiConfiguration getWifiConfiguration();
    method public boolean hasRecommendation();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.net.RecommendationResult> CREATOR;
  }
@@ -26808,6 +26810,7 @@ package android.net.wifi {
    field public int level;
    field public java.lang.CharSequence operatorFriendlyName;
    field public long timestamp;
    field public boolean untrusted;
    field public java.lang.CharSequence venueName;
  }
+45 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.net;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.net.wifi.WifiConfiguration;
@@ -23,6 +24,7 @@ import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;

/**
 * The result of a network recommendation.
@@ -34,7 +36,32 @@ import com.android.internal.annotations.VisibleForTesting;
public final class RecommendationResult implements Parcelable {
    private final WifiConfiguration mWifiConfiguration;

    public RecommendationResult(@Nullable WifiConfiguration wifiConfiguration) {
    /**
     * Create a {@link RecommendationResult} that indicates that no network connection should be
     * attempted at this time.
     *
     * @return a {@link RecommendationResult}
     */
    public static RecommendationResult createDoNotConnectRecommendation() {
        return new RecommendationResult((WifiConfiguration) null);
    }

    /**
     * Create a {@link RecommendationResult} that indicates that a connection attempt should be
     * made for the given Wi-Fi network.
     *
     * @param wifiConfiguration {@link WifiConfiguration} with at least SSID and BSSID set.
     * @return a {@link RecommendationResult}
     */
    public static RecommendationResult createConnectRecommendation(
            @NonNull WifiConfiguration wifiConfiguration) {
        Preconditions.checkNotNull(wifiConfiguration, "wifiConfiguration must not be null");
        Preconditions.checkNotNull(wifiConfiguration.SSID, "SSID must not be null");
        Preconditions.checkNotNull(wifiConfiguration.BSSID, "BSSID must not be null");
        return new RecommendationResult(wifiConfiguration);
    }

    private RecommendationResult(@Nullable WifiConfiguration wifiConfiguration) {
        mWifiConfiguration = wifiConfiguration;
    }

@@ -42,14 +69,29 @@ public final class RecommendationResult implements Parcelable {
        mWifiConfiguration = in.readParcelable(WifiConfiguration.class.getClassLoader());
    }

    /**
     * @return {@code true} if a network recommendation exists. {@code false} indicates that
     *         no connection should be attempted at this time.
     */
    public boolean hasRecommendation() {
        return mWifiConfiguration != null;
    }

    /**
     * @return The recommended {@link WifiConfiguration} to connect to. A {@code null} value
     *         indicates that no WiFi connection should be attempted at this time.
     *         is returned if {@link #hasRecommendation} returns {@code false}.
     */
    public WifiConfiguration getWifiConfiguration() {
    @Nullable public WifiConfiguration getWifiConfiguration() {
        return mWifiConfiguration;
    }

    @Override
    public String toString() {
      return "RecommendationResult{" +
          "mWifiConfiguration=" + mWifiConfiguration +
          "}";
    }

    @Override
    public int describeContents() {
        return 0;
+2 −2
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class NetworkRecommendationProviderTest extends InstrumentationTestCase {
        final NetworkRecommendationProvider.ResultCallback callback =
                new NetworkRecommendationProvider.ResultCallback(mMockRemoteCallback, sequence);

        final RecommendationResult result = new RecommendationResult(null);
        final RecommendationResult result = RecommendationResult.createDoNotConnectRecommendation();
        callback.onResult(result);

        final ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class);
@@ -93,7 +93,7 @@ public class NetworkRecommendationProviderTest extends InstrumentationTestCase {
        final NetworkRecommendationProvider.ResultCallback callback =
                new NetworkRecommendationProvider.ResultCallback(mMockRemoteCallback, sequence);

        final RecommendationResult result = new RecommendationResult(null);
        final RecommendationResult result = RecommendationResult.createDoNotConnectRecommendation();
        callback.onResult(result);

        try {
+4 −4
Original line number Diff line number Diff line
@@ -478,11 +478,11 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
            Log.d(TAG, "Returning the default network recommendation.");
        }

        WifiConfiguration selectedConfig = null;
        if (request != null) {
            selectedConfig = request.getCurrentSelectedConfig();
        if (request != null && request.getCurrentSelectedConfig() != null) {
            return RecommendationResult.createConnectRecommendation(
                request.getCurrentSelectedConfig());
        }
        return new RecommendationResult(selectedConfig);
        return RecommendationResult.createDoNotConnectRecommendation();
    }

    @Override
+6 −3
Original line number Diff line number Diff line
@@ -232,9 +232,10 @@ public class NetworkScoreServiceTest {
        injectProvider();
        when(mContext.getMainLooper()).thenReturn(Looper.getMainLooper());
        final WifiConfiguration wifiConfiguration = new WifiConfiguration();
        wifiConfiguration.SSID = "testRequestRecommendation_resultReturned";
        final RecommendationResult providerResult =
                new RecommendationResult(wifiConfiguration);
        wifiConfiguration.SSID = "testRequestRecommendation_resultReturned_SSID";
        wifiConfiguration.BSSID = "testRequestRecommendation_resultReturned_BSSID";
        final RecommendationResult providerResult = RecommendationResult
                .createConnectRecommendation(wifiConfiguration);
        final Bundle bundle = new Bundle();
        bundle.putParcelable(EXTRA_RECOMMENDATION_RESULT, providerResult);
        doAnswer(invocation -> {
@@ -250,6 +251,8 @@ public class NetworkScoreServiceTest {
        assertNotNull(result);
        assertEquals(providerResult.getWifiConfiguration().SSID,
                result.getWifiConfiguration().SSID);
        assertEquals(providerResult.getWifiConfiguration().BSSID,
                result.getWifiConfiguration().BSSID);
    }

    @Test
Loading