Loading location/java/android/location/timezone/LocationTimeZoneEvent.java +1 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ public final class LocationTimeZoneEvent implements Parcelable { } /** * Gets the time zone IDs of this result. Contains zero or more IDs for a successful lookup. * Gets the time zone IDs of this event. Contains zero or more IDs for a successful lookup. * The value is undefined for an unsuccessful lookup. See also {@link #getEventType()}. */ @NonNull Loading location/java/com/android/internal/location/timezone/LocationTimeZoneProviderRequest.java +8 −29 Original line number Diff line number Diff line Loading @@ -19,17 +19,19 @@ package com.android.internal.location.timezone; import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; import android.os.WorkSource; import java.util.Objects; /** * An request passed to a location time zone provider to configure it. * A request passed to a location time zone provider to configure it. * * @hide */ public final class LocationTimeZoneProviderRequest implements Parcelable { public static final LocationTimeZoneProviderRequest EMPTY_REQUEST = new LocationTimeZoneProviderRequest(false); public static final Creator<LocationTimeZoneProviderRequest> CREATOR = new Creator<LocationTimeZoneProviderRequest>() { @Override Loading @@ -45,23 +47,15 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { /** Location time zone reporting is requested (true) */ private final boolean mReportLocationTimeZone; /** The WorkSource for power attribution. */ @NonNull private final WorkSource mWorkSource; private LocationTimeZoneProviderRequest(boolean reportLocationTimeZone, WorkSource workSource) { private LocationTimeZoneProviderRequest(boolean reportLocationTimeZone) { mReportLocationTimeZone = reportLocationTimeZone; mWorkSource = Objects.requireNonNull(workSource); } public boolean getReportLocationTimeZone() { return mReportLocationTimeZone; } @NonNull public WorkSource getWorkSource() { return mWorkSource; } @Override public int describeContents() { return 0; Loading @@ -70,14 +64,12 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(mReportLocationTimeZone ? 1 : 0); parcel.writeParcelable(mWorkSource, 0); } static LocationTimeZoneProviderRequest createFromParcel(Parcel in) { ClassLoader classLoader = LocationTimeZoneProviderRequest.class.getClassLoader(); return new Builder() .setReportLocationTimeZone(in.readInt() == 1) .setWorkSource(in.readParcelable(classLoader)) .build(); } Loading @@ -90,13 +82,12 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { return false; } LocationTimeZoneProviderRequest that = (LocationTimeZoneProviderRequest) o; return mReportLocationTimeZone == that.mReportLocationTimeZone && mWorkSource.equals(that.mWorkSource); return mReportLocationTimeZone == that.mReportLocationTimeZone; } @Override public int hashCode() { return Objects.hash(mReportLocationTimeZone, mWorkSource); return Objects.hash(mReportLocationTimeZone); } @Override Loading @@ -108,8 +99,6 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { } else { s.append("OFF"); } s.append(","); s.append("workSource=").append(mWorkSource); s.append(']'); return s.toString(); } Loading @@ -118,7 +107,6 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { public static final class Builder { private boolean mReportLocationTimeZone; private WorkSource mWorkSource; /** * Sets the property that enables / disables the provider. This is set to {@code false} by Loading @@ -129,19 +117,10 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { return this; } /** * Sets the {@link WorkSource} to attribute the power usage to. */ public Builder setWorkSource(@NonNull WorkSource workSource) { mWorkSource = Objects.requireNonNull(workSource); return this; } /** Builds the {@link LocationTimeZoneProviderRequest} instance. */ @NonNull public LocationTimeZoneProviderRequest build() { return new LocationTimeZoneProviderRequest(this.mReportLocationTimeZone, this.mWorkSource); return new LocationTimeZoneProviderRequest(this.mReportLocationTimeZone); } } } location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java +0 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.location.timezone.provider; import android.annotation.NonNull; import android.os.WorkSource; import com.android.internal.location.timezone.LocationTimeZoneProviderRequest; Loading @@ -44,11 +43,6 @@ public final class LocationTimeZoneProviderRequestUnbundled { return mRequest.getReportLocationTimeZone(); } @NonNull public WorkSource getWorkSource() { return mRequest.getWorkSource(); } @Override public String toString() { return mRequest.toString(); Loading services/tests/servicestests/src/com/android/internal/location/timezone/LocationTimeZoneProviderRequestTest.java +1 −18 Original line number Diff line number Diff line Loading @@ -18,32 +18,15 @@ package com.android.internal.location.timezone; import static android.location.timezone.ParcelableTestSupport.assertRoundTripParcelable; import android.os.WorkSource; import org.junit.Test; public class LocationTimeZoneProviderRequestTest { private static final WorkSource ARBITRARY_WORK_SOURCE = new WorkSource(123); @Test(expected = RuntimeException.class) public void testSetInvalidWorkSource() { new LocationTimeZoneProviderRequest.Builder().setWorkSource(null); } @Test(expected = RuntimeException.class) public void testWorkSourceRequired() { new LocationTimeZoneProviderRequest.Builder() .setReportLocationTimeZone(true) .build(); } @Test public void testParcelable() { LocationTimeZoneProviderRequest.Builder builder = new LocationTimeZoneProviderRequest.Builder() .setReportLocationTimeZone(true) .setWorkSource(ARBITRARY_WORK_SOURCE); .setReportLocationTimeZone(true); assertRoundTripParcelable(builder.build()); builder.setReportLocationTimeZone(false); Loading Loading
location/java/android/location/timezone/LocationTimeZoneEvent.java +1 −1 Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ public final class LocationTimeZoneEvent implements Parcelable { } /** * Gets the time zone IDs of this result. Contains zero or more IDs for a successful lookup. * Gets the time zone IDs of this event. Contains zero or more IDs for a successful lookup. * The value is undefined for an unsuccessful lookup. See also {@link #getEventType()}. */ @NonNull Loading
location/java/com/android/internal/location/timezone/LocationTimeZoneProviderRequest.java +8 −29 Original line number Diff line number Diff line Loading @@ -19,17 +19,19 @@ package com.android.internal.location.timezone; import android.annotation.NonNull; import android.os.Parcel; import android.os.Parcelable; import android.os.WorkSource; import java.util.Objects; /** * An request passed to a location time zone provider to configure it. * A request passed to a location time zone provider to configure it. * * @hide */ public final class LocationTimeZoneProviderRequest implements Parcelable { public static final LocationTimeZoneProviderRequest EMPTY_REQUEST = new LocationTimeZoneProviderRequest(false); public static final Creator<LocationTimeZoneProviderRequest> CREATOR = new Creator<LocationTimeZoneProviderRequest>() { @Override Loading @@ -45,23 +47,15 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { /** Location time zone reporting is requested (true) */ private final boolean mReportLocationTimeZone; /** The WorkSource for power attribution. */ @NonNull private final WorkSource mWorkSource; private LocationTimeZoneProviderRequest(boolean reportLocationTimeZone, WorkSource workSource) { private LocationTimeZoneProviderRequest(boolean reportLocationTimeZone) { mReportLocationTimeZone = reportLocationTimeZone; mWorkSource = Objects.requireNonNull(workSource); } public boolean getReportLocationTimeZone() { return mReportLocationTimeZone; } @NonNull public WorkSource getWorkSource() { return mWorkSource; } @Override public int describeContents() { return 0; Loading @@ -70,14 +64,12 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { @Override public void writeToParcel(Parcel parcel, int flags) { parcel.writeInt(mReportLocationTimeZone ? 1 : 0); parcel.writeParcelable(mWorkSource, 0); } static LocationTimeZoneProviderRequest createFromParcel(Parcel in) { ClassLoader classLoader = LocationTimeZoneProviderRequest.class.getClassLoader(); return new Builder() .setReportLocationTimeZone(in.readInt() == 1) .setWorkSource(in.readParcelable(classLoader)) .build(); } Loading @@ -90,13 +82,12 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { return false; } LocationTimeZoneProviderRequest that = (LocationTimeZoneProviderRequest) o; return mReportLocationTimeZone == that.mReportLocationTimeZone && mWorkSource.equals(that.mWorkSource); return mReportLocationTimeZone == that.mReportLocationTimeZone; } @Override public int hashCode() { return Objects.hash(mReportLocationTimeZone, mWorkSource); return Objects.hash(mReportLocationTimeZone); } @Override Loading @@ -108,8 +99,6 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { } else { s.append("OFF"); } s.append(","); s.append("workSource=").append(mWorkSource); s.append(']'); return s.toString(); } Loading @@ -118,7 +107,6 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { public static final class Builder { private boolean mReportLocationTimeZone; private WorkSource mWorkSource; /** * Sets the property that enables / disables the provider. This is set to {@code false} by Loading @@ -129,19 +117,10 @@ public final class LocationTimeZoneProviderRequest implements Parcelable { return this; } /** * Sets the {@link WorkSource} to attribute the power usage to. */ public Builder setWorkSource(@NonNull WorkSource workSource) { mWorkSource = Objects.requireNonNull(workSource); return this; } /** Builds the {@link LocationTimeZoneProviderRequest} instance. */ @NonNull public LocationTimeZoneProviderRequest build() { return new LocationTimeZoneProviderRequest(this.mReportLocationTimeZone, this.mWorkSource); return new LocationTimeZoneProviderRequest(this.mReportLocationTimeZone); } } }
location/lib/java/com/android/location/timezone/provider/LocationTimeZoneProviderRequestUnbundled.java +0 −6 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ package com.android.location.timezone.provider; import android.annotation.NonNull; import android.os.WorkSource; import com.android.internal.location.timezone.LocationTimeZoneProviderRequest; Loading @@ -44,11 +43,6 @@ public final class LocationTimeZoneProviderRequestUnbundled { return mRequest.getReportLocationTimeZone(); } @NonNull public WorkSource getWorkSource() { return mRequest.getWorkSource(); } @Override public String toString() { return mRequest.toString(); Loading
services/tests/servicestests/src/com/android/internal/location/timezone/LocationTimeZoneProviderRequestTest.java +1 −18 Original line number Diff line number Diff line Loading @@ -18,32 +18,15 @@ package com.android.internal.location.timezone; import static android.location.timezone.ParcelableTestSupport.assertRoundTripParcelable; import android.os.WorkSource; import org.junit.Test; public class LocationTimeZoneProviderRequestTest { private static final WorkSource ARBITRARY_WORK_SOURCE = new WorkSource(123); @Test(expected = RuntimeException.class) public void testSetInvalidWorkSource() { new LocationTimeZoneProviderRequest.Builder().setWorkSource(null); } @Test(expected = RuntimeException.class) public void testWorkSourceRequired() { new LocationTimeZoneProviderRequest.Builder() .setReportLocationTimeZone(true) .build(); } @Test public void testParcelable() { LocationTimeZoneProviderRequest.Builder builder = new LocationTimeZoneProviderRequest.Builder() .setReportLocationTimeZone(true) .setWorkSource(ARBITRARY_WORK_SOURCE); .setReportLocationTimeZone(true); assertRoundTripParcelable(builder.build()); builder.setReportLocationTimeZone(false); Loading