Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/grapheneos/geocoder/GeocodeProviderImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class GeocodeProviderImpl(private val context: Context) : GeocodeProviderBase(co
) {
verboseLog(TAG) {
"forward geocode parameters: locationName: ${request.locationName}, " +
"lowerLeftLatitude: ${request.lowerLeftLongitude}, lowerLeftLongitude: ${request.lowerLeftLongitude}, " +
"upperRightLatitude: ${request.upperRightLatitude}, upperrightlongitude: ${request.upperRightLongitude}, " +
"lowerLeftLatitude: ${request.lowerLeftLatitude}, lowerLeftLongitude: ${request.lowerLeftLongitude}, " +
"upperRightLatitude: ${request.upperRightLatitude}, upperRightLongitude: ${request.upperRightLongitude}, " +
"maxResults: ${request.maxResults}, locale: ${request.locale}"
}
try {
Expand Down
9 changes: 7 additions & 2 deletions src/app/grapheneos/geocoder/NominatimGeocoder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,17 @@ class NominatimGeocoder : Geocoder {
}
val result = mutableListOf<Address>()
for (feature in response.features?.take(expectedMaxResults) ?: emptyList()) {
val coordinates = feature.geometry.coordinates
if (coordinates.size < 2) {
Log.w(TAG, "skipping feature with invalid coordinates size: ${coordinates.size}")
continue
}
val extra = feature.properties.geocoding.extra?.toMutableMap()
// we don't know which locale was actually used, so we just assume it was the one
// we requested
val address = Address(preferredLocale)
address.latitude = feature.geometry.coordinates[1]
address.longitude = feature.geometry.coordinates[0]
address.latitude = coordinates[1]
address.longitude = coordinates[0]
with(feature.properties.geocoding) {
address.postalCode = this.postcode
address.featureName = this.name
Expand Down
8 changes: 6 additions & 2 deletions src/app/grapheneos/networklocation/LocationReportingTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,14 @@ class LocationReportingTask(
val estimatedGeoPoint = enuPointToGeoPoint(enuPoint, refGeoPoint)
loc.longitude = estimatedGeoPoint.longitude
loc.latitude = estimatedGeoPoint.latitude
loc.accuracy = sqrt(max(result.x.sixSigmaSquared, result.y.sixSigmaSquared)).toFloat()
val accuracySixSigma = sqrt(max(result.x.sixSigmaSquared, result.y.sixSigmaSquared))
// Convert from 6-sigma to 1-sigma
loc.accuracy = accuracySixSigma.div(6.0).toFloat()
estimatedGeoPoint.altitude?.let { estimatedAltitude ->
loc.altitude = estimatedAltitude
loc.verticalAccuracyMeters = sqrt(result.z.sixSigmaSquared).toFloat()
val verticalAccuracySixSigma = sqrt(result.z.sixSigmaSquared)
// Convert from 6-sigma to 1-sigma
loc.verticalAccuracyMeters = verticalAccuracySixSigma.div(6.0).toFloat()
}
return loc
}
Expand Down
5 changes: 3 additions & 2 deletions src/app/grapheneos/networklocation/wifi/WifiApRanger.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.net.wifi.rtt.RangingResultCallback
import android.net.wifi.rtt.WifiRttManager
import android.os.WorkSource
import app.grapheneos.verboseLog
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
Expand All @@ -19,6 +20,7 @@ private const val TAG = "WifiApRanger"
* TODO: WIP Wi-Fi RTT AP ranger, not currently used.
*/
class WifiApRanger(private val context: Context) {
private val rangingExecutor: ExecutorService = Executors.newSingleThreadExecutor()

@Throws(WifiRangerUnavailableException::class, WifiRangerFailedException::class)
suspend fun range(scanResults: List<ScanResult>, workSource: WorkSource): List<RangingResult> {
Expand Down Expand Up @@ -51,11 +53,10 @@ class WifiApRanger(private val context: Context) {
}
}
verboseLog(TAG) { "calling startRanging" }
val executor = Executors.newSingleThreadExecutor()
wifiRttManager.startRanging(
workSource,
request,
executor,
rangingExecutor,
rangingResultCallback
)
continuation.invokeOnCancellation {
Expand Down