Search in sources :

Example 1 with InternetAvail

use of com.vodafone360.people.service.PersistSettings.InternetAvail in project 360-Engine-for-Android by 360.

the class MainApplication method setInternetAvail.

/**
 * Set Internet availability - always makes Internet available, only
 * available in home network, allow manual connection only. This setting is
 * stored in People database.
 *
 * @param internetAvail Internet availability setting.
 * @param forwardToSyncAdapter TRUE if the SyncAdater needs to know about the changes, FALSE otherwise
 * @return SerivceStatus indicating whether the Internet availability
 *         setting has been successfully updated in the database.
 */
public ServiceStatus setInternetAvail(InternetAvail internetAvail, boolean forwardToSyncAdapter) {
    if (getInternetAvail() == internetAvail) {
        return ServiceStatus.SUCCESS;
    }
    if (internetAvail == InternetAvail.ALWAYS_CONNECT && !NativeContactsApi.getInstance().getMasterSyncAutomatically()) {
        // FIXME: Perhaps an abusive use of this error code for when
        // Master Sync Automatically is OFF, should have a different
        LogUtils.logW("ServiceStatus.setInternetAvail() [master sync is off]");
        return ServiceStatus.ERROR_NO_AUTO_CONNECT;
    }
    PersistSettings mPersistSettings = new PersistSettings();
    mPersistSettings.putInternetAvail(internetAvail);
    ServiceStatus ss = mDatabaseHelper.setOption(mPersistSettings);
    // FIXME: This is a hack in order to set the system auto sync on/off depending on our data settings
    if (forwardToSyncAdapter) {
        NativeContactsApi.getInstance().setSyncAutomatically(internetAvail == InternetAvail.ALWAYS_CONNECT);
    }
    synchronized (this) {
        if (mServiceInterface != null) {
            mServiceInterface.notifyDataSettingChanged(internetAvail);
        } else {
            LogUtils.logE("MainApplication.setInternetAvail() " + "mServiceInterface should not be NULL");
        }
    }
    return ss;
}
Also used : PersistSettings(com.vodafone360.people.service.PersistSettings) ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 2 with InternetAvail

use of com.vodafone360.people.service.PersistSettings.InternetAvail in project 360-Engine-for-Android by 360.

the class NetworkAgent method processRoaming.

/**
 * Displaying notification to the user about roaming
 *
 * @param InternetAvail value.
 */
private void processRoaming(InternetAvail val) {
    InternetAvail internetAvail;
    if (val != null) {
        internetAvail = val;
    } else {
        internetAvail = getInternetAvailSetting();
    }
    Intent intent = new Intent();
    if (mContext != null && mIsRoaming && (internetAvail == InternetAvail.ALWAYS_CONNECT) && (mDisableRoamingNotificationUntil == null || mDisableRoamingNotificationUntil < System.currentTimeMillis())) {
        LogUtils.logV("NetworkAgent.processRoaming() " + "Displaying notification - DisplayRoaming[" + mIsRoaming + "]");
        intent.setAction(Intents.ROAMING_ON);
    } else {
        /*
             * We are not roaming then we should remove notification, if no
             * notification were before nothing happens
             */
        LogUtils.logV("NetworkAgent.processRoaming() Removing notification - " + " DisplayRoaming[" + mIsRoaming + "]");
        intent.setAction(Intents.ROAMING_OFF);
    }
    mContext.sendBroadcast(intent);
}
Also used : InternetAvail(com.vodafone360.people.service.PersistSettings.InternetAvail) Intent(android.content.Intent)

Aggregations

Intent (android.content.Intent)1 PersistSettings (com.vodafone360.people.service.PersistSettings)1 InternetAvail (com.vodafone360.people.service.PersistSettings.InternetAvail)1 ServiceStatus (com.vodafone360.people.service.ServiceStatus)1