summaryrefslogtreecommitdiff
path: root/wifi/java
diff options
context:
space:
mode:
author Isaac Katzenelson <isaackatz@google.com> 2023-03-02 19:40:48 +0000
committer Isaac Katzenelson <isaackatz@google.com> 2023-03-02 22:40:50 +0000
commitc4d49db7dbd77d8eb02923c89cb89ad2c9a83a13 (patch)
treed662ed9bb2f9467c42f1180ee6ea7fd50ff10b0f /wifi/java
parentd53c4190cb7bc293f7fe84ad0a9928cd731e6329 (diff)
API Review: Changes to NetworkProviderInfo.Builder ctor
Bug: 268486125 Test: atest (all affected tests in the CL). Change-Id: I9b8d68a284d95c6c7034c15b29c58551c3fa2c95
Diffstat (limited to 'wifi/java')
-rw-r--r--wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java b/wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java
index 1b35b626c302..ed4d699ad4de 100644
--- a/wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java
+++ b/wifi/java/src/android/net/wifi/sharedconnectivity/app/NetworkProviderInfo.java
@@ -80,9 +80,11 @@ public final class NetworkProviderInfo implements Parcelable {
DEVICE_TYPE_WATCH,
DEVICE_TYPE_AUTO
})
- public @interface DeviceType {}
+ public @interface DeviceType {
+ }
- @DeviceType private final int mDeviceType;
+ @DeviceType
+ private final int mDeviceType;
private final String mDeviceName;
private final String mModelName;
private final int mBatteryPercentage;
@@ -98,7 +100,12 @@ public final class NetworkProviderInfo implements Parcelable {
private int mBatteryPercentage;
private int mConnectionStrength;
- public Builder() {}
+ public Builder(@NonNull String deviceName, @NonNull String modelName) {
+ Objects.requireNonNull(deviceName);
+ Objects.requireNonNull(modelName);
+ mDeviceName = deviceName;
+ mModelName = modelName;
+ }
/**
* Sets the device type that provides connectivity.
@@ -120,6 +127,7 @@ public final class NetworkProviderInfo implements Parcelable {
*/
@NonNull
public Builder setDeviceName(@NonNull String deviceName) {
+ Objects.requireNonNull(deviceName);
mDeviceName = deviceName;
return this;
}
@@ -132,6 +140,7 @@ public final class NetworkProviderInfo implements Parcelable {
*/
@NonNull
public Builder setModelName(@NonNull String modelName) {
+ Objects.requireNonNull(modelName);
mModelName = modelName;
return this;
}
@@ -176,15 +185,9 @@ public final class NetworkProviderInfo implements Parcelable {
int batteryPercentage, int connectionStrength) {
if (deviceType != DEVICE_TYPE_UNKNOWN && deviceType != DEVICE_TYPE_PHONE
&& deviceType != DEVICE_TYPE_TABLET && deviceType != DEVICE_TYPE_LAPTOP
- && deviceType != DEVICE_TYPE_WATCH && deviceType != DEVICE_TYPE_AUTO) {
+ && deviceType != DEVICE_TYPE_WATCH && deviceType != DEVICE_TYPE_AUTO) {
throw new IllegalArgumentException("Illegal device type");
}
- if (Objects.isNull(deviceName)) {
- throw new IllegalArgumentException("DeviceName must be set");
- }
- if (Objects.isNull(modelName)) {
- throw new IllegalArgumentException("ModelName must be set");
- }
if (batteryPercentage < 0 || batteryPercentage > 100) {
throw new IllegalArgumentException("BatteryPercentage must be in range 0-100");
}
@@ -269,6 +272,7 @@ public final class NetworkProviderInfo implements Parcelable {
return Objects.hash(mDeviceType, mDeviceName, mModelName, mBatteryPercentage,
mConnectionStrength);
}
+
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mDeviceType);