Skip to content

Commit

Permalink
Location: Entire rewrite of the location subsystem
Browse files Browse the repository at this point in the history
No modules anymore, they became unreliable in recent Android versions due to
"energy savings".
  • Loading branch information
mar-v-in committed Apr 18, 2023
1 parent 956e2ca commit f5ad796
Show file tree
Hide file tree
Showing 141 changed files with 11,420 additions and 1,946 deletions.
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@

buildscript {
ext.cronetVersion = '102.5005.125'
ext.nlpVersion = '2.0-alpha10'
ext.safeParcelVersion = '1.7.0'
ext.safeParcelVersion = '1.7.1'
ext.wearableVersion = '0.1.1'

ext.kotlinVersion = '1.7.10'
ext.coroutineVersion = '1.6.4'

ext.annotationVersion = '1.5.0'
ext.appcompatVersion = '1.4.2'
ext.appcompatVersion = '1.6.1'
ext.biometricVersion = '1.1.0'
ext.coreVersion = '1.8.0'
ext.fragmentVersion = '1.5.1'
ext.coreVersion = '1.9.0'
ext.fragmentVersion = '1.5.5'
ext.lifecycleVersion = '2.5.1'
ext.loaderVersion = '1.1.0'
ext.mediarouterVersion = '1.3.1'
Expand All @@ -36,7 +35,7 @@ buildscript {

ext.androidMinSdk = 14
ext.androidTargetSdk = 29
ext.androidCompileSdk = 31
ext.androidCompileSdk = 33

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

public class GetServiceRequest extends AutoSafeParcelable {
@Field(1)
private int versionCode = 4;
private int versionCode = 6;
@Field(2)
public final int serviceId;
@Field(3)
Expand All @@ -48,6 +48,7 @@ public class GetServiceRequest extends AutoSafeParcelable {
@Field(8)
public Account account;
@Field(9)
@Deprecated
private long field9;
@Field(10)
public Feature[] defaultFeatures;
Expand All @@ -60,7 +61,7 @@ public class GetServiceRequest extends AutoSafeParcelable {
@Field(14)
private boolean field14;
@Field(15)
private String field15;
private String attributionTag;

private GetServiceRequest() {
serviceId = -1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package org.microg.gms.common;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Hide the class, method or field from the public API.
*/
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
public @interface Hide {
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
* marked as public api.
*
* @return true if the method or field is not part of the public api
* @deprecated use {@link Hide} instead
*/
@Deprecated
boolean exclude() default false;
}
13 changes: 0 additions & 13 deletions play-services-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ dependencies {
implementation project(':play-services-safetynet')
implementation project(':play-services-tasks-ktx')

runtimeOnly("org.microg.nlp:geocode-v1:$nlpVersion") {
exclude group: 'org.microg', module: 'safe-parcel'
}
runtimeOnly("org.microg.nlp:location-v2:$nlpVersion") {
exclude group: 'org.microg', module: 'safe-parcel'
}
runtimeOnly("org.microg.nlp:location-v3:$nlpVersion") {
exclude group: 'org.microg', module: 'safe-parcel'
}
implementation("org.microg.nlp:ui:$nlpVersion") {
exclude group: 'org.microg', module: 'safe-parcel'
}

withMapboxImplementation project(':play-services-maps-core-mapbox')
withVtmImplementation project(':play-services-maps-core-vtm')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ import org.microg.gms.checkin.CheckinPrefs
import org.microg.gms.gcm.GcmDatabase
import org.microg.gms.gcm.getGcmServiceInfo
import org.microg.gms.safetynet.SafetyNetPreferences
import org.microg.nlp.client.GeocodeClient
import org.microg.nlp.client.LocationClient
import org.microg.nlp.client.UnifiedLocationClient
import org.microg.tools.ui.ResourceSettingsFragment

class SettingsFragment : ResourceSettingsFragment() {
Expand All @@ -36,8 +33,8 @@ class SettingsFragment : ResourceSettingsFragment() {
findNavController().navigate(requireContext(), R.id.openSafetyNetSettings)
true
}
findPreference<Preference>(PREF_UNIFIEDNLP)!!.onPreferenceClickListener = Preference.OnPreferenceClickListener {
findNavController().navigate(requireContext(), R.id.openUnifiedNlpSettings)
findPreference<Preference>(PREF_LOCATION)!!.onPreferenceClickListener = Preference.OnPreferenceClickListener {
// TODO
true
}
findPreference<Preference>(PREF_EXPOSURE)?.onPreferenceClickListener = Preference.OnPreferenceClickListener {
Expand Down Expand Up @@ -73,13 +70,6 @@ class SettingsFragment : ResourceSettingsFragment() {
findPreference<Preference>(PREF_CHECKIN)!!.setSummary(if (CheckinPrefs.isEnabled(context)) R.string.service_status_enabled_short else R.string.service_status_disabled_short)
findPreference<Preference>(PREF_SNET)!!.setSummary(if (SafetyNetPreferences.isEnabled(context)) R.string.service_status_enabled_short else R.string.service_status_disabled_short)

val backendCount = try {
LocationClient(context, lifecycle).getLocationBackends().size + GeocodeClient(context, lifecycle).getGeocodeBackends().size
} catch (e: Exception) {
0
}
findPreference<Preference>(PREF_UNIFIEDNLP)!!.summary = context.resources.getQuantityString(R.plurals.pref_unifiednlp_summary, backendCount, backendCount)

findPreference<Preference>(PREF_EXPOSURE)?.isVisible = NearbyPreferencesIntegration.isAvailable
findPreference<Preference>(PREF_EXPOSURE)?.icon = NearbyPreferencesIntegration.getIcon(context)
findPreference<Preference>(PREF_EXPOSURE)?.summary = NearbyPreferencesIntegration.getExposurePreferenceSummary(context)
Expand All @@ -89,7 +79,7 @@ class SettingsFragment : ResourceSettingsFragment() {
const val PREF_ABOUT = "pref_about"
const val PREF_GCM = "pref_gcm"
const val PREF_SNET = "pref_snet"
const val PREF_UNIFIEDNLP = "pref_unifiednlp"
const val PREF_LOCATION = "pref_location"
const val PREF_CHECKIN = "pref_checkin"
const val PREF_EXPOSURE = "pref_exposure"
}
Expand Down
4 changes: 0 additions & 4 deletions play-services-core/src/main/res/navigation/nav_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
android:id="@+id/settingsFragment"
android:name="org.microg.gms.ui.SettingsFragment"
android:label="@string/gms_settings_name">
<action
android:id="@+id/openUnifiedNlpSettings"
app:destination="@id/nav_unlp" />
<action
android:id="@+id/openSelfcheck"
app:destination="@id/selfcheckFragment" />
Expand Down Expand Up @@ -154,6 +151,5 @@

<!-- Included -->

<include app:graph="@navigation/nav_unlp" />
<include app:graph="@navigation/nav_nearby" />
</navigation>
6 changes: 4 additions & 2 deletions play-services-core/src/main/res/xml/preferences_start.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@
<PreferenceCategory android:layout="@layout/preference_category_no_label">
<Preference
android:icon="@drawable/ic_map_marker"
android:key="pref_unifiednlp"
android:title="@string/nlp_backends_title" />
android:key="pref_location"
android:title="@string/prefcat_location_service"
android:enabled="false"
app:isPreferenceVisible="false"/>
<Preference
android:key="pref_exposure"
android:title="@string/service_name_exposure"
Expand Down
16 changes: 9 additions & 7 deletions play-services-location/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ apply plugin: 'kotlin-android'

dependencies {
api project(':play-services-location')
compileOnly project(':play-services-location-system-api')
implementation project(':play-services-base-core')

runtimeOnly("org.microg.nlp:service:$nlpVersion") {
exclude group: 'org.microg', module: 'safe-parcel'
}
api("org.microg.nlp:client:$nlpVersion") {
exclude group: 'org.microg', module: 'safe-parcel'
}

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion"
implementation "androidx.lifecycle:lifecycle-service:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"

implementation "com.android.volley:volley:$volleyVersion"

implementation 'org.microg:address-formatter:0.3.1'
}

android {
Expand All @@ -34,6 +32,10 @@ android {
targetSdkVersion androidTargetSdk
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down
57 changes: 52 additions & 5 deletions play-services-location/core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ SPDX-FileCopyrightText: 2020, microG Project Team
~ SPDX-FileCopyrightText: 2020 microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->
<manifest package="org.microg.gms.location.core" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<manifest xmlns:tools="http://schemas.android.com/tools"
package="org.microg.gms.location.core"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.BODY_SENSORS"/>

<uses-permission android:name="android.permission.LOCATION_HARDWARE"
tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.NETWORK_SCAN"
tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE"
tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"
tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS"
tools:ignore="ProtectedPermissions"/>
<uses-permission android:name="android.permission.WATCH_APPOPS"
tools:ignore="ProtectedPermissions"/>

<application>
<uses-library android:name="com.android.location.provider" />

<service android:name="org.microg.gms.location.GoogleLocationManagerService">
<service
android:name="org.microg.gms.location.manager.LocationManagerService"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.location.internal.GoogleLocationManagerService.START"/>
</intent-filter>
</service>
<service android:name="org.microg.gms.location.ReportingAndroidService">
<service android:name="org.microg.gms.location.reporting.ReportingAndroidService"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.location.reporting.service.START"/>
<action android:name="com.google.android.gms.location.reporting.service.START"/>

<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</service>
<service
android:name="org.microg.gms.location.network.NetworkLocationService"
android:exported="false"/>
<service
android:name="org.microg.gms.location.provider.NetworkLocationProviderService"
android:exported="true"
android:permission="android.permission.WRITE_SECURE_SETTINGS">
<intent-filter>
<action android:name="com.android.location.service.v2.NetworkLocationProvider"/>
<action android:name="com.android.location.service.v3.NetworkLocationProvider"/>
</intent-filter>
<meta-data android:name="serviceVersion" android:value="2"/>
</service>
<service
android:name="org.microg.gms.location.provider.GeocodeProviderService"
android:exported="true"
android:permission="android.permission.WRITE_SECURE_SETTINGS">
<intent-filter>
<action android:name="com.android.location.service.GeocodeProvider"/>
<action android:name="com.google.android.location.GeocodeProvider"/>
</intent-filter>
<meta-data android:name="serviceVersion" android:value="2"/>
</service>
</application>
</manifest>
Loading

0 comments on commit f5ad796

Please sign in to comment.