Example usage for android.provider CalendarContract AUTHORITY

List of usage examples for android.provider CalendarContract AUTHORITY

Introduction

In this page you can find the example usage for android.provider CalendarContract AUTHORITY.

Prototype

String AUTHORITY

To view the source code for android.provider CalendarContract AUTHORITY.

Click Source Link

Document

This authority is used for writing to or querying from the calendar provider.

Usage

From source file:com.chen.emailsync.SyncManager.java

/**
 * Determine whether a mailbox of a given type in a given account can be synced automatically
 * by SyncServiceManager.  This is an increasingly complex determination, taking into account
 * security policies and user settings (both within the Email application and in the Settings
 * application)//from   w w w .  j a v a 2s .c  om
 *
 * @param account the Account that the mailbox is in
 * @param type the type of the Mailbox
 * @return whether or not to start a sync
 */
private boolean isMailboxSyncable(Account account, int type) {
    // This 'if' statement performs checks to see whether or not a mailbox is a
    // candidate for syncing based on policies, user settings, & other restrictions
    if (type == Mailbox.TYPE_OUTBOX) {
        // Outbox is always syncable
        return true;
    } else if (type == Mailbox.TYPE_EAS_ACCOUNT_MAILBOX) {
        // Always sync EAS mailbox unless master sync is off
        return ContentResolver.getMasterSyncAutomatically();
    } else if (type == Mailbox.TYPE_CONTACTS || type == Mailbox.TYPE_CALENDAR) {
        // Contacts/Calendar obey this setting from ContentResolver
        if (!ContentResolver.getMasterSyncAutomatically()) {
            return false;
        }
        // Get the right authority for the mailbox
        String authority;
        if (type == Mailbox.TYPE_CONTACTS) {
            authority = ContactsContract.AUTHORITY;
        } else {
            authority = CalendarContract.AUTHORITY;
            if (!mCalendarObservers.containsKey(account.mId)) {
                // Make sure we have an observer for this Calendar, as
                // we need to be able to detect sync state changes, sigh
                registerCalendarObserver(account);
            }
        }
        // See if "sync automatically" is set; if not, punt
        if (!ContentResolver.getSyncAutomatically(mAccountList.getAmAccount(account), authority)) {
            return false;
            // See if the calendar is enabled from the Calendar app UI; if not, punt
        } else if ((type == Mailbox.TYPE_CALENDAR) && !isCalendarEnabled(account.mId)) {
            return false;
        }
        // Never automatically sync trash
    } else if (type == Mailbox.TYPE_TRASH) {
        return false;
        // For non-outbox, non-account mail, we do two checks:
        // 1) are we restricted by policy (i.e. manual sync only),
        // 2) has the user checked the "Sync Email" box in Account Settings, and
    } else if (!canAutoSync(account) || !canSyncEmail(mAccountList.getAmAccount(account))) {
        return false;
    }
    return true;
}

From source file:com.android.exchange.ExchangeService.java

/**
 * Determine whether a mailbox of a given type in a given account can be synced automatically
 * by ExchangeService.  This is an increasingly complex determination, taking into account
 * security policies and user settings (both within the Email application and in the Settings
 * application)/*from www . jav a 2 s.c o m*/
 *
 * @param account the Account that the mailbox is in
 * @param type the type of the Mailbox
 * @return whether or not to start a sync
 */
private boolean isMailboxSyncable(Account account, int type) {
    // This 'if' statement performs checks to see whether or not a mailbox is a
    // candidate for syncing based on policies, user settings, & other restrictions
    if (type == Mailbox.TYPE_OUTBOX || type == Mailbox.TYPE_EAS_ACCOUNT_MAILBOX) {
        // Outbox and account mailbox are always syncable
        return true;
    } else if (type == Mailbox.TYPE_CONTACTS || type == Mailbox.TYPE_CALENDAR) {
        // Contacts/Calendar obey this setting from ContentResolver
        if (!ContentResolver.getMasterSyncAutomatically()) {
            return false;
        }
        // Get the right authority for the mailbox
        String authority;
        if (type == Mailbox.TYPE_CONTACTS) {
            authority = ContactsContract.AUTHORITY;
        } else {
            authority = CalendarContract.AUTHORITY;
            if (!mCalendarObservers.containsKey(account.mId)) {
                // Make sure we have an observer for this Calendar, as
                // we need to be able to detect sync state changes, sigh
                registerCalendarObserver(account);
            }
        }
        // See if "sync automatically" is set; if not, punt
        if (!ContentResolver.getSyncAutomatically(account.mAmAccount, authority)) {
            return false;
            // See if the calendar is enabled from the Calendar app UI; if not, punt
        } else if ((type == Mailbox.TYPE_CALENDAR) && !isCalendarEnabled(account.mId)) {
            return false;
        }
        // Never automatically sync trash
    } else if (type == Mailbox.TYPE_TRASH) {
        return false;
        // For non-outbox, non-account mail, we do three checks:
        // 1) are we restricted by policy (i.e. manual sync only),
        // 2) has the user checked the "Sync Email" box in Account Settings, and
        // 3) does the user have the master "background data" box checked in Settings
    } else if (!canAutoSync(account) || !canSyncEmail(account.mAmAccount) || !mBackgroundData) {
        return false;
    }
    return true;
}