From ebb9f2d54e44230536c88adf9fc3fd60fc3e051d Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Wed, 27 Dec 2023 05:11:45 +0900 Subject: [PATCH] Auth: Add option to authenticate without android id https://github.com/microg/GmsCore/commit/8663e52563040bfcc57432173f891108fa693f07 --- .../microg/gms/settings/SettingsContract.kt | 2 ++ .../microg/gms/settings/SettingsProvider.kt | 2 ++ .../java/org/microg/gms/auth/AuthRequest.java | 4 +++- .../kotlin/org/microg/gms/auth/AuthPrefs.kt | 7 +++++++ .../src/main/res/values/strings.xml | 2 ++ .../src/main/res/xml/preferences_account.xml | 20 +++++++++++++++++++ 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt b/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt index 9249b449..bf0d7042 100644 --- a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt +++ b/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt @@ -78,10 +78,12 @@ object SettingsContract { const val TRUST_GOOGLE = "auth_manager_trust_google" const val VISIBLE = "auth_manager_visible" + const val INCLUDE_ANDROID_ID = "auth_include_android_id" val PROJECTION = arrayOf( TRUST_GOOGLE, VISIBLE, + INCLUDE_ANDROID_ID, ) } diff --git a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt b/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt index 5da489f0..9a5a0e31 100644 --- a/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt +++ b/play-services-base-core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt @@ -213,6 +213,7 @@ class SettingsProvider : ContentProvider() { when (key) { Auth.TRUST_GOOGLE -> getSettingsBoolean(key, true) Auth.VISIBLE -> getSettingsBoolean(key, false) + Auth.INCLUDE_ANDROID_ID -> getSettingsBoolean(key, true) else -> throw IllegalArgumentException("Unknown key: $key") } } @@ -224,6 +225,7 @@ class SettingsProvider : ContentProvider() { when (key) { Auth.TRUST_GOOGLE -> editor.putBoolean(key, value as Boolean) Auth.VISIBLE -> editor.putBoolean(key, value as Boolean) + Auth.INCLUDE_ANDROID_ID -> editor.putBoolean(key, value as Boolean) else -> throw IllegalArgumentException("Unknown key: $key") } } diff --git a/play-services-core/src/main/java/org/microg/gms/auth/AuthRequest.java b/play-services-core/src/main/java/org/microg/gms/auth/AuthRequest.java index 55ff536b..e1b4749a 100644 --- a/play-services-core/src/main/java/org/microg/gms/auth/AuthRequest.java +++ b/play-services-core/src/main/java/org/microg/gms/auth/AuthRequest.java @@ -113,7 +113,9 @@ public class AuthRequest extends HttpFormClient.Request { public AuthRequest fromContext(Context context) { build(context); locale(Utils.getLocale(context)); - androidIdHex = Long.toHexString(LastCheckinInfo.read(context).getAndroidId()); + if (AuthPrefs.shouldIncludeAndroidId(context)) { + androidIdHex = Long.toHexString(LastCheckinInfo.read(context).getAndroidId()); + } return this; } diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/AuthPrefs.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/AuthPrefs.kt index 00a124aa..5df2669d 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/auth/AuthPrefs.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/AuthPrefs.kt @@ -24,4 +24,11 @@ object AuthPrefs { } } + @JvmStatic + fun shouldIncludeAndroidId(context: Context): Boolean { + return SettingsContract.getSettings(context, Auth.getContentUri(context), arrayOf(Auth.INCLUDE_ANDROID_ID)) { c -> + c.getInt(0) != 0 + } + } + } diff --git a/play-services-core/src/main/res/values/strings.xml b/play-services-core/src/main/res/values/strings.xml index 1c836304..c27278b1 100755 --- a/play-services-core/src/main/res/values/strings.xml +++ b/play-services-core/src/main/res/values/strings.xml @@ -82,6 +82,8 @@ This can take a couple of minutes." Personal info & privacy Sign-in & security + Authenticate with device registration + When disabled, authentication requests won\'t be linked to the device registration, which allows unauthorized devices to sign in, but may have unforeseen consequences. Trust Google for app permissions When disabled, the user is asked before an apps authorization request is sent to Google. Some applications will fail to use the Google account if this is disabled. Allow apps to find accounts diff --git a/play-services-core/src/main/res/xml/preferences_account.xml b/play-services-core/src/main/res/xml/preferences_account.xml index c952b6e0..1f24d32e 100755 --- a/play-services-core/src/main/res/xml/preferences_account.xml +++ b/play-services-core/src/main/res/xml/preferences_account.xml @@ -11,6 +11,7 @@ android:targetPackage="com.android.settings" /> +<<<<<<< HEAD +======= + + + + + +>>>>>>> c8d53d6b (Auth: Add option to authenticate without android id https://github.com/microg/GmsCore/commit/8663e52563040bfcc57432173f891108fa693f07) \ No newline at end of file