Loading core/java/android/net/LinkAddress.java +21 −14 Original line number Diff line number Diff line Loading @@ -102,9 +102,9 @@ public class LinkAddress implements Parcelable { /** * 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 * the time existing connections can still use this address until it expires, but new * connections should use the new address. {@link #LIFETIME_PERMANENT} indicates this * or was deprecated. At the time existing connections can still use this address until it * expires, but new connections should use the new address. {@link #LIFETIME_UNKNOWN} indicates * this information is not available. {@link #LIFETIME_PERMANENT} indicates this * {@link LinkAddress} will never be deprecated. */ private long deprecationTime; Loading Loading @@ -261,10 +261,10 @@ public class LinkAddress implements Parcelable { * @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}). * @param deprecationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when * this {@link LinkAddress} will be or was deprecated. * {@link #LIFETIME_UNKNOWN} indicates this information is not available. * At the time existing connections can still use this address until it * expires, but new connections should use the new address. * this {@link LinkAddress} will be or was deprecated. At the time * existing connections can still use this address until it expires, but * new connections should use the new address. {@link #LIFETIME_UNKNOWN} * indicates this information is not available. * {@link #LIFETIME_PERMANENT} indicates this {@link LinkAddress} will * never be deprecated. * @param expirationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when this Loading Loading @@ -441,7 +441,7 @@ public class LinkAddress implements Parcelable { if (expirationTime == LIFETIME_PERMANENT) { flags |= IFA_F_PERMANENT; } 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. flags &= ~IFA_F_PERMANENT; } Loading @@ -458,10 +458,13 @@ public class LinkAddress implements Parcelable { } /** * @return The time that this address will be deprecated. At the time the existing connection * can still use this address until it expires, but the new connection should use the new * address. This is the EPOCH time in milliseconds. 0 indicates this information is not * available. * Get the deprecation time, as reported by {@link SystemClock#elapsedRealtime}, when this * {@link LinkAddress} will be or was deprecated. At the time existing connections can still use * this address until it expires, but new connections should use the new address. * * @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 */ Loading @@ -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 * time in milliseconds. 0 indicates this information is not available. * Get the expiration time, as reported by {@link SystemClock#elapsedRealtime}, when this * {@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 */ Loading tests/net/common/java/android/net/LinkAddressTest.java +9 −15 Original line number Diff line number Diff line Loading @@ -326,26 +326,23 @@ public class LinkAddressTest { assertParcelSane(l, 6); } /* @Test public void testDeprecationTime() { try { new LinkAddress(V6_ADDRESS, 64, 0, 456, LinkAddress.LIFETIME_UNKNOWN, SystemClock.elapsedRealtime() + 200000); LinkAddress.LIFETIME_UNKNOWN, 100000L); fail("Only one time provided should cause exception"); } catch (IllegalArgumentException expected) { } try { new LinkAddress(V6_ADDRESS, 64, 0, 456, SystemClock.elapsedRealtime() - 100000, SystemClock.elapsedRealtime() - 200000); 200000L, 100000L); fail("deprecation time later than expiration time should cause exception"); } catch (IllegalArgumentException expected) { } try { new LinkAddress(V6_ADDRESS, 64, 0, 456, -2, SystemClock.elapsedRealtime()); -2, 100000L); fail("negative deprecation time should cause exception"); } catch (IllegalArgumentException expected) { } } Loading @@ -354,14 +351,13 @@ public class LinkAddressTest { public void testExpirationTime() { try { new LinkAddress(V6_ADDRESS, 64, 0, 456, SystemClock.elapsedRealtime() + 200000, LinkAddress.LIFETIME_UNKNOWN); 200000L, LinkAddress.LIFETIME_UNKNOWN); fail("Only one time provided should cause exception"); } catch (IllegalArgumentException expected) { } try { new LinkAddress(V6_ADDRESS, 64, 0, 456, SystemClock.elapsedRealtime() - 10000, -2); 100000L, -2); fail("negative expiration time should cause exception"); } catch (IllegalArgumentException expected) { } } Loading @@ -374,12 +370,12 @@ public class LinkAddressTest { // Test if deprecated bit was added/remove automatically based on the provided deprecation // time 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. assertTrue((l.getFlags() & IFA_F_DEPRECATED) != 0); 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. assertTrue((l.getFlags() & IFA_F_DEPRECATED) == 0); Loading @@ -389,12 +385,10 @@ public class LinkAddressTest { assertTrue((l.getFlags() & IFA_F_PERMANENT) != 0); l = new LinkAddress(V6_ADDRESS, 64, IFA_F_PERMANENT, RT_SCOPE_HOST, SystemClock.elapsedRealtime() - 100000, SystemClock.elapsedRealtime() + 100000); 1000L, SystemClock.elapsedRealtime() + 100000L); // Check if the permanent flag is removed assertTrue((l.getFlags() & IFA_F_PERMANENT) == 0); }*/ } private void assertGlobalPreferred(LinkAddress l, String msg) { assertTrue(msg, l.isGlobalPreferred()); Loading Loading
core/java/android/net/LinkAddress.java +21 −14 Original line number Diff line number Diff line Loading @@ -102,9 +102,9 @@ public class LinkAddress implements Parcelable { /** * 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 * the time existing connections can still use this address until it expires, but new * connections should use the new address. {@link #LIFETIME_PERMANENT} indicates this * or was deprecated. At the time existing connections can still use this address until it * expires, but new connections should use the new address. {@link #LIFETIME_UNKNOWN} indicates * this information is not available. {@link #LIFETIME_PERMANENT} indicates this * {@link LinkAddress} will never be deprecated. */ private long deprecationTime; Loading Loading @@ -261,10 +261,10 @@ public class LinkAddress implements Parcelable { * @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}). * @param deprecationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when * this {@link LinkAddress} will be or was deprecated. * {@link #LIFETIME_UNKNOWN} indicates this information is not available. * At the time existing connections can still use this address until it * expires, but new connections should use the new address. * this {@link LinkAddress} will be or was deprecated. At the time * existing connections can still use this address until it expires, but * new connections should use the new address. {@link #LIFETIME_UNKNOWN} * indicates this information is not available. * {@link #LIFETIME_PERMANENT} indicates this {@link LinkAddress} will * never be deprecated. * @param expirationTime The time, as reported by {@link SystemClock#elapsedRealtime}, when this Loading Loading @@ -441,7 +441,7 @@ public class LinkAddress implements Parcelable { if (expirationTime == LIFETIME_PERMANENT) { flags |= IFA_F_PERMANENT; } 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. flags &= ~IFA_F_PERMANENT; } Loading @@ -458,10 +458,13 @@ public class LinkAddress implements Parcelable { } /** * @return The time that this address will be deprecated. At the time the existing connection * can still use this address until it expires, but the new connection should use the new * address. This is the EPOCH time in milliseconds. 0 indicates this information is not * available. * Get the deprecation time, as reported by {@link SystemClock#elapsedRealtime}, when this * {@link LinkAddress} will be or was deprecated. At the time existing connections can still use * this address until it expires, but new connections should use the new address. * * @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 */ Loading @@ -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 * time in milliseconds. 0 indicates this information is not available. * Get the expiration time, as reported by {@link SystemClock#elapsedRealtime}, when this * {@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 */ Loading
tests/net/common/java/android/net/LinkAddressTest.java +9 −15 Original line number Diff line number Diff line Loading @@ -326,26 +326,23 @@ public class LinkAddressTest { assertParcelSane(l, 6); } /* @Test public void testDeprecationTime() { try { new LinkAddress(V6_ADDRESS, 64, 0, 456, LinkAddress.LIFETIME_UNKNOWN, SystemClock.elapsedRealtime() + 200000); LinkAddress.LIFETIME_UNKNOWN, 100000L); fail("Only one time provided should cause exception"); } catch (IllegalArgumentException expected) { } try { new LinkAddress(V6_ADDRESS, 64, 0, 456, SystemClock.elapsedRealtime() - 100000, SystemClock.elapsedRealtime() - 200000); 200000L, 100000L); fail("deprecation time later than expiration time should cause exception"); } catch (IllegalArgumentException expected) { } try { new LinkAddress(V6_ADDRESS, 64, 0, 456, -2, SystemClock.elapsedRealtime()); -2, 100000L); fail("negative deprecation time should cause exception"); } catch (IllegalArgumentException expected) { } } Loading @@ -354,14 +351,13 @@ public class LinkAddressTest { public void testExpirationTime() { try { new LinkAddress(V6_ADDRESS, 64, 0, 456, SystemClock.elapsedRealtime() + 200000, LinkAddress.LIFETIME_UNKNOWN); 200000L, LinkAddress.LIFETIME_UNKNOWN); fail("Only one time provided should cause exception"); } catch (IllegalArgumentException expected) { } try { new LinkAddress(V6_ADDRESS, 64, 0, 456, SystemClock.elapsedRealtime() - 10000, -2); 100000L, -2); fail("negative expiration time should cause exception"); } catch (IllegalArgumentException expected) { } } Loading @@ -374,12 +370,12 @@ public class LinkAddressTest { // Test if deprecated bit was added/remove automatically based on the provided deprecation // time 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. assertTrue((l.getFlags() & IFA_F_DEPRECATED) != 0); 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. assertTrue((l.getFlags() & IFA_F_DEPRECATED) == 0); Loading @@ -389,12 +385,10 @@ public class LinkAddressTest { assertTrue((l.getFlags() & IFA_F_PERMANENT) != 0); l = new LinkAddress(V6_ADDRESS, 64, IFA_F_PERMANENT, RT_SCOPE_HOST, SystemClock.elapsedRealtime() - 100000, SystemClock.elapsedRealtime() + 100000); 1000L, SystemClock.elapsedRealtime() + 100000L); // Check if the permanent flag is removed assertTrue((l.getFlags() & IFA_F_PERMANENT) == 0); }*/ } private void assertGlobalPreferred(LinkAddress l, String msg) { assertTrue(msg, l.isGlobalPreferred()); Loading