Skip to content
This repository was archived by the owner on Apr 6, 2024. It is now read-only.

Update to latest upstream #152

Merged
merged 12 commits into from Jul 3, 2021
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

buildscript {
ext.cronetVersion = '91.0.4472.120'
ext.cronetVersion = '91.0.4472.120.1'
ext.safeParcelVersion = '1.7.0'

ext.kotlinVersion = '1.4.32'
Expand Down Expand Up @@ -36,7 +36,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "com.squareup.wire:wire-gradle-plugin:$wireVersion"
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri May 14 01:45:11 CEST 2021
#Sat Jul 03 09:49:43 CEST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion play-services-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<provider
android:name="org.microg.gms.settings.SettingsProvider"
android:authorities="org.microg.gms.settings"
android:exported="true" />
android:exported="false" />

<!-- Services Framework -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected void collectLibraries(List<AbstractAboutFragment.Library> libraries) {
libraries.add(new AbstractAboutFragment.Library("de.hdodenhof.circleimageview", "CircleImageView", "Apache License 2.0, Henning Dodenhof"));
libraries.add(new AbstractAboutFragment.Library("su.litvak.chromecast.api.v2", "ChromeCast Java API v2", "Apache License 2.0, Vitaly Litvak"));
libraries.add(new AbstractAboutFragment.Library("org.conscrypt", "Conscrypt", "Apache License 2.0, The Android Open Source Project"));
libraries.add(new AbstractAboutFragment.Library("org.chromium.net", "Cronet", "BSD-style License, The Chromium Authors"));
libraries.add(new AbstractAboutFragment.Library("org.microg.safeparcel", "SafeParcel", "Apache License 2.0, microG Team"));
libraries.add(new AbstractAboutFragment.Library("com.squareup.wire", "Wire Protocol Buffers", "Apache License 2.0, Square Inc."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import android.net.Uri
import android.os.Binder

object SettingsContract {
const val AUTHORITY = "org.microg.gms.settings"
Expand Down Expand Up @@ -81,15 +82,24 @@ object SettingsContract {
)
}

fun <T> getSettings(context: Context, uri: Uri, projection: Array<out String>?, f: (Cursor) -> T): T {
private fun <T> withoutCallingIdentity(f: () -> T): T {
val identity = Binder.clearCallingIdentity()
try {
return f.invoke()
} finally {
Binder.restoreCallingIdentity(identity)
}
}

fun <T> getSettings(context: Context, uri: Uri, projection: Array<out String>?, f: (Cursor) -> T): T = withoutCallingIdentity {
context.contentResolver.query(uri, projection, null, null, null).use { c ->
require(c != null) { "Cursor for query $uri ${projection?.toList()} was null" }
if (!c.moveToFirst()) error("Cursor for query $uri ${projection?.toList()} was empty")
return f.invoke(c)
f.invoke(c)
}
}

fun setSettings(context: Context, uri: Uri, v: ContentValues.() -> Unit) {
fun setSettings(context: Context, uri: Uri, v: ContentValues.() -> Unit) = withoutCallingIdentity {
val values = ContentValues().apply { v.invoke(this) }
val affected = context.contentResolver.update(uri, values, null, null)
require(affected == 1) { "Update for $uri with $values affected 0 rows"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ class SettingsProvider : ContentProvider() {
Gcm.NETWORK_ROAMING -> Integer.parseInt(preferences.getString(key, "0") ?: "0")
Gcm.NETWORK_OTHER -> Integer.parseInt(preferences.getString(key, "0") ?: "0")

Gcm.LEARNT_MOBILE -> preferences.getInt(key, 300000)
Gcm.LEARNT_WIFI -> preferences.getInt(key, 300000)
Gcm.LEARNT_OTHER -> preferences.getInt(key, 300000)
Gcm.LEARNT_MOBILE -> preferences.getInt(key, 60000)
Gcm.LEARNT_WIFI -> preferences.getInt(key, 60000)
Gcm.LEARNT_OTHER -> preferences.getInt(key, 60000)

else -> throw IllegalArgumentException("Unknown key: $key")
}
Expand Down
6 changes: 5 additions & 1 deletion play-services-cronet-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'

dependencies {
implementation("org.microg:cronet-api:$cronetVersion")
// TODO: Embedding the API causes random crashes as the Android AOT compiler will link the native implementation to
// out API classes even if embedded by a third-party app that comes with their own API classes.
// Need to find a better way to disable AOT for Cronet. Could be by packaging cronet as it's own apk that is
// embedded in the main APK but only loaded at runtime so that the AOT compiler has no way to become active.
// implementation("org.microg:cronet-api:$cronetVersion")
implementation("org.microg:cronet-common:$cronetVersion")
implementation("org.microg:cronet-native:$cronetVersion")
}
Expand Down