OSDN Git Service

Refresh should always update the field
authorLucas Dupin <dupin@google.com>
Mon, 20 May 2019 16:29:31 +0000 (09:29 -0700)
committerLucas Dupin <dupin@google.com>
Mon, 20 May 2019 18:29:45 +0000 (11:29 -0700)
Otherwise it's hard to keep track of things happening or not, since
the request would be postponed, leading to bugs elsewhere.

Test: Wait for time to pass on lock screen
Test: Enter/leave AOD
Fixes: 132955195
Change-Id: I54f806f9dd2d1cf4acac420bab08d4579f867a5f

core/java/android/widget/TextClock.java

index 616c4b5..b7dd88b 100644 (file)
@@ -175,6 +175,9 @@ public class TextClock extends TextView {
             if (mTimeZone == null && Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
                 final String timeZone = intent.getStringExtra("time-zone");
                 createTime(timeZone);
+            } else if (!mShouldRunTicker && (Intent.ACTION_TIME_TICK.equals(intent.getAction())
+                    || Intent.ACTION_TIME_CHANGED.equals(intent.getAction()))) {
+                return;
             }
             onTimeChanged();
         }
@@ -642,12 +645,9 @@ public class TextClock extends TextView {
      */
     @UnsupportedAppUsage
     private void onTimeChanged() {
-        // mShouldRunTicker always equals the last value passed into onVisibilityAggregated
-        if (mShouldRunTicker) {
-            mTime.setTimeInMillis(System.currentTimeMillis());
-            setText(DateFormat.format(mFormat, mTime));
-            setContentDescription(DateFormat.format(mDescFormat, mTime));
-        }
+        mTime.setTimeInMillis(System.currentTimeMillis());
+        setText(DateFormat.format(mFormat, mTime));
+        setContentDescription(DateFormat.format(mDescFormat, mTime));
     }
 
     /** @hide */