diff options
Diffstat (limited to 'src/android/net/dhcp/DhcpLease.java')
-rw-r--r-- | src/android/net/dhcp/DhcpLease.java | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/src/android/net/dhcp/DhcpLease.java b/src/android/net/dhcp/DhcpLease.java index 3226f28..37d9cc0 100644 --- a/src/android/net/dhcp/DhcpLease.java +++ b/src/android/net/dhcp/DhcpLease.java @@ -16,8 +16,6 @@ package android.net.dhcp; -import static android.net.shared.Inet4AddressUtils.inet4AddressToIntHTH; - import android.net.MacAddress; import android.os.SystemClock; import android.text.TextUtils; @@ -45,7 +43,6 @@ public class DhcpLease { private final MacAddress mHwAddr; @NonNull private final Inet4Address mNetAddr; - private final int mPrefixLength; /** * Expiration time for the lease, to compare with {@link SystemClock#elapsedRealtime()}. */ @@ -54,12 +51,10 @@ public class DhcpLease { private final String mHostname; public DhcpLease(@Nullable byte[] clientId, @NonNull MacAddress hwAddr, - @NonNull Inet4Address netAddr, int prefixLength, long expTime, - @Nullable String hostname) { + @NonNull Inet4Address netAddr, long expTime, @Nullable String hostname) { mClientId = (clientId == null ? null : Arrays.copyOf(clientId, clientId.length)); mHwAddr = hwAddr; mNetAddr = netAddr; - mPrefixLength = prefixLength; mExpTime = expTime; mHostname = hostname; } @@ -92,10 +87,6 @@ public class DhcpLease { return mNetAddr; } - public int getPrefixLength() { - return mPrefixLength; - } - public long getExpTime() { return mExpTime; } @@ -108,8 +99,7 @@ public class DhcpLease { * @return A {@link DhcpLease} with expiration time set to max(expTime, currentExpTime) */ public DhcpLease renewedLease(long expTime, @Nullable String hostname) { - return new DhcpLease(mClientId, mHwAddr, mNetAddr, mPrefixLength, - Math.max(expTime, mExpTime), + return new DhcpLease(mClientId, mHwAddr, mNetAddr, Math.max(expTime, mExpTime), (hostname == null ? mHostname : hostname)); } @@ -135,14 +125,13 @@ public class DhcpLease { return Arrays.equals(mClientId, other.mClientId) && mHwAddr.equals(other.mHwAddr) && mNetAddr.equals(other.mNetAddr) - && mPrefixLength == other.mPrefixLength && mExpTime == other.mExpTime && TextUtils.equals(mHostname, other.mHostname); } @Override public int hashCode() { - return Objects.hash(mClientId, mHwAddr, mNetAddr, mPrefixLength, mHostname, mExpTime); + return Objects.hash(mClientId, mHwAddr, mNetAddr, mHostname, mExpTime); } static String clientIdToString(byte[] bytes) { @@ -158,24 +147,8 @@ public class DhcpLease { @Override public String toString() { - return String.format("clientId: %s, hwAddr: %s, netAddr: %s/%d, expTime: %d," - + "hostname: %s", + return String.format("clientId: %s, hwAddr: %s, netAddr: %s, expTime: %d, hostname: %s", clientIdToString(mClientId), mHwAddr.toString(), inet4AddrToString(mNetAddr), - mPrefixLength, mExpTime, mHostname); - } - - /** - * Create a {@link DhcpLeaseParcelable} containing the information held in this lease. - */ - public DhcpLeaseParcelable toParcelable() { - final DhcpLeaseParcelable p = new DhcpLeaseParcelable(); - p.clientId = mClientId == null ? null : Arrays.copyOf(mClientId, mClientId.length); - p.hwAddr = mHwAddr.toByteArray(); - p.netAddr = inet4AddressToIntHTH(mNetAddr); - p.prefixLength = mPrefixLength; - p.expTime = mExpTime; - p.hostname = mHostname; - - return p; + mExpTime, mHostname); } } |