Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e540a1c authored by Neil Fuller's avatar Neil Fuller Committed by Gerrit Code Review
Browse files

Merge "Rename phoneId to slotIndex"

parents 6bf0c618 d8da3387
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;
+16 −16
Original line number Diff line number Diff line
@@ -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. */
+18 −18
Original line number Diff line number Diff line
@@ -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;
        }

        /**
+5 −5
Original line number Diff line number Diff line
@@ -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));
+7 −7
Original line number Diff line number Diff line
@@ -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");
Loading