Handle multiple phoneIds in time detection

Android has dual sim devices, which means multiple "phone" time
signals. NITZ is generally trusted and considered "good enough" in the
absence of better signals, but it is provided by carriers and it's not
unusual for the signals to be incorrect by minutes. We don't want the
device system clock just flicking to the latest signal received.

The changes to the SimpleTimeDetectorStrategy try to balance recency and
provide some consistency / determinism. See comments in the code for
details. The time zone detection works in a similar way, particularly
with respect to choosing the lowest phoneId in the event of a tie.

There will be a follow-up change to remove the word "Simple" from
SimpleTimeDetectorStrategy as it no longer applies.

Test: atest services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeDetectorStrategyTest.java
Test: atest android.app.timedetector
Bug: 140712361
Change-Id: I228aff8709eabfcec910af22f7ab08fee32d566a
diff --git a/core/java/android/app/timedetector/PhoneTimeSuggestion.java b/core/java/android/app/timedetector/PhoneTimeSuggestion.java
index dd02af7..4a89a12 100644
--- a/core/java/android/app/timedetector/PhoneTimeSuggestion.java
+++ b/core/java/android/app/timedetector/PhoneTimeSuggestion.java
@@ -166,7 +166,12 @@
         }
 
         /** Returns the builder for call chaining. */
-        public Builder setUtcTime(TimestampedValue<Long> utcTime) {
+        public Builder setUtcTime(@Nullable TimestampedValue<Long> utcTime) {
+            if (utcTime != null) {
+                // utcTime can be null, but the value it holds cannot.
+                Objects.requireNonNull(utcTime.getValue());
+            }
+
             mUtcTime = utcTime;
             return this;
         }