Fixed the documentation and unit tests
Fixed the documentation and re-eanble the
broken unit tests.
Test: LinkAddressTest
Bug: 142949345
Merged-In: I0ac8c022f70cdf9305c183996c2464a8e04ba5ae
Change-Id: I0ac8c022f70cdf9305c183996c2464a8e04ba5ae
(cherry picked from commit b67261b01c)
This commit is contained in:
@@ -102,9 +102,9 @@ public class LinkAddress implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The time, as reported by {@link SystemClock#elapsedRealtime}, when this LinkAddress will be
|
* The time, as reported by {@link SystemClock#elapsedRealtime}, when this LinkAddress will be
|
||||||
* or was deprecated. {@link #LIFETIME_UNKNOWN} indicates this information is not available. At
|
* or was deprecated. At the time existing connections can still use this address until it
|
||||||
* the time existing connections can still use this address until it expires, but new
|
* expires, but new connections should use the new address. {@link #LIFETIME_UNKNOWN} indicates
|
||||||
* connections should use the new address. {@link #LIFETIME_PERMANENT} indicates this
|
* this information is not available. {@link #LIFETIME_PERMANENT} indicates this
|
||||||
* {@link LinkAddress} will never be deprecated.
|
* {@link LinkAddress} will never be deprecated.
|
||||||
*/
|
*/
|
||||||
private long deprecationTime;
|
private long deprecationTime;
|
||||||
@@ -261,10 +261,10 @@ public class LinkAddress implements Parcelable {
|
|||||||
* @param scope An integer defining the scope in which the address is unique (e.g.,
|
* @param scope An integer defining the scope in which the address is unique (e.g.,
|
||||||
* {@link OsConstants#RT_SCOPE_LINK} or {@link OsConstants#RT_SCOPE_SITE}).
|
* {@link OsConstants#RT_SCOPE_LINK} or {@link OsConstants#RT_SCOPE_SITE}).
|
||||||
* @param deprecationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when
|
* @param deprecationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when
|
||||||
* this {@link LinkAddress} will be or was deprecated.
|
* this {@link LinkAddress} will be or was deprecated. At the time
|
||||||
* {@link #LIFETIME_UNKNOWN} indicates this information is not available.
|
* existing connections can still use this address until it expires, but
|
||||||
* At the time existing connections can still use this address until it
|
* new connections should use the new address. {@link #LIFETIME_UNKNOWN}
|
||||||
* expires, but new connections should use the new address.
|
* indicates this information is not available.
|
||||||
* {@link #LIFETIME_PERMANENT} indicates this {@link LinkAddress} will
|
* {@link #LIFETIME_PERMANENT} indicates this {@link LinkAddress} will
|
||||||
* never be deprecated.
|
* never be deprecated.
|
||||||
* @param expirationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when this
|
* @param expirationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when this
|
||||||
@@ -441,7 +441,7 @@ public class LinkAddress implements Parcelable {
|
|||||||
if (expirationTime == LIFETIME_PERMANENT) {
|
if (expirationTime == LIFETIME_PERMANENT) {
|
||||||
flags |= IFA_F_PERMANENT;
|
flags |= IFA_F_PERMANENT;
|
||||||
} else if (expirationTime != LIFETIME_UNKNOWN) {
|
} else if (expirationTime != LIFETIME_UNKNOWN) {
|
||||||
// If we know this address expired or will expire in the future or, then this address
|
// If we know this address expired or will expire in the future, then this address
|
||||||
// should not be permanent.
|
// should not be permanent.
|
||||||
flags &= ~IFA_F_PERMANENT;
|
flags &= ~IFA_F_PERMANENT;
|
||||||
}
|
}
|
||||||
@@ -458,10 +458,13 @@ public class LinkAddress implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The time that this address will be deprecated. At the time the existing connection
|
* Get the deprecation time, as reported by {@link SystemClock#elapsedRealtime}, when this
|
||||||
* can still use this address until it expires, but the new connection should use the new
|
* {@link LinkAddress} will be or was deprecated. At the time existing connections can still use
|
||||||
* address. This is the EPOCH time in milliseconds. 0 indicates this information is not
|
* this address until it expires, but new connections should use the new address.
|
||||||
* available.
|
*
|
||||||
|
* @return The deprecation time in milliseconds. {@link #LIFETIME_UNKNOWN} indicates this
|
||||||
|
* information is not available. {@link #LIFETIME_PERMANENT} indicates this {@link LinkAddress}
|
||||||
|
* will never be deprecated.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@@ -472,8 +475,12 @@ public class LinkAddress implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The time that this address will expire and will be no longer valid. This is the EPOCH
|
* Get the expiration time, as reported by {@link SystemClock#elapsedRealtime}, when this
|
||||||
* time in milliseconds. 0 indicates this information is not available.
|
* {@link LinkAddress} will expire and be removed from the interface.
|
||||||
|
*
|
||||||
|
* @return The expiration time in milliseconds. {@link #LIFETIME_UNKNOWN} indicates this
|
||||||
|
* information is not available. {@link #LIFETIME_PERMANENT} indicates this {@link LinkAddress}
|
||||||
|
* will never expire.
|
||||||
*
|
*
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -326,26 +326,23 @@ public class LinkAddressTest {
|
|||||||
assertParcelSane(l, 6);
|
assertParcelSane(l, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeprecationTime() {
|
public void testDeprecationTime() {
|
||||||
try {
|
try {
|
||||||
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
||||||
LinkAddress.LIFETIME_UNKNOWN,
|
LinkAddress.LIFETIME_UNKNOWN, 100000L);
|
||||||
SystemClock.elapsedRealtime() + 200000);
|
|
||||||
fail("Only one time provided should cause exception");
|
fail("Only one time provided should cause exception");
|
||||||
} catch (IllegalArgumentException expected) { }
|
} catch (IllegalArgumentException expected) { }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
||||||
SystemClock.elapsedRealtime() - 100000,
|
200000L, 100000L);
|
||||||
SystemClock.elapsedRealtime() - 200000);
|
|
||||||
fail("deprecation time later than expiration time should cause exception");
|
fail("deprecation time later than expiration time should cause exception");
|
||||||
} catch (IllegalArgumentException expected) { }
|
} catch (IllegalArgumentException expected) { }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
||||||
-2, SystemClock.elapsedRealtime());
|
-2, 100000L);
|
||||||
fail("negative deprecation time should cause exception");
|
fail("negative deprecation time should cause exception");
|
||||||
} catch (IllegalArgumentException expected) { }
|
} catch (IllegalArgumentException expected) { }
|
||||||
}
|
}
|
||||||
@@ -354,14 +351,13 @@ public class LinkAddressTest {
|
|||||||
public void testExpirationTime() {
|
public void testExpirationTime() {
|
||||||
try {
|
try {
|
||||||
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
||||||
SystemClock.elapsedRealtime() + 200000,
|
200000L, LinkAddress.LIFETIME_UNKNOWN);
|
||||||
LinkAddress.LIFETIME_UNKNOWN);
|
|
||||||
fail("Only one time provided should cause exception");
|
fail("Only one time provided should cause exception");
|
||||||
} catch (IllegalArgumentException expected) { }
|
} catch (IllegalArgumentException expected) { }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
new LinkAddress(V6_ADDRESS, 64, 0, 456,
|
||||||
SystemClock.elapsedRealtime() - 10000, -2);
|
100000L, -2);
|
||||||
fail("negative expiration time should cause exception");
|
fail("negative expiration time should cause exception");
|
||||||
} catch (IllegalArgumentException expected) { }
|
} catch (IllegalArgumentException expected) { }
|
||||||
}
|
}
|
||||||
@@ -374,12 +370,12 @@ public class LinkAddressTest {
|
|||||||
// Test if deprecated bit was added/remove automatically based on the provided deprecation
|
// Test if deprecated bit was added/remove automatically based on the provided deprecation
|
||||||
// time
|
// time
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, 0, RT_SCOPE_HOST,
|
l = new LinkAddress(V6_ADDRESS, 64, 0, RT_SCOPE_HOST,
|
||||||
SystemClock.elapsedRealtime() - 100000, LinkAddress.LIFETIME_PERMANENT);
|
1L, LinkAddress.LIFETIME_PERMANENT);
|
||||||
// Check if the flag is added automatically.
|
// Check if the flag is added automatically.
|
||||||
assertTrue((l.getFlags() & IFA_F_DEPRECATED) != 0);
|
assertTrue((l.getFlags() & IFA_F_DEPRECATED) != 0);
|
||||||
|
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, IFA_F_DEPRECATED, RT_SCOPE_HOST,
|
l = new LinkAddress(V6_ADDRESS, 64, IFA_F_DEPRECATED, RT_SCOPE_HOST,
|
||||||
SystemClock.elapsedRealtime() + 100000, LinkAddress.LIFETIME_PERMANENT);
|
SystemClock.elapsedRealtime() + 100000L, LinkAddress.LIFETIME_PERMANENT);
|
||||||
// Check if the flag is removed automatically.
|
// Check if the flag is removed automatically.
|
||||||
assertTrue((l.getFlags() & IFA_F_DEPRECATED) == 0);
|
assertTrue((l.getFlags() & IFA_F_DEPRECATED) == 0);
|
||||||
|
|
||||||
@@ -389,12 +385,10 @@ public class LinkAddressTest {
|
|||||||
assertTrue((l.getFlags() & IFA_F_PERMANENT) != 0);
|
assertTrue((l.getFlags() & IFA_F_PERMANENT) != 0);
|
||||||
|
|
||||||
l = new LinkAddress(V6_ADDRESS, 64, IFA_F_PERMANENT, RT_SCOPE_HOST,
|
l = new LinkAddress(V6_ADDRESS, 64, IFA_F_PERMANENT, RT_SCOPE_HOST,
|
||||||
SystemClock.elapsedRealtime() - 100000,
|
1000L, SystemClock.elapsedRealtime() + 100000L);
|
||||||
SystemClock.elapsedRealtime() + 100000);
|
|
||||||
// Check if the permanent flag is removed
|
// Check if the permanent flag is removed
|
||||||
assertTrue((l.getFlags() & IFA_F_PERMANENT) == 0);
|
assertTrue((l.getFlags() & IFA_F_PERMANENT) == 0);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
private void assertGlobalPreferred(LinkAddress l, String msg) {
|
private void assertGlobalPreferred(LinkAddress l, String msg) {
|
||||||
assertTrue(msg, l.isGlobalPreferred());
|
assertTrue(msg, l.isGlobalPreferred());
|
||||||
|
|||||||
Reference in New Issue
Block a user