Loading play-services-base/core/build.gradle +8 −0 Original line number Diff line number Diff line Loading @@ -32,10 +32,18 @@ android { versionName version minSdkVersion androidMinSdk targetSdkVersion androidTargetSdk if (localProperties.get("ichnaea.endpoint", "") != "") { buildConfigField "String", "ICHNAEA_ENDPOINT_DEFAULT", "\"${localProperties.get("ichnaea.endpoint")}\"" } else if (localProperties.get("ichnaea.key", "") != "") { buildConfigField "String", "ICHNAEA_ENDPOINT_DEFAULT", "\"https://location.services.mozilla.com/?key=${localProperties.get("ichnaea.key")}\"" } else { buildConfigField "String", "ICHNAEA_ENDPOINT_DEFAULT", "\"\"" } } buildFeatures { dataBinding = true buildConfig = true } sourceSets { Loading play-services-base/core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt +6 −4 Original line number Diff line number Diff line Loading @@ -163,20 +163,22 @@ object SettingsContract { fun getContentUri(context: Context) = Uri.withAppendedPath(getAuthorityUri(context), id) fun getContentType(context: Context) = "vnd.android.cursor.item/vnd.${getAuthority(context)}.$id" const val WIFI_MLS = "location_wifi_mls" const val WIFI_ICHNAEA = "location_wifi_mls" const val WIFI_MOVING = "location_wifi_moving" const val WIFI_LEARNING = "location_wifi_learning" const val CELL_MLS = "location_cell_mls" const val CELL_ICHNAEA = "location_cell_mls" const val CELL_LEARNING = "location_cell_learning" const val GEOCODER_NOMINATIM = "location_geocoder_nominatim" const val ICHNAEA_ENDPOINT = "location_ichnaea_endpoint" val PROJECTION = arrayOf( WIFI_MLS, WIFI_ICHNAEA, WIFI_MOVING, WIFI_LEARNING, CELL_MLS, CELL_ICHNAEA, CELL_LEARNING, GEOCODER_NOMINATIM, ICHNAEA_ENDPOINT, ) } Loading play-services-base/core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt +7 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import android.database.MatrixCursor import android.net.Uri import android.os.Build.VERSION.SDK_INT import android.preference.PreferenceManager import org.microg.gms.base.core.BuildConfig import org.microg.gms.common.PackageUtils.warnIfNotMainProcess import org.microg.gms.settings.SettingsContract.Auth import org.microg.gms.settings.SettingsContract.CheckIn Loading Loading @@ -310,12 +311,13 @@ class SettingsProvider : ContentProvider() { private fun queryLocation(p: Array<out String>): Cursor = MatrixCursor(p).addRow(p) { key -> when (key) { Location.WIFI_MLS -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("org.microg.nlp.backend.ichnaea")) Location.WIFI_ICHNAEA -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("org.microg.nlp.backend.ichnaea")) Location.WIFI_MOVING -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("de.sorunome.unifiednlp.trains")) Location.WIFI_LEARNING -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("helium314.localbackend", "org.fitchfamily.android.dejavu")) Location.CELL_MLS -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("org.microg.nlp.backend.ichnaea")) Location.CELL_ICHNAEA -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("org.microg.nlp.backend.ichnaea")) Location.CELL_LEARNING -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("helium314.localbackend", "org.fitchfamily.android.dejavu")) Location.GEOCODER_NOMINATIM -> getSettingsBoolean(key, hasUnifiedNlpGeocoderBackend("org.microg.nlp.backend.nominatim") ) Location.ICHNAEA_ENDPOINT -> getSettingsString(key, BuildConfig.ICHNAEA_ENDPOINT_DEFAULT) else -> throw IllegalArgumentException("Unknown key: $key") } } Loading @@ -328,12 +330,13 @@ class SettingsProvider : ContentProvider() { val editor = preferences.edit() values.valueSet().forEach { (key, value) -> when (key) { Location.WIFI_MLS -> editor.putBoolean(key, value as Boolean) Location.WIFI_ICHNAEA -> editor.putBoolean(key, value as Boolean) Location.WIFI_MOVING -> editor.putBoolean(key, value as Boolean) Location.WIFI_LEARNING -> editor.putBoolean(key, value as Boolean) Location.CELL_MLS -> editor.putBoolean(key, value as Boolean) Location.CELL_ICHNAEA -> editor.putBoolean(key, value as Boolean) Location.CELL_LEARNING -> editor.putBoolean(key, value as Boolean) Location.GEOCODER_NOMINATIM -> editor.putBoolean(key, value as Boolean) Location.ICHNAEA_ENDPOINT -> editor.putString(key, value as String) else -> throw IllegalArgumentException("Unknown key: $key") } } Loading play-services-core/src/main/kotlin/org/microg/gms/provision/ProvisionService.kt +6 −2 Original line number Diff line number Diff line Loading @@ -40,8 +40,12 @@ class ProvisionService : LifecycleService() { DroidGuardPreferences.setEnabled(this@ProvisionService, it) } LocationSettings(this@ProvisionService).apply { intent?.extras?.getBooleanOrNull("wifi_mls")?.let { wifiMls = it } intent?.extras?.getBooleanOrNull("cell_mls")?.let { cellMls = it } intent?.extras?.getBooleanOrNull("wifi_mls")?.let { wifiIchnaea = it } intent?.extras?.getBooleanOrNull("wifi_ichnaea")?.let { wifiIchnaea = it } intent?.extras?.getBooleanOrNull("cell_mls")?.let { cellIchnaea = it } intent?.extras?.getBooleanOrNull("cell_ichnaea")?.let { cellIchnaea = it } intent?.extras?.getString("ichnaea_endpoint")?.let { ichneaeEndpoint = it } intent?.extras?.getBooleanOrNull("ichnaea_contribute")?.let { ichnaeaContribute = it } intent?.extras?.getBooleanOrNull("wifi_learning")?.let { wifiLearning = it } intent?.extras?.getBooleanOrNull("cell_learning")?.let { cellLearning = it } intent?.extras?.getBooleanOrNull("wifi_moving")?.let { wifiMoving = it } Loading play-services-location/core/base/src/main/kotlin/org/microg/gms/location/LocationSettings.kt +30 −39 Original line number Diff line number Diff line Loading @@ -5,55 +5,46 @@ package org.microg.gms.location import android.content.ContentValues import android.content.Context import android.database.Cursor import org.microg.gms.settings.SettingsContract class LocationSettings(private val context: Context) { var wifiMls : Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.WIFI_MLS)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.WIFI_MLS, value)} } private fun <T> getSettings(vararg projection: String, f: (Cursor) -> T): T = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), projection, f) private fun setSettings(v: ContentValues.() -> Unit) = SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context), v) var wifiIchnaea: Boolean get() = getSettings(SettingsContract.Location.WIFI_ICHNAEA) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.WIFI_ICHNAEA, value) } var wifiMoving: Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.WIFI_MOVING)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.WIFI_MOVING, value)} } get() = getSettings(SettingsContract.Location.WIFI_MOVING) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.WIFI_MOVING, value) } var wifiLearning: Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.WIFI_LEARNING)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.WIFI_LEARNING, value)} } get() = getSettings(SettingsContract.Location.WIFI_LEARNING) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.WIFI_LEARNING, value) } var cellMls : Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.CELL_MLS)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.CELL_MLS, value)} } var cellIchnaea: Boolean get() = getSettings(SettingsContract.Location.CELL_ICHNAEA) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.CELL_ICHNAEA, value) } var cellLearning: Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.CELL_LEARNING)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.CELL_LEARNING, value)} } get() = getSettings(SettingsContract.Location.CELL_LEARNING) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.CELL_LEARNING, value) } var geocoderNominatim: Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.GEOCODER_NOMINATIM)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.GEOCODER_NOMINATIM, value)} } get() = getSettings(SettingsContract.Location.GEOCODER_NOMINATIM) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.GEOCODER_NOMINATIM, value) } var ichneaeEndpoint: String get() = getSettings(SettingsContract.Location.ICHNAEA_ENDPOINT) { c -> c.getString(0) } set(value) = setSettings { put(SettingsContract.Location.ICHNAEA_ENDPOINT, value) } var ichnaeaContribute: Boolean get() = false set(value) = Unit } No newline at end of file Loading
play-services-base/core/build.gradle +8 −0 Original line number Diff line number Diff line Loading @@ -32,10 +32,18 @@ android { versionName version minSdkVersion androidMinSdk targetSdkVersion androidTargetSdk if (localProperties.get("ichnaea.endpoint", "") != "") { buildConfigField "String", "ICHNAEA_ENDPOINT_DEFAULT", "\"${localProperties.get("ichnaea.endpoint")}\"" } else if (localProperties.get("ichnaea.key", "") != "") { buildConfigField "String", "ICHNAEA_ENDPOINT_DEFAULT", "\"https://location.services.mozilla.com/?key=${localProperties.get("ichnaea.key")}\"" } else { buildConfigField "String", "ICHNAEA_ENDPOINT_DEFAULT", "\"\"" } } buildFeatures { dataBinding = true buildConfig = true } sourceSets { Loading
play-services-base/core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt +6 −4 Original line number Diff line number Diff line Loading @@ -163,20 +163,22 @@ object SettingsContract { fun getContentUri(context: Context) = Uri.withAppendedPath(getAuthorityUri(context), id) fun getContentType(context: Context) = "vnd.android.cursor.item/vnd.${getAuthority(context)}.$id" const val WIFI_MLS = "location_wifi_mls" const val WIFI_ICHNAEA = "location_wifi_mls" const val WIFI_MOVING = "location_wifi_moving" const val WIFI_LEARNING = "location_wifi_learning" const val CELL_MLS = "location_cell_mls" const val CELL_ICHNAEA = "location_cell_mls" const val CELL_LEARNING = "location_cell_learning" const val GEOCODER_NOMINATIM = "location_geocoder_nominatim" const val ICHNAEA_ENDPOINT = "location_ichnaea_endpoint" val PROJECTION = arrayOf( WIFI_MLS, WIFI_ICHNAEA, WIFI_MOVING, WIFI_LEARNING, CELL_MLS, CELL_ICHNAEA, CELL_LEARNING, GEOCODER_NOMINATIM, ICHNAEA_ENDPOINT, ) } Loading
play-services-base/core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt +7 −4 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ import android.database.MatrixCursor import android.net.Uri import android.os.Build.VERSION.SDK_INT import android.preference.PreferenceManager import org.microg.gms.base.core.BuildConfig import org.microg.gms.common.PackageUtils.warnIfNotMainProcess import org.microg.gms.settings.SettingsContract.Auth import org.microg.gms.settings.SettingsContract.CheckIn Loading Loading @@ -310,12 +311,13 @@ class SettingsProvider : ContentProvider() { private fun queryLocation(p: Array<out String>): Cursor = MatrixCursor(p).addRow(p) { key -> when (key) { Location.WIFI_MLS -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("org.microg.nlp.backend.ichnaea")) Location.WIFI_ICHNAEA -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("org.microg.nlp.backend.ichnaea")) Location.WIFI_MOVING -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("de.sorunome.unifiednlp.trains")) Location.WIFI_LEARNING -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("helium314.localbackend", "org.fitchfamily.android.dejavu")) Location.CELL_MLS -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("org.microg.nlp.backend.ichnaea")) Location.CELL_ICHNAEA -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("org.microg.nlp.backend.ichnaea")) Location.CELL_LEARNING -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("helium314.localbackend", "org.fitchfamily.android.dejavu")) Location.GEOCODER_NOMINATIM -> getSettingsBoolean(key, hasUnifiedNlpGeocoderBackend("org.microg.nlp.backend.nominatim") ) Location.ICHNAEA_ENDPOINT -> getSettingsString(key, BuildConfig.ICHNAEA_ENDPOINT_DEFAULT) else -> throw IllegalArgumentException("Unknown key: $key") } } Loading @@ -328,12 +330,13 @@ class SettingsProvider : ContentProvider() { val editor = preferences.edit() values.valueSet().forEach { (key, value) -> when (key) { Location.WIFI_MLS -> editor.putBoolean(key, value as Boolean) Location.WIFI_ICHNAEA -> editor.putBoolean(key, value as Boolean) Location.WIFI_MOVING -> editor.putBoolean(key, value as Boolean) Location.WIFI_LEARNING -> editor.putBoolean(key, value as Boolean) Location.CELL_MLS -> editor.putBoolean(key, value as Boolean) Location.CELL_ICHNAEA -> editor.putBoolean(key, value as Boolean) Location.CELL_LEARNING -> editor.putBoolean(key, value as Boolean) Location.GEOCODER_NOMINATIM -> editor.putBoolean(key, value as Boolean) Location.ICHNAEA_ENDPOINT -> editor.putString(key, value as String) else -> throw IllegalArgumentException("Unknown key: $key") } } Loading
play-services-core/src/main/kotlin/org/microg/gms/provision/ProvisionService.kt +6 −2 Original line number Diff line number Diff line Loading @@ -40,8 +40,12 @@ class ProvisionService : LifecycleService() { DroidGuardPreferences.setEnabled(this@ProvisionService, it) } LocationSettings(this@ProvisionService).apply { intent?.extras?.getBooleanOrNull("wifi_mls")?.let { wifiMls = it } intent?.extras?.getBooleanOrNull("cell_mls")?.let { cellMls = it } intent?.extras?.getBooleanOrNull("wifi_mls")?.let { wifiIchnaea = it } intent?.extras?.getBooleanOrNull("wifi_ichnaea")?.let { wifiIchnaea = it } intent?.extras?.getBooleanOrNull("cell_mls")?.let { cellIchnaea = it } intent?.extras?.getBooleanOrNull("cell_ichnaea")?.let { cellIchnaea = it } intent?.extras?.getString("ichnaea_endpoint")?.let { ichneaeEndpoint = it } intent?.extras?.getBooleanOrNull("ichnaea_contribute")?.let { ichnaeaContribute = it } intent?.extras?.getBooleanOrNull("wifi_learning")?.let { wifiLearning = it } intent?.extras?.getBooleanOrNull("cell_learning")?.let { cellLearning = it } intent?.extras?.getBooleanOrNull("wifi_moving")?.let { wifiMoving = it } Loading
play-services-location/core/base/src/main/kotlin/org/microg/gms/location/LocationSettings.kt +30 −39 Original line number Diff line number Diff line Loading @@ -5,55 +5,46 @@ package org.microg.gms.location import android.content.ContentValues import android.content.Context import android.database.Cursor import org.microg.gms.settings.SettingsContract class LocationSettings(private val context: Context) { var wifiMls : Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.WIFI_MLS)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.WIFI_MLS, value)} } private fun <T> getSettings(vararg projection: String, f: (Cursor) -> T): T = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), projection, f) private fun setSettings(v: ContentValues.() -> Unit) = SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context), v) var wifiIchnaea: Boolean get() = getSettings(SettingsContract.Location.WIFI_ICHNAEA) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.WIFI_ICHNAEA, value) } var wifiMoving: Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.WIFI_MOVING)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.WIFI_MOVING, value)} } get() = getSettings(SettingsContract.Location.WIFI_MOVING) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.WIFI_MOVING, value) } var wifiLearning: Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.WIFI_LEARNING)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.WIFI_LEARNING, value)} } get() = getSettings(SettingsContract.Location.WIFI_LEARNING) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.WIFI_LEARNING, value) } var cellMls : Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.CELL_MLS)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.CELL_MLS, value)} } var cellIchnaea: Boolean get() = getSettings(SettingsContract.Location.CELL_ICHNAEA) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.CELL_ICHNAEA, value) } var cellLearning: Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.CELL_LEARNING)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.CELL_LEARNING, value)} } get() = getSettings(SettingsContract.Location.CELL_LEARNING) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.CELL_LEARNING, value) } var geocoderNominatim: Boolean get() = SettingsContract.getSettings(context, SettingsContract.Location.getContentUri(context), arrayOf(SettingsContract.Location.GEOCODER_NOMINATIM)) { c -> c.getInt(0) != 0 } set(value) { SettingsContract.setSettings(context, SettingsContract.Location.getContentUri(context)) { put(SettingsContract.Location.GEOCODER_NOMINATIM, value)} } get() = getSettings(SettingsContract.Location.GEOCODER_NOMINATIM) { c -> c.getInt(0) != 0 } set(value) = setSettings { put(SettingsContract.Location.GEOCODER_NOMINATIM, value) } var ichneaeEndpoint: String get() = getSettings(SettingsContract.Location.ICHNAEA_ENDPOINT) { c -> c.getString(0) } set(value) = setSettings { put(SettingsContract.Location.ICHNAEA_ENDPOINT, value) } var ichnaeaContribute: Boolean get() = false set(value) = Unit } No newline at end of file