Java Code Examples for android.accounts.Account#equals()
The following examples show how to use
android.accounts.Account#equals() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyncStorageEngine.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Either set backoff for a specific authority, or set backoff for all the * accounts on a specific adapter/all adapters. * * @param account account for which to set backoff. Null to specify all accounts. * @param userId id of the user making this request. * @param providerName provider for which to set backoff. Null to specify all providers. * @return true if a change occured. */ private boolean setBackoffLocked(Account account, int userId, String providerName, long nextSyncTime, long nextDelay) { boolean changed = false; for (AccountInfo accountInfo : mAccounts.values()) { if (account != null && !account.equals(accountInfo.accountAndUser.account) && userId != accountInfo.accountAndUser.userId) { continue; } for (AuthorityInfo authorityInfo : accountInfo.authorities.values()) { if (providerName != null && !providerName.equals(authorityInfo.target.provider)) { continue; } if (authorityInfo.backoffTime != nextSyncTime || authorityInfo.backoffDelay != nextDelay) { authorityInfo.backoffTime = nextSyncTime; authorityInfo.backoffDelay = nextDelay; changed = true; } } } return changed; }
Example 2
Source File: FileActivity.java From Cirrus_depricated with GNU General Public License v2.0 | 6 votes |
/** * Tries to swap the current ownCloud {@link Account} for other valid and existing. * <p/> * If no valid ownCloud {@link Account} exists, the the user is requested * to create a new ownCloud {@link Account}. * <p/> * POSTCONDITION: updates {@link #mAccountWasSet} and {@link #mAccountWasRestored}. */ private void swapToDefaultAccount() { // default to the most recently used account Account newAccount = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext()); if (newAccount == null) { /// no account available: force account creation createFirstAccount(); mRedirectingToSetupAccount = true; mAccountWasSet = false; mAccountWasRestored = false; } else { mAccountWasSet = true; mAccountWasRestored = (newAccount.equals(mAccount)); mAccount = newAccount; } }
Example 3
Source File: AuthHelper.java From android-atleap with Apache License 2.0 | 6 votes |
/** * Check if the specified account exist * @param context context * @param account account to check * @return <code>true</code> if account exist */ public static boolean isAccountExist(Context context, Account account) { if (account == null) return false; final AccountManager accountManager = AccountManager.get(context); Account[] accounts = accountManager.getAccountsByType(account.type); if (accounts == null || accounts.length == 0) { return false; } else { for (Account a : accounts) { if (a.equals(account)) return true; } return false; } }
Example 4
Source File: SyncStatusHelper.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@VisibleForTesting protected void updateSyncSettingsForAccountInternal(Account account) { // Null check here otherwise Findbugs complains. if (account == null) return; boolean oldSyncAutomatically = mSyncAutomatically; int oldIsSyncable = mIsSyncable; Account oldAccount = mAccount; mAccount = account; StrictMode.ThreadPolicy oldPolicy = temporarilyAllowDiskWritesAndDiskReads(); mSyncAutomatically = mSyncContentResolverWrapper.getSyncAutomatically( account, mContractAuthority); mIsSyncable = mSyncContentResolverWrapper.getIsSyncable(account, mContractAuthority); StrictMode.setThreadPolicy(oldPolicy); mDidUpdate = (oldIsSyncable != mIsSyncable) || (oldSyncAutomatically != mSyncAutomatically) || (!account.equals(oldAccount)); }
Example 5
Source File: SyncStatusHelper.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * Register with Android Sync Manager. This is what causes the "Chrome" option to appear in * Settings -> Accounts / Sync . * * @param account the account to enable Chrome sync on */ private void makeSyncable(Account account) { synchronized (mCachedSettings) { mCachedSettings.setIsSyncable(account); } StrictMode.ThreadPolicy oldPolicy = temporarilyAllowDiskWritesAndDiskReads(); // Disable the syncability of Chrome for all other accounts. Don't use // our cache as we're touching many accounts that aren't signed in, so this saves // extra calls to Android sync configuration. Account[] googleAccounts = AccountManagerHelper.get(mApplicationContext). getGoogleAccounts(); for (Account accountToSetNotSyncable : googleAccounts) { if (!accountToSetNotSyncable.equals(account) && mSyncContentResolverWrapper.getIsSyncable( accountToSetNotSyncable, mContractAuthority) > 0) { mSyncContentResolverWrapper.setIsSyncable(accountToSetNotSyncable, mContractAuthority, 0); } } StrictMode.setThreadPolicy(oldPolicy); }
Example 6
Source File: SyncStatusHelper.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@VisibleForTesting protected void updateSyncSettingsForAccountInternal(Account account) { // Null check here otherwise Findbugs complains. if (account == null) return; boolean oldSyncAutomatically = mSyncAutomatically; int oldIsSyncable = mIsSyncable; Account oldAccount = mAccount; mAccount = account; StrictMode.ThreadPolicy oldPolicy = temporarilyAllowDiskWritesAndDiskReads(); mSyncAutomatically = mSyncContentResolverWrapper.getSyncAutomatically( account, mContractAuthority); mIsSyncable = mSyncContentResolverWrapper.getIsSyncable(account, mContractAuthority); StrictMode.setThreadPolicy(oldPolicy); mDidUpdate = (oldIsSyncable != mIsSyncable) || (oldSyncAutomatically != mSyncAutomatically) || (!account.equals(oldAccount)); }
Example 7
Source File: SyncStatusHelper.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * Register with Android Sync Manager. This is what causes the "Chrome" option to appear in * Settings -> Accounts / Sync . * * @param account the account to enable Chrome sync on */ private void makeSyncable(Account account) { synchronized (mCachedSettings) { mCachedSettings.setIsSyncable(account); } StrictMode.ThreadPolicy oldPolicy = temporarilyAllowDiskWritesAndDiskReads(); // Disable the syncability of Chrome for all other accounts. Don't use // our cache as we're touching many accounts that aren't signed in, so this saves // extra calls to Android sync configuration. Account[] googleAccounts = AccountManagerHelper.get(mApplicationContext). getGoogleAccounts(); for (Account accountToSetNotSyncable : googleAccounts) { if (!accountToSetNotSyncable.equals(account) && mSyncContentResolverWrapper.getIsSyncable( accountToSetNotSyncable, mContractAuthority) > 0) { mSyncContentResolverWrapper.setIsSyncable(accountToSetNotSyncable, mContractAuthority, 0); } } StrictMode.setThreadPolicy(oldPolicy); }
Example 8
Source File: SigninHelper.java From delion with Apache License 2.0 | 5 votes |
private static boolean accountExists(Context context, Account account) { Account[] accounts = AccountManagerHelper.get(context).getGoogleAccounts(); for (Account a : accounts) { if (a.equals(account)) { return true; } } return false; }
Example 9
Source File: SigninHelper.java From AndroidChromium with Apache License 2.0 | 5 votes |
private static boolean accountExists(Context context, Account account) { Account[] accounts = AccountManagerHelper.get(context).getGoogleAccounts(); for (Account a : accounts) { if (a.equals(account)) { return true; } } return false; }
Example 10
Source File: SigninHelper.java From 365browser with Apache License 2.0 | 5 votes |
private static boolean accountExists(Context context, Account account) { Account[] accounts = AccountManagerHelper.get().getGoogleAccounts(); for (Account a : accounts) { if (a.equals(account)) { return true; } } return false; }
Example 11
Source File: InvalidationClientService.java From 365browser with Apache License 2.0 | 5 votes |
/** * If {@code intendedAccount} is non-{@null} and differs from the account stored in preferences, * then stops the existing client (if any) and updates the stored account. */ private void ensureAccount(@Nullable Account intendedAccount) { if (intendedAccount == null) { return; } InvalidationPreferences invPrefs = new InvalidationPreferences(); if (!intendedAccount.equals(invPrefs.getSavedSyncedAccount())) { if (sIsClientStarted) { stopClient(); } setAccount(intendedAccount); } }
Example 12
Source File: InvalidationService.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * If {@code intendedAccount} is non-{@null} and differs from the account stored in preferences, * then stops the existing client (if any) and updates the stored account. */ private void ensureAccount(@Nullable Account intendedAccount) { if (intendedAccount == null) { return; } InvalidationPreferences invPrefs = new InvalidationPreferences(this); if (!intendedAccount.equals(invPrefs.getSavedSyncedAccount())) { if (sIsClientStarted) { stopClient(); } setAccount(intendedAccount); } }
Example 13
Source File: InvalidationService.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
/** * If {@code intendedAccount} is non-{@null} and differs from the account stored in preferences, * then stops the existing client (if any) and updates the stored account. */ private void ensureAccount(@Nullable Account intendedAccount) { if (intendedAccount == null) { return; } InvalidationPreferences invPrefs = new InvalidationPreferences(this); if (!intendedAccount.equals(invPrefs.getSavedSyncedAccount())) { if (sIsClientStarted) { stopClient(); } setAccount(intendedAccount); } }
Example 14
Source File: ChromeBrowserSyncAdapter.java From delion with Apache License 2.0 | 4 votes |
@Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE)) { Account signedInAccount = ChromeSigninController.get(getContext()).getSignedInUser(); if (account.equals(signedInAccount)) { ContentResolver.setIsSyncable(account, authority, 1); } else { ContentResolver.setIsSyncable(account, authority, 0); } return; } PendingInvalidation invalidation = new PendingInvalidation(extras); DelayedInvalidationsController controller = DelayedInvalidationsController.getInstance(); if (!controller.shouldNotifyInvalidation(extras)) { controller.addPendingInvalidation(getContext(), account.name, invalidation); return; } // Browser startup is asynchronous, so we will need to wait for startup to finish. Semaphore semaphore = new Semaphore(0); // Configure the BrowserParts with all the data it needs. BrowserParts parts = getBrowserParts(mApplication, account.name, invalidation, syncResult, semaphore); startBrowserProcess(parts, syncResult, semaphore); try { // This code is only synchronously calling a single native method // to trigger and asynchronous sync cycle, so 5 minutes is generous. if (!semaphore.tryAcquire(5, TimeUnit.MINUTES)) { Log.w(TAG, "Sync request timed out!"); syncResult.stats.numIoExceptions++; } } catch (InterruptedException e) { Log.w(TAG, "Got InterruptedException when trying to request an invalidation.", e); // Using numIoExceptions so Android will treat this as a soft error. syncResult.stats.numIoExceptions++; } }
Example 15
Source File: ChromeBrowserSyncAdapter.java From AndroidChromium with Apache License 2.0 | 4 votes |
@Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE)) { Account signedInAccount = ChromeSigninController.get(getContext()).getSignedInUser(); if (account.equals(signedInAccount)) { ContentResolver.setIsSyncable(account, authority, 1); } else { ContentResolver.setIsSyncable(account, authority, 0); } return; } PendingInvalidation invalidation = new PendingInvalidation(extras); DelayedInvalidationsController controller = DelayedInvalidationsController.getInstance(); if (!controller.shouldNotifyInvalidation(extras)) { controller.addPendingInvalidation(getContext(), account.name, invalidation); return; } // Browser startup is asynchronous, so we will need to wait for startup to finish. Semaphore semaphore = new Semaphore(0); // Configure the BrowserParts with all the data it needs. BrowserParts parts = getBrowserParts(mApplication, account.name, invalidation, syncResult, semaphore); startBrowserProcess(parts, syncResult, semaphore); try { // This code is only synchronously calling a single native method // to trigger and asynchronous sync cycle, so 5 minutes is generous. if (!semaphore.tryAcquire(5, TimeUnit.MINUTES)) { Log.w(TAG, "Sync request timed out!"); syncResult.stats.numIoExceptions++; } } catch (InterruptedException e) { Log.w(TAG, "Got InterruptedException when trying to request an invalidation.", e); // Using numIoExceptions so Android will treat this as a soft error. syncResult.stats.numIoExceptions++; } }
Example 16
Source File: ChromeBrowserSyncAdapter.java From 365browser with Apache License 2.0 | 4 votes |
@Override public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) { if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_INITIALIZE)) { Account signedInAccount = ChromeSigninController.get().getSignedInUser(); if (account.equals(signedInAccount)) { ContentResolver.setIsSyncable(account, authority, 1); } else { ContentResolver.setIsSyncable(account, authority, 0); } return; } PendingInvalidation invalidation = new PendingInvalidation(extras); DelayedInvalidationsController controller = DelayedInvalidationsController.getInstance(); if (!controller.shouldNotifyInvalidation(extras)) { controller.addPendingInvalidation(getContext(), account.name, invalidation); return; } // Browser startup is asynchronous, so we will need to wait for startup to finish. Semaphore semaphore = new Semaphore(0); // Configure the BrowserParts with all the data it needs. BrowserParts parts = getBrowserParts(mApplication, account.name, invalidation, syncResult, semaphore); startBrowserProcess(parts, syncResult, semaphore); try { // This code is only synchronously calling a single native method // to trigger and asynchronous sync cycle, so 5 minutes is generous. if (!semaphore.tryAcquire(5, TimeUnit.MINUTES)) { Log.w(TAG, "Sync request timed out!"); syncResult.stats.numIoExceptions++; } } catch (InterruptedException e) { Log.w(TAG, "Got InterruptedException when trying to request an invalidation.", e); // Using numIoExceptions so Android will treat this as a soft error. syncResult.stats.numIoExceptions++; } }