Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion play-services-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@

<activity
android:name="org.microg.gms.auth.consent.ConsentSignInActivity"
android:process=":ui"
android:exported="false"
android:excludeFromRecents="true"
android:configChanges="keyboardHidden|keyboard|orientation|screenSize"
android:theme="@style/Theme.AppCompat.DayNight.Dialog"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.microg.gms.auth.signin

import android.accounts.Account
import android.accounts.AccountManager
import android.content.Context
import android.os.Bundle
import android.os.Parcel
Expand All @@ -37,6 +38,7 @@ import com.google.android.gms.common.internal.ConnectionInfo
import com.google.android.gms.common.internal.GetServiceRequest
import com.google.android.gms.common.internal.IGmsCallbacks
import org.microg.gms.BaseService
import org.microg.gms.auth.AuthConstants
import org.microg.gms.auth.AuthPrefs
import org.microg.gms.common.GmsService
import org.microg.gms.common.PackageUtils
Expand Down Expand Up @@ -77,8 +79,12 @@ class AuthSignInServiceImpl(
}
lifecycleScope.launchWhenStarted {
try {
val account = account ?: options?.account ?: SignInConfigurationService.getDefaultAccount(context, packageName)
if (account != null && options?.isForceCodeForRefreshToken != true && options?.includeUnacceptableScope != true) {
val account = account
?: options?.account
?: SignInConfigurationService.getDefaultAccount(context, packageName)
?: AccountManager.get(context).getAccountsByType(AuthConstants.DEFAULT_ACCOUNT_TYPE).firstOrNull()
Log.d(TAG, "silentSignIn: account -> ${account?.name}")
if (account != null && options?.isForceCodeForRefreshToken != true) {
if (getOAuthManager(context, packageName, options, account).isPermitted || AuthPrefs.isTrustGooglePermitted(context)) {
val googleSignInAccount = performSignIn(context, packageName, options, account)
if (googleSignInAccount != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ suspend fun checkAccountAuthStatus(context: Context, packageName: String, scopeL
suspend fun performSignIn(context: Context, packageName: String, options: GoogleSignInOptions?, account: Account, permitted: Boolean = false): GoogleSignInAccount? {
val authManager = getOAuthManager(context, packageName, options, account)
val authResponse = withContext(Dispatchers.IO) {
if (options?.includeUnacceptableScope == true) {
if (options?.includeUnacceptableScope == true || !permitted) {
authManager.setTokenRequestOptions(consentRequestOptions)
}
if (permitted) authManager.isPermitted = true
Expand Down Expand Up @@ -134,7 +134,8 @@ suspend fun performSignIn(context: Context, packageName: String, options: Google
val serverAuthCode: String? = if (options?.isServerAuthCodeRequested == true) serverAuthTokenResponse?.auth else null
val expirationTime = min(authResponse.expiry.orMaxIfNegative(), idTokenResponse?.expiry.orMaxIfNegative())
val obfuscatedIdentifier: String = MessageDigest.getInstance("MD5").digest("$googleUserId:$packageName".encodeToByteArray()).toHexString().uppercase()
val grantedScopes = authResponse.grantedScopes?.split(" ").orEmpty().map { Scope(it) }.toSet()
val grantedScopeList = authResponse.grantedScopes ?: idTokenResponse?.grantedScopes ?: serverAuthTokenResponse?.grantedScopes
val grantedScopes = grantedScopeList?.split(" ").orEmpty().map { Scope(it) }.toSet()
val (givenName, familyName, displayName, photoUrl) = if (options?.includeProfile == true) {
val databaseHelper = DatabaseHelper(context)
val cursor = databaseHelper.getOwner(account.name)
Expand Down Expand Up @@ -184,6 +185,7 @@ suspend fun performConsentView(context: Context, packageName: String, account: A
return withContext(Dispatchers.IO) {
val deferred = CompletableDeferred<String?>()
val intent = Intent(context, ConsentSignInActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK
putExtra(CONSENT_URL, consentResponse.consentUrl)
putExtra(CONSENT_MESSENGER, Messenger(object : Handler(Looper.getMainLooper()) {
override fun handleMessage(msg: Message) {
Expand Down
Loading