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

Commit e5d975cd authored by Wyatt Riley's avatar Wyatt Riley Committed by Android (Google) Code Review
Browse files

Merge "GNSS Batching - Default Implementation"

parents 4561f901 cf879db3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -388,6 +388,7 @@ LOCAL_SRC_FILES += \
	core/java/com/android/internal/widget/IRemoteViewsAdapterConnection.aidl \
	keystore/java/android/security/IKeyChainAliasCallback.aidl \
	keystore/java/android/security/IKeyChainService.aidl \
	location/java/android/location/IBatchedLocationCallback.aidl \
	location/java/android/location/ICountryDetector.aidl \
	location/java/android/location/ICountryListener.aidl \
	location/java/android/location/IFusedProvider.aidl \
+9 −0
Original line number Diff line number Diff line
@@ -21413,6 +21413,11 @@ package android.location {
    field public static final android.os.Parcelable.Creator<android.location.Address> CREATOR;
  }
  public abstract class BatchedLocationCallback {
    ctor public BatchedLocationCallback();
    method public void onLocationBatch(java.util.List<android.location.Location>);
  }
  public class Criteria implements android.os.Parcelable {
    ctor public Criteria();
    ctor public Criteria(android.location.Criteria);
@@ -21951,14 +21956,17 @@ package android.location {
    method public void clearTestProviderEnabled(java.lang.String);
    method public void clearTestProviderLocation(java.lang.String);
    method public void clearTestProviderStatus(java.lang.String);
    method public void flushGnssBatch();
    method public java.util.List<java.lang.String> getAllProviders();
    method public java.lang.String getBestProvider(android.location.Criteria, boolean);
    method public int getGnssBatchSize();
    method public deprecated android.location.GpsStatus getGpsStatus(android.location.GpsStatus);
    method public android.location.Location getLastKnownLocation(java.lang.String);
    method public android.location.LocationProvider getProvider(java.lang.String);
    method public java.util.List<java.lang.String> getProviders(boolean);
    method public java.util.List<java.lang.String> getProviders(android.location.Criteria, boolean);
    method public boolean isProviderEnabled(java.lang.String);
    method public boolean registerGnssBatchedLocationCallback(long, boolean, android.location.BatchedLocationCallback, android.os.Handler);
    method public boolean registerGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback);
    method public boolean registerGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback, android.os.Handler);
    method public boolean registerGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback);
@@ -21989,6 +21997,7 @@ package android.location {
    method public void setTestProviderEnabled(java.lang.String, boolean);
    method public void setTestProviderLocation(java.lang.String, android.location.Location);
    method public void setTestProviderStatus(java.lang.String, int, android.os.Bundle, long);
    method public boolean unregisterGnssBatchedLocationCallback(android.location.BatchedLocationCallback);
    method public void unregisterGnssMeasurementsCallback(android.location.GnssMeasurementsEvent.Callback);
    method public void unregisterGnssNavigationMessageCallback(android.location.GnssNavigationMessage.Callback);
    method public void unregisterGnssStatusCallback(android.location.GnssStatus.Callback);
+44 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.location;

import android.annotation.IntDef;
import android.annotation.SystemApi;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;

/**
 * Used for receiving notifications from the LocationManager when
 * the a batch of location is ready. These methods are called if the
 * BatchedLocationCallback has been registered with the location manager service
 * using the
 * {@link LocationManager#registerGnssBatchedLocationCallback#startGnssBatch(long,
 * boolean, BatchedLocationCallback, android.os.Handler)} method.
 * @hide
 */
@SystemApi
public abstract class BatchedLocationCallback {

    /**
     * Called when a new batch of locations is ready
     *
     * @param locations A list of all new locations (possibly zero of them.)
     */
    public void onLocationBatch(List<Location> locations) {}
}
+66 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package android.location;

import android.content.Context;
import android.os.RemoteException;

import java.util.List;

/**
 * A handler class to manage transport callbacks for {@link BatchedLocationCallback}.
 *
 * @hide
 */
class BatchedLocationCallbackTransport
        extends LocalListenerHelper<BatchedLocationCallback> {
    private final ILocationManager mLocationManager;

    private final IBatchedLocationCallback mCallbackTransport = new CallbackTransport();

    public BatchedLocationCallbackTransport(Context context, ILocationManager locationManager) {
        super(context, "BatchedLocationCallbackTransport");
        mLocationManager = locationManager;
    }

    @Override
    protected boolean registerWithServer() throws RemoteException {
        return mLocationManager.addGnssBatchingCallback(
                mCallbackTransport,
                getContext().getPackageName());
    }

    @Override
    protected void unregisterFromServer() throws RemoteException {
        mLocationManager.removeGnssBatchingCallback();
    }

    private class CallbackTransport extends IBatchedLocationCallback.Stub {
        @Override
        public void onLocationBatch(final List<Location> locations) {
            ListenerOperation<BatchedLocationCallback> operation =
                    new ListenerOperation<BatchedLocationCallback>() {
                @Override
                public void execute(BatchedLocationCallback callback)
                        throws RemoteException {
                    callback.onLocationBatch(locations);
                }
            };
            foreach(operation);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public final class GnssNavigationMessage implements Parcelable {
     */
    public static abstract class Callback {
        /**
         * The status of GNSS measurements event.
         * The status of GNSS Navigation Message event.
         * @hide
         */
        @Retention(RetentionPolicy.SOURCE)
Loading