Loading api/system-current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -25762,6 +25762,8 @@ package android.net { method public android.net.wifi.WifiConfiguration[] getConnectableConfigs(); method public android.net.wifi.WifiConfiguration getConnectedConfig(); method public android.net.wifi.WifiConfiguration getDefaultWifiConfig(); method public int getLastSelectedNetworkId(); method public long getLastSelectedNetworkTimestamp(); method public android.net.wifi.ScanResult[] getScanResults(); method public void setConnectableConfigs(android.net.wifi.WifiConfiguration[]); method public void setConnectedConfig(android.net.wifi.WifiConfiguration); Loading @@ -25775,6 +25777,7 @@ package android.net { method public android.net.RecommendationRequest.Builder setConnectableConfigs(android.net.wifi.WifiConfiguration[]); method public android.net.RecommendationRequest.Builder setConnectedWifiConfig(android.net.wifi.WifiConfiguration); method public android.net.RecommendationRequest.Builder setDefaultWifiConfig(android.net.wifi.WifiConfiguration); method public android.net.RecommendationRequest.Builder setLastSelectedNetwork(int, long); method public android.net.RecommendationRequest.Builder setScanResults(android.net.wifi.ScanResult[]); } core/java/android/net/RecommendationRequest.java +46 −17 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ public final class RecommendationRequest implements Parcelable { private final WifiConfiguration mDefaultConfig; private WifiConfiguration mConnectedConfig; private WifiConfiguration[] mConnectableConfigs; private final int mLastSelectedNetworkId; private final long mLastSelectedNetworkTimestamp; /** * Builder class for constructing {@link RecommendationRequest} instances. Loading @@ -48,17 +50,9 @@ public final class RecommendationRequest implements Parcelable { private WifiConfiguration mDefaultConfig; private WifiConfiguration mConnectedConfig; private WifiConfiguration[] mConnectableConfigs; private int mLastSelectedNetworkId; private long mLastSelectedTimestamp; /** * @param scanResults the array of {@link ScanResult}s the recommendation must be * constrained to i.e. if a non-null wifi config recommendation is * returned then it must be able to connect to one of the networks in * the results list. * * If the array is {@code null} or empty then there is no constraint. * * @return this */ public Builder setScanResults(ScanResult[] scanResults) { mScanResults = scanResults; return this; Loading Loading @@ -89,7 +83,20 @@ public final class RecommendationRequest implements Parcelable { * @return this */ public Builder setConnectableConfigs(WifiConfiguration[] connectableConfigs) { mConnectableConfigs = connectableConfigs; this.mConnectableConfigs = connectableConfigs; return this; } /** * @param networkId The {@link WifiConfiguration#networkId} of the last user selected * network. * @param timestamp The {@link android.os.SystemClock#elapsedRealtime()} when the user * selected {@code networkId}. * @return this */ public Builder setLastSelectedNetwork(int networkId, long timestamp) { this.mLastSelectedNetworkId = networkId; this.mLastSelectedTimestamp = timestamp; return this; } Loading @@ -97,10 +104,8 @@ public final class RecommendationRequest implements Parcelable { * @return a new {@link RecommendationRequest} instance */ public RecommendationRequest build() { return new RecommendationRequest(mScanResults, mDefaultConfig, mConnectedConfig, mConnectableConfigs); return new RecommendationRequest(mScanResults, mDefaultConfig, mConnectedConfig, mConnectableConfigs, mLastSelectedNetworkId, mLastSelectedTimestamp); } } Loading Loading @@ -154,15 +159,35 @@ public final class RecommendationRequest implements Parcelable { mConnectableConfigs = connectableConfigs; } /** * @return The {@link WifiConfiguration#networkId} of the last user selected network. * {@code 0} if not set. */ public int getLastSelectedNetworkId() { return mLastSelectedNetworkId; } /** * @return The {@link android.os.SystemClock#elapsedRealtime()} when the user selected * {@link #getLastSelectedNetworkId()}. {@code 0} if not set. */ public long getLastSelectedNetworkTimestamp() { return mLastSelectedNetworkTimestamp; } @VisibleForTesting RecommendationRequest(ScanResult[] scanResults, WifiConfiguration defaultWifiConfig, WifiConfiguration connectedWifiConfig, WifiConfiguration[] connectableConfigs) { WifiConfiguration[] connectableConfigs, int lastSelectedNetworkId, long lastSelectedNetworkTimestamp) { mScanResults = scanResults; mDefaultConfig = defaultWifiConfig; mConnectedConfig = connectedWifiConfig; mConnectableConfigs = connectableConfigs; mLastSelectedNetworkId = lastSelectedNetworkId; mLastSelectedNetworkTimestamp = lastSelectedNetworkTimestamp; } protected RecommendationRequest(Parcel in) { Loading Loading @@ -190,6 +215,9 @@ public final class RecommendationRequest implements Parcelable { } else { mConnectableConfigs = null; } mLastSelectedNetworkId = in.readInt(); mLastSelectedNetworkTimestamp = in.readLong(); } @Override Loading Loading @@ -220,7 +248,8 @@ public final class RecommendationRequest implements Parcelable { dest.writeInt(0); } dest.writeInt(mLastSelectedNetworkId); dest.writeLong(mLastSelectedNetworkTimestamp); } public static final Creator<RecommendationRequest> CREATOR = Loading core/tests/coretests/src/android/net/RecommendationRequestTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package android.net; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.os.Parcel; import android.os.SystemClock; import android.test.AndroidTestCase; public class RecommendationRequestTest extends AndroidTestCase { Loading @@ -10,6 +11,8 @@ public class RecommendationRequestTest extends AndroidTestCase { private WifiConfiguration mDefaultConfig; private WifiConfiguration mConnectedConfig; private WifiConfiguration[] mConnectableConfigs; private int mLastSelectedNetworkId; private long mLastSelectedNetworkTimestamp; @Override public void setUp() throws Exception { Loading @@ -35,6 +38,8 @@ public class RecommendationRequestTest extends AndroidTestCase { mConnectedConfig = new WifiConfiguration(); mConnectedConfig.SSID = "connected_config"; mConnectableConfigs = new WifiConfiguration[] {mDefaultConfig, mConnectedConfig}; mLastSelectedNetworkId = 5; mLastSelectedNetworkTimestamp = SystemClock.elapsedRealtime(); } public void testParceling() throws Exception { Loading @@ -43,6 +48,7 @@ public class RecommendationRequestTest extends AndroidTestCase { .setScanResults(mScanResults) .setConnectedWifiConfig(mConnectedConfig) .setConnectableConfigs(mConnectableConfigs) .setLastSelectedNetwork(mLastSelectedNetworkId, mLastSelectedNetworkTimestamp) .build(); RecommendationRequest parceled = passThroughParcel(request); Loading @@ -60,6 +66,8 @@ public class RecommendationRequestTest extends AndroidTestCase { for (int i = 0; i < parceledConfigs.length; i++) { assertEquals(mConnectableConfigs[i].SSID, parceledConfigs[i].SSID); } assertEquals(mLastSelectedNetworkId, parceled.getLastSelectedNetworkId()); assertEquals(mLastSelectedNetworkTimestamp, parceled.getLastSelectedNetworkTimestamp()); } public void testParceling_nullScanResults() throws Exception { Loading @@ -82,6 +90,16 @@ public class RecommendationRequestTest extends AndroidTestCase { assertNull(parceledConfigs); } public void testParceling_unsetLastSelectedNetwork() throws Exception { RecommendationRequest request = new RecommendationRequest.Builder() .build(); RecommendationRequest parceled = passThroughParcel(request); assertEquals(0, parceled.getLastSelectedNetworkId()); assertEquals(0, parceled.getLastSelectedNetworkTimestamp()); } private RecommendationRequest passThroughParcel(RecommendationRequest request) { Parcel p = Parcel.obtain(); RecommendationRequest output = null; Loading Loading
api/system-current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -25762,6 +25762,8 @@ package android.net { method public android.net.wifi.WifiConfiguration[] getConnectableConfigs(); method public android.net.wifi.WifiConfiguration getConnectedConfig(); method public android.net.wifi.WifiConfiguration getDefaultWifiConfig(); method public int getLastSelectedNetworkId(); method public long getLastSelectedNetworkTimestamp(); method public android.net.wifi.ScanResult[] getScanResults(); method public void setConnectableConfigs(android.net.wifi.WifiConfiguration[]); method public void setConnectedConfig(android.net.wifi.WifiConfiguration); Loading @@ -25775,6 +25777,7 @@ package android.net { method public android.net.RecommendationRequest.Builder setConnectableConfigs(android.net.wifi.WifiConfiguration[]); method public android.net.RecommendationRequest.Builder setConnectedWifiConfig(android.net.wifi.WifiConfiguration); method public android.net.RecommendationRequest.Builder setDefaultWifiConfig(android.net.wifi.WifiConfiguration); method public android.net.RecommendationRequest.Builder setLastSelectedNetwork(int, long); method public android.net.RecommendationRequest.Builder setScanResults(android.net.wifi.ScanResult[]); }
core/java/android/net/RecommendationRequest.java +46 −17 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ public final class RecommendationRequest implements Parcelable { private final WifiConfiguration mDefaultConfig; private WifiConfiguration mConnectedConfig; private WifiConfiguration[] mConnectableConfigs; private final int mLastSelectedNetworkId; private final long mLastSelectedNetworkTimestamp; /** * Builder class for constructing {@link RecommendationRequest} instances. Loading @@ -48,17 +50,9 @@ public final class RecommendationRequest implements Parcelable { private WifiConfiguration mDefaultConfig; private WifiConfiguration mConnectedConfig; private WifiConfiguration[] mConnectableConfigs; private int mLastSelectedNetworkId; private long mLastSelectedTimestamp; /** * @param scanResults the array of {@link ScanResult}s the recommendation must be * constrained to i.e. if a non-null wifi config recommendation is * returned then it must be able to connect to one of the networks in * the results list. * * If the array is {@code null} or empty then there is no constraint. * * @return this */ public Builder setScanResults(ScanResult[] scanResults) { mScanResults = scanResults; return this; Loading Loading @@ -89,7 +83,20 @@ public final class RecommendationRequest implements Parcelable { * @return this */ public Builder setConnectableConfigs(WifiConfiguration[] connectableConfigs) { mConnectableConfigs = connectableConfigs; this.mConnectableConfigs = connectableConfigs; return this; } /** * @param networkId The {@link WifiConfiguration#networkId} of the last user selected * network. * @param timestamp The {@link android.os.SystemClock#elapsedRealtime()} when the user * selected {@code networkId}. * @return this */ public Builder setLastSelectedNetwork(int networkId, long timestamp) { this.mLastSelectedNetworkId = networkId; this.mLastSelectedTimestamp = timestamp; return this; } Loading @@ -97,10 +104,8 @@ public final class RecommendationRequest implements Parcelable { * @return a new {@link RecommendationRequest} instance */ public RecommendationRequest build() { return new RecommendationRequest(mScanResults, mDefaultConfig, mConnectedConfig, mConnectableConfigs); return new RecommendationRequest(mScanResults, mDefaultConfig, mConnectedConfig, mConnectableConfigs, mLastSelectedNetworkId, mLastSelectedTimestamp); } } Loading Loading @@ -154,15 +159,35 @@ public final class RecommendationRequest implements Parcelable { mConnectableConfigs = connectableConfigs; } /** * @return The {@link WifiConfiguration#networkId} of the last user selected network. * {@code 0} if not set. */ public int getLastSelectedNetworkId() { return mLastSelectedNetworkId; } /** * @return The {@link android.os.SystemClock#elapsedRealtime()} when the user selected * {@link #getLastSelectedNetworkId()}. {@code 0} if not set. */ public long getLastSelectedNetworkTimestamp() { return mLastSelectedNetworkTimestamp; } @VisibleForTesting RecommendationRequest(ScanResult[] scanResults, WifiConfiguration defaultWifiConfig, WifiConfiguration connectedWifiConfig, WifiConfiguration[] connectableConfigs) { WifiConfiguration[] connectableConfigs, int lastSelectedNetworkId, long lastSelectedNetworkTimestamp) { mScanResults = scanResults; mDefaultConfig = defaultWifiConfig; mConnectedConfig = connectedWifiConfig; mConnectableConfigs = connectableConfigs; mLastSelectedNetworkId = lastSelectedNetworkId; mLastSelectedNetworkTimestamp = lastSelectedNetworkTimestamp; } protected RecommendationRequest(Parcel in) { Loading Loading @@ -190,6 +215,9 @@ public final class RecommendationRequest implements Parcelable { } else { mConnectableConfigs = null; } mLastSelectedNetworkId = in.readInt(); mLastSelectedNetworkTimestamp = in.readLong(); } @Override Loading Loading @@ -220,7 +248,8 @@ public final class RecommendationRequest implements Parcelable { dest.writeInt(0); } dest.writeInt(mLastSelectedNetworkId); dest.writeLong(mLastSelectedNetworkTimestamp); } public static final Creator<RecommendationRequest> CREATOR = Loading
core/tests/coretests/src/android/net/RecommendationRequestTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package android.net; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.os.Parcel; import android.os.SystemClock; import android.test.AndroidTestCase; public class RecommendationRequestTest extends AndroidTestCase { Loading @@ -10,6 +11,8 @@ public class RecommendationRequestTest extends AndroidTestCase { private WifiConfiguration mDefaultConfig; private WifiConfiguration mConnectedConfig; private WifiConfiguration[] mConnectableConfigs; private int mLastSelectedNetworkId; private long mLastSelectedNetworkTimestamp; @Override public void setUp() throws Exception { Loading @@ -35,6 +38,8 @@ public class RecommendationRequestTest extends AndroidTestCase { mConnectedConfig = new WifiConfiguration(); mConnectedConfig.SSID = "connected_config"; mConnectableConfigs = new WifiConfiguration[] {mDefaultConfig, mConnectedConfig}; mLastSelectedNetworkId = 5; mLastSelectedNetworkTimestamp = SystemClock.elapsedRealtime(); } public void testParceling() throws Exception { Loading @@ -43,6 +48,7 @@ public class RecommendationRequestTest extends AndroidTestCase { .setScanResults(mScanResults) .setConnectedWifiConfig(mConnectedConfig) .setConnectableConfigs(mConnectableConfigs) .setLastSelectedNetwork(mLastSelectedNetworkId, mLastSelectedNetworkTimestamp) .build(); RecommendationRequest parceled = passThroughParcel(request); Loading @@ -60,6 +66,8 @@ public class RecommendationRequestTest extends AndroidTestCase { for (int i = 0; i < parceledConfigs.length; i++) { assertEquals(mConnectableConfigs[i].SSID, parceledConfigs[i].SSID); } assertEquals(mLastSelectedNetworkId, parceled.getLastSelectedNetworkId()); assertEquals(mLastSelectedNetworkTimestamp, parceled.getLastSelectedNetworkTimestamp()); } public void testParceling_nullScanResults() throws Exception { Loading @@ -82,6 +90,16 @@ public class RecommendationRequestTest extends AndroidTestCase { assertNull(parceledConfigs); } public void testParceling_unsetLastSelectedNetwork() throws Exception { RecommendationRequest request = new RecommendationRequest.Builder() .build(); RecommendationRequest parceled = passThroughParcel(request); assertEquals(0, parceled.getLastSelectedNetworkId()); assertEquals(0, parceled.getLastSelectedNetworkTimestamp()); } private RecommendationRequest passThroughParcel(RecommendationRequest request) { Parcel p = Parcel.obtain(); RecommendationRequest output = null; Loading