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 b67261b01c787392bb24a6fe3f067937e33a0d6a)
diff --git a/core/java/android/net/LinkAddress.java b/core/java/android/net/LinkAddress.java
index 8d9f0d0..a9d7f17 100644
--- a/core/java/android/net/LinkAddress.java
+++ b/core/java/android/net/LinkAddress.java
@@ -102,9 +102,9 @@
 
     /**
      * 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;
@@ -261,10 +261,10 @@
      * @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
@@ -441,7 +441,7 @@
         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;
         }
@@ -458,10 +458,13 @@
     }
 
     /**
-     * @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
      */
@@ -472,8 +475,12 @@
     }
 
     /**
-     * @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
      */
diff --git a/tests/net/common/java/android/net/LinkAddressTest.java b/tests/net/common/java/android/net/LinkAddressTest.java
index e566e44..06c6301 100644
--- a/tests/net/common/java/android/net/LinkAddressTest.java
+++ b/tests/net/common/java/android/net/LinkAddressTest.java
@@ -326,26 +326,23 @@
         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) { }
     }
@@ -354,14 +351,13 @@
     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) { }
     }
@@ -374,12 +370,12 @@
         // 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);
 
@@ -389,12 +385,10 @@
         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());