summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Neil Fuller <nfuller@google.com> 2020-01-31 09:39:52 +0000
committer Neil Fuller <nfuller@google.com> 2020-01-31 17:06:33 +0000
commitd8da3387c44c1b702b399f46ff60d4b35be7992d (patch)
treef06529991ed9e7255aa79c47867383efbb5241c9
parent147863d9fc8c6b5790cb866ec31f34ebd70990dc (diff)
Rename phoneId to slotIndex
Rename phoneId to slotIndex. Some of the classes are being put in an API surface and phoneId is an internal concept. slotIndex is its replacement and should be identical. Bug: 148403082 Test: treehugger build only Change-Id: Iecbf347c9d13877f2e3f74b6daa22661bade257a
-rw-r--r--api/module-lib-current.txt4
-rw-r--r--core/java/android/app/timedetector/PhoneTimeSuggestion.java32
-rw-r--r--core/java/android/app/timezonedetector/PhoneTimeZoneSuggestion.java36
-rw-r--r--core/tests/coretests/src/android/app/timedetector/PhoneTimeSuggestionTest.java10
-rw-r--r--core/tests/coretests/src/android/app/timezonedetector/PhoneTimeZoneSuggestionTest.java14
-rw-r--r--services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java57
-rw-r--r--services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java31
7 files changed, 93 insertions, 91 deletions
diff --git a/api/module-lib-current.txt b/api/module-lib-current.txt
index c657e0049670..e8c3ac1e3081 100644
--- a/api/module-lib-current.txt
+++ b/api/module-lib-current.txt
@@ -6,7 +6,7 @@ package android.app.timedetector {
method public void addDebugInfo(@NonNull java.util.List<java.lang.String>);
method public int describeContents();
method @NonNull public java.util.List<java.lang.String> getDebugInfo();
- method public int getPhoneId();
+ method public int getSlotIndex();
method @Nullable public android.os.TimestampedValue<java.lang.Long> getUtcTime();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.timedetector.PhoneTimeSuggestion> CREATOR;
@@ -34,8 +34,8 @@ package android.app.timezonedetector {
method public int describeContents();
method @NonNull public java.util.List<java.lang.String> getDebugInfo();
method public int getMatchType();
- method public int getPhoneId();
method public int getQuality();
+ method public int getSlotIndex();
method @Nullable public String getZoneId();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.timezonedetector.PhoneTimeZoneSuggestion> CREATOR;
diff --git a/core/java/android/app/timedetector/PhoneTimeSuggestion.java b/core/java/android/app/timedetector/PhoneTimeSuggestion.java
index bd649f88f40a..eab88383fa1d 100644
--- a/core/java/android/app/timedetector/PhoneTimeSuggestion.java
+++ b/core/java/android/app/timedetector/PhoneTimeSuggestion.java
@@ -57,19 +57,19 @@ public final class PhoneTimeSuggestion implements Parcelable {
}
};
- private final int mPhoneId;
+ private final int mSlotIndex;
@Nullable private final TimestampedValue<Long> mUtcTime;
@Nullable private ArrayList<String> mDebugInfo;
private PhoneTimeSuggestion(Builder builder) {
- mPhoneId = builder.mPhoneId;
+ mSlotIndex = builder.mSlotIndex;
mUtcTime = builder.mUtcTime;
mDebugInfo = builder.mDebugInfo != null ? new ArrayList<>(builder.mDebugInfo) : null;
}
private static PhoneTimeSuggestion createFromParcel(Parcel in) {
- int phoneId = in.readInt();
- PhoneTimeSuggestion suggestion = new PhoneTimeSuggestion.Builder(phoneId)
+ int slotIndex = in.readInt();
+ PhoneTimeSuggestion suggestion = new PhoneTimeSuggestion.Builder(slotIndex)
.setUtcTime(in.readParcelable(null /* classLoader */))
.build();
@SuppressWarnings("unchecked")
@@ -87,17 +87,17 @@ public final class PhoneTimeSuggestion implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeInt(mPhoneId);
+ dest.writeInt(mSlotIndex);
dest.writeParcelable(mUtcTime, 0);
dest.writeList(mDebugInfo);
}
/**
- * Returns an identifier for the source of this suggestion. When a device has several "phones",
- * i.e. sim slots or equivalent, it is used to identify which one.
+ * Returns an identifier for the source of this suggestion. When a device has several sim slots
+ * or equivalent, it is used to identify which one the suggestion is from.
*/
- public int getPhoneId() {
- return mPhoneId;
+ public int getSlotIndex() {
+ return mSlotIndex;
}
/**
@@ -152,19 +152,19 @@ public final class PhoneTimeSuggestion implements Parcelable {
return false;
}
PhoneTimeSuggestion that = (PhoneTimeSuggestion) o;
- return mPhoneId == that.mPhoneId
+ return mSlotIndex == that.mSlotIndex
&& Objects.equals(mUtcTime, that.mUtcTime);
}
@Override
public int hashCode() {
- return Objects.hash(mPhoneId, mUtcTime);
+ return Objects.hash(mSlotIndex, mUtcTime);
}
@Override
public String toString() {
return "PhoneTimeSuggestion{"
- + "mPhoneId='" + mPhoneId + '\''
+ + "mSlotIndex='" + mSlotIndex + '\''
+ ", mUtcTime=" + mUtcTime
+ ", mDebugInfo=" + mDebugInfo
+ '}';
@@ -177,13 +177,13 @@ public final class PhoneTimeSuggestion implements Parcelable {
*/
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public static final class Builder {
- private final int mPhoneId;
+ private final int mSlotIndex;
@Nullable private TimestampedValue<Long> mUtcTime;
@Nullable private List<String> mDebugInfo;
- /** Creates a builder with the specified {@code phoneId}. */
- public Builder(int phoneId) {
- mPhoneId = phoneId;
+ /** Creates a builder with the specified {@code slotIndex}. */
+ public Builder(int slotIndex) {
+ mSlotIndex = slotIndex;
}
/** Returns the builder for call chaining. */
diff --git a/core/java/android/app/timezonedetector/PhoneTimeZoneSuggestion.java b/core/java/android/app/timezonedetector/PhoneTimeZoneSuggestion.java
index d71ffcb9f772..ebaf951130ca 100644
--- a/core/java/android/app/timezonedetector/PhoneTimeZoneSuggestion.java
+++ b/core/java/android/app/timezonedetector/PhoneTimeZoneSuggestion.java
@@ -66,12 +66,12 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
/**
* Creates an empty time zone suggestion, i.e. one that will cancel previous suggestions with
- * the same {@code phoneId}.
+ * the same {@code slotIndex}.
*/
@NonNull
public static PhoneTimeZoneSuggestion createEmptySuggestion(
- int phoneId, @NonNull String debugInfo) {
- return new Builder(phoneId).addDebugInfo(debugInfo).build();
+ int slotIndex, @NonNull String debugInfo) {
+ return new Builder(slotIndex).addDebugInfo(debugInfo).build();
}
/** @hide */
@@ -135,7 +135,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
* The ID of the phone this suggestion is associated with. For multiple-sim devices this
* helps to establish source so filtering / stickiness can be implemented.
*/
- private final int mPhoneId;
+ private final int mSlotIndex;
/**
* The suggestion. {@code null} means there is no current suggestion and any previous suggestion
@@ -165,7 +165,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
private List<String> mDebugInfo;
private PhoneTimeZoneSuggestion(Builder builder) {
- mPhoneId = builder.mPhoneId;
+ mSlotIndex = builder.mSlotIndex;
mZoneId = builder.mZoneId;
mMatchType = builder.mMatchType;
mQuality = builder.mQuality;
@@ -175,8 +175,8 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
@SuppressWarnings("unchecked")
private static PhoneTimeZoneSuggestion createFromParcel(Parcel in) {
// Use the Builder so we get validation during build().
- int phoneId = in.readInt();
- PhoneTimeZoneSuggestion suggestion = new Builder(phoneId)
+ int slotIndex = in.readInt();
+ PhoneTimeZoneSuggestion suggestion = new Builder(slotIndex)
.setZoneId(in.readString())
.setMatchType(in.readInt())
.setQuality(in.readInt())
@@ -190,7 +190,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
- dest.writeInt(mPhoneId);
+ dest.writeInt(mSlotIndex);
dest.writeString(mZoneId);
dest.writeInt(mMatchType);
dest.writeInt(mQuality);
@@ -203,11 +203,11 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
}
/**
- * Returns an identifier for the source of this suggestion. When a device has several "phones",
- * i.e. sim slots or equivalent, it is used to identify which one.
+ * Returns an identifier for the source of this suggestion. When a device has several sim slots
+ * or equivalent, it is used to identify which one the suggestion is from.
*/
- public int getPhoneId() {
- return mPhoneId;
+ public int getSlotIndex() {
+ return mSlotIndex;
}
/**
@@ -282,7 +282,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
return false;
}
PhoneTimeZoneSuggestion that = (PhoneTimeZoneSuggestion) o;
- return mPhoneId == that.mPhoneId
+ return mSlotIndex == that.mSlotIndex
&& mMatchType == that.mMatchType
&& mQuality == that.mQuality
&& Objects.equals(mZoneId, that.mZoneId);
@@ -290,13 +290,13 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
@Override
public int hashCode() {
- return Objects.hash(mPhoneId, mZoneId, mMatchType, mQuality);
+ return Objects.hash(mSlotIndex, mZoneId, mMatchType, mQuality);
}
@Override
public String toString() {
return "PhoneTimeZoneSuggestion{"
- + "mPhoneId=" + mPhoneId
+ + "mSlotIndex=" + mSlotIndex
+ ", mZoneId='" + mZoneId + '\''
+ ", mMatchType=" + mMatchType
+ ", mQuality=" + mQuality
@@ -311,14 +311,14 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
*/
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
public static final class Builder {
- private final int mPhoneId;
+ private final int mSlotIndex;
@Nullable private String mZoneId;
@MatchType private int mMatchType;
@Quality private int mQuality;
@Nullable private List<String> mDebugInfo;
- public Builder(int phoneId) {
- mPhoneId = phoneId;
+ public Builder(int slotIndex) {
+ mSlotIndex = slotIndex;
}
/**
diff --git a/core/tests/coretests/src/android/app/timedetector/PhoneTimeSuggestionTest.java b/core/tests/coretests/src/android/app/timedetector/PhoneTimeSuggestionTest.java
index ba29a97b55ab..d17b63597a21 100644
--- a/core/tests/coretests/src/android/app/timedetector/PhoneTimeSuggestionTest.java
+++ b/core/tests/coretests/src/android/app/timedetector/PhoneTimeSuggestionTest.java
@@ -27,17 +27,17 @@ import android.os.TimestampedValue;
import org.junit.Test;
public class PhoneTimeSuggestionTest {
- private static final int PHONE_ID = 99999;
+ private static final int SLOT_INDEX = 99999;
@Test
public void testEquals() {
- PhoneTimeSuggestion.Builder builder1 = new PhoneTimeSuggestion.Builder(PHONE_ID);
+ PhoneTimeSuggestion.Builder builder1 = new PhoneTimeSuggestion.Builder(SLOT_INDEX);
{
PhoneTimeSuggestion one = builder1.build();
assertEquals(one, one);
}
- PhoneTimeSuggestion.Builder builder2 = new PhoneTimeSuggestion.Builder(PHONE_ID);
+ PhoneTimeSuggestion.Builder builder2 = new PhoneTimeSuggestion.Builder(SLOT_INDEX);
{
PhoneTimeSuggestion one = builder1.build();
PhoneTimeSuggestion two = builder2.build();
@@ -59,7 +59,7 @@ public class PhoneTimeSuggestionTest {
assertEquals(two, one);
}
- PhoneTimeSuggestion.Builder builder3 = new PhoneTimeSuggestion.Builder(PHONE_ID + 1);
+ PhoneTimeSuggestion.Builder builder3 = new PhoneTimeSuggestion.Builder(SLOT_INDEX + 1);
builder3.setUtcTime(new TimestampedValue<>(1111L, 2222L));
{
PhoneTimeSuggestion one = builder1.build();
@@ -80,7 +80,7 @@ public class PhoneTimeSuggestionTest {
@Test
public void testParcelable() {
- PhoneTimeSuggestion.Builder builder = new PhoneTimeSuggestion.Builder(PHONE_ID);
+ PhoneTimeSuggestion.Builder builder = new PhoneTimeSuggestion.Builder(SLOT_INDEX);
assertRoundTripParcelable(builder.build());
builder.setUtcTime(new TimestampedValue<>(1111L, 2222L));
diff --git a/core/tests/coretests/src/android/app/timezonedetector/PhoneTimeZoneSuggestionTest.java b/core/tests/coretests/src/android/app/timezonedetector/PhoneTimeZoneSuggestionTest.java
index 0108a0bbab47..384dbf9fab07 100644
--- a/core/tests/coretests/src/android/app/timezonedetector/PhoneTimeZoneSuggestionTest.java
+++ b/core/tests/coretests/src/android/app/timezonedetector/PhoneTimeZoneSuggestionTest.java
@@ -26,17 +26,17 @@ import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class PhoneTimeZoneSuggestionTest {
- private static final int PHONE_ID = 99999;
+ private static final int SLOT_INDEX = 99999;
@Test
public void testEquals() {
- PhoneTimeZoneSuggestion.Builder builder1 = new PhoneTimeZoneSuggestion.Builder(PHONE_ID);
+ PhoneTimeZoneSuggestion.Builder builder1 = new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX);
{
PhoneTimeZoneSuggestion one = builder1.build();
assertEquals(one, one);
}
- PhoneTimeZoneSuggestion.Builder builder2 = new PhoneTimeZoneSuggestion.Builder(PHONE_ID);
+ PhoneTimeZoneSuggestion.Builder builder2 = new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX);
{
PhoneTimeZoneSuggestion one = builder1.build();
PhoneTimeZoneSuggestion two = builder2.build();
@@ -45,7 +45,7 @@ public class PhoneTimeZoneSuggestionTest {
}
PhoneTimeZoneSuggestion.Builder builder3 =
- new PhoneTimeZoneSuggestion.Builder(PHONE_ID + 1);
+ new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX + 1);
{
PhoneTimeZoneSuggestion one = builder1.build();
PhoneTimeZoneSuggestion three = builder3.build();
@@ -120,7 +120,7 @@ public class PhoneTimeZoneSuggestionTest {
@Test(expected = RuntimeException.class)
public void testBuilderValidates_emptyZone_badMatchType() {
- PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(PHONE_ID);
+ PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX);
// No zone ID, so match type should be left unset.
builder.setMatchType(PhoneTimeZoneSuggestion.MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET);
builder.build();
@@ -128,7 +128,7 @@ public class PhoneTimeZoneSuggestionTest {
@Test(expected = RuntimeException.class)
public void testBuilderValidates_zoneSet_badMatchType() {
- PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(PHONE_ID);
+ PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX);
builder.setZoneId("Europe/London");
builder.setQuality(PhoneTimeZoneSuggestion.QUALITY_SINGLE_ZONE);
builder.build();
@@ -136,7 +136,7 @@ public class PhoneTimeZoneSuggestionTest {
@Test
public void testParcelable() {
- PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(PHONE_ID);
+ PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX);
assertRoundTripParcelable(builder.build());
builder.setZoneId("Europe/London");
diff --git a/services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java b/services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java
index e95fc4a4a938..a1e643f15a8e 100644
--- a/services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java
+++ b/services/core/java/com/android/server/timedetector/TimeDetectorStrategyImpl.java
@@ -101,11 +101,12 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
private TimestampedValue<Long> mLastAutoSystemClockTimeSet;
/**
- * A mapping from phoneId to a time suggestion. We typically expect one or two mappings: devices
- * will have a small number of telephony devices and phoneIds are assumed to be stable.
+ * A mapping from slotIndex to a time suggestion. We typically expect one or two mappings:
+ * devices will have a small number of telephony devices and slotIndexs are assumed to be
+ * stable.
*/
@GuardedBy("this")
- private final ArrayMapWithHistory<Integer, PhoneTimeSuggestion> mSuggestionByPhoneId =
+ private final ArrayMapWithHistory<Integer, PhoneTimeSuggestion> mSuggestionBySlotIndex =
new ArrayMapWithHistory<>(KEEP_SUGGESTION_HISTORY_SIZE);
@GuardedBy("this")
@@ -155,7 +156,7 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
}
// Perform validation / input filtering and record the validated suggestion against the
- // phoneId.
+ // slotIndex.
if (!validateAndStorePhoneSuggestion(timeSuggestion)) {
return;
}
@@ -202,7 +203,7 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
ipw.println("Phone suggestion history:");
ipw.increaseIndent(); // level 2
- mSuggestionByPhoneId.dump(ipw);
+ mSuggestionBySlotIndex.dump(ipw);
ipw.decreaseIndent(); // level 2
ipw.println("Network suggestion history:");
@@ -223,8 +224,8 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
return false;
}
- int phoneId = suggestion.getPhoneId();
- PhoneTimeSuggestion previousSuggestion = mSuggestionByPhoneId.get(phoneId);
+ int slotIndex = suggestion.getSlotIndex();
+ PhoneTimeSuggestion previousSuggestion = mSuggestionBySlotIndex.get(slotIndex);
if (previousSuggestion != null) {
// We can log / discard suggestions with obvious issues with the reference time clock.
if (previousSuggestion.getUtcTime() == null
@@ -249,7 +250,7 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
}
// Store the latest suggestion.
- mSuggestionByPhoneId.put(phoneId, suggestion);
+ mSuggestionBySlotIndex.put(slotIndex, suggestion);
return true;
}
@@ -323,15 +324,15 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
//
// [1] https://en.wikipedia.org/wiki/NITZ
//
- // Generally, when there are suggestions from multiple phoneIds they should usually
+ // Generally, when there are suggestions from multiple slotIndexs they should usually
// approximately agree. In cases where signals *are* inaccurate we don't want to vacillate
- // between signals from two phoneIds. However, it is known for NITZ signals to be incorrect
- // occasionally, which means we also don't want to stick forever with one phoneId. Without
- // cross-referencing across sources (e.g. the current device time, NTP), or doing some kind
- // of statistical analysis of consistency within and across phoneIds, we can't know which
- // suggestions are more correct.
+ // between signals from two slotIndexs. However, it is known for NITZ signals to be
+ // incorrect occasionally, which means we also don't want to stick forever with one
+ // slotIndex. Without cross-referencing across sources (e.g. the current device time, NTP),
+ // or doing some kind of statistical analysis of consistency within and across slotIndexs,
+ // we can't know which suggestions are more correct.
//
- // For simplicity, we try to value recency, then consistency of phoneId.
+ // For simplicity, we try to value recency, then consistency of slotIndex.
//
// The heuristic works as follows:
// Recency: The most recent suggestion from each phone is scored. The score is based on a
@@ -339,20 +340,20 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
// bucket, thus applying a loose reference time ordering. The suggestion with the highest
// score is used.
// Consistency: If there a multiple suggestions with the same score, the suggestion with the
- // lowest phoneId is always taken.
+ // lowest slotIndex is always taken.
//
// In the trivial case with a single ID this will just mean that the latest received
// suggestion is used.
PhoneTimeSuggestion bestSuggestion = null;
int bestScore = PHONE_INVALID_SCORE;
- for (int i = 0; i < mSuggestionByPhoneId.size(); i++) {
- Integer phoneId = mSuggestionByPhoneId.keyAt(i);
- PhoneTimeSuggestion candidateSuggestion = mSuggestionByPhoneId.valueAt(i);
+ for (int i = 0; i < mSuggestionBySlotIndex.size(); i++) {
+ Integer slotIndex = mSuggestionBySlotIndex.keyAt(i);
+ PhoneTimeSuggestion candidateSuggestion = mSuggestionBySlotIndex.valueAt(i);
if (candidateSuggestion == null) {
// Unexpected - null suggestions should never be stored.
- Slog.w(LOG_TAG, "Latest suggestion unexpectedly null for phoneId."
- + " phoneId=" + phoneId);
+ Slog.w(LOG_TAG, "Latest suggestion unexpectedly null for slotIndex."
+ + " slotIndex=" + slotIndex);
continue;
} else if (candidateSuggestion.getUtcTime() == null) {
// Unexpected - we do not store empty suggestions.
@@ -372,10 +373,10 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
bestSuggestion = candidateSuggestion;
bestScore = candidateScore;
} else if (bestScore == candidateScore) {
- // Tie! Use the suggestion with the lowest phoneId.
- int candidatePhoneId = candidateSuggestion.getPhoneId();
- int bestPhoneId = bestSuggestion.getPhoneId();
- if (candidatePhoneId < bestPhoneId) {
+ // Tie! Use the suggestion with the lowest slotIndex.
+ int candidateSlotIndex = candidateSuggestion.getSlotIndex();
+ int bestSlotIndex = bestSuggestion.getSlotIndex();
+ if (candidateSlotIndex < bestSlotIndex) {
bestSuggestion = candidateSuggestion;
}
}
@@ -396,7 +397,7 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
}
// The score is based on the age since receipt. Suggestions are bucketed so two
- // suggestions in the same bucket from different phoneIds are scored the same.
+ // suggestions in the same bucket from different slotIndexs are scored the same.
long ageMillis = elapsedRealtimeMillis - utcTime.getReferenceTimeMillis();
// Turn the age into a discrete value: 0 <= bucketIndex < PHONE_BUCKET_COUNT.
@@ -560,8 +561,8 @@ public final class TimeDetectorStrategyImpl implements TimeDetectorStrategy {
*/
@VisibleForTesting
@Nullable
- public synchronized PhoneTimeSuggestion getLatestPhoneSuggestion(int phoneId) {
- return mSuggestionByPhoneId.get(phoneId);
+ public synchronized PhoneTimeSuggestion getLatestPhoneSuggestion(int slotIndex) {
+ return mSuggestionBySlotIndex.get(slotIndex);
}
/**
diff --git a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java
index b4a439991dd9..b0e006908231 100644
--- a/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java
+++ b/services/core/java/com/android/server/timezonedetector/TimeZoneDetectorStrategy.java
@@ -172,12 +172,12 @@ public class TimeZoneDetectorStrategy {
private final LocalLog mTimeZoneChangesLog = new LocalLog(30, false /* useLocalTimestamps */);
/**
- * A mapping from phoneId to a phone time zone suggestion. We typically expect one or two
- * mappings: devices will have a small number of telephony devices and phoneIds are assumed to
+ * A mapping from slotIndex to a phone time zone suggestion. We typically expect one or two
+ * mappings: devices will have a small number of telephony devices and slotIndexs are assumed to
* be stable.
*/
@GuardedBy("this")
- private ArrayMapWithHistory<Integer, QualifiedPhoneTimeZoneSuggestion> mSuggestionByPhoneId =
+ private ArrayMapWithHistory<Integer, QualifiedPhoneTimeZoneSuggestion> mSuggestionBySlotIndex =
new ArrayMapWithHistory<>(KEEP_PHONE_SUGGESTION_HISTORY_SIZE);
/**
@@ -205,7 +205,7 @@ public class TimeZoneDetectorStrategy {
/**
* Suggests a time zone for the device, or withdraws a previous suggestion if
* {@link PhoneTimeZoneSuggestion#getZoneId()} is {@code null}. The suggestion is scoped to a
- * specific {@link PhoneTimeZoneSuggestion#getPhoneId() phone}.
+ * specific {@link PhoneTimeZoneSuggestion#getSlotIndex() phone}.
* See {@link PhoneTimeZoneSuggestion} for an explanation of the metadata associated with a
* suggestion. The strategy uses suggestions to decide whether to modify the device's time zone
* setting and what to set it to.
@@ -221,8 +221,8 @@ public class TimeZoneDetectorStrategy {
QualifiedPhoneTimeZoneSuggestion scoredSuggestion =
new QualifiedPhoneTimeZoneSuggestion(suggestion, score);
- // Store the suggestion against the correct phoneId.
- mSuggestionByPhoneId.put(suggestion.getPhoneId(), scoredSuggestion);
+ // Store the suggestion against the correct slotIndex.
+ mSuggestionBySlotIndex.put(suggestion.getSlotIndex(), scoredSuggestion);
// Now perform auto time zone detection. The new suggestion may be used to modify the time
// zone setting.
@@ -384,8 +384,9 @@ public class TimeZoneDetectorStrategy {
// and find the best. Note that we deliberately do not look at age: the caller can
// rate-limit so age is not a strong indicator of confidence. Instead, the callers are
// expected to withdraw suggestions they no longer have confidence in.
- for (int i = 0; i < mSuggestionByPhoneId.size(); i++) {
- QualifiedPhoneTimeZoneSuggestion candidateSuggestion = mSuggestionByPhoneId.valueAt(i);
+ for (int i = 0; i < mSuggestionBySlotIndex.size(); i++) {
+ QualifiedPhoneTimeZoneSuggestion candidateSuggestion =
+ mSuggestionBySlotIndex.valueAt(i);
if (candidateSuggestion == null) {
// Unexpected
continue;
@@ -396,10 +397,10 @@ public class TimeZoneDetectorStrategy {
} else if (candidateSuggestion.score > bestSuggestion.score) {
bestSuggestion = candidateSuggestion;
} else if (candidateSuggestion.score == bestSuggestion.score) {
- // Tie! Use the suggestion with the lowest phoneId.
- int candidatePhoneId = candidateSuggestion.suggestion.getPhoneId();
- int bestPhoneId = bestSuggestion.suggestion.getPhoneId();
- if (candidatePhoneId < bestPhoneId) {
+ // Tie! Use the suggestion with the lowest slotIndex.
+ int candidateSlotIndex = candidateSuggestion.suggestion.getSlotIndex();
+ int bestSlotIndex = bestSuggestion.suggestion.getSlotIndex();
+ if (candidateSlotIndex < bestSlotIndex) {
bestSuggestion = candidateSuggestion;
}
}
@@ -455,7 +456,7 @@ public class TimeZoneDetectorStrategy {
ipw.println("Phone suggestion history:");
ipw.increaseIndent(); // level 2
- mSuggestionByPhoneId.dump(ipw);
+ mSuggestionBySlotIndex.dump(ipw);
ipw.decreaseIndent(); // level 2
ipw.decreaseIndent(); // level 1
ipw.flush();
@@ -465,8 +466,8 @@ public class TimeZoneDetectorStrategy {
* A method used to inspect strategy state during tests. Not intended for general use.
*/
@VisibleForTesting
- public synchronized QualifiedPhoneTimeZoneSuggestion getLatestPhoneSuggestion(int phoneId) {
- return mSuggestionByPhoneId.get(phoneId);
+ public synchronized QualifiedPhoneTimeZoneSuggestion getLatestPhoneSuggestion(int slotIndex) {
+ return mSuggestionBySlotIndex.get(slotIndex);
}
/**