summaryrefslogtreecommitdiff
path: root/src/android/net/dhcp/DhcpLease.java
diff options
context:
space:
mode:
authorRemi NGUYEN VAN <reminv@google.com>2020-02-13 16:27:21 +0000
committerRemi NGUYEN VAN <reminv@google.com>2020-02-13 16:28:35 +0000
commite8fff42022f8c22e84d51bc093189d469bdd9af1 (patch)
treed4856f75ccbb78298ff7b246b1bad0d93687b391 /src/android/net/dhcp/DhcpLease.java
parentdc018dd943f0c11e0b9172dee0db0966871af20d (diff)
Revert "Add DhcpLeaseCallbacks"
This reverts commit dc018dd943f0c11e0b9172dee0db0966871af20d. Reason for revert: crashes tethering: b/149458372 Bug: 149458372 Change-Id: I1fad8528443d8cc133f719aad042cb22d3a8e2a0
Diffstat (limited to 'src/android/net/dhcp/DhcpLease.java')
-rw-r--r--src/android/net/dhcp/DhcpLease.java37
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);
}
}