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

Commit 87309946 authored by Katherine Kuan's avatar Katherine Kuan
Browse files

Check if google authenticator is on device for no account prompt

Bug: 5570306

Change-Id: I32efcbc178f41df113d9ebe855bd7494f3cbd9cd
parent 252159e0
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.contacts.model.GoogleAccountType;
import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture;
import android.accounts.AuthenticatorDescription;
import android.accounts.AuthenticatorException;
import android.accounts.OperationCanceledException;
import android.app.Activity;
@@ -57,11 +58,24 @@ public class AccountPromptUtils {

    /**
     * Returns true if the "no account" prompt should be shown
     * (according to {@link SharedPreferences}), otherwise return false.
     * (according to {@link SharedPreferences}), otherwise return false. Since this prompt is
     * Google-specific for the time being, this method will also return false if the Google
     * account type is not available from the {@link AccountManager}.
     */
    public static boolean shouldShowAccountPrompt(Context context) {
        // TODO: Remove the filtering of account types once there is an API in
        // {@link AccountManager} to show a similar account prompt
        // (see {@link AccountManager#addAccount()} in {@link #launchAccountPrompt()}
        // for any type of account. Bug: 5375902
        AuthenticatorDescription[] allTypes =
                AccountManager.get(context).getAuthenticatorTypes();
        for (AuthenticatorDescription authenticatorType : allTypes) {
            if (GoogleAccountType.ACCOUNT_TYPE.equals(authenticatorType.type)) {
                return getSharedPreferences(context).getBoolean(KEY_SHOW_ACCOUNT_PROMPT, true);
            }
        }
        return false;
    }

    /**
     * Remember to never show the "no account" prompt again by saving this to