Fix new notification showing timestamp "now" after turning off DND

DateTimeView won't update timestamp until the view is attached to
window and received TIME_TICK intent.

Update timestamp on onAttachedToWindow().

Test: manual 1) turn on DND 2) send a notification and wait some time 3)
turn off DND and check the timestamp
Fixes: 77970557

Change-Id: Ia8420aacf5b91b0bb9cbec561629ddbfc8de4f67
diff --git a/core/java/android/widget/DateTimeView.java b/core/java/android/widget/DateTimeView.java
index 4db3607..a22f345 100644
--- a/core/java/android/widget/DateTimeView.java
+++ b/core/java/android/widget/DateTimeView.java
@@ -104,8 +104,16 @@
             sReceiverInfo.set(ri);
         }
         ri.addView(this);
+        // The view may not be added to the view hierarchy immediately right after setTime()
+        // is called which means it won't get any update from intents before being added.
+        // In such case, the view might show the incorrect relative time after being added to the
+        // view hierarchy until the next update intent comes.
+        // So we update the time here if mShowRelativeTime is enabled to prevent this case.
+        if (mShowRelativeTime) {
+            update();
+        }
     }
-        
+
     @Override
     protected void onDetachedFromWindow() {
         super.onDetachedFromWindow();