API review: access field by method
- InvalidPacketException, public field should be a method so
add getter to get error code.
- KeepalivePacketData, public fields should be methods so
add getter for fields.
Bug: 151322799
Test: atest FrameworksNetTests
atest FrameworksWifiTests
atest FrameworksTelephonyTests: some failure in CarrierAppUtilsTest
Copy from ag/10731108
Change-Id: Id01e6135193716cc21bba11da529bf1507a954f7
Merged-In: Id01e6135193716cc21bba11da529bf1507a954f7
This commit is contained in:
parent
57de4563f4
commit
60011ce0a1
1 changed files with 66 additions and 32 deletions
|
|
@ -94,10 +94,10 @@ public final class NattKeepalivePacketData extends KeepalivePacketData implement
|
|||
|
||||
/** Write to parcel */
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
out.writeString(srcAddress.getHostAddress());
|
||||
out.writeString(dstAddress.getHostAddress());
|
||||
out.writeInt(srcPort);
|
||||
out.writeInt(dstPort);
|
||||
out.writeString(getSrcAddress().getHostAddress());
|
||||
out.writeString(getDstAddress().getHostAddress());
|
||||
out.writeInt(getSrcPort());
|
||||
out.writeInt(getDstPort());
|
||||
}
|
||||
|
||||
/** Parcelable Creator */
|
||||
|
|
@ -115,7 +115,7 @@ public final class NattKeepalivePacketData extends KeepalivePacketData implement
|
|||
dstAddress, dstPort);
|
||||
} catch (InvalidPacketException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid NAT-T keepalive data: " + e.error);
|
||||
"Invalid NAT-T keepalive data: " + e.getError());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -128,14 +128,16 @@ public final class NattKeepalivePacketData extends KeepalivePacketData implement
|
|||
public boolean equals(@Nullable final Object o) {
|
||||
if (!(o instanceof NattKeepalivePacketData)) return false;
|
||||
final NattKeepalivePacketData other = (NattKeepalivePacketData) o;
|
||||
return this.srcAddress.equals(other.srcAddress)
|
||||
&& this.dstAddress.equals(other.dstAddress)
|
||||
&& this.srcPort == other.srcPort
|
||||
&& this.dstPort == other.dstPort;
|
||||
final InetAddress srcAddress = getSrcAddress();
|
||||
final InetAddress dstAddress = getDstAddress();
|
||||
return srcAddress.equals(other.getSrcAddress())
|
||||
&& dstAddress.equals(other.getDstAddress())
|
||||
&& getSrcPort() == other.getSrcPort()
|
||||
&& getDstPort() == other.getDstPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(srcAddress, dstAddress, srcPort, dstPort);
|
||||
return Objects.hash(getSrcAddress(), getDstAddress(), getSrcPort(), getDstPort());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue