Merge "Remove deprecated recommendation request code." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b2bd32929b
@@ -254,18 +254,6 @@ package android.net {
|
||||
field public static final int BADGING_SD = 10; // 0xa
|
||||
}
|
||||
|
||||
public abstract class NetworkRecommendationProvider {
|
||||
ctor public deprecated NetworkRecommendationProvider(android.os.Handler);
|
||||
method public deprecated void onRequestRecommendation(android.net.RecommendationRequest, android.net.NetworkRecommendationProvider.ResultCallback);
|
||||
field public static final deprecated java.lang.String EXTRA_RECOMMENDATION_RESULT = "android.net.extra.RECOMMENDATION_RESULT";
|
||||
field public static final deprecated java.lang.String EXTRA_SEQUENCE = "android.net.extra.SEQUENCE";
|
||||
}
|
||||
|
||||
public static deprecated class NetworkRecommendationProvider.ResultCallback {
|
||||
ctor public NetworkRecommendationProvider.ResultCallback(android.os.IRemoteCallback, int);
|
||||
method public void onResult(android.net.RecommendationResult);
|
||||
}
|
||||
|
||||
public abstract class PskKeyManager {
|
||||
ctor public PskKeyManager();
|
||||
field public static final int MAX_IDENTITY_HINT_LENGTH_BYTES = 128; // 0x80
|
||||
@@ -273,37 +261,6 @@ package android.net {
|
||||
field public static final int MAX_KEY_LENGTH_BYTES = 256; // 0x100
|
||||
}
|
||||
|
||||
public final deprecated class RecommendationRequest implements android.os.Parcelable {
|
||||
ctor protected RecommendationRequest(android.os.Parcel);
|
||||
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);
|
||||
field public static final android.os.Parcelable.Creator<android.net.RecommendationRequest> CREATOR;
|
||||
}
|
||||
|
||||
public static final deprecated class RecommendationRequest.Builder {
|
||||
ctor public RecommendationRequest.Builder();
|
||||
method public android.net.RecommendationRequest build();
|
||||
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[]);
|
||||
}
|
||||
|
||||
public final deprecated class RecommendationResult implements android.os.Parcelable {
|
||||
method public static android.net.RecommendationResult createConnectRecommendation(android.net.wifi.WifiConfiguration);
|
||||
method public static android.net.RecommendationResult createDoNotConnectRecommendation();
|
||||
method public android.net.wifi.WifiConfiguration getWifiConfiguration();
|
||||
method public boolean hasRecommendation();
|
||||
field public static final android.os.Parcelable.Creator<android.net.RecommendationResult> CREATOR;
|
||||
}
|
||||
|
||||
public class SSLCertificateSocketFactory extends javax.net.ssl.SSLSocketFactory {
|
||||
method public static deprecated org.apache.http.conn.ssl.SSLSocketFactory getHttpSocketFactory(int, android.net.SSLSessionCache);
|
||||
}
|
||||
|
||||
@@ -252,18 +252,6 @@ package android.net {
|
||||
field public static final int BADGING_SD = 10; // 0xa
|
||||
}
|
||||
|
||||
public abstract class NetworkRecommendationProvider {
|
||||
ctor public deprecated NetworkRecommendationProvider(android.os.Handler);
|
||||
method public deprecated void onRequestRecommendation(android.net.RecommendationRequest, android.net.NetworkRecommendationProvider.ResultCallback);
|
||||
field public static final deprecated java.lang.String EXTRA_RECOMMENDATION_RESULT = "android.net.extra.RECOMMENDATION_RESULT";
|
||||
field public static final deprecated java.lang.String EXTRA_SEQUENCE = "android.net.extra.SEQUENCE";
|
||||
}
|
||||
|
||||
public static deprecated class NetworkRecommendationProvider.ResultCallback {
|
||||
ctor public NetworkRecommendationProvider.ResultCallback(android.os.IRemoteCallback, int);
|
||||
method public void onResult(android.net.RecommendationResult);
|
||||
}
|
||||
|
||||
public abstract class PskKeyManager {
|
||||
ctor public PskKeyManager();
|
||||
field public static final int MAX_IDENTITY_HINT_LENGTH_BYTES = 128; // 0x80
|
||||
@@ -271,37 +259,6 @@ package android.net {
|
||||
field public static final int MAX_KEY_LENGTH_BYTES = 256; // 0x100
|
||||
}
|
||||
|
||||
public final deprecated class RecommendationRequest implements android.os.Parcelable {
|
||||
ctor protected RecommendationRequest(android.os.Parcel);
|
||||
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);
|
||||
field public static final android.os.Parcelable.Creator<android.net.RecommendationRequest> CREATOR;
|
||||
}
|
||||
|
||||
public static final deprecated class RecommendationRequest.Builder {
|
||||
ctor public RecommendationRequest.Builder();
|
||||
method public android.net.RecommendationRequest build();
|
||||
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[]);
|
||||
}
|
||||
|
||||
public final deprecated class RecommendationResult implements android.os.Parcelable {
|
||||
method public static android.net.RecommendationResult createConnectRecommendation(android.net.wifi.WifiConfiguration);
|
||||
method public static android.net.RecommendationResult createDoNotConnectRecommendation();
|
||||
method public android.net.wifi.WifiConfiguration getWifiConfiguration();
|
||||
method public boolean hasRecommendation();
|
||||
field public static final android.os.Parcelable.Creator<android.net.RecommendationResult> CREATOR;
|
||||
}
|
||||
|
||||
public class SSLCertificateSocketFactory extends javax.net.ssl.SSLSocketFactory {
|
||||
method public static deprecated org.apache.http.conn.ssl.SSLSocketFactory getHttpSocketFactory(int, android.net.SSLSessionCache);
|
||||
}
|
||||
|
||||
@@ -254,18 +254,6 @@ package android.net {
|
||||
field public static final int BADGING_SD = 10; // 0xa
|
||||
}
|
||||
|
||||
public abstract class NetworkRecommendationProvider {
|
||||
ctor public deprecated NetworkRecommendationProvider(android.os.Handler);
|
||||
method public deprecated void onRequestRecommendation(android.net.RecommendationRequest, android.net.NetworkRecommendationProvider.ResultCallback);
|
||||
field public static final deprecated java.lang.String EXTRA_RECOMMENDATION_RESULT = "android.net.extra.RECOMMENDATION_RESULT";
|
||||
field public static final deprecated java.lang.String EXTRA_SEQUENCE = "android.net.extra.SEQUENCE";
|
||||
}
|
||||
|
||||
public static deprecated class NetworkRecommendationProvider.ResultCallback {
|
||||
ctor public NetworkRecommendationProvider.ResultCallback(android.os.IRemoteCallback, int);
|
||||
method public void onResult(android.net.RecommendationResult);
|
||||
}
|
||||
|
||||
public abstract class PskKeyManager {
|
||||
ctor public PskKeyManager();
|
||||
field public static final int MAX_IDENTITY_HINT_LENGTH_BYTES = 128; // 0x80
|
||||
@@ -273,37 +261,6 @@ package android.net {
|
||||
field public static final int MAX_KEY_LENGTH_BYTES = 256; // 0x100
|
||||
}
|
||||
|
||||
public final deprecated class RecommendationRequest implements android.os.Parcelable {
|
||||
ctor protected RecommendationRequest(android.os.Parcel);
|
||||
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);
|
||||
field public static final android.os.Parcelable.Creator<android.net.RecommendationRequest> CREATOR;
|
||||
}
|
||||
|
||||
public static final deprecated class RecommendationRequest.Builder {
|
||||
ctor public RecommendationRequest.Builder();
|
||||
method public android.net.RecommendationRequest build();
|
||||
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[]);
|
||||
}
|
||||
|
||||
public final deprecated class RecommendationResult implements android.os.Parcelable {
|
||||
method public static android.net.RecommendationResult createConnectRecommendation(android.net.wifi.WifiConfiguration);
|
||||
method public static android.net.RecommendationResult createDoNotConnectRecommendation();
|
||||
method public android.net.wifi.WifiConfiguration getWifiConfiguration();
|
||||
method public boolean hasRecommendation();
|
||||
field public static final android.os.Parcelable.Creator<android.net.RecommendationResult> CREATOR;
|
||||
}
|
||||
|
||||
public class SSLCertificateSocketFactory extends javax.net.ssl.SSLSocketFactory {
|
||||
method public static deprecated org.apache.http.conn.ssl.SSLSocketFactory getHttpSocketFactory(int, android.net.SSLSessionCache);
|
||||
}
|
||||
|
||||
@@ -20,19 +20,14 @@ import android.Manifest.permission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.IRemoteCallback;
|
||||
import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* The base class for implementing a network recommendation provider.
|
||||
@@ -55,32 +50,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
public abstract class NetworkRecommendationProvider {
|
||||
private static final String TAG = "NetworkRecProvider";
|
||||
private static final boolean VERBOSE = Build.IS_DEBUGGABLE && Log.isLoggable(TAG, Log.VERBOSE);
|
||||
/** The key into the callback Bundle where the RecommendationResult will be found.
|
||||
* @deprecated to be removed.
|
||||
* @removed
|
||||
*/
|
||||
public static final String EXTRA_RECOMMENDATION_RESULT =
|
||||
"android.net.extra.RECOMMENDATION_RESULT";
|
||||
/** The key into the callback Bundle where the sequence will be found.
|
||||
* @deprecated to be removed.
|
||||
* @removed
|
||||
*/
|
||||
public static final String EXTRA_SEQUENCE = "android.net.extra.SEQUENCE";
|
||||
private final IBinder mService;
|
||||
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
* @param handler indicates which thread to use when handling requests. Cannot be {@code null}.
|
||||
* @deprecated use {@link #NetworkRecommendationProvider(Context, Executor)}
|
||||
* @removed
|
||||
*/
|
||||
public NetworkRecommendationProvider(Handler handler) {
|
||||
if (handler == null) {
|
||||
throw new IllegalArgumentException("The provided handler cannot be null.");
|
||||
}
|
||||
mService = new ServiceWrapper(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
* @param context the current context instance. Cannot be {@code null}.
|
||||
@@ -92,19 +63,6 @@ public abstract class NetworkRecommendationProvider {
|
||||
mService = new ServiceWrapper(context, executor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked when a recommendation has been requested.
|
||||
*
|
||||
* @param request a {@link RecommendationRequest} instance containing additional
|
||||
* request details
|
||||
* @param callback a {@link ResultCallback} instance. When a {@link RecommendationResult} is
|
||||
* available it must be passed into
|
||||
* {@link ResultCallback#onResult(RecommendationResult)}.
|
||||
* @deprecated to be removed.
|
||||
* @removed
|
||||
*/
|
||||
public void onRequestRecommendation(RecommendationRequest request, ResultCallback callback) {}
|
||||
|
||||
/**
|
||||
* Invoked when network scores have been requested.
|
||||
* <p>
|
||||
@@ -122,66 +80,6 @@ public abstract class NetworkRecommendationProvider {
|
||||
return mService;
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback implementing applications should invoke when a {@link RecommendationResult}
|
||||
* is available.
|
||||
*
|
||||
* @deprecated to be removed.
|
||||
* @removed
|
||||
*/
|
||||
public static class ResultCallback {
|
||||
private final IRemoteCallback mCallback;
|
||||
private final int mSequence;
|
||||
private final AtomicBoolean mCallbackRun;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public ResultCallback(IRemoteCallback callback, int sequence) {
|
||||
mCallback = callback;
|
||||
mSequence = sequence;
|
||||
mCallbackRun = new AtomicBoolean(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the callback with the available {@link RecommendationResult}.
|
||||
* @param result a {@link RecommendationResult} instance.
|
||||
*/
|
||||
public void onResult(RecommendationResult result) {
|
||||
if (VERBOSE) Log.v(TAG, "onResult(seq=" + mSequence + ")");
|
||||
if (!mCallbackRun.compareAndSet(false, true)) {
|
||||
throw new IllegalStateException("The callback cannot be run more than once. "
|
||||
+ "seq=" + mSequence);
|
||||
}
|
||||
final Bundle data = new Bundle();
|
||||
data.putInt(EXTRA_SEQUENCE, mSequence);
|
||||
data.putParcelable(EXTRA_RECOMMENDATION_RESULT, result);
|
||||
try {
|
||||
mCallback.sendResult(data);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Callback failed for seq: " + mSequence, e);
|
||||
}
|
||||
if (VERBOSE) Log.v(TAG, "onResult() complete. seq=" + mSequence);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
ResultCallback that = (ResultCallback) o;
|
||||
|
||||
return mSequence == that.mSequence
|
||||
&& Objects.equals(mCallback, that.mCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mCallback, mSequence);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A wrapper around INetworkRecommendationProvider that dispatches to the provided Handler.
|
||||
*/
|
||||
@@ -190,12 +88,6 @@ public abstract class NetworkRecommendationProvider {
|
||||
private final Executor mExecutor;
|
||||
private final Handler mHandler;
|
||||
|
||||
ServiceWrapper(Handler handler) {
|
||||
mHandler = handler;
|
||||
mExecutor = null;
|
||||
mContext = null;
|
||||
}
|
||||
|
||||
ServiceWrapper(Context context, Executor executor) {
|
||||
mContext = context;
|
||||
mExecutor = executor;
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package android.net;
|
||||
|
||||
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
/**
|
||||
* A request for a network recommendation.
|
||||
*
|
||||
* @see {@link NetworkScoreManager#requestRecommendation(RecommendationRequest)}.
|
||||
* @hide
|
||||
* @deprecated to be removed.
|
||||
* @removed
|
||||
*/
|
||||
public final class RecommendationRequest implements Parcelable {
|
||||
private final ScanResult[] mScanResults;
|
||||
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.
|
||||
* @hide
|
||||
* @deprecated to be removed.
|
||||
* @removed
|
||||
*/
|
||||
public static final class Builder {
|
||||
private ScanResult[] mScanResults;
|
||||
private WifiConfiguration mDefaultConfig;
|
||||
private WifiConfiguration mConnectedConfig;
|
||||
private WifiConfiguration[] mConnectableConfigs;
|
||||
private int mLastSelectedNetworkId = -1;
|
||||
private long mLastSelectedTimestamp;
|
||||
|
||||
public Builder setScanResults(ScanResult[] scanResults) {
|
||||
mScanResults = scanResults;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param config the {@link WifiConfiguration} to return if no recommendation is available.
|
||||
* @return this
|
||||
*/
|
||||
public Builder setDefaultWifiConfig(WifiConfiguration config) {
|
||||
this.mDefaultConfig = config;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param config the {@link WifiConfiguration} of the connected network at the time the
|
||||
* this request was made.
|
||||
* @return this
|
||||
*/
|
||||
public Builder setConnectedWifiConfig(WifiConfiguration config) {
|
||||
this.mConnectedConfig = config;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param connectableConfigs the set of saved {@link WifiConfiguration}s that can be
|
||||
* connected to based on the current set of {@link ScanResult}s.
|
||||
* @return this
|
||||
*/
|
||||
public Builder setConnectableConfigs(WifiConfiguration[] 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a new {@link RecommendationRequest} instance
|
||||
*/
|
||||
public RecommendationRequest build() {
|
||||
return new RecommendationRequest(mScanResults, mDefaultConfig, mConnectedConfig,
|
||||
mConnectableConfigs, mLastSelectedNetworkId, mLastSelectedTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 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.
|
||||
*/
|
||||
public ScanResult[] getScanResults() {
|
||||
return mScanResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link WifiConfiguration} to return if no recommendation is available.
|
||||
*/
|
||||
public WifiConfiguration getDefaultWifiConfig() {
|
||||
return mDefaultConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link WifiConfiguration} of the connected network at the time the this request
|
||||
* was made.
|
||||
*/
|
||||
public WifiConfiguration getConnectedConfig() {
|
||||
return mConnectedConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the set of saved {@link WifiConfiguration}s that can be connected to based on the
|
||||
* current set of {@link ScanResult}s.
|
||||
*/
|
||||
public WifiConfiguration[] getConnectableConfigs() {
|
||||
return mConnectableConfigs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param connectedConfig the {@link WifiConfiguration} of the connected network at the time
|
||||
* the this request was made.
|
||||
*/
|
||||
public void setConnectedConfig(WifiConfiguration connectedConfig) {
|
||||
mConnectedConfig = connectedConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param connectableConfigs the set of saved {@link WifiConfiguration}s that can be connected
|
||||
* to based on the current set of {@link ScanResult}s.
|
||||
*/
|
||||
public void setConnectableConfigs(WifiConfiguration[] connectableConfigs) {
|
||||
mConnectableConfigs = connectableConfigs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The {@link WifiConfiguration#networkId} of the last user selected network.
|
||||
* {@code -1} 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,
|
||||
int lastSelectedNetworkId,
|
||||
long lastSelectedNetworkTimestamp) {
|
||||
mScanResults = scanResults;
|
||||
mDefaultConfig = defaultWifiConfig;
|
||||
mConnectedConfig = connectedWifiConfig;
|
||||
mConnectableConfigs = connectableConfigs;
|
||||
mLastSelectedNetworkId = lastSelectedNetworkId;
|
||||
mLastSelectedNetworkTimestamp = lastSelectedNetworkTimestamp;
|
||||
}
|
||||
|
||||
protected RecommendationRequest(Parcel in) {
|
||||
final int resultCount = in.readInt();
|
||||
if (resultCount > 0) {
|
||||
mScanResults = new ScanResult[resultCount];
|
||||
final ClassLoader classLoader = ScanResult.class.getClassLoader();
|
||||
for (int i = 0; i < resultCount; i++) {
|
||||
mScanResults[i] = in.readParcelable(classLoader);
|
||||
}
|
||||
} else {
|
||||
mScanResults = null;
|
||||
}
|
||||
|
||||
mDefaultConfig = in.readParcelable(WifiConfiguration.class.getClassLoader());
|
||||
mConnectedConfig = in.readParcelable(WifiConfiguration.class.getClassLoader());
|
||||
|
||||
final int configCount = in.readInt();
|
||||
if (configCount > 0) {
|
||||
mConnectableConfigs = new WifiConfiguration[configCount];
|
||||
final ClassLoader classLoader = WifiConfiguration.class.getClassLoader();
|
||||
for (int i = 0; i < configCount; i++) {
|
||||
mConnectableConfigs[i] = in.readParcelable(classLoader);
|
||||
}
|
||||
} else {
|
||||
mConnectableConfigs = null;
|
||||
}
|
||||
|
||||
mLastSelectedNetworkId = in.readInt();
|
||||
mLastSelectedNetworkTimestamp = in.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (mScanResults != null) {
|
||||
dest.writeInt(mScanResults.length);
|
||||
for (int i = 0; i < mScanResults.length; i++) {
|
||||
dest.writeParcelable(mScanResults[i], flags);
|
||||
}
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
|
||||
dest.writeParcelable(mDefaultConfig, flags);
|
||||
dest.writeParcelable(mConnectedConfig, flags);
|
||||
|
||||
if (mConnectableConfigs != null) {
|
||||
dest.writeInt(mConnectableConfigs.length);
|
||||
for (int i = 0; i < mConnectableConfigs.length; i++) {
|
||||
dest.writeParcelable(mConnectableConfigs[i], flags);
|
||||
}
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
|
||||
dest.writeInt(mLastSelectedNetworkId);
|
||||
dest.writeLong(mLastSelectedNetworkTimestamp);
|
||||
}
|
||||
|
||||
public static final Creator<RecommendationRequest> CREATOR =
|
||||
new Creator<RecommendationRequest>() {
|
||||
@Override
|
||||
public RecommendationRequest createFromParcel(Parcel in) {
|
||||
return new RecommendationRequest(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecommendationRequest[] newArray(int size) {
|
||||
return new RecommendationRequest[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License
|
||||
*/
|
||||
|
||||
package android.net;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
/**
|
||||
* The result of a network recommendation.
|
||||
*
|
||||
* @see {@link NetworkScoreManager#requestRecommendation(RecommendationRequest)}.
|
||||
* @hide
|
||||
* @deprecated to be removed.
|
||||
* @removed
|
||||
*/
|
||||
public final class RecommendationResult implements Parcelable {
|
||||
private final WifiConfiguration mWifiConfiguration;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
private RecommendationResult(Parcel in) {
|
||||
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
|
||||
* is returned if {@link #hasRecommendation} returns {@code false}.
|
||||
*/
|
||||
@Nullable public WifiConfiguration getWifiConfiguration() {
|
||||
return mWifiConfiguration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RecommendationResult{" +
|
||||
"mWifiConfiguration=" + mWifiConfiguration +
|
||||
"}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
out.writeParcelable(mWifiConfiguration, flags);
|
||||
}
|
||||
|
||||
public static final Creator<RecommendationResult> CREATOR =
|
||||
new Creator<RecommendationResult>() {
|
||||
@Override
|
||||
public RecommendationResult createFromParcel(Parcel in) {
|
||||
return new RecommendationResult(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecommendationResult[] newArray(int size) {
|
||||
return new RecommendationResult[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user