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

Commit d0045fbf authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Rename phoneId to slotIndex" am: 4e540a1c

Change-Id: If220028441547c85c3540c52af9f714a15853b3a
parents 4b9770b9 4e540a1c
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line 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 void addDebugInfo(@NonNull java.util.List<java.lang.String>);
    method public int describeContents();
    method public int describeContents();
    method @NonNull public java.util.List<java.lang.String> getDebugInfo();
    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 @Nullable public android.os.TimestampedValue<java.lang.Long> getUtcTime();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.timedetector.PhoneTimeSuggestion> CREATOR;
    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 public int describeContents();
    method @NonNull public java.util.List<java.lang.String> getDebugInfo();
    method @NonNull public java.util.List<java.lang.String> getDebugInfo();
    method public int getMatchType();
    method public int getMatchType();
    method public int getPhoneId();
    method public int getQuality();
    method public int getQuality();
    method public int getSlotIndex();
    method @Nullable public String getZoneId();
    method @Nullable public String getZoneId();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.timezonedetector.PhoneTimeZoneSuggestion> CREATOR;
    field @NonNull public static final android.os.Parcelable.Creator<android.app.timezonedetector.PhoneTimeZoneSuggestion> CREATOR;
+16 −16
Original line number Original line 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 final TimestampedValue<Long> mUtcTime;
    @Nullable private ArrayList<String> mDebugInfo;
    @Nullable private ArrayList<String> mDebugInfo;


    private PhoneTimeSuggestion(Builder builder) {
    private PhoneTimeSuggestion(Builder builder) {
        mPhoneId = builder.mPhoneId;
        mSlotIndex = builder.mSlotIndex;
        mUtcTime = builder.mUtcTime;
        mUtcTime = builder.mUtcTime;
        mDebugInfo = builder.mDebugInfo != null ? new ArrayList<>(builder.mDebugInfo) : null;
        mDebugInfo = builder.mDebugInfo != null ? new ArrayList<>(builder.mDebugInfo) : null;
    }
    }


    private static PhoneTimeSuggestion createFromParcel(Parcel in) {
    private static PhoneTimeSuggestion createFromParcel(Parcel in) {
        int phoneId = in.readInt();
        int slotIndex = in.readInt();
        PhoneTimeSuggestion suggestion = new PhoneTimeSuggestion.Builder(phoneId)
        PhoneTimeSuggestion suggestion = new PhoneTimeSuggestion.Builder(slotIndex)
                .setUtcTime(in.readParcelable(null /* classLoader */))
                .setUtcTime(in.readParcelable(null /* classLoader */))
                .build();
                .build();
        @SuppressWarnings("unchecked")
        @SuppressWarnings("unchecked")
@@ -87,17 +87,17 @@ public final class PhoneTimeSuggestion implements Parcelable {


    @Override
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mPhoneId);
        dest.writeInt(mSlotIndex);
        dest.writeParcelable(mUtcTime, 0);
        dest.writeParcelable(mUtcTime, 0);
        dest.writeList(mDebugInfo);
        dest.writeList(mDebugInfo);
    }
    }


    /**
    /**
     * Returns an identifier for the source of this suggestion. When a device has several "phones",
     * Returns an identifier for the source of this suggestion. When a device has several sim slots
     * i.e. sim slots or equivalent, it is used to identify which one.
     * or equivalent, it is used to identify which one the suggestion is from.
     */
     */
    public int getPhoneId() {
    public int getSlotIndex() {
        return mPhoneId;
        return mSlotIndex;
    }
    }


    /**
    /**
@@ -152,19 +152,19 @@ public final class PhoneTimeSuggestion implements Parcelable {
            return false;
            return false;
        }
        }
        PhoneTimeSuggestion that = (PhoneTimeSuggestion) o;
        PhoneTimeSuggestion that = (PhoneTimeSuggestion) o;
        return mPhoneId == that.mPhoneId
        return mSlotIndex == that.mSlotIndex
                && Objects.equals(mUtcTime, that.mUtcTime);
                && Objects.equals(mUtcTime, that.mUtcTime);
    }
    }


    @Override
    @Override
    public int hashCode() {
    public int hashCode() {
        return Objects.hash(mPhoneId, mUtcTime);
        return Objects.hash(mSlotIndex, mUtcTime);
    }
    }


    @Override
    @Override
    public String toString() {
    public String toString() {
        return "PhoneTimeSuggestion{"
        return "PhoneTimeSuggestion{"
                + "mPhoneId='" + mPhoneId + '\''
                + "mSlotIndex='" + mSlotIndex + '\''
                + ", mUtcTime=" + mUtcTime
                + ", mUtcTime=" + mUtcTime
                + ", mDebugInfo=" + mDebugInfo
                + ", mDebugInfo=" + mDebugInfo
                + '}';
                + '}';
@@ -177,13 +177,13 @@ public final class PhoneTimeSuggestion implements Parcelable {
     */
     */
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    public static final class Builder {
    public static final class Builder {
        private final int mPhoneId;
        private final int mSlotIndex;
        @Nullable private TimestampedValue<Long> mUtcTime;
        @Nullable private TimestampedValue<Long> mUtcTime;
        @Nullable private List<String> mDebugInfo;
        @Nullable private List<String> mDebugInfo;


        /** Creates a builder with the specified {@code phoneId}. */
        /** Creates a builder with the specified {@code slotIndex}. */
        public Builder(int phoneId) {
        public Builder(int slotIndex) {
            mPhoneId = phoneId;
            mSlotIndex = slotIndex;
        }
        }


        /** Returns the builder for call chaining. */
        /** Returns the builder for call chaining. */
+18 −18
Original line number Original line 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
     * Creates an empty time zone suggestion, i.e. one that will cancel previous suggestions with
     * the same {@code phoneId}.
     * the same {@code slotIndex}.
     */
     */
    @NonNull
    @NonNull
    public static PhoneTimeZoneSuggestion createEmptySuggestion(
    public static PhoneTimeZoneSuggestion createEmptySuggestion(
            int phoneId, @NonNull String debugInfo) {
            int slotIndex, @NonNull String debugInfo) {
        return new Builder(phoneId).addDebugInfo(debugInfo).build();
        return new Builder(slotIndex).addDebugInfo(debugInfo).build();
    }
    }


    /** @hide */
    /** @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
     * 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.
     * 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
     * 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 List<String> mDebugInfo;


    private PhoneTimeZoneSuggestion(Builder builder) {
    private PhoneTimeZoneSuggestion(Builder builder) {
        mPhoneId = builder.mPhoneId;
        mSlotIndex = builder.mSlotIndex;
        mZoneId = builder.mZoneId;
        mZoneId = builder.mZoneId;
        mMatchType = builder.mMatchType;
        mMatchType = builder.mMatchType;
        mQuality = builder.mQuality;
        mQuality = builder.mQuality;
@@ -175,8 +175,8 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
    @SuppressWarnings("unchecked")
    @SuppressWarnings("unchecked")
    private static PhoneTimeZoneSuggestion createFromParcel(Parcel in) {
    private static PhoneTimeZoneSuggestion createFromParcel(Parcel in) {
        // Use the Builder so we get validation during build().
        // Use the Builder so we get validation during build().
        int phoneId = in.readInt();
        int slotIndex = in.readInt();
        PhoneTimeZoneSuggestion suggestion = new Builder(phoneId)
        PhoneTimeZoneSuggestion suggestion = new Builder(slotIndex)
                .setZoneId(in.readString())
                .setZoneId(in.readString())
                .setMatchType(in.readInt())
                .setMatchType(in.readInt())
                .setQuality(in.readInt())
                .setQuality(in.readInt())
@@ -190,7 +190,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {


    @Override
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(mPhoneId);
        dest.writeInt(mSlotIndex);
        dest.writeString(mZoneId);
        dest.writeString(mZoneId);
        dest.writeInt(mMatchType);
        dest.writeInt(mMatchType);
        dest.writeInt(mQuality);
        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",
     * Returns an identifier for the source of this suggestion. When a device has several sim slots
     * i.e. sim slots or equivalent, it is used to identify which one.
     * or equivalent, it is used to identify which one the suggestion is from.
     */
     */
    public int getPhoneId() {
    public int getSlotIndex() {
        return mPhoneId;
        return mSlotIndex;
    }
    }


    /**
    /**
@@ -282,7 +282,7 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
            return false;
            return false;
        }
        }
        PhoneTimeZoneSuggestion that = (PhoneTimeZoneSuggestion) o;
        PhoneTimeZoneSuggestion that = (PhoneTimeZoneSuggestion) o;
        return mPhoneId == that.mPhoneId
        return mSlotIndex == that.mSlotIndex
                && mMatchType == that.mMatchType
                && mMatchType == that.mMatchType
                && mQuality == that.mQuality
                && mQuality == that.mQuality
                && Objects.equals(mZoneId, that.mZoneId);
                && Objects.equals(mZoneId, that.mZoneId);
@@ -290,13 +290,13 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {


    @Override
    @Override
    public int hashCode() {
    public int hashCode() {
        return Objects.hash(mPhoneId, mZoneId, mMatchType, mQuality);
        return Objects.hash(mSlotIndex, mZoneId, mMatchType, mQuality);
    }
    }


    @Override
    @Override
    public String toString() {
    public String toString() {
        return "PhoneTimeZoneSuggestion{"
        return "PhoneTimeZoneSuggestion{"
                + "mPhoneId=" + mPhoneId
                + "mSlotIndex=" + mSlotIndex
                + ", mZoneId='" + mZoneId + '\''
                + ", mZoneId='" + mZoneId + '\''
                + ", mMatchType=" + mMatchType
                + ", mMatchType=" + mMatchType
                + ", mQuality=" + mQuality
                + ", mQuality=" + mQuality
@@ -311,14 +311,14 @@ public final class PhoneTimeZoneSuggestion implements Parcelable {
     */
     */
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
    public static final class Builder {
    public static final class Builder {
        private final int mPhoneId;
        private final int mSlotIndex;
        @Nullable private String mZoneId;
        @Nullable private String mZoneId;
        @MatchType private int mMatchType;
        @MatchType private int mMatchType;
        @Quality private int mQuality;
        @Quality private int mQuality;
        @Nullable private List<String> mDebugInfo;
        @Nullable private List<String> mDebugInfo;


        public Builder(int phoneId) {
        public Builder(int slotIndex) {
            mPhoneId = phoneId;
            mSlotIndex = slotIndex;
        }
        }


        /**
        /**
+5 −5
Original line number Original line Diff line number Diff line
@@ -27,17 +27,17 @@ import android.os.TimestampedValue;
import org.junit.Test;
import org.junit.Test;


public class PhoneTimeSuggestionTest {
public class PhoneTimeSuggestionTest {
    private static final int PHONE_ID = 99999;
    private static final int SLOT_INDEX = 99999;


    @Test
    @Test
    public void testEquals() {
    public void testEquals() {
        PhoneTimeSuggestion.Builder builder1 = new PhoneTimeSuggestion.Builder(PHONE_ID);
        PhoneTimeSuggestion.Builder builder1 = new PhoneTimeSuggestion.Builder(SLOT_INDEX);
        {
        {
            PhoneTimeSuggestion one = builder1.build();
            PhoneTimeSuggestion one = builder1.build();
            assertEquals(one, one);
            assertEquals(one, one);
        }
        }


        PhoneTimeSuggestion.Builder builder2 = new PhoneTimeSuggestion.Builder(PHONE_ID);
        PhoneTimeSuggestion.Builder builder2 = new PhoneTimeSuggestion.Builder(SLOT_INDEX);
        {
        {
            PhoneTimeSuggestion one = builder1.build();
            PhoneTimeSuggestion one = builder1.build();
            PhoneTimeSuggestion two = builder2.build();
            PhoneTimeSuggestion two = builder2.build();
@@ -59,7 +59,7 @@ public class PhoneTimeSuggestionTest {
            assertEquals(two, one);
            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));
        builder3.setUtcTime(new TimestampedValue<>(1111L, 2222L));
        {
        {
            PhoneTimeSuggestion one = builder1.build();
            PhoneTimeSuggestion one = builder1.build();
@@ -80,7 +80,7 @@ public class PhoneTimeSuggestionTest {


    @Test
    @Test
    public void testParcelable() {
    public void testParcelable() {
        PhoneTimeSuggestion.Builder builder = new PhoneTimeSuggestion.Builder(PHONE_ID);
        PhoneTimeSuggestion.Builder builder = new PhoneTimeSuggestion.Builder(SLOT_INDEX);
        assertRoundTripParcelable(builder.build());
        assertRoundTripParcelable(builder.build());


        builder.setUtcTime(new TimestampedValue<>(1111L, 2222L));
        builder.setUtcTime(new TimestampedValue<>(1111L, 2222L));
+7 −7
Original line number Original line Diff line number Diff line
@@ -26,17 +26,17 @@ import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.Test;


public class PhoneTimeZoneSuggestionTest {
public class PhoneTimeZoneSuggestionTest {
    private static final int PHONE_ID = 99999;
    private static final int SLOT_INDEX = 99999;


    @Test
    @Test
    public void testEquals() {
    public void testEquals() {
        PhoneTimeZoneSuggestion.Builder builder1 = new PhoneTimeZoneSuggestion.Builder(PHONE_ID);
        PhoneTimeZoneSuggestion.Builder builder1 = new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX);
        {
        {
            PhoneTimeZoneSuggestion one = builder1.build();
            PhoneTimeZoneSuggestion one = builder1.build();
            assertEquals(one, one);
            assertEquals(one, one);
        }
        }


        PhoneTimeZoneSuggestion.Builder builder2 = new PhoneTimeZoneSuggestion.Builder(PHONE_ID);
        PhoneTimeZoneSuggestion.Builder builder2 = new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX);
        {
        {
            PhoneTimeZoneSuggestion one = builder1.build();
            PhoneTimeZoneSuggestion one = builder1.build();
            PhoneTimeZoneSuggestion two = builder2.build();
            PhoneTimeZoneSuggestion two = builder2.build();
@@ -45,7 +45,7 @@ public class PhoneTimeZoneSuggestionTest {
        }
        }


        PhoneTimeZoneSuggestion.Builder builder3 =
        PhoneTimeZoneSuggestion.Builder builder3 =
                new PhoneTimeZoneSuggestion.Builder(PHONE_ID + 1);
                new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX + 1);
        {
        {
            PhoneTimeZoneSuggestion one = builder1.build();
            PhoneTimeZoneSuggestion one = builder1.build();
            PhoneTimeZoneSuggestion three = builder3.build();
            PhoneTimeZoneSuggestion three = builder3.build();
@@ -120,7 +120,7 @@ public class PhoneTimeZoneSuggestionTest {


    @Test(expected = RuntimeException.class)
    @Test(expected = RuntimeException.class)
    public void testBuilderValidates_emptyZone_badMatchType() {
    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.
        // No zone ID, so match type should be left unset.
        builder.setMatchType(PhoneTimeZoneSuggestion.MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET);
        builder.setMatchType(PhoneTimeZoneSuggestion.MATCH_TYPE_NETWORK_COUNTRY_AND_OFFSET);
        builder.build();
        builder.build();
@@ -128,7 +128,7 @@ public class PhoneTimeZoneSuggestionTest {


    @Test(expected = RuntimeException.class)
    @Test(expected = RuntimeException.class)
    public void testBuilderValidates_zoneSet_badMatchType() {
    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.setZoneId("Europe/London");
        builder.setQuality(PhoneTimeZoneSuggestion.QUALITY_SINGLE_ZONE);
        builder.setQuality(PhoneTimeZoneSuggestion.QUALITY_SINGLE_ZONE);
        builder.build();
        builder.build();
@@ -136,7 +136,7 @@ public class PhoneTimeZoneSuggestionTest {


    @Test
    @Test
    public void testParcelable() {
    public void testParcelable() {
        PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(PHONE_ID);
        PhoneTimeZoneSuggestion.Builder builder = new PhoneTimeZoneSuggestion.Builder(SLOT_INDEX);
        assertRoundTripParcelable(builder.build());
        assertRoundTripParcelable(builder.build());


        builder.setZoneId("Europe/London");
        builder.setZoneId("Europe/London");
Loading