Skip to content
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/crowdin_pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod +x ./gradlew
./gradlew --no-daemon clean :play-services-core:assembleDefaultDebug
./gradlew --no-daemon clean :play-services-core:assembleMapboxDefaultDebug

# Step 3: Checkout dev branch to prepare for merging
- name: Checkout dev branch for merge
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ jobs:
fi
done
- name: "Execute Gradle build"
run: "./gradlew --no-daemon clean :play-services-core:assembleDefaultRelease"
run: "./gradlew --no-daemon clean :play-services-core:assembleMapboxDefaultRelease"

- uses: ilharp/sign-android-release@v2
name: "Sign app APK"
id: sign_app
with:
releaseDir: play-services-core/build/outputs/apk/default/release
releaseDir: play-services-core/build/outputs/apk/mapboxDefault/release
signingKey: ${{ secrets.KEYSTORE_B64 }}
keyAlias: ${{ secrets.KEYSTORE_ENTRY_ALIAS }}
keyStorePassword: ${{ secrets.KEYSTORE_PASSWORD }}
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ buildscript {

ext.androidBuildGradleVersion = '8.13.2'

// ext.androidBuildVersionTools = '34.0.0'
ext.androidBuildVersionTools = '35.0.0'

ext.androidMinSdk = 24
ext.androidTargetSdk = 29
Expand All @@ -48,6 +48,9 @@ buildscript {
':play-services-cast-core',
':play-services-cast-framework-core',
':play-services-conscrypt-provider-core',
':play-services-location-core',
':play-services-location-core-base',
':play-services-maps',
':play-services-core-proto', // deprecated
':play-services-core:microg-ui-tools',
':play-services-api',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,42 @@ object SettingsContract {
)
}

object Location {
private const val id = "location"
fun getContentUri(context: Context) = Uri.withAppendedPath(getAuthorityUri(context), id)
fun getContentType(context: Context) = "vnd.android.cursor.item/vnd.${getAuthority(context)}.$id"

const val WIFI_ICHNAEA = "location_wifi_mls"
const val WIFI_MOVING = "location_wifi_moving"
const val WIFI_LEARNING = "location_wifi_learning"
const val WIFI_CACHING = "location_wifi_caching"
const val CELL_ICHNAEA = "location_cell_mls"
const val CELL_LEARNING = "location_cell_learning"
const val CELL_CACHING = "location_cell_caching"
const val GEOCODER_NOMINATIM = "location_geocoder_nominatim"
const val ICHNAEA_ENDPOINT = "location_ichnaea_endpoint"
const val ONLINE_SOURCE = "location_online_source"
const val ICHNAEA_CONTRIBUTE = "location_ichnaea_contribute"
const val MAPS_TIMELINE = "location_timeline"
const val MAPS_TIMELINE_UPLOAD = "location_timeline_upload"

val PROJECTION = arrayOf(
WIFI_ICHNAEA,
WIFI_MOVING,
WIFI_LEARNING,
WIFI_CACHING,
CELL_ICHNAEA,
CELL_LEARNING,
CELL_CACHING,
GEOCODER_NOMINATIM,
ICHNAEA_ENDPOINT,
ONLINE_SOURCE,
ICHNAEA_CONTRIBUTE,
MAPS_TIMELINE,
MAPS_TIMELINE_UPLOAD,
)
}

object Profile {
private const val id = "profile"
fun getContentUri(context: Context) = Uri.withAppendedPath(getAuthorityUri(context), id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.microg.gms.common.PackageUtils.warnIfNotMainProcess
import org.microg.gms.settings.SettingsContract.Auth
import org.microg.gms.settings.SettingsContract.CheckIn
import org.microg.gms.settings.SettingsContract.Gcm
import org.microg.gms.settings.SettingsContract.Location
import org.microg.gms.settings.SettingsContract.Profile
import org.microg.gms.settings.SettingsContract.getAuthority
import java.io.File
Expand Down Expand Up @@ -69,6 +70,7 @@ class SettingsProvider : ContentProvider() {
CheckIn.getContentUri(context!!) -> queryCheckIn(projection ?: CheckIn.PROJECTION)
Gcm.getContentUri(context!!) -> queryGcm(projection ?: Gcm.PROJECTION)
Auth.getContentUri(context!!) -> queryAuth(projection ?: Auth.PROJECTION)
Location.getContentUri(context!!) -> queryLocation(projection ?: Location.PROJECTION)
Profile.getContentUri(context!!) -> queryProfile(projection ?: Profile.PROJECTION)
else -> null
}
Expand All @@ -85,6 +87,7 @@ class SettingsProvider : ContentProvider() {
CheckIn.getContentUri(context!!) -> updateCheckIn(values)
Gcm.getContentUri(context!!) -> updateGcm(values)
Auth.getContentUri(context!!) -> updateAuth(values)
Location.getContentUri(context!!) -> updateLocation(values)
Profile.getContentUri(context!!) -> updateProfile(values)
else -> return 0
}
Expand Down Expand Up @@ -240,6 +243,62 @@ class SettingsProvider : ContentProvider() {
editor.apply()
}

private fun queryLocation(p: Array<out String>): Cursor = MatrixCursor(p).addRow(p) { key ->
when (key) {
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, false)
Location.WIFI_CACHING -> getSettingsBoolean(key, getSettingsBoolean(Location.WIFI_LEARNING, false) == 1)
Location.CELL_ICHNAEA -> getSettingsBoolean(key, hasUnifiedNlpLocationBackend("org.microg.nlp.backend.ichnaea"))
Location.CELL_LEARNING -> getSettingsBoolean(key, true)
Location.CELL_CACHING -> getSettingsBoolean(key, getSettingsBoolean(Location.CELL_LEARNING, true) == 1)
Location.GEOCODER_NOMINATIM -> getSettingsBoolean(key, hasUnifiedNlpGeocoderBackend("org.microg.nlp.backend.nominatim"))
Location.ICHNAEA_ENDPOINT -> getSettingsString(key)
Location.ONLINE_SOURCE -> getSettingsString(key)
Location.ICHNAEA_CONTRIBUTE -> getSettingsBoolean(key, false)
Location.MAPS_TIMELINE -> getSettingsBoolean(key, false)
Location.MAPS_TIMELINE_UPLOAD -> getSettingsBoolean(key, false)
else -> throw IllegalArgumentException("Unknown key: $key")
}
}

private fun hasUnifiedNlpPrefixInStringSet(key: String, vararg prefixes: String) =
getUnifiedNlpSettingsStringSetCompat(key, emptySet()).any { entry ->
prefixes.any { prefix -> entry.startsWith(prefix) }
}

private fun hasUnifiedNlpLocationBackend(vararg packageNames: String) =
hasUnifiedNlpPrefixInStringSet("location_backends", *packageNames.map { "$it/" }.toTypedArray())

private fun hasUnifiedNlpGeocoderBackend(vararg packageNames: String) =
hasUnifiedNlpPrefixInStringSet("geocoder_backends", *packageNames.map { "$it/" }.toTypedArray())

private fun updateLocation(values: ContentValues) {
if (values.size() == 0) return
val editor = preferences.edit()
values.valueSet().forEach { (key, value) ->
when (key) {
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_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 -> (value as String).let {
if (it.isBlank()) editor.remove(key) else editor.putString(key, it)
}
Location.ONLINE_SOURCE -> (value as? String).let {
if (it.isNullOrBlank()) editor.remove(key) else editor.putString(key, it)
}
Location.ICHNAEA_CONTRIBUTE -> editor.putBoolean(key, value as Boolean)
Location.MAPS_TIMELINE -> editor.putBoolean(key, value as Boolean)
Location.MAPS_TIMELINE_UPLOAD -> editor.putBoolean(key, value as Boolean)
else -> throw IllegalArgumentException("Unknown key: $key")
}
}
editor.apply()
}

private fun MatrixCursor.addRow(
p: Array<out String>,
valueGetter: (String) -> Any?
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* SPDX-FileCopyrightText: 2024 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package org.microg.gms.utils

private val singleInstanceLock = Any()
private val singleInstanceMap: MutableMap<Class<*>, Any> = hashMapOf()

fun <T : Any> singleInstanceOf(tClass: Class<T>, tCreator: () -> T): T {
val volatileItem = singleInstanceMap[tClass]
@Suppress("UNCHECKED_CAST")
if (volatileItem != null && tClass.isAssignableFrom(volatileItem.javaClass)) return volatileItem as T
val itemLock = synchronized(singleInstanceLock) {
val item = singleInstanceMap[tClass]
if (item != null) {
@Suppress("UNCHECKED_CAST")
if (tClass.isAssignableFrom(item.javaClass)) return item as T
item
} else {
val lock = Any()
singleInstanceMap[tClass] = lock
lock
}
}
synchronized(itemLock) {
val item = synchronized(singleInstanceMap) { singleInstanceMap[tClass] }
if (item == null) throw IllegalStateException()
@Suppress("UNCHECKED_CAST")
if (tClass.isAssignableFrom(item.javaClass)) return item as T
if (item != itemLock) throw IllegalStateException()

val newItem = tCreator()
synchronized(singleInstanceMap) {
singleInstanceMap[tClass] = newItem
}
return newItem
}
}

inline fun <reified T : Any> singleInstanceOf(noinline creator: () -> T): T =
singleInstanceOf(T::class.java, creator)
16 changes: 16 additions & 0 deletions play-services-base/core/src/main/res/drawable/ic_radio_checked.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ SPDX-FileCopyrightText: 2019 The Android Open Source Project
~ SPDX-FileCopyrightText: 2021 microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorAccent"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5 5,-2.24 5,-5 -2.24,-5 -5,-5zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ SPDX-FileCopyrightText: 2019 The Android Open Source Project
~ SPDX-FileCopyrightText: 2021 microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z" />
</vector>
37 changes: 36 additions & 1 deletion play-services-base/core/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,42 @@
~ SPDX-License-Identifier: Apache-2.0
-->

<resources>
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="Theme.Base.Light.Dialog" parent="Theme.AppCompat.Light.Dialog" />

<style name="Theme.Base.Light.Dialog.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="Theme.Base.Light.Dialog.Alert" parent="Theme.AppCompat.Light.Dialog.Alert" />

<style name="Theme.Base.Light.Dialog.Alert.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="Theme.Base.DayNight.Dialog.Alert" parent="Theme.AppCompat.DayNight.Dialog.Alert" />

<style name="Theme.Base.DayNight.Dialog.Alert.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="Theme.Base.Translucent" parent="Theme.Base.DayNight.Dialog.Alert.NoActionBar">
<item name="background">@android:color/transparent</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:windowOptOutEdgeToEdgeEnforcement" tools:targetApi="35">true</item>
</style>

<style name="Theme.App.Translucent" parent="Theme.Base.Translucent" />

<declare-styleable name="PreferenceTheme">
<attr format="reference" name="switchBarPreferenceStyle"/>
Expand Down
14 changes: 13 additions & 1 deletion play-services-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

configurations {
mapboxRuntimeOnly
vtmRuntimeOnly
defaultRuntimeOnly
}

Expand All @@ -18,6 +20,10 @@ dependencies {
implementation project(projectName)
}

mapboxRuntimeOnly project(':play-services-maps-core-mapbox')
vtmRuntimeOnly project(':play-services-maps-core-vtm')
defaultRuntimeOnly project(':play-services-location-core-provider')

// AndroidX Legacy
implementation "androidx.legacy:legacy-support-v4:$androidXLegacyVersion"

Expand Down Expand Up @@ -110,8 +116,14 @@ android {
}
}

flavorDimensions = ['target']
flavorDimensions = ['maps', 'target']
productFlavors {
"mapbox" {
dimension 'maps'
}
"vtm" {
dimension 'maps'
}
"default" {
dimension 'target'
}
Expand Down
5 changes: 4 additions & 1 deletion play-services-core/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<item name="android:colorBackgroundCacheHint">@null</item>
</style>

<!-- Compatibility alias used by the upstream Location implementation. -->
<style name="Theme.App.Translucent" parent="@style/AppTheme.Transparent" />

<!--app theme base-->

<style name="AppTheme.Base" parent="@style/Theme.Material3Expressive.Light.NoActionBar">
Expand Down Expand Up @@ -95,4 +98,4 @@
<item name="android:listPreferredItemPaddingStart">17dp</item>
<item name="android:listPreferredItemPaddingEnd">17dp</item>
</style>
</resources>
</resources>
43 changes: 43 additions & 0 deletions play-services-location/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* SPDX-FileCopyrightText: 2015 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'signing'

android {
namespace "com.google.android.gms.location"

compileSdkVersion androidCompileSdk
buildToolsVersion "$androidBuildVersionTools"

buildFeatures {
aidl = true
}

defaultConfig {
versionName version
minSdkVersion androidMinSdk
targetSdkVersion androidTargetSdk
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

apply from: '../gradle/publish-android.gradle'

description = 'microG implementation of play-services-location'

dependencies {
// Dependencies from play-services-location:21.0.1
api project(':play-services-base')
api project(':play-services-basement')
api project(':play-services-tasks')

annotationProcessor project(':safe-parcel-processor')
}
Loading
Loading