diff --git a/play-services-core/src/main/kotlin/org/microg/gms/auth/signin/AuthSignInService.kt b/play-services-core/src/main/kotlin/org/microg/gms/auth/signin/AuthSignInService.kt index dcab8f3c53..c0bd6f4de0 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/auth/signin/AuthSignInService.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/auth/signin/AuthSignInService.kt @@ -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 @@ -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 @@ -77,10 +79,14 @@ 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) + val googleSignInAccount = performSignIn(context, packageName, options, account, true) if (googleSignInAccount != null) { sendResult(googleSignInAccount, Status(CommonStatusCodes.SUCCESS)) } else {