From dbecd4aab3ff3defe781ae2bcf507f4105c44741 Mon Sep 17 00:00:00 2001
From: Oizaro <75915943+Oizaro@users.noreply.github.com>
Date: Thu, 1 Jul 2021 15:38:17 +0200
Subject: [PATCH] Update to latest upstream
---
build.gradle | 2 +-
.../src/main/AndroidManifest.xml | 2 +-
.../microg/gms/settings/SettingsContract.kt | 22 ++++++++++++++-----
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/build.gradle b/build.gradle
index b2439556..a669a080 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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'
diff --git a/play-services-core/src/main/AndroidManifest.xml b/play-services-core/src/main/AndroidManifest.xml
index 1447b73a..21e13688 100644
--- a/play-services-core/src/main/AndroidManifest.xml
+++ b/play-services-core/src/main/AndroidManifest.xml
@@ -96,7 +96,7 @@
+ android:exported="false" />
diff --git a/play-services-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt b/play-services-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt
index c3d517dd..4a25b985 100644
--- a/play-services-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt
+++ b/play-services-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt
@@ -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"
@@ -81,15 +82,24 @@ object SettingsContract {
)
}
- fun getSettings(context: Context, uri: Uri, projection: Array?, f: (Cursor) -> T): T {
- 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)
+ private fun withoutCallingIdentity(f: () -> T): T {
+ val identity = Binder.clearCallingIdentity()
+ try {
+ return f.invoke()
+ } finally {
+ Binder.restoreCallingIdentity(identity)
}
}
- fun setSettings(context: Context, uri: Uri, v: ContentValues.() -> Unit) {
+ fun getSettings(context: Context, uri: Uri, projection: Array?, 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")
+ f.invoke(c)
+ }
+ }
+
+ 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"}