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

Unverified Commit 5a15565d authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Location: Use Ichnaea API key from local.properties

parent 3a42d956
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -37,6 +37,14 @@ buildscript {
    ext.androidTargetSdk = 29
    ext.androidCompileSdk = 33

    ext.localProperties = new Properties()

    try {
        ext.localProperties.load(rootProject.file('local.properties').newDataInputStream())
    } catch (ignored) {
        // Ignore
    }

    repositories {
        mavenCentral()
        google()
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ android {
        versionName version
        minSdkVersion androidMinSdk
        targetSdkVersion androidTargetSdk
        buildConfigField "String", "ICHNAEA_KEY", "\"${localProperties.get("ichnaea.key", "")}\""
    }

    sourceSets {
+7 −3
Original line number Diff line number Diff line
@@ -7,11 +7,13 @@ package org.microg.gms.location.network.mozilla

import android.content.Context
import android.location.Location
import android.net.Uri
import android.os.Bundle
import android.util.Log
import com.android.volley.Request.Method
import com.android.volley.toolbox.JsonObjectRequest
import com.android.volley.toolbox.Volley
import org.microg.gms.location.core.BuildConfig
import org.microg.gms.location.network.NetworkLocationService
import org.microg.gms.location.network.cell.CellDetails
import org.microg.gms.location.network.precision
@@ -66,7 +68,9 @@ class MozillaLocationServiceClient(context: Context) {
    }

    private suspend fun rawGeoLocate(request: GeolocateRequest): GeolocateResponse = suspendCoroutine { continuation ->
        queue.add(JsonObjectRequest(Method.POST, GEOLOCATE_URL.format(API_KEY), request.toJson(), {
        queue.add(JsonObjectRequest(Method.POST, Uri.parse(GEOLOCATE_URL).buildUpon().apply {
            if (API_KEY != null) appendQueryParameter("key", API_KEY)
        }.build().toString(), request.toJson(), {
            continuation.resume(it.toGeolocateResponse())
        }, {
            continuation.resumeWithException(it)
@@ -75,11 +79,11 @@ class MozillaLocationServiceClient(context: Context) {

    companion object {
        private const val TAG = "MozillaLocation"
        private const val GEOLOCATE_URL = "https://location.services.mozilla.com/v1/geolocate?key=%s"
        private const val API_KEY = "068ab754-c06b-473d-a1e5-60e7b1a2eb77"
        private const val GEOLOCATE_URL = "https://location.services.mozilla.com/v1/geolocate"
        private const val WIFI_BASE_PRECISION_COUNT = 8.0
        private const val CELL_DEFAULT_PRECISION = 1.0
        private const val CELL_FALLBACK_PRECISION = 0.5
        private val API_KEY: String? = BuildConfig.ICHNAEA_KEY.takeIf { it.isNotBlank() }
        const val LOCATION_EXTRA_FALLBACK = "fallback"
    }

+1 −11
Original line number Diff line number Diff line
@@ -38,16 +38,6 @@ def execResult(...args) {
    return stdout.toString().trim()
}

def mapboxKey() {
    Properties properties = new Properties()
    try {
        properties.load(project.rootProject.file('local.properties').newDataInputStream())
    } catch (ignored) {
        // Ignore
    }
    return properties.getProperty("mapbox.key", "invalid")
}

android {
    compileSdkVersion androidCompileSdk
    buildToolsVersion "$androidBuildVersionTools"
@@ -56,7 +46,7 @@ android {
        versionName version
        minSdkVersion androidMinSdk
        targetSdkVersion androidTargetSdk
        buildConfigField "String", "MAPBOX_KEY", "\"${mapboxKey()}\""
        buildConfigField "String", "MAPBOX_KEY", "\"${localProperties.getProperty("mapbox.key", "")}\""

        ndk {
            abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"