diff --git a/play-services-base-core/src/main/AndroidManifest.xml b/play-services-base-core/src/main/AndroidManifest.xml index be78c54f..f260e226 100644 --- a/play-services-base-core/src/main/AndroidManifest.xml +++ b/play-services-base-core/src/main/AndroidManifest.xml @@ -3,11 +3,23 @@ ~ SPDX-FileCopyrightText: 2020, microG Project Team ~ SPDX-License-Identifier: Apache-2.0 --> +<<<<<<< HEAD +======= + +>>>>>>> 0f8fb823 (Expose device profile as content https://github.com/microg/GmsCore/commit/9d5a99710f0cbe9055a43df371eaae77610583f3) + + diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileProvider.kt b/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileProvider.kt new file mode 100644 index 00000000..53e4149f --- /dev/null +++ b/play-services-base-core/src/main/kotlin/org/microg/gms/profile/ProfileProvider.kt @@ -0,0 +1,52 @@ +/* + * SPDX-FileCopyrightText: 2023 e Foundation + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.microg.gms.profile + +import android.content.ContentProvider +import android.content.ContentValues +import android.database.Cursor +import android.database.MatrixCursor +import android.net.Uri +import org.microg.gms.settings.SettingsContract + +class ProfileProvider : ContentProvider() { + + val COLUMN_ID = "profile_id" + val COLUMN_VALUE = "profile_value" + + override fun onCreate(): Boolean { + ProfileManager.ensureInitialized(context!!) + return true + } + + override fun query( + uri: Uri, + projection: Array?, + selection: String?, + selectionArgs: Array?, + sortOrder: String? + ): Cursor = + MatrixCursor(arrayOf(COLUMN_ID, COLUMN_VALUE)).apply { + ProfileManager.getActiveProfileData(context!!).entries + .forEach { + addRow(arrayOf(it.key, it.value)) + } + } + + override fun getType(uri: Uri): String { + return "vnd.android.cursor.item/vnd.${SettingsContract.getAuthority(context!!)}.${uri.path}" + } + + override fun insert(uri: Uri, values: ContentValues?): Nothing = throw UnsupportedOperationException() + + override fun delete(uri: Uri, selection: String?, selectionArgs: Array?): Nothing = + throw UnsupportedOperationException() + + override fun update( + uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array? + ): Nothing = throw UnsupportedOperationException() + +}