Loading services/core/java/com/android/server/location/gnss/hal/GnssNative.java +114 −80 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.location.GnssMeasurementsEvent; import android.location.GnssNavigationMessage; import android.location.GnssStatus; import android.location.Location; import android.os.Binder; import android.os.SystemClock; import android.util.Log; Loading Loading @@ -921,6 +922,7 @@ public class GnssNative { @NativeEntryPoint void reportGnssServiceDied() { // Not necessary to clear (and restore) binder identity since it runs on another thread. Log.e(TAG, "gnss hal died - restarting shortly..."); // move to another thread just in case there is some awkward gnss thread dependency with Loading @@ -940,6 +942,7 @@ public class GnssNative { @NativeEntryPoint void reportLocation(boolean hasLatLong, Location location) { Binder.withCleanCallingIdentity(() -> { if (hasLatLong && !mHasFirstFix) { mHasFirstFix = true; Loading Loading @@ -967,33 +970,40 @@ public class GnssNative { for (int i = 0; i < mLocationCallbacks.length; i++) { mLocationCallbacks[i].onReportLocation(hasLatLong, location); } }); } @NativeEntryPoint void reportStatus(@StatusCallbacks.GnssStatusValue int gnssStatus) { Binder.withCleanCallingIdentity(() -> { for (int i = 0; i < mStatusCallbacks.length; i++) { mStatusCallbacks[i].onReportStatus(gnssStatus); } }); } @NativeEntryPoint void reportSvStatus(int svCount, int[] svidWithFlags, float[] cn0DbHzs, float[] elevations, float[] azimuths, float[] carrierFrequencies, float[] basebandCn0DbHzs) { Binder.withCleanCallingIdentity(() -> { GnssStatus gnssStatus = GnssStatus.wrap(svCount, svidWithFlags, cn0DbHzs, elevations, azimuths, carrierFrequencies, basebandCn0DbHzs); for (int i = 0; i < mSvStatusCallbacks.length; i++) { mSvStatusCallbacks[i].onReportSvStatus(gnssStatus); } }); } @NativeEntryPoint void reportAGpsStatus(int agpsType, int agpsStatus, byte[] suplIpAddr) { mAGpsCallbacks.onReportAGpsStatus(agpsType, agpsStatus, suplIpAddr); Binder.withCleanCallingIdentity( () -> mAGpsCallbacks.onReportAGpsStatus(agpsType, agpsStatus, suplIpAddr)); } @NativeEntryPoint void reportNmea(long timestamp) { Binder.withCleanCallingIdentity(() -> { if (mItarSpeedLimitExceeded) { return; } Loading @@ -1001,10 +1011,12 @@ public class GnssNative { for (int i = 0; i < mNmeaCallbacks.length; i++) { mNmeaCallbacks[i].onReportNmea(timestamp); } }); } @NativeEntryPoint void reportMeasurementData(GnssMeasurementsEvent event) { Binder.withCleanCallingIdentity(() -> { if (mItarSpeedLimitExceeded) { return; } Loading @@ -1012,17 +1024,21 @@ public class GnssNative { for (int i = 0; i < mMeasurementCallbacks.length; i++) { mMeasurementCallbacks[i].onReportMeasurements(event); } }); } @NativeEntryPoint void reportAntennaInfo(List<GnssAntennaInfo> antennaInfos) { Binder.withCleanCallingIdentity(() -> { for (int i = 0; i < mAntennaInfoCallbacks.length; i++) { mAntennaInfoCallbacks[i].onReportAntennaInfo(antennaInfos); } }); } @NativeEntryPoint void reportNavigationMessage(GnssNavigationMessage event) { Binder.withCleanCallingIdentity(() -> { if (mItarSpeedLimitExceeded) { return; } Loading @@ -1030,6 +1046,7 @@ public class GnssNative { for (int i = 0; i < mNavigationMessageCallbacks.length; i++) { mNavigationMessageCallbacks[i].onReportNavigationMessage(event); } }); } @NativeEntryPoint Loading Loading @@ -1061,6 +1078,7 @@ public class GnssNative { private void onCapabilitiesChanged(GnssCapabilities oldCapabilities, GnssCapabilities newCapabilities) { Binder.withCleanCallingIdentity(() -> { if (newCapabilities.equals(oldCapabilities)) { return; } Loading @@ -1070,6 +1088,7 @@ public class GnssNative { for (int i = 0; i < mBaseCallbacks.length; i++) { mBaseCallbacks[i].onCapabilitiesChanged(oldCapabilities, newCapabilities); } }); } @NativeEntryPoint Loading @@ -1089,88 +1108,103 @@ public class GnssNative { @NativeEntryPoint void reportLocationBatch(Location[] locations) { Binder.withCleanCallingIdentity(() -> { for (int i = 0; i < mLocationCallbacks.length; i++) { mLocationCallbacks[i].onReportLocations(locations); } }); } @NativeEntryPoint void psdsDownloadRequest(int psdsType) { mPsdsCallbacks.onRequestPsdsDownload(psdsType); Binder.withCleanCallingIdentity(() -> mPsdsCallbacks.onRequestPsdsDownload(psdsType)); } @NativeEntryPoint void reportGeofenceTransition(int geofenceId, Location location, int transition, long transitionTimestamp) { mGeofenceCallbacks.onReportGeofenceTransition(geofenceId, location, transition, transitionTimestamp); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceTransition(geofenceId, location, transition, transitionTimestamp)); } @NativeEntryPoint void reportGeofenceStatus(int status, Location location) { mGeofenceCallbacks.onReportGeofenceStatus(status, location); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceStatus(status, location)); } @NativeEntryPoint void reportGeofenceAddStatus(int geofenceId, @GeofenceCallbacks.GeofenceStatus int status) { mGeofenceCallbacks.onReportGeofenceAddStatus(geofenceId, status); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceAddStatus(geofenceId, status)); } @NativeEntryPoint void reportGeofenceRemoveStatus(int geofenceId, @GeofenceCallbacks.GeofenceStatus int status) { mGeofenceCallbacks.onReportGeofenceRemoveStatus(geofenceId, status); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceRemoveStatus(geofenceId, status)); } @NativeEntryPoint void reportGeofencePauseStatus(int geofenceId, @GeofenceCallbacks.GeofenceStatus int status) { mGeofenceCallbacks.onReportGeofencePauseStatus(geofenceId, status); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofencePauseStatus(geofenceId, status)); } @NativeEntryPoint void reportGeofenceResumeStatus(int geofenceId, @GeofenceCallbacks.GeofenceStatus int status) { mGeofenceCallbacks.onReportGeofenceResumeStatus(geofenceId, status); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceResumeStatus(geofenceId, status)); } @NativeEntryPoint void reportNiNotification(int notificationId, int niType, int notifyFlags, int timeout, int defaultResponse, String requestorId, String text, int requestorIdEncoding, int textEncoding) { mNotificationCallbacks.onReportNiNotification(notificationId, niType, notifyFlags, timeout, defaultResponse, requestorId, text, requestorIdEncoding, textEncoding); Binder.withCleanCallingIdentity( () -> mNotificationCallbacks.onReportNiNotification(notificationId, niType, notifyFlags, timeout, defaultResponse, requestorId, text, requestorIdEncoding, textEncoding)); } @NativeEntryPoint void requestSetID(int flags) { mAGpsCallbacks.onRequestSetID(flags); Binder.withCleanCallingIdentity(() -> mAGpsCallbacks.onRequestSetID(flags)); } @NativeEntryPoint void requestLocation(boolean independentFromGnss, boolean isUserEmergency) { mLocationRequestCallbacks.onRequestLocation(independentFromGnss, isUserEmergency); Binder.withCleanCallingIdentity( () -> mLocationRequestCallbacks.onRequestLocation(independentFromGnss, isUserEmergency)); } @NativeEntryPoint void requestUtcTime() { mTimeCallbacks.onRequestUtcTime(); Binder.withCleanCallingIdentity(() -> mTimeCallbacks.onRequestUtcTime()); } @NativeEntryPoint void requestRefLocation() { mLocationRequestCallbacks.onRequestRefLocation(); Binder.withCleanCallingIdentity( () -> mLocationRequestCallbacks.onRequestRefLocation()); } @NativeEntryPoint void reportNfwNotification(String proxyAppPackageName, byte protocolStack, String otherProtocolStackName, byte requestor, String requestorId, byte responseType, boolean inEmergencyMode, boolean isCachedLocation) { mNotificationCallbacks.onReportNfwNotification(proxyAppPackageName, protocolStack, otherProtocolStackName, requestor, requestorId, responseType, inEmergencyMode, isCachedLocation); Binder.withCleanCallingIdentity( () -> mNotificationCallbacks.onReportNfwNotification(proxyAppPackageName, protocolStack, otherProtocolStackName, requestor, requestorId, responseType, inEmergencyMode, isCachedLocation)); } @NativeEntryPoint boolean isInEmergencySession() { return mEmergencyHelper.isInEmergency(mConfiguration.getEsExtensionSec()); return Binder.withCleanCallingIdentity( () -> mEmergencyHelper.isInEmergency(mConfiguration.getEsExtensionSec())); } /** Loading Loading
services/core/java/com/android/server/location/gnss/hal/GnssNative.java +114 −80 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.location.GnssMeasurementsEvent; import android.location.GnssNavigationMessage; import android.location.GnssStatus; import android.location.Location; import android.os.Binder; import android.os.SystemClock; import android.util.Log; Loading Loading @@ -921,6 +922,7 @@ public class GnssNative { @NativeEntryPoint void reportGnssServiceDied() { // Not necessary to clear (and restore) binder identity since it runs on another thread. Log.e(TAG, "gnss hal died - restarting shortly..."); // move to another thread just in case there is some awkward gnss thread dependency with Loading @@ -940,6 +942,7 @@ public class GnssNative { @NativeEntryPoint void reportLocation(boolean hasLatLong, Location location) { Binder.withCleanCallingIdentity(() -> { if (hasLatLong && !mHasFirstFix) { mHasFirstFix = true; Loading Loading @@ -967,33 +970,40 @@ public class GnssNative { for (int i = 0; i < mLocationCallbacks.length; i++) { mLocationCallbacks[i].onReportLocation(hasLatLong, location); } }); } @NativeEntryPoint void reportStatus(@StatusCallbacks.GnssStatusValue int gnssStatus) { Binder.withCleanCallingIdentity(() -> { for (int i = 0; i < mStatusCallbacks.length; i++) { mStatusCallbacks[i].onReportStatus(gnssStatus); } }); } @NativeEntryPoint void reportSvStatus(int svCount, int[] svidWithFlags, float[] cn0DbHzs, float[] elevations, float[] azimuths, float[] carrierFrequencies, float[] basebandCn0DbHzs) { Binder.withCleanCallingIdentity(() -> { GnssStatus gnssStatus = GnssStatus.wrap(svCount, svidWithFlags, cn0DbHzs, elevations, azimuths, carrierFrequencies, basebandCn0DbHzs); for (int i = 0; i < mSvStatusCallbacks.length; i++) { mSvStatusCallbacks[i].onReportSvStatus(gnssStatus); } }); } @NativeEntryPoint void reportAGpsStatus(int agpsType, int agpsStatus, byte[] suplIpAddr) { mAGpsCallbacks.onReportAGpsStatus(agpsType, agpsStatus, suplIpAddr); Binder.withCleanCallingIdentity( () -> mAGpsCallbacks.onReportAGpsStatus(agpsType, agpsStatus, suplIpAddr)); } @NativeEntryPoint void reportNmea(long timestamp) { Binder.withCleanCallingIdentity(() -> { if (mItarSpeedLimitExceeded) { return; } Loading @@ -1001,10 +1011,12 @@ public class GnssNative { for (int i = 0; i < mNmeaCallbacks.length; i++) { mNmeaCallbacks[i].onReportNmea(timestamp); } }); } @NativeEntryPoint void reportMeasurementData(GnssMeasurementsEvent event) { Binder.withCleanCallingIdentity(() -> { if (mItarSpeedLimitExceeded) { return; } Loading @@ -1012,17 +1024,21 @@ public class GnssNative { for (int i = 0; i < mMeasurementCallbacks.length; i++) { mMeasurementCallbacks[i].onReportMeasurements(event); } }); } @NativeEntryPoint void reportAntennaInfo(List<GnssAntennaInfo> antennaInfos) { Binder.withCleanCallingIdentity(() -> { for (int i = 0; i < mAntennaInfoCallbacks.length; i++) { mAntennaInfoCallbacks[i].onReportAntennaInfo(antennaInfos); } }); } @NativeEntryPoint void reportNavigationMessage(GnssNavigationMessage event) { Binder.withCleanCallingIdentity(() -> { if (mItarSpeedLimitExceeded) { return; } Loading @@ -1030,6 +1046,7 @@ public class GnssNative { for (int i = 0; i < mNavigationMessageCallbacks.length; i++) { mNavigationMessageCallbacks[i].onReportNavigationMessage(event); } }); } @NativeEntryPoint Loading Loading @@ -1061,6 +1078,7 @@ public class GnssNative { private void onCapabilitiesChanged(GnssCapabilities oldCapabilities, GnssCapabilities newCapabilities) { Binder.withCleanCallingIdentity(() -> { if (newCapabilities.equals(oldCapabilities)) { return; } Loading @@ -1070,6 +1088,7 @@ public class GnssNative { for (int i = 0; i < mBaseCallbacks.length; i++) { mBaseCallbacks[i].onCapabilitiesChanged(oldCapabilities, newCapabilities); } }); } @NativeEntryPoint Loading @@ -1089,88 +1108,103 @@ public class GnssNative { @NativeEntryPoint void reportLocationBatch(Location[] locations) { Binder.withCleanCallingIdentity(() -> { for (int i = 0; i < mLocationCallbacks.length; i++) { mLocationCallbacks[i].onReportLocations(locations); } }); } @NativeEntryPoint void psdsDownloadRequest(int psdsType) { mPsdsCallbacks.onRequestPsdsDownload(psdsType); Binder.withCleanCallingIdentity(() -> mPsdsCallbacks.onRequestPsdsDownload(psdsType)); } @NativeEntryPoint void reportGeofenceTransition(int geofenceId, Location location, int transition, long transitionTimestamp) { mGeofenceCallbacks.onReportGeofenceTransition(geofenceId, location, transition, transitionTimestamp); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceTransition(geofenceId, location, transition, transitionTimestamp)); } @NativeEntryPoint void reportGeofenceStatus(int status, Location location) { mGeofenceCallbacks.onReportGeofenceStatus(status, location); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceStatus(status, location)); } @NativeEntryPoint void reportGeofenceAddStatus(int geofenceId, @GeofenceCallbacks.GeofenceStatus int status) { mGeofenceCallbacks.onReportGeofenceAddStatus(geofenceId, status); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceAddStatus(geofenceId, status)); } @NativeEntryPoint void reportGeofenceRemoveStatus(int geofenceId, @GeofenceCallbacks.GeofenceStatus int status) { mGeofenceCallbacks.onReportGeofenceRemoveStatus(geofenceId, status); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceRemoveStatus(geofenceId, status)); } @NativeEntryPoint void reportGeofencePauseStatus(int geofenceId, @GeofenceCallbacks.GeofenceStatus int status) { mGeofenceCallbacks.onReportGeofencePauseStatus(geofenceId, status); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofencePauseStatus(geofenceId, status)); } @NativeEntryPoint void reportGeofenceResumeStatus(int geofenceId, @GeofenceCallbacks.GeofenceStatus int status) { mGeofenceCallbacks.onReportGeofenceResumeStatus(geofenceId, status); Binder.withCleanCallingIdentity( () -> mGeofenceCallbacks.onReportGeofenceResumeStatus(geofenceId, status)); } @NativeEntryPoint void reportNiNotification(int notificationId, int niType, int notifyFlags, int timeout, int defaultResponse, String requestorId, String text, int requestorIdEncoding, int textEncoding) { mNotificationCallbacks.onReportNiNotification(notificationId, niType, notifyFlags, timeout, defaultResponse, requestorId, text, requestorIdEncoding, textEncoding); Binder.withCleanCallingIdentity( () -> mNotificationCallbacks.onReportNiNotification(notificationId, niType, notifyFlags, timeout, defaultResponse, requestorId, text, requestorIdEncoding, textEncoding)); } @NativeEntryPoint void requestSetID(int flags) { mAGpsCallbacks.onRequestSetID(flags); Binder.withCleanCallingIdentity(() -> mAGpsCallbacks.onRequestSetID(flags)); } @NativeEntryPoint void requestLocation(boolean independentFromGnss, boolean isUserEmergency) { mLocationRequestCallbacks.onRequestLocation(independentFromGnss, isUserEmergency); Binder.withCleanCallingIdentity( () -> mLocationRequestCallbacks.onRequestLocation(independentFromGnss, isUserEmergency)); } @NativeEntryPoint void requestUtcTime() { mTimeCallbacks.onRequestUtcTime(); Binder.withCleanCallingIdentity(() -> mTimeCallbacks.onRequestUtcTime()); } @NativeEntryPoint void requestRefLocation() { mLocationRequestCallbacks.onRequestRefLocation(); Binder.withCleanCallingIdentity( () -> mLocationRequestCallbacks.onRequestRefLocation()); } @NativeEntryPoint void reportNfwNotification(String proxyAppPackageName, byte protocolStack, String otherProtocolStackName, byte requestor, String requestorId, byte responseType, boolean inEmergencyMode, boolean isCachedLocation) { mNotificationCallbacks.onReportNfwNotification(proxyAppPackageName, protocolStack, otherProtocolStackName, requestor, requestorId, responseType, inEmergencyMode, isCachedLocation); Binder.withCleanCallingIdentity( () -> mNotificationCallbacks.onReportNfwNotification(proxyAppPackageName, protocolStack, otherProtocolStackName, requestor, requestorId, responseType, inEmergencyMode, isCachedLocation)); } @NativeEntryPoint boolean isInEmergencySession() { return mEmergencyHelper.isInEmergency(mConfiguration.getEsExtensionSec()); return Binder.withCleanCallingIdentity( () -> mEmergencyHelper.isInEmergency(mConfiguration.getEsExtensionSec())); } /** Loading