Search in sources :

Example 11 with PersistSettings

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

the class NowPlusDBHelperLoginTest method testSetFetchOption.

/*
	 * set and fetch option
	 */
public void testSetFetchOption() {
    Log.i(LOG_TAG, "***** EXECUTING testAddDeleteContactsDetails *****");
    Log.i(LOG_TAG, "Test contact functionality (add delete contacts details)");
    Log.i(LOG_TAG, "Test 1a: Initialise test environment and load database");
    assertTrue(initialise());
    Log.i(LOG_TAG, "Test 1b: Remove user data");
    mDatabaseHelper.removeUserData();
    ServiceStatus status = mTestUtility.waitForEvent(WAIT_EVENT_TIMEOUT_MS, DbTestUtility.CONTACTS_INT_EVENT_MASK);
    assertEquals(ServiceStatus.SUCCESS, status);
    PersistSettings setting = new PersistSettings();
    setting.putInternetAvail(InternetAvail.ALWAYS_CONNECT);
    status = mDatabaseHelper.setOption(setting);
    assertEquals(ServiceStatus.SUCCESS, status);
    PersistSettings fetchedSetting = mDatabaseHelper.fetchOption(PersistSettings.Option.INTERNETAVAIL);
    assertEquals(fetchedSetting.toString(), setting.toString());
    shutdown();
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "testModifyFetchCredentials has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : PersistSettings(com.vodafone360.people.service.PersistSettings) ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 12 with PersistSettings

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

the class ContactSyncEngine method setFirstTimeNativeSyncComplete.

/**
     * Helper function to update the database when the state of the
     * {@link #mFirstTimeNativeSyncComplete} flag changes.
     * 
     * @param value New value to the flag. True indicates that the native fetch
     *            part of the first time sync has been completed. The flag is
     *            never set to false again by the engine, it will be only set to
     *            false when a remove user data is done (and the database is
     *            deleted).
     * @return SUCCESS or a suitable error code if the database could not be
     *         updated.
     */
private ServiceStatus setFirstTimeNativeSyncComplete(boolean value) {
    if (mFirstTimeSyncComplete == value) {
        return ServiceStatus.SUCCESS;
    }
    PersistSettings setting = new PersistSettings();
    setting.putFirstTimeNativeSyncComplete(value);
    ServiceStatus status = mDb.setOption(setting);
    if (ServiceStatus.SUCCESS == status) {
        mFirstTimeNativeSyncComplete = value;
    }
    return status;
}
Also used : PersistSettings(com.vodafone360.people.service.PersistSettings) ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Example 13 with PersistSettings

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

the class DatabaseHelper method fetchOption.

/***
     * Fetches a setting from the database.
     * 
     * @param option The option required.
     * @return A {@link PersistSettings} object which contains the setting data
     *         if successful, null otherwise
     * @see #setOption(PersistSettings)
     */
public PersistSettings fetchOption(PersistSettings.Option option) {
    PersistSettings setting = StateTable.fetchOption(option, getWritableDatabase());
    if (setting == null) {
        setting = new PersistSettings();
        setting.putDefaultOptionData();
    }
    return setting;
}
Also used : PersistSettings(com.vodafone360.people.service.PersistSettings)

Example 14 with PersistSettings

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

the class NowPlusStateTableTest method testSetFetchOption.

/*
     * set and fetch option
     */
public void testSetFetchOption() {
    final String fnName = "testContactRevision";
    mTestStep = 1;
    Log.i(LOG_TAG, "***** EXECUTING " + fnName + "*****");
    Log.i(LOG_TAG, "test setting and fetching option");
    SQLiteDatabase writableDb = mTestDatabase.getWritableDatabase();
    SQLiteDatabase readableDb = mTestDatabase.getReadableDatabase();
    PersistSettings setting = new PersistSettings();
    setting.putInternetAvail(InternetAvail.ALWAYS_CONNECT);
    // try to set and fetch option before creating a table
    ServiceStatus status = StateTable.setOption(setting, writableDb);
    assertNull(status);
    PersistSettings fetchedSetting = StateTable.fetchOption(PersistSettings.Option.INTERNETAVAIL, readableDb);
    assertNull(fetchedSetting);
    createTable();
    status = StateTable.setOption(setting, writableDb);
    assertEquals(ServiceStatus.SUCCESS, status);
    fetchedSetting = StateTable.fetchOption(PersistSettings.Option.INTERNETAVAIL, readableDb);
    assertEquals(fetchedSetting.toString(), setting.toString());
    Log.i(LOG_TAG, "*************************************");
    Log.i(LOG_TAG, "testSetFetchOption has completed successfully");
    Log.i(LOG_TAG, "**************************************");
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) PersistSettings(com.vodafone360.people.service.PersistSettings) ServiceStatus(com.vodafone360.people.service.ServiceStatus)

Aggregations

PersistSettings (com.vodafone360.people.service.PersistSettings)13 ServiceStatus (com.vodafone360.people.service.ServiceStatus)9 ContentValues (android.content.ContentValues)1 Cursor (android.database.Cursor)1 SQLException (android.database.SQLException)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 SQLiteException (android.database.sqlite.SQLiteException)1