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

Commit d693c3f8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Update batching APIs" into sc-dev am: df079b79

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13460963

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ifc3a94dbaf4deb703de4624529da6b9f1bc09779
parents 9ff2a283 df079b79
Loading
Loading
Loading
Loading
+2 −14
Original line number Diff line number Diff line
@@ -19459,7 +19459,7 @@ package android.location {
  public interface LocationListener {
    method public default void onFlushComplete(int);
    method public void onLocationChanged(@NonNull android.location.Location);
    method public default void onLocationChanged(@NonNull android.location.LocationResult);
    method public default void onLocationChanged(@NonNull java.util.List<android.location.Location>);
    method public default void onProviderDisabled(@NonNull String);
    method public default void onProviderEnabled(@NonNull String);
    method @Deprecated public default void onStatusChanged(String, int, android.os.Bundle);
@@ -19545,8 +19545,8 @@ package android.location {
    field public static final String FUSED_PROVIDER = "fused";
    field public static final String GPS_PROVIDER = "gps";
    field public static final String KEY_FLUSH_COMPLETE = "flushComplete";
    field public static final String KEY_LOCATIONS = "locations";
    field public static final String KEY_LOCATION_CHANGED = "location";
    field public static final String KEY_LOCATION_RESULT = "locationResult";
    field public static final String KEY_PROVIDER_ENABLED = "providerEnabled";
    field public static final String KEY_PROXIMITY_ENTERING = "entering";
    field @Deprecated public static final String KEY_STATUS_CHANGED = "status";
@@ -19604,18 +19604,6 @@ package android.location {
    method @NonNull public android.location.LocationRequest.Builder setQuality(int);
  }
  public final class LocationResult implements android.os.Parcelable {
    method @NonNull public java.util.List<android.location.Location> asList();
    method @NonNull public static android.location.LocationResult create(@NonNull android.location.Location);
    method @NonNull public static android.location.LocationResult create(@NonNull java.util.List<android.location.Location>);
    method public int describeContents();
    method @NonNull public android.location.Location get(@IntRange(from=0) int);
    method @NonNull public android.location.Location getLastLocation();
    method @IntRange(from=1) public int size();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.location.LocationResult> CREATOR;
  }
  public interface OnNmeaMessageListener {
    method public void onNmeaMessage(String, long);
  }
+1 −5
Original line number Diff line number Diff line
@@ -4718,10 +4718,6 @@ package android.location {
    method @NonNull @RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS) public android.location.LocationRequest.Builder setWorkSource(@Nullable android.os.WorkSource);
  }
  public final class LocationResult implements android.os.Parcelable {
    method @NonNull public static android.location.LocationResult wrap(@NonNull android.location.Location);
  }
  public final class SatellitePvt implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public android.location.SatellitePvt.ClockInfo getClockInfo();
@@ -4788,7 +4784,7 @@ package android.location.provider {
    method public abstract void onSendExtraCommand(@NonNull String, @Nullable android.os.Bundle);
    method public abstract void onSetRequest(@NonNull android.location.provider.ProviderRequest);
    method public void reportLocation(@NonNull android.location.Location);
    method public void reportLocation(@NonNull android.location.LocationResult);
    method public void reportLocations(@NonNull java.util.List<android.location.Location>);
    method public void setAllowed(boolean);
    method public void setProperties(@NonNull android.location.provider.ProviderProperties);
    field public static final String ACTION_FUSED_PROVIDER = "com.android.location.service.FusedLocationProvider";
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package android.location;

import android.location.LocationResult;
import android.location.Location;
import android.os.IRemoteCallback;

/**
@@ -24,7 +24,7 @@ import android.os.IRemoteCallback;
 */
oneway interface ILocationListener
{
    void onLocationChanged(in LocationResult locationResult, in @nullable IRemoteCallback onCompleteCallback);
    void onLocationChanged(in List<Location> locations, in @nullable IRemoteCallback onCompleteCallback);
    void onProviderEnabledChanged(String provider, boolean enabled);
    void onFlushComplete(int requestCode);
}
+10 −6
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.location;
import android.annotation.NonNull;
import android.os.Bundle;

import java.util.List;
import java.util.concurrent.Executor;

/**
@@ -48,15 +49,18 @@ public interface LocationListener {
    /**
     * Called when the location has changed and locations are being delivered in batches. The
     * default implementation calls through to ({@link #onLocationChanged(Location)} with all
     * locations in the batch, from earliest to latest.
     * locations in the batch. The list of locations is always guaranteed to be non-empty, and is
     * always guaranteed to be ordered from earliest location to latest location (so that the
     * earliest location in the batch is at index 0 in the list, and the latest location in the
     * batch is at index size-1 in the list).
     *
     * @see LocationRequest#getMaxUpdateDelayMillis()
     * @param locationResult the location result list
     * @param locations the location list
     */
    default void onLocationChanged(@NonNull LocationResult locationResult) {
        final int size = locationResult.size();
        for (int i = 0; i < size; ++i) {
            onLocationChanged(locationResult.get(i));
    default void onLocationChanged(@NonNull List<Location> locations) {
        final int size = locations.size();
        for (int i = 0; i < size; i++) {
            onLocationChanged(locations.get(i));
        }
    }

+15 −8
Original line number Diff line number Diff line
@@ -232,19 +232,26 @@ public class LocationManager {

    /**
     * Key used for an extra holding a {@link Location} value when a location change is sent using
     * a PendingIntent.
     * a PendingIntent. If the location change includes a list of batched locations via
     * {@link #KEY_LOCATIONS} then this key will still be present, and will hold the last location
     * in the batch. Use {@link Intent#getParcelableExtra(String)} to retrieve the location.
     *
     * @see #requestLocationUpdates(String, LocationRequest, PendingIntent)
     */
    public static final String KEY_LOCATION_CHANGED = "location";

    /**
     * Key used for an extra holding a {@link LocationResult} value when a location change is sent
     * using a PendingIntent.
     * Key used for an extra holding a array of {@link Location}s when a location change is sent
     * using a PendingIntent. This key will only be present if the location change includes
     * multiple (ie, batched) locations, otherwise only {@link #KEY_LOCATION_CHANGED} will be
     * present. Use {@link Intent#getParcelableArrayExtra(String)} to retrieve the locations.
     *
     * <p>The array of locations will never be empty, and will ordered from earliest location to
     * latest location, the same as with {@link LocationListener#onLocationChanged(List)}.
     *
     * @see #requestLocationUpdates(String, LocationRequest, PendingIntent)
     */
    public static final String KEY_LOCATION_RESULT = "locationResult";
    public static final String KEY_LOCATIONS = "locations";

    /**
     * Key used for an extra holding an integer request code when location flush completion is sent
@@ -3018,12 +3025,12 @@ public class LocationManager {
        }

        @Override
        public void onLocationChanged(LocationResult locationResult,
        public void onLocationChanged(List<Location> locations,
                @Nullable IRemoteCallback onCompleteCallback) {
            executeSafely(mExecutor, () -> mListener, new ListenerOperation<LocationListener>() {
                @Override
                public void operate(LocationListener listener) {
                    listener.onLocationChanged(locationResult);
                    listener.onLocationChanged(locations);
                }

                @Override
@@ -3366,8 +3373,8 @@ public class LocationManager {
        }

        @Override
        public void onLocationChanged(@NonNull LocationResult locationResult) {
            mCallback.onLocationBatch(locationResult.asList());
        public void onLocationChanged(@NonNull List<Location> locations) {
            mCallback.onLocationBatch(locations);
        }
    }

Loading