Search in sources :

Example 16 with MainApplication

use of com.vodafone360.people.MainApplication in project 360-Engine-for-Android by 360.

the class UploadServerContactsTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mApplication = (MainApplication) Instrumentation.newApplication(MainApplication.class, getInstrumentation().getTargetContext());
    mApplication.onCreate();
    mDb = mApplication.getDatabase();
    mDb.removeUserData();
    mEngineTester = new EngineTestFramework(this);
    mEng = new DummyContactSyncEngine(mEngineTester);
    mProcessor = new UploadServerContactProcessorTest(mEng, mApplication.getDatabase());
    mEng.setProcessor(mProcessor);
    mEngineTester.setEngine(mEng);
    mState = State.IDLE;
    NetworkAgent.setAgentState(NetworkAgent.AgentState.CONNECTED);
    mBulkContactTest = false;
}
Also used : EngineTestFramework(com.vodafone360.people.tests.engine.EngineTestFramework)

Example 17 with MainApplication

use of com.vodafone360.people.MainApplication in project 360-Engine-for-Android by 360.

the class NetworkAgent method onConnectionStateChanged.

/**
     * Contains the main logic that determines the agent state for network
     * access
     */
private void onConnectionStateChanged() {
    if (mContext != null) {
        MainApplication app = (MainApplication) ((RemoteService) mContext).getApplication();
        if ((app.getInternetAvail() == InternetAvail.MANUAL_CONNECT)) {
            LogUtils.logV("NetworkAgent.onConnectionStateChanged()" + " Internet allowed only in manual mode");
            sDisconnectReason = AgentDisconnectReason.DATA_SETTING_SET_TO_MANUAL_CONNECTION;
            setNewState(AgentState.DISCONNECTED);
            return;
        }
    }
    if (!mNetworkWorking) {
        LogUtils.logV("NetworkAgent.onConnectionStateChanged() Network is not working");
        sDisconnectReason = AgentDisconnectReason.NO_WORKING_NETWORK;
        setNewState(AgentState.DISCONNECTED);
        return;
    }
    if (mIsRoaming && !mDataRoaming && !mWifiNetworkAvailable) {
        LogUtils.logV("NetworkAgent.onConnectionStateChanged() " + "Connect while roaming not allowed");
        sDisconnectReason = AgentDisconnectReason.DATA_ROAMING_DISABLED;
        setNewState(AgentState.DISCONNECTED);
        return;
    }
    if (mIsInBackground && !mBackgroundData) {
        LogUtils.logV("NetworkAgent.onConnectionStateChanged() Background connection not allowed");
        sDisconnectReason = AgentDisconnectReason.BACKGROUND_CONNECTION_DISABLED;
        setNewState(AgentState.DISCONNECTED);
        return;
    }
    if (!mInternetConnected) {
        LogUtils.logV("NetworkAgent.onConnectionStateChanged() No internet connection");
        sDisconnectReason = AgentDisconnectReason.NO_INTERNET_CONNECTION;
        // If 2g call is started, notify contact sync engine to pause.
        if (mNetworkInfo != null && VOICE_CALL_STARTED_2G_STRING.equals(mNetworkInfo.getReason())) {
            EngineManager.getInstance().getContactSyncEngine().pauseSync();
        }
        setNewState(AgentState.DISCONNECTED);
        return;
    }
    // If 2g voice call is finished, set resume state
    if (mNetworkInfo != null && VOICE_CALL_ENDED_2G_STRING.equals(mNetworkInfo.getReason())) {
        mIsResumeSync = true;
    }
    if (mWifiNetworkAvailable) {
        LogUtils.logV("NetworkAgent.onConnectionStateChanged() WIFI connected");
    } else {
        LogUtils.logV("NetworkAgent.onConnectionStateChanged() Cellular connected");
    }
    LogUtils.logV("NetworkAgent.onConnectionStateChanged() Connection available");
    setNewState(AgentState.CONNECTED);
}
Also used : MainApplication(com.vodafone360.people.MainApplication)

Example 18 with MainApplication

use of com.vodafone360.people.MainApplication in project 360-Engine-for-Android by 360.

the class EngineManager method createLoginEngine.

/**
     * Create instance of LoginEngine.
     */
private synchronized void createLoginEngine() {
    final MainApplication app = (MainApplication) mService.getApplication();
    mLoginEngine = new LoginEngine(mService, mUiEventCallback, app.getDatabase());
    addEngine(mLoginEngine);
}
Also used : LoginEngine(com.vodafone360.people.engine.login.LoginEngine) MainApplication(com.vodafone360.people.MainApplication)

Example 19 with MainApplication

use of com.vodafone360.people.MainApplication in project 360-Engine-for-Android by 360.

the class EngineManager method createGroupsEngine.

private synchronized void createGroupsEngine() {
    final MainApplication app = (MainApplication) mService.getApplication();
    mGroupsEngine = new GroupsEngine(mService, mUiEventCallback, app.getDatabase());
    addEngine(mGroupsEngine);
}
Also used : GroupsEngine(com.vodafone360.people.engine.groups.GroupsEngine) MainApplication(com.vodafone360.people.MainApplication)

Example 20 with MainApplication

use of com.vodafone360.people.MainApplication in project 360-Engine-for-Android by 360.

the class EngineManager method createActivitiesEngine.

/**
     * Create instance of ActivitiesEngine.
     */
private synchronized void createActivitiesEngine() {
    final MainApplication app = (MainApplication) mService.getApplication();
    mActivitiesEngine = new ActivitiesEngine(mService, mUiEventCallback, app.getDatabase());
    getLoginEngine().addListener(mActivitiesEngine);
    addEngine(mActivitiesEngine);
}
Also used : ActivitiesEngine(com.vodafone360.people.engine.activities.ActivitiesEngine) MainApplication(com.vodafone360.people.MainApplication)

Aggregations

MainApplication (com.vodafone360.people.MainApplication)12 EngineTestFramework (com.vodafone360.people.tests.engine.EngineTestFramework)4 Intent (android.content.Intent)2 ActivitiesEngine (com.vodafone360.people.engine.activities.ActivitiesEngine)2 IdentityEngine (com.vodafone360.people.engine.identities.IdentityEngine)2 LoginEngine (com.vodafone360.people.engine.login.LoginEngine)2 SyncMeEngine (com.vodafone360.people.engine.meprofile.SyncMeEngine)2 PresenceEngine (com.vodafone360.people.engine.presence.PresenceEngine)2 NetworkErrorException (android.accounts.NetworkErrorException)1 Instrumentation (android.app.Instrumentation)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 SmallTest (android.test.suitebuilder.annotation.SmallTest)1 Suppress (android.test.suitebuilder.annotation.Suppress)1 ContactSyncEngine (com.vodafone360.people.engine.contactsync.ContactSyncEngine)1 ContentEngine (com.vodafone360.people.engine.content.ContentEngine)1 GroupsEngine (com.vodafone360.people.engine.groups.GroupsEngine)1 Authenticator (com.vodafone360.people.service.Authenticator)1 RemoteService (com.vodafone360.people.service.RemoteService)1