use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.
the class LoginEngine method setRegistrationComplete.
/**
* Helper function to set the registration complete flag and update the
* database with the new state.
*
* @param value true if registration is completed
*/
private void setRegistrationComplete(boolean value) {
LogUtils.logD("LoginEngine.setRegistrationComplete(" + value + ")");
if (value != mIsRegistrationComplete) {
StateTable.setRegistrationComplete(value, mDb.getWritableDatabase());
mIsRegistrationComplete = value;
if (mIsRegistrationComplete) {
// Create NAB Account at this point (does nothing on 1.X
// devices)
final NativeContactsApi nabApi = NativeContactsApi.getInstance();
if (!nabApi.isPeopleAccountCreated()) {
// TODO: React upon failure to create account
nabApi.addPeopleAccount(LoginPreferences.getUsername());
}
}
}
}
use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.
the class UpdateNativeContactsTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
createDatabase();
NativeContactsApi.createInstance(getContext());
if (VersionUtils.is2XPlatform()) {
// Add Account for the case where we are in 2.X
NativeContactsApi.getInstance().addPeopleAccount(PEOPLE_ACCOUNT.getName());
Thread.sleep(100);
}
mContactSyncCallback = new ContactSyncCallback();
}
use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.
the class NativeImporterTest method filterAccountsByType.
/**
* Filters the given array of accounts by the given type.
*
* @param accounts the array of accounts to filter
* @param type the type of accounts to filter
* @return an array containing the filtered accounts or null if none
*/
private static Account[] filterAccountsByType(Account[] accounts, String type) {
if (accounts != null) {
final int length = accounts.length;
final ArrayList<Account> matchingAccounts = new ArrayList<Account>(length);
// find the corresponding accounts
for (int i = 0; i < length; i++) {
final Account account = accounts[i];
if (type.equals(account.getType())) {
matchingAccounts.add(account);
}
}
if (matchingAccounts.size() > 0) {
accounts = new Account[matchingAccounts.size()];
matchingAccounts.toArray(accounts);
return accounts;
}
}
return null;
}
use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.
the class NativeContactsApiTest method testAddGetRemoveContacts.
@MediumTest
@Suppress
public void testAddGetRemoveContacts() {
Account account = null;
if (mUsing2xApi) {
// Add Account for the case where we are in 2.X
mNabApi.addPeopleAccount(PEOPLE_USERNAME);
account = s360PeopleAccount;
threadWait(100);
}
long[] ids = getContactIdsForAllAccounts();
assertNull(ids);
final int numRandomContacts = 10;
long expectedContactId = ContactChange.INVALID_ID;
for (int i = 0; i < numRandomContacts; i++) {
long id = i;
final ContactChange[] newContactCcList = ContactChangeHelper.randomContact(id, id, -1);
final ContactChange[] newIds = mNabApi.addContact(account, newContactCcList);
// expected num ids is + 1 for contact id
verifyNewContactIds(expectedContactId, newContactCcList, newIds);
expectedContactId = newIds[0].getNabContactId() + 1;
// GET CONTACTS AND COMPARE
ids = getContactIdsForAllAccounts();
assertNotNull(ids);
assertEquals(i + 1, ids.length);
final ContactChange[] fetchedContactCcList = mNabApi.getContact(ids[i]);
assertNotNull(fetchedContactCcList);
if (!ContactChangeHelper.areChangeListsEqual(newContactCcList, fetchedContactCcList, false)) {
Log.e(LOG_TAG, "ADD FAILED: Print of contact to be added follows:");
ContactChangeHelper.printContactChangeList(newContactCcList);
Log.e(LOG_TAG, "ADD FAILED: Print of contact fetched follows:");
ContactChangeHelper.printContactChangeList(fetchedContactCcList);
// fail test at this point
assertFalse(true);
}
}
// DELETE
final int idCount = ids.length;
for (int i = 0; i < idCount; i++) {
mNabApi.removeContact(ids[i]);
}
ids = getContactIdsForAllAccounts();
assertNull(ids);
}
use of com.vodafone360.people.engine.contactsync.NativeContactsApi.Account in project 360-Engine-for-Android by 360.
the class PeopleServiceTest method testRegistration.
/*
* List of APIs that are called in tests within this class:
* mPeopleService.fetchUsernameState(name);
* mPeopleService.fetchTermsOfService();
* mPeopleService.fetchPrivacyStatement();
* mPeopleService.register(details);
* mPeopleService.addEventCallback(mHandler);
* mPeopleService.removeEventCallback(mHandler);
* mPeopleService.getLoginRequired();
* mPeopleService.logon(loginDetails);
* mPeopleService.fetchAvailableIdentities(filter);
* mPeopleService.fetchMyIdentities(filter);
* mPeopleService.validateIdentityCredentials(false, "facebook", "testUser", "testPass", null);
* mPeopleService.setIdentityCapabilityStatus("facebook", "testUser", stat);
* mPeopleService.getRoamingNotificationType();
* mPeopleService.setForceConnection(true);
* mPeopleService.getForceConnection()
* mPeopleService.getRoamingDeviceSetting();
* mPeopleService.notifyDataSettingChanged(InternetAvail.ALWAYS_CONNECT);
* mPeopleService.setShowRoamingNotificationAgain(true);
* mPeopleService.setNetworkAgentState(sas);
* mPeopleService.getNetworkAgentState();
* mPeopleService.startActivitySync();
* mPeopleService.startBackgroundContactSync();
* mPeopleService.startContactSync();
*
* void checkForUpdates();
* void setNewUpdateFrequency();
* PresenceList getPresenceList();
*
*/
public void testRegistration() {
if (!ENABLE_REGISTRATION_TEST) {
Log.i(LOG_TAG, "Skipping registration tests...");
return;
}
Log.i(LOG_TAG, "**** testRegistration ****\n");
assertTrue("Unable to create People service", lazyLoadPeopleService());
String name = "scottkennedy1111";
Log.i(LOG_TAG, "Fetching username state for a name (" + name + ") - checking correct state is returned");
mPeopleService.fetchUsernameState(name);
ServiceStatus status = waitForEvent(WAIT_EVENT_TIMEOUT_MS, TEST_RESPONSE);
assertEquals("fetchUsernameState() failed with status = " + status.name(), ServiceStatus.ERROR_INTERNAL_SERVER_ERROR, status);
Log.i(LOG_TAG, "Fetching terms of service...");
mPeopleService.fetchTermsOfService();
status = waitForEvent(WAIT_EVENT_TIMEOUT_MS, TEST_RESPONSE);
assertEquals("fetchTermsOfService() failed with status = " + status.name(), ServiceStatus.ERROR_INTERNAL_SERVER_ERROR, status);
Log.i(LOG_TAG, "Fetching privacy statement...");
mPeopleService.fetchPrivacyStatement();
status = waitForEvent(WAIT_EVENT_TIMEOUT_MS, TEST_RESPONSE);
assertEquals("fetchPrivacyStatement() failed with status = " + status.name(), ServiceStatus.ERROR_INTERNAL_SERVER_ERROR, status);
Log.i(LOG_TAG, "Trying to register new account (username: " + name + ")");
RegistrationDetails details = new RegistrationDetails();
details.mFullname = "Gerry Rafferty";
details.mUsername = name;
details.mPassword = "TestTestTest";
details.mAcceptedTAndC = true;
details.mBirthdayDate = "1978-01-01";
details.mCountrycode = "En";
details.mEmail = "test@test.com";
details.mLanguage = "English";
details.mMobileModelId = 1L;
details.mMobileOperatorId = 1L;
details.mMsisdn = "447775128930";
details.mSendConfirmationMail = false;
details.mSendConfirmationSms = true;
details.mSubscribeToNewsLetter = false;
details.mTimezone = "GMT";
mPeopleService.register(details);
status = waitForEvent(WAIT_EVENT_TIMEOUT_MS, TEST_RESPONSE);
assertEquals("register() failed with status = " + status.name(), ServiceStatus.ERROR_INTERNAL_SERVER_ERROR, status);
Log.i(LOG_TAG, "**** testRegistration (SUCCESS) ****\n");
}
Aggregations