diff --git a/play-services-base/core/package/build.gradle b/play-services-base/core/package/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..02142c68be6cda138f6722b122eecc8137ba76eb
--- /dev/null
+++ b/play-services-base/core/package/build.gradle
@@ -0,0 +1,44 @@
+/*
+ * SPDX-FileCopyrightText: 2023 microG Project Team
+ * SPDX-FileCopyrightText: 2023 e Foundation
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+
+dependencies {
+ implementation project(':play-services-base-core')
+}
+
+android {
+ namespace "org.microg.gms.core.pkg"
+
+ compileSdkVersion androidCompileSdk
+ buildToolsVersion "$androidBuildVersionTools"
+
+ defaultConfig {
+ versionName version
+ minSdkVersion androidMinSdk
+ targetSdkVersion androidTargetSdk
+ }
+
+ sourceSets {
+ main {
+ java.srcDirs = ['src/main/kotlin']
+ }
+ }
+
+ lintOptions {
+ disable 'MissingTranslation'
+ }
+
+ compileOptions {
+ sourceCompatibility = 1.8
+ targetCompatibility = 1.8
+ }
+
+ kotlinOptions {
+ jvmTarget = 1.8
+ }
+}
diff --git a/play-services-base/core/package/src/main/AndroidManifest.xml b/play-services-base/core/package/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9a7aa8fb7fa4a5da9f99ad36e34df15785757029
--- /dev/null
+++ b/play-services-base/core/package/src/main/AndroidManifest.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
diff --git a/play-services-base/core/package/src/main/kotlin/org/microg/gms/profile/ProfileProvider.kt b/play-services-base/core/package/src/main/kotlin/org/microg/gms/profile/ProfileProvider.kt
new file mode 100644
index 0000000000000000000000000000000000000000..53e4149f42e433e90e7a851f4e619db7bdc4e4cd
--- /dev/null
+++ b/play-services-base/core/package/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()
+
+}
diff --git a/play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt b/play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt
index d367cb34dcf58de2b6b63d8187b386074a4e0c9b..69b26894b4174c5722660941cc8539cc38053180 100644
--- a/play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt
+++ b/play-services-base/core/src/main/kotlin/org/microg/gms/profile/ProfileManager.kt
@@ -93,6 +93,9 @@ object ProfileManager {
}
}.getOrDefault(false)
+ fun getActiveProfileData(context: Context): Map =
+ getProfileData(context, getProfile(context), getRealData())
+
private fun getProfileData(context: Context, profile: String, realData: Map): Map {
try {
if (profile in listOf(PROFILE_REAL, PROFILE_NATIVE)) return realData
@@ -243,7 +246,7 @@ object ProfileManager {
}
}
- private fun applyProfileData(profileData: Map) {
+ fun applyProfileData(profileData: Map) {
fun applyStringField(key: String, valueSetter: (String) -> Unit) = profileData[key]?.let { valueSetter(it) }
fun applyIntField(key: String, valueSetter: (Int) -> Unit) = profileData[key]?.toIntOrNull()?.let { valueSetter(it) }
fun applyLongField(key: String, valueSetter: (Long) -> Unit) = profileData[key]?.toLongOrNull()?.let { valueSetter(it) }
diff --git a/play-services-core/build.gradle b/play-services-core/build.gradle
index 4b99a557dbaa27674bf3d444d120cf104ceb21fc..eb6454a5c8ec4c68df6554a7ffb2b1fd5ab51d9c 100644
--- a/play-services-core/build.gradle
+++ b/play-services-core/build.gradle
@@ -46,6 +46,7 @@ dependencies {
implementation project(':play-services-core-proto')
implementation project(':play-services-core:microg-ui-tools') // deprecated
+ implementation project(':play-services-base-core-package')
implementation project(':play-services-api')
implementation project(':play-services-appinvite')
diff --git a/settings.gradle b/settings.gradle
index aceae3a68a2387d3a5628b3a8de29873f2004243..63a1e400b4d5dc7179e4f8cce212133409c304f9 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -106,3 +106,6 @@ sublude ':firebase-auth:core'
include ':play-services-core:microg-ui-tools' // Legacy
include ':play-services-core'
+
+include ':play-services-base-core-package'
+project(':play-services-base-core-package').projectDir = file('play-services-base/core/package')