Show location icon when reporting GNSS measurements/status
GNSS measurements and status can be used to compute user location.
Hence, the location icon must be turned on in the status bar to
notify the user every time the measurements are reported to an
application. Also, check for location permission before delivery
as the application may have lost location permission.
Bug: 113332106
Test: Tested it manually using GNSS logger application.
Change-Id: I985610cab207af50a84e7e47390c51359375bb78
diff --git a/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java b/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java
index 1b4fd18..679919f 100644
--- a/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java
+++ b/services/core/java/com/android/server/location/GnssNavigationMessageProvider.java
@@ -16,6 +16,7 @@
package com.android.server.location;
+import android.content.Context;
import android.location.GnssNavigationMessage;
import android.location.IGnssNavigationMessageListener;
import android.os.Handler;
@@ -39,13 +40,14 @@
private final GnssNavigationMessageProviderNative mNative;
private boolean mCollectionStarted;
- protected GnssNavigationMessageProvider(Handler handler) {
- this(handler, new GnssNavigationMessageProviderNative());
+ protected GnssNavigationMessageProvider(Context context, Handler handler) {
+ this(context, handler, new GnssNavigationMessageProviderNative());
}
@VisibleForTesting
- GnssNavigationMessageProvider(Handler handler, GnssNavigationMessageProviderNative aNative) {
- super(handler, TAG);
+ GnssNavigationMessageProvider(Context context, Handler handler,
+ GnssNavigationMessageProviderNative aNative) {
+ super(context, handler, TAG);
mNative = aNative;
}
@@ -84,15 +86,10 @@
}
public void onNavigationMessageAvailable(final GnssNavigationMessage event) {
- ListenerOperation<IGnssNavigationMessageListener> operation =
- new ListenerOperation<IGnssNavigationMessageListener>() {
- @Override
- public void execute(IGnssNavigationMessageListener listener)
- throws RemoteException {
- listener.onGnssNavigationMessageReceived(event);
- }
- };
- foreach(operation);
+ foreach((IGnssNavigationMessageListener listener, int uid, String packageName) -> {
+ listener.onGnssNavigationMessageReceived(event);
+ }
+ );
}
public void onCapabilitiesUpdated(boolean isGnssNavigationMessageSupported) {
@@ -138,7 +135,8 @@
}
@Override
- public void execute(IGnssNavigationMessageListener listener) throws RemoteException {
+ public void execute(IGnssNavigationMessageListener listener,
+ int uid, String packageName) throws RemoteException {
listener.onStatusChanged(mStatus);
}
}