Merge "Updating Eth Update Request to use Builder" am: e5fd971d2e am: 3fb1f8adab am: be7ea07ec8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1991011 Change-Id: Idf1b3a44c21886540230cae43ec30035024a74c5
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package android.net;
|
package android.net;
|
||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@@ -27,13 +28,13 @@ import java.util.Objects;
|
|||||||
@SystemApi
|
@SystemApi
|
||||||
public final class EthernetNetworkUpdateRequest implements Parcelable {
|
public final class EthernetNetworkUpdateRequest implements Parcelable {
|
||||||
@NonNull
|
@NonNull
|
||||||
private final StaticIpConfiguration mIpConfig;
|
private final IpConfiguration mIpConfig;
|
||||||
@NonNull
|
@NonNull
|
||||||
private final NetworkCapabilities mNetworkCapabilities;
|
private final NetworkCapabilities mNetworkCapabilities;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public StaticIpConfiguration getIpConfig() {
|
public IpConfiguration getIpConfiguration() {
|
||||||
return new StaticIpConfiguration(mIpConfig);
|
return new IpConfiguration(mIpConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -41,20 +42,75 @@ public final class EthernetNetworkUpdateRequest implements Parcelable {
|
|||||||
return new NetworkCapabilities(mNetworkCapabilities);
|
return new NetworkCapabilities(mNetworkCapabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EthernetNetworkUpdateRequest(@NonNull final StaticIpConfiguration ipConfig,
|
private EthernetNetworkUpdateRequest(@NonNull final IpConfiguration ipConfig,
|
||||||
@NonNull final NetworkCapabilities networkCapabilities) {
|
@NonNull final NetworkCapabilities networkCapabilities) {
|
||||||
Objects.requireNonNull(ipConfig);
|
Objects.requireNonNull(ipConfig);
|
||||||
Objects.requireNonNull(networkCapabilities);
|
Objects.requireNonNull(networkCapabilities);
|
||||||
mIpConfig = new StaticIpConfiguration(ipConfig);
|
mIpConfig = new IpConfiguration(ipConfig);
|
||||||
mNetworkCapabilities = new NetworkCapabilities(networkCapabilities);
|
mNetworkCapabilities = new NetworkCapabilities(networkCapabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EthernetNetworkUpdateRequest(@NonNull final Parcel source) {
|
private EthernetNetworkUpdateRequest(@NonNull final Parcel source) {
|
||||||
Objects.requireNonNull(source);
|
Objects.requireNonNull(source);
|
||||||
mIpConfig = StaticIpConfiguration.CREATOR.createFromParcel(source);
|
mIpConfig = IpConfiguration.CREATOR.createFromParcel(source);
|
||||||
mNetworkCapabilities = NetworkCapabilities.CREATOR.createFromParcel(source);
|
mNetworkCapabilities = NetworkCapabilities.CREATOR.createFromParcel(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builder used to create {@link EthernetNetworkUpdateRequest} objects.
|
||||||
|
*/
|
||||||
|
public static final class Builder {
|
||||||
|
@Nullable
|
||||||
|
private IpConfiguration mBuilderIpConfig;
|
||||||
|
@Nullable
|
||||||
|
private NetworkCapabilities mBuilderNetworkCapabilities;
|
||||||
|
|
||||||
|
public Builder(){}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to populate the builder's values with an already built
|
||||||
|
* {@link EthernetNetworkUpdateRequest}.
|
||||||
|
* @param request the {@link EthernetNetworkUpdateRequest} to populate with.
|
||||||
|
*/
|
||||||
|
public Builder(@NonNull final EthernetNetworkUpdateRequest request) {
|
||||||
|
Objects.requireNonNull(request);
|
||||||
|
mBuilderIpConfig = new IpConfiguration(request.mIpConfig);
|
||||||
|
mBuilderNetworkCapabilities = new NetworkCapabilities(request.mNetworkCapabilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the {@link IpConfiguration} to be used with the {@code Builder}.
|
||||||
|
* @param ipConfig the {@link IpConfiguration} to set.
|
||||||
|
* @return The builder to facilitate chaining.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public Builder setIpConfiguration(@NonNull final IpConfiguration ipConfig) {
|
||||||
|
Objects.requireNonNull(ipConfig);
|
||||||
|
mBuilderIpConfig = new IpConfiguration(ipConfig);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the {@link NetworkCapabilities} to be used with the {@code Builder}.
|
||||||
|
* @param nc the {@link NetworkCapabilities} to set.
|
||||||
|
* @return The builder to facilitate chaining.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public Builder setNetworkCapabilities(@NonNull final NetworkCapabilities nc) {
|
||||||
|
Objects.requireNonNull(nc);
|
||||||
|
mBuilderNetworkCapabilities = new NetworkCapabilities(nc);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build {@link EthernetNetworkUpdateRequest} return the current update request.
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public EthernetNetworkUpdateRequest build() {
|
||||||
|
return new EthernetNetworkUpdateRequest(mBuilderIpConfig, mBuilderNetworkCapabilities);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "EthernetNetworkUpdateRequest{"
|
return "EthernetNetworkUpdateRequest{"
|
||||||
@@ -68,7 +124,7 @@ public final class EthernetNetworkUpdateRequest implements Parcelable {
|
|||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
EthernetNetworkUpdateRequest that = (EthernetNetworkUpdateRequest) o;
|
EthernetNetworkUpdateRequest that = (EthernetNetworkUpdateRequest) o;
|
||||||
|
|
||||||
return Objects.equals(that.getIpConfig(), mIpConfig)
|
return Objects.equals(that.getIpConfiguration(), mIpConfig)
|
||||||
&& Objects.equals(that.getNetworkCapabilities(), mNetworkCapabilities);
|
&& Objects.equals(that.getNetworkCapabilities(), mNetworkCapabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user