Use listener for AntennaInfo
Replace broadcast with listeners in response to API feedback. Bug: 178714745 Test: atest CtsLocationFineTestCases Change-Id: Ibb52b167c916fa6b5a9238371ba26b86801389d2
This commit is contained in:
@@ -19293,8 +19293,8 @@ package android.location {
|
||||
method @NonNull public android.location.GnssAntennaInfo.Builder setSignalGainCorrections(@Nullable android.location.GnssAntennaInfo.SphericalCorrections);
|
||||
}
|
||||
|
||||
@Deprecated public static interface GnssAntennaInfo.Listener {
|
||||
method @Deprecated public void onGnssAntennaInfoReceived(@NonNull java.util.List<android.location.GnssAntennaInfo>);
|
||||
public static interface GnssAntennaInfo.Listener {
|
||||
method public void onGnssAntennaInfoReceived(@NonNull java.util.List<android.location.GnssAntennaInfo>);
|
||||
}
|
||||
|
||||
public static final class GnssAntennaInfo.PhaseCenterOffset implements android.os.Parcelable {
|
||||
@@ -19683,7 +19683,7 @@ package android.location {
|
||||
method public boolean hasProvider(@NonNull String);
|
||||
method public boolean isLocationEnabled();
|
||||
method public boolean isProviderEnabled(@NonNull String);
|
||||
method @Deprecated public boolean registerAntennaInfoListener(@NonNull java.util.concurrent.Executor, @NonNull android.location.GnssAntennaInfo.Listener);
|
||||
method public boolean registerAntennaInfoListener(@NonNull java.util.concurrent.Executor, @NonNull android.location.GnssAntennaInfo.Listener);
|
||||
method @Deprecated @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementsEvent.Callback);
|
||||
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementsEvent.Callback, @Nullable android.os.Handler);
|
||||
method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public boolean registerGnssMeasurementsCallback(@NonNull java.util.concurrent.Executor, @NonNull android.location.GnssMeasurementsEvent.Callback);
|
||||
@@ -19720,13 +19720,11 @@ package android.location {
|
||||
method public void setTestProviderEnabled(@NonNull String, boolean);
|
||||
method public void setTestProviderLocation(@NonNull String, @NonNull android.location.Location);
|
||||
method @Deprecated public void setTestProviderStatus(@NonNull String, int, @Nullable android.os.Bundle, long);
|
||||
method @Deprecated public void unregisterAntennaInfoListener(@NonNull android.location.GnssAntennaInfo.Listener);
|
||||
method public void unregisterAntennaInfoListener(@NonNull android.location.GnssAntennaInfo.Listener);
|
||||
method public void unregisterGnssMeasurementsCallback(@NonNull android.location.GnssMeasurementsEvent.Callback);
|
||||
method public void unregisterGnssNavigationMessageCallback(@NonNull android.location.GnssNavigationMessage.Callback);
|
||||
method public void unregisterGnssStatusCallback(@NonNull android.location.GnssStatus.Callback);
|
||||
field public static final String ACTION_GNSS_ANTENNA_INFOS_CHANGED = "android.location.action.GNSS_ANTENNA_INFOS_CHANGED";
|
||||
field public static final String ACTION_GNSS_CAPABILITIES_CHANGED = "android.location.action.GNSS_CAPABILITIES_CHANGED";
|
||||
field public static final String EXTRA_GNSS_ANTENNA_INFOS = "android.location.extra.GNSS_ANTENNA_INFOS";
|
||||
field public static final String EXTRA_GNSS_CAPABILITIES = "android.location.extra.GNSS_CAPABILITIES";
|
||||
field public static final String EXTRA_LOCATION_ENABLED = "android.location.extra.LOCATION_ENABLED";
|
||||
field public static final String EXTRA_PROVIDER_ENABLED = "android.location.extra.PROVIDER_ENABLED";
|
||||
|
||||
@@ -39,11 +39,7 @@ public final class GnssAntennaInfo implements Parcelable {
|
||||
|
||||
/**
|
||||
* Used for receiving GNSS antenna info from the GNSS engine.
|
||||
*
|
||||
* @deprecated Prefer to use a broadcast receiver for
|
||||
* {@link LocationManager#ACTION_GNSS_ANTENNA_INFOS_CHANGED}.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Listener {
|
||||
/**
|
||||
* Invoked on a change to GNSS antenna info.
|
||||
|
||||
26
location/java/android/location/IGnssAntennaInfoListener.aidl
Normal file
26
location/java/android/location/IGnssAntennaInfoListener.aidl
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2020, 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.location.GnssAntennaInfo;
|
||||
|
||||
/**
|
||||
* {@hide}
|
||||
*/
|
||||
oneway interface IGnssAntennaInfoListener {
|
||||
void onGnssAntennaInfoChanged(in List<GnssAntennaInfo> antennaInfos);
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import android.location.GnssCapabilities;
|
||||
import android.location.GnssMeasurementCorrections;
|
||||
import android.location.GnssMeasurementRequest;
|
||||
import android.location.IGeocodeListener;
|
||||
import android.location.IGnssAntennaInfoListener;
|
||||
import android.location.IGnssMeasurementsListener;
|
||||
import android.location.IGnssStatusListener;
|
||||
import android.location.IGnssNavigationMessageListener;
|
||||
@@ -92,6 +93,9 @@ interface ILocationManager
|
||||
void addGnssNavigationMessageListener(in IGnssNavigationMessageListener listener, String packageName, @nullable String attributionTag, String listenerId);
|
||||
void removeGnssNavigationMessageListener(in IGnssNavigationMessageListener listener);
|
||||
|
||||
void addGnssAntennaInfoListener(in IGnssAntennaInfoListener listener, String packageName, @nullable String attributionTag, String listenerId);
|
||||
void removeGnssAntennaInfoListener(in IGnssAntennaInfoListener listener);
|
||||
|
||||
void addProviderRequestListener(in IProviderRequestListener listener);
|
||||
void removeProviderRequestListener(in IProviderRequestListener listener);
|
||||
|
||||
|
||||
@@ -43,10 +43,8 @@ import android.app.PropertyInvalidatedCache;
|
||||
import android.compat.Compatibility;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.EnabledAfter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.provider.IProviderRequestListener;
|
||||
import android.location.provider.ProviderProperties;
|
||||
@@ -348,28 +346,6 @@ public class LocationManager {
|
||||
*/
|
||||
public static final String EXTRA_GNSS_CAPABILITIES = "android.location.extra.GNSS_CAPABILITIES";
|
||||
|
||||
/**
|
||||
* Broadcast intent action when GNSS antenna infos change. Includes an intent extra,
|
||||
* {@link #EXTRA_GNSS_ANTENNA_INFOS}, with an ArrayList of the new {@link GnssAntennaInfo}. This
|
||||
* may be read via {@link android.content.Intent#getParcelableArrayListExtra(String)}.
|
||||
*
|
||||
* @see #EXTRA_GNSS_ANTENNA_INFOS
|
||||
* @see #getGnssAntennaInfos()
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||
public static final String ACTION_GNSS_ANTENNA_INFOS_CHANGED =
|
||||
"android.location.action.GNSS_ANTENNA_INFOS_CHANGED";
|
||||
|
||||
/**
|
||||
* Intent extra included with {@link #ACTION_GNSS_ANTENNA_INFOS_CHANGED} broadcasts, containing
|
||||
* the new ArrayList of {@link GnssAntennaInfo}. This may be read via
|
||||
* {@link android.content.Intent#getParcelableArrayListExtra(String)}.
|
||||
*
|
||||
* @see #ACTION_GNSS_ANTENNA_INFOS_CHANGED
|
||||
*/
|
||||
public static final String EXTRA_GNSS_ANTENNA_INFOS =
|
||||
"android.location.extra.GNSS_ANTENNA_INFOS";
|
||||
|
||||
/**
|
||||
* Broadcast intent action for Settings app to inject a footer at the bottom of location
|
||||
* settings. This is for use only by apps that are included in the system image.
|
||||
@@ -2659,10 +2635,11 @@ public class LocationManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a GNSS antenna info listener. GNSS antenna info updates will only be received while
|
||||
* the {@link #GPS_PROVIDER} is enabled, and while the client app is in the foreground.
|
||||
* Registers a GNSS antenna info listener that will receive all changes to antenna info. Use
|
||||
* {@link #getGnssAntennaInfos()} to get current antenna info.
|
||||
*
|
||||
* <p>Not all GNSS chipsets support antenna info updates, see {@link #getGnssCapabilities()}.
|
||||
* <p>Not all GNSS chipsets support antenna info updates, see {@link #getGnssCapabilities()}. If
|
||||
* unsupported, the listener will never be invoked.
|
||||
*
|
||||
* <p>Prior to Android S, this requires the {@link Manifest.permission#ACCESS_FINE_LOCATION}
|
||||
* permission.
|
||||
@@ -2673,10 +2650,7 @@ public class LocationManager {
|
||||
*
|
||||
* @throws IllegalArgumentException if executor is null
|
||||
* @throws IllegalArgumentException if listener is null
|
||||
*
|
||||
* @deprecated Prefer to use a receiver for {@link #ACTION_GNSS_ANTENNA_INFOS_CHANGED}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean registerAntennaInfoListener(
|
||||
@NonNull @CallbackExecutor Executor executor,
|
||||
@NonNull GnssAntennaInfo.Listener listener) {
|
||||
@@ -2686,13 +2660,10 @@ public class LocationManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a GNSS Antenna Info listener.
|
||||
* Unregisters a GNSS antenna info listener.
|
||||
*
|
||||
* @param listener a {@link GnssAntennaInfo.Listener} object to remove
|
||||
*
|
||||
* @deprecated Prefer to use a receiver for {@link #ACTION_GNSS_ANTENNA_INFOS_CHANGED}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void unregisterAntennaInfoListener(@NonNull GnssAntennaInfo.Listener listener) {
|
||||
GnssLazyLoader.sGnssAntennaInfoListeners.removeListener(listener);
|
||||
}
|
||||
@@ -3009,14 +2980,17 @@ public class LocationManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTransport(GnssAntennaInfoTransport transport) {
|
||||
transport.getContext().registerReceiver(transport,
|
||||
new IntentFilter(ACTION_GNSS_ANTENNA_INFOS_CHANGED));
|
||||
protected void registerTransport(GnssAntennaInfoTransport transport)
|
||||
throws RemoteException {
|
||||
getService().addGnssAntennaInfoListener(transport, transport.getPackage(),
|
||||
transport.getAttributionTag(),
|
||||
AppOpsManager.toReceiverId(transport.getListener()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void unregisterTransport(GnssAntennaInfoTransport transport) {
|
||||
transport.getContext().unregisterReceiver(transport);
|
||||
protected void unregisterTransport(GnssAntennaInfoTransport transport)
|
||||
throws RemoteException {
|
||||
getService().removeGnssAntennaInfoListener(transport);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3376,11 +3350,12 @@ public class LocationManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static class GnssAntennaInfoTransport extends BroadcastReceiver implements
|
||||
private static class GnssAntennaInfoTransport extends IGnssAntennaInfoListener.Stub implements
|
||||
ListenerTransport<GnssAntennaInfo.Listener> {
|
||||
|
||||
private final Executor mExecutor;
|
||||
private final Context mContext;
|
||||
private final String mPackageName;
|
||||
private final String mAttributionTag;
|
||||
|
||||
private volatile @Nullable GnssAntennaInfo.Listener mListener;
|
||||
|
||||
@@ -3389,12 +3364,17 @@ public class LocationManager {
|
||||
Preconditions.checkArgument(executor != null, "invalid null executor");
|
||||
Preconditions.checkArgument(listener != null, "invalid null listener");
|
||||
mExecutor = executor;
|
||||
mContext = context;
|
||||
mPackageName = context.getPackageName();
|
||||
mAttributionTag = context.getAttributionTag();
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return mContext;
|
||||
public String getPackage() {
|
||||
return mPackageName;
|
||||
}
|
||||
|
||||
public String getAttributionTag() {
|
||||
return mAttributionTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3408,12 +3388,8 @@ public class LocationManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
ArrayList<GnssAntennaInfo> infos = intent.getParcelableArrayListExtra(
|
||||
EXTRA_GNSS_ANTENNA_INFOS);
|
||||
if (infos != null) {
|
||||
execute(mExecutor, callback -> callback.onGnssAntennaInfoReceived(infos));
|
||||
}
|
||||
public void onGnssAntennaInfoChanged(List<GnssAntennaInfo> antennaInfos) {
|
||||
execute(mExecutor, callback -> callback.onGnssAntennaInfoReceived(antennaInfos));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import android.location.GnssCapabilities;
|
||||
import android.location.GnssMeasurementCorrections;
|
||||
import android.location.GnssMeasurementRequest;
|
||||
import android.location.IGeocodeListener;
|
||||
import android.location.IGnssAntennaInfoListener;
|
||||
import android.location.IGnssMeasurementsListener;
|
||||
import android.location.IGnssNavigationMessageListener;
|
||||
import android.location.IGnssNmeaListener;
|
||||
@@ -929,6 +930,22 @@ public class LocationManagerService extends ILocationManager.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGnssAntennaInfoListener(IGnssAntennaInfoListener listener, String packageName,
|
||||
@Nullable String attributionTag, String listenerId) {
|
||||
if (mGnssManagerService != null) {
|
||||
mGnssManagerService.addGnssAntennaInfoListener(listener, packageName, attributionTag,
|
||||
listenerId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGnssAntennaInfoListener(IGnssAntennaInfoListener listener) {
|
||||
if (mGnssManagerService != null) {
|
||||
mGnssManagerService.removeGnssAntennaInfoListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProviderRequestListener(IProviderRequestListener listener) {
|
||||
for (LocationProviderManager manager : mProviderManagers) {
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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 com.android.server.location.gnss;
|
||||
|
||||
import static com.android.server.location.gnss.GnssManagerService.TAG;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.location.GnssAntennaInfo;
|
||||
import android.location.IGnssAntennaInfoListener;
|
||||
import android.location.util.identity.CallerIdentity;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.android.server.location.gnss.hal.GnssNative;
|
||||
import com.android.server.location.listeners.BinderListenerRegistration;
|
||||
import com.android.server.location.listeners.ListenerMultiplexer;
|
||||
import com.android.server.location.listeners.ListenerRegistration;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Antenna info HAL module and listener multiplexer.
|
||||
*/
|
||||
public class GnssAntennaInfoProvider extends
|
||||
ListenerMultiplexer<IBinder, IGnssAntennaInfoListener,
|
||||
ListenerRegistration<IGnssAntennaInfoListener>, Void> implements
|
||||
GnssNative.BaseCallbacks, GnssNative.AntennaInfoCallbacks {
|
||||
|
||||
/**
|
||||
* Registration object for GNSS listeners.
|
||||
*/
|
||||
protected class AntennaInfoListenerRegistration extends
|
||||
BinderListenerRegistration<Void, IGnssAntennaInfoListener> {
|
||||
|
||||
protected AntennaInfoListenerRegistration(CallerIdentity callerIdentity,
|
||||
IGnssAntennaInfoListener listener) {
|
||||
super(null, callerIdentity, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GnssAntennaInfoProvider getOwner() {
|
||||
return GnssAntennaInfoProvider.this;
|
||||
}
|
||||
}
|
||||
|
||||
private final GnssNative mGnssNative;
|
||||
|
||||
private volatile @Nullable List<GnssAntennaInfo> mAntennaInfos;
|
||||
|
||||
GnssAntennaInfoProvider(GnssNative gnssNative) {
|
||||
mGnssNative = gnssNative;
|
||||
mGnssNative.addBaseCallbacks(this);
|
||||
mGnssNative.addAntennaInfoCallbacks(this);
|
||||
}
|
||||
|
||||
@Nullable List<GnssAntennaInfo> getAntennaInfos() {
|
||||
return mAntennaInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
public boolean isSupported() {
|
||||
return mGnssNative.isAntennaInfoSupported();
|
||||
}
|
||||
|
||||
public void addListener(CallerIdentity callerIdentity, IGnssAntennaInfoListener listener) {
|
||||
long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
putRegistration(listener.asBinder(),
|
||||
new AntennaInfoListenerRegistration(callerIdentity, listener));
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeListener(IGnssAntennaInfoListener listener) {
|
||||
long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
removeRegistration(listener.asBinder());
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean registerWithService(Void merged,
|
||||
Collection<ListenerRegistration<IGnssAntennaInfoListener>> listenerRegistrations) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void unregisterWithService() {}
|
||||
|
||||
@Override
|
||||
protected boolean isActive(ListenerRegistration<IGnssAntennaInfoListener> registration) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void mergeRegistrations(
|
||||
Collection<ListenerRegistration<IGnssAntennaInfoListener>> listenerRegistrations) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHalStarted() {
|
||||
mGnssNative.startAntennaInfoListening();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHalRestarted() {
|
||||
mGnssNative.startAntennaInfoListening();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReportAntennaInfo(List<GnssAntennaInfo> antennaInfos) {
|
||||
if (antennaInfos.equals(mAntennaInfos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAntennaInfos = antennaInfos;
|
||||
deliverToListeners(listener -> {
|
||||
listener.onGnssAntennaInfoChanged(antennaInfos);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -229,7 +229,7 @@ public abstract class GnssListenerMultiplexer<TRequest, TListener extends IInter
|
||||
* registrations will be treated as inactive and the backing service will never be registered.
|
||||
*
|
||||
*/
|
||||
protected boolean isServiceSupported() {
|
||||
public boolean isSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ public abstract class GnssListenerMultiplexer<TRequest, TListener extends IInter
|
||||
|
||||
@Override
|
||||
protected boolean isActive(GnssListenerRegistration registration) {
|
||||
if (!isServiceSupported()) {
|
||||
if (!isSupported()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ public abstract class GnssListenerMultiplexer<TRequest, TListener extends IInter
|
||||
|
||||
@Override
|
||||
protected void onRegister() {
|
||||
if (!isServiceSupported()) {
|
||||
if (!isSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ public abstract class GnssListenerMultiplexer<TRequest, TListener extends IInter
|
||||
|
||||
@Override
|
||||
protected void onUnregister() {
|
||||
if (!isServiceSupported()) {
|
||||
if (!isSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ public abstract class GnssListenerMultiplexer<TRequest, TListener extends IInter
|
||||
|
||||
@Override
|
||||
protected String getServiceState() {
|
||||
if (!isServiceSupported()) {
|
||||
if (!isSupported()) {
|
||||
return "unsupported";
|
||||
} else {
|
||||
return super.getServiceState();
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.location.GnssAntennaInfo;
|
||||
import android.location.GnssCapabilities;
|
||||
import android.location.GnssMeasurementCorrections;
|
||||
import android.location.GnssMeasurementRequest;
|
||||
import android.location.IGnssAntennaInfoListener;
|
||||
import android.location.IGnssMeasurementsListener;
|
||||
import android.location.IGnssNavigationMessageListener;
|
||||
import android.location.IGnssNmeaListener;
|
||||
@@ -49,7 +50,6 @@ import com.android.server.location.gnss.hal.GnssNative;
|
||||
import com.android.server.location.injector.Injector;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** Manages Gnss providers and related Gnss functions for LocationManagerService. */
|
||||
@@ -68,11 +68,11 @@ public class GnssManagerService {
|
||||
private final GnssNmeaProvider mGnssNmeaProvider;
|
||||
private final GnssMeasurementsProvider mGnssMeasurementsProvider;
|
||||
private final GnssNavigationMessageProvider mGnssNavigationMessageProvider;
|
||||
private final GnssAntennaInfoProvider mGnssAntennaInfoProvider;
|
||||
private final IGpsGeofenceHardware mGnssGeofenceProxy;
|
||||
|
||||
private final GnssGeofenceHalModule mGeofenceHalModule;
|
||||
private final GnssCapabilitiesHalModule mCapabilitiesHalModule;
|
||||
private final GnssAntennaInfoHalModule mAntennaInfoHalModule;
|
||||
|
||||
private final GnssMetrics mGnssMetrics;
|
||||
|
||||
@@ -89,11 +89,11 @@ public class GnssManagerService {
|
||||
mGnssNmeaProvider = new GnssNmeaProvider(injector, mGnssNative);
|
||||
mGnssMeasurementsProvider = new GnssMeasurementsProvider(injector, mGnssNative);
|
||||
mGnssNavigationMessageProvider = new GnssNavigationMessageProvider(injector, mGnssNative);
|
||||
mGnssAntennaInfoProvider = new GnssAntennaInfoProvider(mGnssNative);
|
||||
mGnssGeofenceProxy = new GnssGeofenceProxy(mGnssNative);
|
||||
|
||||
mGeofenceHalModule = new GnssGeofenceHalModule(mGnssNative);
|
||||
mCapabilitiesHalModule = new GnssCapabilitiesHalModule(mGnssNative);
|
||||
mAntennaInfoHalModule = new GnssAntennaInfoHalModule(mGnssNative);
|
||||
|
||||
// allow gnss access to begin - we must assume that callbacks can start immediately
|
||||
mGnssNative.register();
|
||||
@@ -140,7 +140,7 @@ public class GnssManagerService {
|
||||
* Get GNSS antenna information.
|
||||
*/
|
||||
public @Nullable List<GnssAntennaInfo> getGnssAntennaInfos() {
|
||||
return mAntennaInfoHalModule.getAntennaInfos();
|
||||
return mGnssAntennaInfoProvider.getAntennaInfos();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,6 +241,24 @@ public class GnssManagerService {
|
||||
mGnssNavigationMessageProvider.removeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a GNSS antenna info listener.
|
||||
*/
|
||||
public void addGnssAntennaInfoListener(IGnssAntennaInfoListener listener, String packageName,
|
||||
@Nullable String attributionTag, String listenerId) {
|
||||
|
||||
CallerIdentity identity = CallerIdentity.fromBinder(mContext, packageName, attributionTag,
|
||||
listenerId);
|
||||
mGnssAntennaInfoProvider.addListener(identity, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a GNSS antenna info listener.
|
||||
*/
|
||||
public void removeGnssAntennaInfoListener(IGnssAntennaInfoListener listener) {
|
||||
mGnssAntennaInfoProvider.removeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Ni Response, indicating a location request initiated by a network carrier.
|
||||
*/
|
||||
@@ -263,25 +281,34 @@ public class GnssManagerService {
|
||||
|
||||
ipw.println("Capabilities: " + mGnssNative.getCapabilities());
|
||||
|
||||
List<GnssAntennaInfo> infos = mAntennaInfoHalModule.getAntennaInfos();
|
||||
if (infos != null) {
|
||||
ipw.println("Antenna Infos: " + infos);
|
||||
if (mGnssStatusProvider.isSupported()) {
|
||||
ipw.println("Status Provider:");
|
||||
ipw.increaseIndent();
|
||||
mGnssStatusProvider.dump(fd, ipw, args);
|
||||
ipw.decreaseIndent();
|
||||
}
|
||||
|
||||
ipw.println("Measurements Provider:");
|
||||
ipw.increaseIndent();
|
||||
mGnssMeasurementsProvider.dump(fd, ipw, args);
|
||||
ipw.decreaseIndent();
|
||||
if (mGnssMeasurementsProvider.isSupported()) {
|
||||
ipw.println("Measurements Provider:");
|
||||
ipw.increaseIndent();
|
||||
mGnssMeasurementsProvider.dump(fd, ipw, args);
|
||||
ipw.decreaseIndent();
|
||||
}
|
||||
|
||||
ipw.println("Navigation Message Provider:");
|
||||
ipw.increaseIndent();
|
||||
mGnssNavigationMessageProvider.dump(fd, ipw, args);
|
||||
ipw.decreaseIndent();
|
||||
if (mGnssNavigationMessageProvider.isSupported()) {
|
||||
ipw.println("Navigation Message Provider:");
|
||||
ipw.increaseIndent();
|
||||
mGnssNavigationMessageProvider.dump(fd, ipw, args);
|
||||
ipw.decreaseIndent();
|
||||
}
|
||||
|
||||
ipw.println("Status Provider:");
|
||||
ipw.increaseIndent();
|
||||
mGnssStatusProvider.dump(fd, ipw, args);
|
||||
ipw.decreaseIndent();
|
||||
if (mGnssAntennaInfoProvider.isSupported()) {
|
||||
ipw.println("Navigation Message Provider:");
|
||||
ipw.increaseIndent();
|
||||
ipw.println("Antenna Infos: " + mGnssAntennaInfoProvider.getAntennaInfos());
|
||||
mGnssAntennaInfoProvider.dump(fd, ipw, args);
|
||||
ipw.decreaseIndent();
|
||||
}
|
||||
|
||||
GnssPowerStats powerStats = mGnssNative.getPowerStats();
|
||||
if (powerStats != null) {
|
||||
@@ -399,53 +426,4 @@ public class GnssManagerService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class GnssAntennaInfoHalModule implements GnssNative.BaseCallbacks,
|
||||
GnssNative.AntennaInfoCallbacks {
|
||||
|
||||
private final GnssNative mGnssNative;
|
||||
|
||||
private volatile @Nullable List<GnssAntennaInfo> mAntennaInfos;
|
||||
|
||||
GnssAntennaInfoHalModule(GnssNative gnssNative) {
|
||||
mGnssNative = gnssNative;
|
||||
mGnssNative.addBaseCallbacks(this);
|
||||
mGnssNative.addAntennaInfoCallbacks(this);
|
||||
}
|
||||
|
||||
@Nullable List<GnssAntennaInfo> getAntennaInfos() {
|
||||
return mAntennaInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHalStarted() {
|
||||
mGnssNative.startAntennaInfoListening();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHalRestarted() {
|
||||
mGnssNative.startAntennaInfoListening();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReportAntennaInfo(List<GnssAntennaInfo> antennaInfos) {
|
||||
if (antennaInfos.equals(mAntennaInfos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mAntennaInfos = antennaInfos;
|
||||
|
||||
long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
Intent intent = new Intent(LocationManager.ACTION_GNSS_ANTENNA_INFOS_CHANGED)
|
||||
.putParcelableArrayListExtra(LocationManager.EXTRA_GNSS_ANTENNA_INFOS,
|
||||
new ArrayList<>(antennaInfos))
|
||||
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY)
|
||||
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public final class GnssMeasurementsProvider extends
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isServiceSupported() {
|
||||
public boolean isSupported() {
|
||||
return mGnssNative.isMeasurementSupported();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class GnssNavigationMessageProvider extends
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isServiceSupported() {
|
||||
public boolean isSupported() {
|
||||
return mGnssNative.isNavigationMessageCollectionSupported();
|
||||
}
|
||||
|
||||
|
||||
@@ -699,11 +699,11 @@ public class GnssNative {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if antenna info listening is supported.
|
||||
* Returns true if antenna info is supported.
|
||||
*/
|
||||
public boolean isAntennaInfoListeningSupported() {
|
||||
public boolean isAntennaInfoSupported() {
|
||||
Preconditions.checkState(mRegistered);
|
||||
return mGnssHal.isAntennaInfoListeningSupported();
|
||||
return mGnssHal.isAntennaInfoSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1259,7 +1259,7 @@ public class GnssNative {
|
||||
return native_stop_navigation_message_collection();
|
||||
}
|
||||
|
||||
protected boolean isAntennaInfoListeningSupported() {
|
||||
protected boolean isAntennaInfoSupported() {
|
||||
return native_is_antenna_info_supported();
|
||||
}
|
||||
|
||||
|
||||
@@ -500,7 +500,7 @@ public final class FakeGnssHal extends GnssNative.GnssHal {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAntennaInfoListeningSupported() {
|
||||
protected boolean isAntennaInfoSupported() {
|
||||
return mIsAntennaInfoListeningSupported;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user