From 721de46e35d5a87674adae2e6525f0af2c4ebb2e Mon Sep 17 00:00:00 2001 From: "Eric Lin (Tzu Hsiang Lin)" Date: Thu, 18 Feb 2021 12:04:44 +0800 Subject: Respectful code cleanup. (#140) Replaced "whitelist" with a more respectful term: allowlist. https://developers.google.com/style/word-list?hl=zh-tw#blacklist --- .../mobly/snippet/bundled/AccountSnippet.java | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/main/java/com/google/android/mobly') diff --git a/src/main/java/com/google/android/mobly/snippet/bundled/AccountSnippet.java b/src/main/java/com/google/android/mobly/snippet/bundled/AccountSnippet.java index aac543a..3c21dbf 100644 --- a/src/main/java/com/google/android/mobly/snippet/bundled/AccountSnippet.java +++ b/src/main/java/com/google/android/mobly/snippet/bundled/AccountSnippet.java @@ -66,14 +66,14 @@ public class AccountSnippet implements Snippet { private final AccountManager mAccountManager; private final List mSyncStatusObserverHandles; - private final Map> mSyncWhitelist; + private final Map> mSyncAllowList; private final ReentrantReadWriteLock mLock; public AccountSnippet() { Context context = InstrumentationRegistry.getInstrumentation().getContext(); mAccountManager = AccountManager.get(context); mSyncStatusObserverHandles = new LinkedList<>(); - mSyncWhitelist = new HashMap<>(); + mSyncAllowList = new HashMap<>(); mLock = new ReentrantReadWriteLock(); } @@ -133,13 +133,13 @@ public class AccountSnippet implements Snippet { if (!adapter.accountType.equals(GOOGLE_ACCOUNT_TYPE)) { continue; } - // If a content provider is not whitelisted, then disable it. - // Because startSync and stopSync synchronously update the whitelist - // and sync settings, writelock both the whitelist check and the + // If a content provider is not allowListed, then disable it. + // Because startSync and stopSync synchronously update the allowList + // and sync settings, writelock both the allowList check and the // call to sync together. mLock.writeLock().lock(); try { - if (!isAdapterWhitelisted(username, adapter.authority)) { + if (!isAdapterAllowListed(username, adapter.authority)) { updateSync(account, adapter.authority, false /* sync */); } } finally { @@ -187,21 +187,21 @@ public class AccountSnippet implements Snippet { } /** - * Checks to see if the SyncAdapter is whitelisted. + * Checks to see if the SyncAdapter is allowListed. * - *

AccountSnippet disables syncing by default when adding an account, except for whitelisted - * SyncAdapters. This function checks the whitelist for a specific account-authority pair. + *

AccountSnippet disables syncing by default when adding an account, except for allowListed + * SyncAdapters. This function checks the allowList for a specific account-authority pair. * * @param username Username of the account (including @gmail.com). * @param authority The authority of a content provider that should be checked. */ - private boolean isAdapterWhitelisted(String username, String authority) { + private boolean isAdapterAllowListed(String username, String authority) { boolean result = false; mLock.readLock().lock(); try { - Set whitelistedProviders = mSyncWhitelist.get(username); - if (whitelistedProviders != null) { - result = whitelistedProviders.contains(authority); + Set allowListedProviders = mSyncAllowList.get(username); + if (allowListedProviders != null) { + result = allowListedProviders.contains(authority); } } finally { mLock.readLock().unlock(); @@ -244,7 +244,7 @@ public class AccountSnippet implements Snippet { /** * Enables syncing of a SyncAdapter for a given content provider. * - *

Adds the authority to a whitelist, and immediately requests a sync. + *

Adds the authority to a allowList, and immediately requests a sync. * * @param username Username of the account (including @gmail.com). * @param authority The authority of a content provider that should be synced. @@ -254,13 +254,13 @@ public class AccountSnippet implements Snippet { if (!listAccounts().contains(username)) { throw new AccountSnippetException("Account " + username + " is not on the device"); } - // Add to the whitelist + // Add to the allowList mLock.writeLock().lock(); try { - if (mSyncWhitelist.containsKey(username)) { - mSyncWhitelist.get(username).add(authority); + if (mSyncAllowList.containsKey(username)) { + mSyncAllowList.get(username).add(authority); } else { - mSyncWhitelist.put(username, new HashSet(Arrays.asList(authority))); + mSyncAllowList.put(username, new HashSet(Arrays.asList(authority))); } // Update the Sync settings for (SyncAdapterType adapter : ContentResolver.getSyncAdapterTypes()) { @@ -279,7 +279,7 @@ public class AccountSnippet implements Snippet { /** * Disables syncing of a SyncAdapter for a given content provider. * - *

Removes the content provider authority from a whitelist. + *

Removes the content provider authority from a allowList. * * @param username Username of the account (including @gmail.com). * @param authority The authority of a content provider that should not be synced. @@ -289,14 +289,14 @@ public class AccountSnippet implements Snippet { if (!listAccounts().contains(username)) { throw new AccountSnippetException("Account " + username + " is not on the device"); } - // Remove from whitelist + // Remove from allowList mLock.writeLock().lock(); try { - if (mSyncWhitelist.containsKey(username)) { - Set whitelistedProviders = mSyncWhitelist.get(username); - whitelistedProviders.remove(authority); - if (whitelistedProviders.isEmpty()) { - mSyncWhitelist.remove(username); + if (mSyncAllowList.containsKey(username)) { + Set allowListedProviders = mSyncAllowList.get(username); + allowListedProviders.remove(authority); + if (allowListedProviders.isEmpty()) { + mSyncAllowList.remove(username); } } // Update the Sync settings -- cgit v1.2.3