Merge "Expose ScanResult#untrusted as a @SystemApi." am: a93e57f1ac
am: a3943850ab
Change-Id: Id763d2f82e10dd5843258ef09d0e65824e2c2de6
This commit is contained in:
@@ -25757,9 +25757,11 @@ package android.net {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class RecommendationResult implements android.os.Parcelable {
|
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 int describeContents();
|
||||||
method public android.net.wifi.WifiConfiguration getWifiConfiguration();
|
method public android.net.wifi.WifiConfiguration getWifiConfiguration();
|
||||||
|
method public boolean hasRecommendation();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
field public static final android.os.Parcelable.Creator<android.net.RecommendationResult> CREATOR;
|
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 int level;
|
||||||
field public java.lang.CharSequence operatorFriendlyName;
|
field public java.lang.CharSequence operatorFriendlyName;
|
||||||
field public long timestamp;
|
field public long timestamp;
|
||||||
|
field public boolean untrusted;
|
||||||
field public java.lang.CharSequence venueName;
|
field public java.lang.CharSequence venueName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.net.wifi.WifiConfiguration;
|
import android.net.wifi.WifiConfiguration;
|
||||||
@@ -23,6 +24,7 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
import com.android.internal.util.Preconditions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The result of a network recommendation.
|
* The result of a network recommendation.
|
||||||
@@ -34,7 +36,32 @@ import com.android.internal.annotations.VisibleForTesting;
|
|||||||
public final class RecommendationResult implements Parcelable {
|
public final class RecommendationResult implements Parcelable {
|
||||||
private final WifiConfiguration mWifiConfiguration;
|
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;
|
mWifiConfiguration = wifiConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,13 +70,28 @@ public final class RecommendationResult implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The recommended {@link WifiConfiguration} to connect to. A {@code null} value
|
* @return {@code true} if a network recommendation exists. {@code false} indicates that
|
||||||
* indicates that no WiFi connection should be attempted at this time.
|
* no connection should be attempted at this time.
|
||||||
*/
|
*/
|
||||||
public WifiConfiguration getWifiConfiguration() {
|
public boolean hasRecommendation() {
|
||||||
|
return mWifiConfiguration != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The recommended {@link WifiConfiguration} to connect to. A {@code null} value
|
||||||
|
* is returned if {@link #hasRecommendation} returns {@code false}.
|
||||||
|
*/
|
||||||
|
@Nullable public WifiConfiguration getWifiConfiguration() {
|
||||||
return mWifiConfiguration;
|
return mWifiConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "RecommendationResult{" +
|
||||||
|
"mWifiConfiguration=" + mWifiConfiguration +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class NetworkRecommendationProviderTest extends InstrumentationTestCase {
|
|||||||
final NetworkRecommendationProvider.ResultCallback callback =
|
final NetworkRecommendationProvider.ResultCallback callback =
|
||||||
new NetworkRecommendationProvider.ResultCallback(mMockRemoteCallback, sequence);
|
new NetworkRecommendationProvider.ResultCallback(mMockRemoteCallback, sequence);
|
||||||
|
|
||||||
final RecommendationResult result = new RecommendationResult(null);
|
final RecommendationResult result = RecommendationResult.createDoNotConnectRecommendation();
|
||||||
callback.onResult(result);
|
callback.onResult(result);
|
||||||
|
|
||||||
final ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class);
|
final ArgumentCaptor<Bundle> bundleCaptor = ArgumentCaptor.forClass(Bundle.class);
|
||||||
@@ -93,7 +93,7 @@ public class NetworkRecommendationProviderTest extends InstrumentationTestCase {
|
|||||||
final NetworkRecommendationProvider.ResultCallback callback =
|
final NetworkRecommendationProvider.ResultCallback callback =
|
||||||
new NetworkRecommendationProvider.ResultCallback(mMockRemoteCallback, sequence);
|
new NetworkRecommendationProvider.ResultCallback(mMockRemoteCallback, sequence);
|
||||||
|
|
||||||
final RecommendationResult result = new RecommendationResult(null);
|
final RecommendationResult result = RecommendationResult.createDoNotConnectRecommendation();
|
||||||
callback.onResult(result);
|
callback.onResult(result);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -478,11 +478,11 @@ public class NetworkScoreService extends INetworkScoreService.Stub {
|
|||||||
Log.d(TAG, "Returning the default network recommendation.");
|
Log.d(TAG, "Returning the default network recommendation.");
|
||||||
}
|
}
|
||||||
|
|
||||||
WifiConfiguration selectedConfig = null;
|
if (request != null && request.getCurrentSelectedConfig() != null) {
|
||||||
if (request != null) {
|
return RecommendationResult.createConnectRecommendation(
|
||||||
selectedConfig = request.getCurrentSelectedConfig();
|
request.getCurrentSelectedConfig());
|
||||||
}
|
}
|
||||||
return new RecommendationResult(selectedConfig);
|
return RecommendationResult.createDoNotConnectRecommendation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -232,9 +232,10 @@ public class NetworkScoreServiceTest {
|
|||||||
injectProvider();
|
injectProvider();
|
||||||
when(mContext.getMainLooper()).thenReturn(Looper.getMainLooper());
|
when(mContext.getMainLooper()).thenReturn(Looper.getMainLooper());
|
||||||
final WifiConfiguration wifiConfiguration = new WifiConfiguration();
|
final WifiConfiguration wifiConfiguration = new WifiConfiguration();
|
||||||
wifiConfiguration.SSID = "testRequestRecommendation_resultReturned";
|
wifiConfiguration.SSID = "testRequestRecommendation_resultReturned_SSID";
|
||||||
final RecommendationResult providerResult =
|
wifiConfiguration.BSSID = "testRequestRecommendation_resultReturned_BSSID";
|
||||||
new RecommendationResult(wifiConfiguration);
|
final RecommendationResult providerResult = RecommendationResult
|
||||||
|
.createConnectRecommendation(wifiConfiguration);
|
||||||
final Bundle bundle = new Bundle();
|
final Bundle bundle = new Bundle();
|
||||||
bundle.putParcelable(EXTRA_RECOMMENDATION_RESULT, providerResult);
|
bundle.putParcelable(EXTRA_RECOMMENDATION_RESULT, providerResult);
|
||||||
doAnswer(invocation -> {
|
doAnswer(invocation -> {
|
||||||
@@ -250,6 +251,8 @@ public class NetworkScoreServiceTest {
|
|||||||
assertNotNull(result);
|
assertNotNull(result);
|
||||||
assertEquals(providerResult.getWifiConfiguration().SSID,
|
assertEquals(providerResult.getWifiConfiguration().SSID,
|
||||||
result.getWifiConfiguration().SSID);
|
result.getWifiConfiguration().SSID);
|
||||||
|
assertEquals(providerResult.getWifiConfiguration().BSSID,
|
||||||
|
result.getWifiConfiguration().BSSID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package android.net.wifi;
|
package android.net.wifi;
|
||||||
|
|
||||||
|
import android.annotation.SystemApi;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
@@ -259,10 +260,10 @@ public class ScanResult implements Parcelable {
|
|||||||
public long blackListTimestamp;
|
public long blackListTimestamp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Status: indicating the scan result is not a result
|
* Status indicating the scan result does not correspond to a user's saved configuration
|
||||||
* that is part of user's saved configurations
|
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi
|
||||||
public boolean untrusted;
|
public boolean untrusted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user