Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ae174ea authored by davinci9196's avatar davinci9196 Committed by Marvin W.
Browse files

Auth: Don't reset account visibility if already set

parent f7ee6646
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

@@ -218,8 +219,12 @@ public class AuthManagerServiceImpl extends IAuthManagerService.Stub {
    public Bundle requestGoogleAccountsAccess(String packageName) throws RemoteException {
        PackageUtils.assertGooglePackagePermission(context, GooglePackagePermission.ACCOUNT);
        if (SDK_INT >= 26) {
            Map<Account, Integer> visibilityForPackage = get(context).getAccountsAndVisibilityForPackage(packageName, AuthConstants.DEFAULT_ACCOUNT_TYPE);
            for (Account account : get(context).getAccountsByType(AuthConstants.DEFAULT_ACCOUNT_TYPE)) {
                AccountManager.get(context).setAccountVisibility(account, packageName, VISIBILITY_VISIBLE);
                Integer visibility = visibilityForPackage.get(account);
                if (visibility != null && visibility != VISIBILITY_VISIBLE) {
                    get(context).setAccountVisibility(account, packageName, VISIBILITY_VISIBLE);
                }
            }
            Bundle res = new Bundle();
            res.putString("Error", "Ok");