Commit 65427697 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Signin][Android] Remove unused methods in AccountManagerFacade

This CL removes some unused methods in AccountManagerFacade and cleaned
FirstRunUtilsTest.

Bug: 1057040
Change-Id: Ie1f8103182053d528d48b3f2a5a27ef151f3b5de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083452Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746776}
parent 106fee20
......@@ -90,7 +90,7 @@ public class FirstRunUtils {
@VisibleForTesting
static boolean hasGoogleAccounts() {
return AccountManagerFacade.get().hasGoogleAccounts();
return !AccountManagerFacade.get().tryGetGoogleAccounts().isEmpty();
}
@SuppressLint("InlinedApi")
......
......@@ -46,7 +46,7 @@ public class FirstRunUtilsTest {
private static class FakeAuthenticationAccountManager extends FakeAccountManagerDelegate {
private final String mAccountType;
public FakeAuthenticationAccountManager(String accountType) {
FakeAuthenticationAccountManager(String accountType) {
super(FakeAccountManagerDelegate.DISABLE_PROFILE_DATA_SOURCE);
mAccountType = accountType;
}
......@@ -70,11 +70,6 @@ public class FirstRunUtilsTest {
AccountHolder.builder(mTestAccount).alwaysAccept(true).build());
}
// This test previously flaked on the try bot: http://crbug.com/543160.
// Re-enabling this test since there has been related cleanup/refactoring
// during the time the test was disabled. If the test starts flaking again,
// re-open the bug.
// TODO(nyquist): Remove this if the test is not flaky anymore.
@Test
@SmallTest
@Feature({"GoogleAccounts"})
......@@ -85,20 +80,10 @@ public class FirstRunUtilsTest {
addTestAccount();
ContextUtils.initApplicationContextForTests(mAccountTestingContext);
boolean hasAccounts = FirstRunUtils.hasGoogleAccounts();
Assert.assertTrue(hasAccounts);
boolean hasAuthenticator = FirstRunUtils.hasGoogleAccountAuthenticator();
Assert.assertTrue(hasAuthenticator);
Assert.assertTrue(FirstRunUtils.hasGoogleAccounts());
Assert.assertTrue(FirstRunUtils.hasGoogleAccountAuthenticator());
}
// This test previously flaked on the try bot: http://crbug.com/543160.
// Re-enabling this test since there has been related cleanup/refactoring
// during the time the test was disabled. If the test starts flaking again,
// re-open the bug.
// TODO(nyquist): Remove this if the test is not flaky anymore.
@Test
@SmallTest
@Feature({"GoogleAccounts"})
......@@ -108,12 +93,7 @@ public class FirstRunUtilsTest {
setUpAccountManager("Not A Google Account");
ContextUtils.initApplicationContextForTests(mAccountTestingContext);
boolean hasAccounts = FirstRunUtils.hasGoogleAccounts();
Assert.assertFalse(hasAccounts);
boolean hasAuthenticator = FirstRunUtils.hasGoogleAccountAuthenticator();
Assert.assertFalse(hasAuthenticator);
Assert.assertFalse(FirstRunUtils.hasGoogleAccounts());
Assert.assertFalse(FirstRunUtils.hasGoogleAccountAuthenticator());
}
}
......@@ -258,14 +258,6 @@ public class AccountManagerFacade {
return accountNames;
}
/**
* Asynchronous version of {@link #tryGetGoogleAccountNames()}.
*/
@MainThread
public void tryGetGoogleAccountNames(final Callback<List<String>> callback) {
runAfterCacheIsPopulated(() -> callback.onResult(tryGetGoogleAccountNames()));
}
/**
* Asynchronous version of {@link #tryGetGoogleAccountNames()}.
*/
......@@ -315,14 +307,6 @@ public class AccountManagerFacade {
return maybeAccounts.get();
}
/**
* Asynchronous version of {@link #getGoogleAccounts()}.
*/
@MainThread
public void getGoogleAccounts(Callback<AccountManagerResult<List<Account>>> callback) {
runAfterCacheIsPopulated(() -> callback.onResult(mFilteredAccounts.get()));
}
/**
* Retrieves all Google accounts on the device.
* Returns an empty array if an error occurs while getting account list.
......@@ -344,23 +328,6 @@ public class AccountManagerFacade {
runAfterCacheIsPopulated(() -> callback.onResult(tryGetGoogleAccounts()));
}
/**
* Determine whether there are any Google accounts on the device.
* Returns false if an error occurs while getting account list.
*/
@AnyThread
public boolean hasGoogleAccounts() {
return !tryGetGoogleAccounts().isEmpty();
}
/**
* Asynchronous version of {@link #hasGoogleAccounts()}.
*/
@MainThread
public void hasGoogleAccounts(final Callback<Boolean> callback) {
runAfterCacheIsPopulated(() -> callback.onResult(hasGoogleAccounts()));
}
private String canonicalizeName(String name) {
String[] parts = AT_SYMBOL.split(name);
if (parts.length != 2) return name;
......@@ -390,14 +357,6 @@ public class AccountManagerFacade {
return null;
}
/**
* Asynchronous version of {@link #getAccountFromName(String)}.
*/
@MainThread
public void getAccountFromName(String accountName, final Callback<Account> callback) {
runAfterCacheIsPopulated(() -> callback.onResult(getAccountFromName(accountName)));
}
/**
* Returns whether an account exists with the given name.
* Returns false if an error occurs while getting account list.
......@@ -407,16 +366,6 @@ public class AccountManagerFacade {
return getAccountFromName(accountName) != null;
}
/**
* Asynchronous version of {@link #hasAccountForName(String)}.
*/
// TODO(maxbogue): Remove once this function is used outside of tests.
@VisibleForTesting
@MainThread
public void hasAccountForName(String accountName, final Callback<Boolean> callback) {
runAfterCacheIsPopulated(() -> callback.onResult(hasAccountForName(accountName)));
}
/**
* @return Whether or not there is an account authenticator for Google accounts.
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment