Example usage for android.net NetworkInfo isRoaming

List of usage examples for android.net NetworkInfo isRoaming

Introduction

In this page you can find the example usage for android.net NetworkInfo isRoaming.

Prototype

@Deprecated
public boolean isRoaming() 

Source Link

Document

Indicates whether the device is currently roaming on this network.

Usage

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

/**
 * Determine whether the account is allowed to sync automatically, as opposed to manually, based
 * on whether the "require manual sync when roaming" policy is in force and applicable
 * @param account the account/*from w  ww  .  j  av a2  s .  co  m*/
 * @return whether or not the account can sync automatically
 */
/*package*/ static boolean canAutoSync(Account account) {
    ExchangeService exchangeService = INSTANCE;
    if (exchangeService == null) {
        return false;
    }
    NetworkInfo networkInfo = exchangeService.mNetworkInfo;

    // Enforce manual sync only while roaming here
    long policyKey = account.mPolicyKey;
    // Quick exit from this check
    if ((policyKey != 0) && (networkInfo != null)
            && (ConnectivityManager.isNetworkTypeMobile(networkInfo.getType()))) {
        // We'll cache the Policy data here
        Policy policy = account.mPolicy;
        if (policy == null) {
            policy = Policy.restorePolicyWithId(INSTANCE, policyKey);
            account.mPolicy = policy;
        }
        if (policy != null && policy.mRequireManualSyncWhenRoaming && networkInfo.isRoaming()) {
            return false;
        }
    }
    return true;
}