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

Commit 2888fccd authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refactor API naming and add unbundled support"

parents deba83c0 509580fb
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -184,8 +184,7 @@ public final class LocationRequest implements Parcelable {
     * @return a new location request
     */
    public static LocationRequest create() {
        LocationRequest request = new LocationRequest();
        return request;
        return new LocationRequest();
    }

    /** @hide */
@@ -230,11 +229,9 @@ public final class LocationRequest implements Parcelable {
                quality = ACCURACY_FINE;
                break;
            default: {
                switch (criteria.getPowerRequirement()) {
                    case Criteria.POWER_HIGH:
                if (criteria.getPowerRequirement() == Criteria.POWER_HIGH) {
                    quality = POWER_HIGH;
                        break;
                    default:
                } else {
                    quality = POWER_LOW;
                }
            }
@@ -288,7 +285,7 @@ public final class LocationRequest implements Parcelable {
     *
     * @param quality an accuracy or power constant
     * @return the same object, so that setters can be chained
     * @throws InvalidArgumentException if the quality constant is not valid
     * @throws IllegalArgumentException if the quality constant is not valid
     */
    public LocationRequest setQuality(int quality) {
        checkQuality(quality);
@@ -331,7 +328,7 @@ public final class LocationRequest implements Parcelable {
     *
     * @param millis desired interval in millisecond, inexact
     * @return the same object, so that setters can be chained
     * @throws InvalidArgumentException if the interval is less than zero
     * @throws IllegalArgumentException if the interval is less than zero
     */
    public LocationRequest setInterval(long millis) {
        checkInterval(millis);
@@ -433,7 +430,7 @@ public final class LocationRequest implements Parcelable {
     *
     * @param millis fastest interval for updates in milliseconds, exact
     * @return the same object, so that setters can be chained
     * @throws InvalidArgumentException if the interval is less than zero
     * @throws IllegalArgumentException if the interval is less than zero
     */
    public LocationRequest setFastestInterval(long millis) {
        checkInterval(millis);
@@ -528,7 +525,7 @@ public final class LocationRequest implements Parcelable {
     *
     * @param numUpdates the number of location updates requested
     * @return the same object, so that setters can be chained
     * @throws InvalidArgumentException if numUpdates is 0 or less
     * @throws IllegalArgumentException if numUpdates is 0 or less
     */
    public LocationRequest setNumUpdates(int numUpdates) {
        if (numUpdates <= 0) {
@@ -668,7 +665,7 @@ public final class LocationRequest implements Parcelable {
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
    private static void checkProvider(String name) {
        if (name == null) {
            throw new IllegalArgumentException("invalid provider: " + name);
            throw new IllegalArgumentException("invalid provider: null");
        }
    }

@@ -758,9 +755,11 @@ public final class LocationRequest implements Parcelable {
        if (mNumUpdates != Integer.MAX_VALUE) {
            s.append(" num=").append(mNumUpdates);
        }
        s.append(" lowPowerMode=").append(mLowPowerMode);
        if (mLowPowerMode) {
            s.append(" lowPowerMode");
        }
        if (mLocationSettingsIgnored) {
            s.append(" ignoreSettings");
            s.append(" locationSettingsIgnored");
        }
        s.append(']');
        return s.toString();
+9 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ public final class ProviderRequest implements Parcelable {
     * restrictions or any other restricting factors and always satisfy this request to the best of
     * their ability. This flag should only be used in event of an emergency.
     */
    public boolean forceLocation = false;
    public boolean locationSettingsIgnored = false;

    /**
     * Whether provider shall make stronger than normal tradeoffs to substantially restrict power
@@ -70,6 +70,7 @@ public final class ProviderRequest implements Parcelable {
                    request.reportLocation = in.readInt() == 1;
                    request.interval = in.readLong();
                    request.lowPowerMode = in.readBoolean();
                    request.locationSettingsIgnored = in.readBoolean();
                    int count = in.readInt();
                    for (int i = 0; i < count; i++) {
                        request.locationRequests.add(LocationRequest.CREATOR.createFromParcel(in));
@@ -93,6 +94,7 @@ public final class ProviderRequest implements Parcelable {
        parcel.writeInt(reportLocation ? 1 : 0);
        parcel.writeLong(interval);
        parcel.writeBoolean(lowPowerMode);
        parcel.writeBoolean(locationSettingsIgnored);
        parcel.writeInt(locationRequests.size());
        for (LocationRequest request : locationRequests) {
            request.writeToParcel(parcel, flags);
@@ -107,7 +109,12 @@ public final class ProviderRequest implements Parcelable {
            s.append("ON");
            s.append(" interval=");
            TimeUtils.formatDuration(interval, s);
            s.append(" lowPowerMode=" + lowPowerMode);
            if (lowPowerMode) {
                s.append(" lowPowerMode");
            }
            if (locationSettingsIgnored) {
                s.append(" locationSettingsIgnored");
            }
        } else {
            s.append("OFF");
        }
+2 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ package com.android.location.provider {
    method public long getInterval();
    method public int getQuality();
    method public float getSmallestDisplacement();
    method public boolean isLocationSettingsIgnored();
    field public static final int ACCURACY_BLOCK = 102; // 0x66
    field public static final int ACCURACY_CITY = 104; // 0x68
    field public static final int ACCURACY_FINE = 100; // 0x64
@@ -44,10 +45,10 @@ package com.android.location.provider {
  }

  public final class ProviderRequestUnbundled {
    method public boolean getForceLocation();
    method public long getInterval();
    method public java.util.List<com.android.location.provider.LocationRequestUnbundled> getLocationRequests();
    method public boolean getReportLocation();
    method public boolean isLocationSettingsIgnored();
  }

}
+9 −0
Original line number Diff line number Diff line
@@ -121,6 +121,15 @@ public final class LocationRequestUnbundled {
        return delegate.getSmallestDisplacement();
    }

    /**
     * Returns true if location settings will be ignored in order to satisfy this request.
     *
     * @return true if location settings will be ignored in order to satisfy this request
     */
    public boolean isLocationSettingsIgnored() {
        return delegate.isLocationSettingsIgnored();
    }

    @Override
    public String toString() {
      return delegate.toString();
+3 −3
Original line number Diff line number Diff line
@@ -46,15 +46,15 @@ public final class ProviderRequestUnbundled {
        return mRequest.interval;
    }

    public boolean getForceLocation() {
        return mRequest.forceLocation;
    public boolean isLocationSettingsIgnored() {
        return mRequest.locationSettingsIgnored;
    }

    /**
     * Never null.
     */
    public List<LocationRequestUnbundled> getLocationRequests() {
        List<LocationRequestUnbundled> result = new ArrayList<LocationRequestUnbundled>(
        List<LocationRequestUnbundled> result = new ArrayList<>(
                mRequest.locationRequests.size());
        for (LocationRequest r : mRequest.locationRequests) {
          result.add(new LocationRequestUnbundled(r));
Loading