mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2025-01-05 17:15:57 +01:00
Update to latest upstream (#151)
* Exposure Notifications: Request permissions for Android 12 Beta
* Refactor settings access to use a SettingsProvider
to enable safe usage of settings no matter which process is getting/setting them.
Previously, different processes were accessing settings in an unsafe way and the warn methods were throwing Runtime exceptions which went largely unnoticed, but happened, especially on a fresh start of the OS.
Change-Id: Ie4134e7be2a7ca4a373790f45fbcbd09bf02ad86
* Bump version
* Fix settings provider being called with wrong identity
Fixes #1503
* Revert "Make the application persistent"
This reverts commit 3eb3380c2d
.
See #1487 for details
* Cronet: Use updated version
* Update to latest upstream
Co-authored-by: Marvin W <git@larma.de>
Co-authored-by: Torsten Grote <t@grobox.de>
This commit is contained in:
parent
6b9aa61849
commit
e519443293
@ -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'
|
||||
|
@ -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 -->
|
||||
|
||||
|
@ -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 <T> getSettings(context: Context, uri: Uri, projection: Array<out String>?, 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 <T> 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 <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")
|
||||
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"}
|
||||
|
Loading…
Reference in New Issue
Block a user