|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.vodafone360.people.engine.contactsync.BaseSyncProcessor com.vodafone360.people.engine.contactsync.DownloadServerContacts
public class DownloadServerContacts
Handles download of contacts from People server.
Nested Class Summary | |
---|---|
static class |
DownloadServerContacts.InternalState
Enumeration which holds the various states for the download server processor. |
Field Summary | |
---|---|
private static boolean |
EXTRA_DEBUG_TRACE
Set to true for extra logcat trace (debug only) |
private java.util.ArrayList<Contact> |
mAddContactList
List of all contacts received from the server that need to be added to the database. |
private java.util.ArrayList<ContactDetail> |
mAddDetailList
List of all contact details received from the server that need to be added to the local database. |
private static int |
MAX_CONTACT_CHANGES_PER_PAGE
Maximum number of database updates for each engine run (to ensure the processor doesn't block the worker thread for too long). |
protected static int |
MAX_DOWN_PAGE_SIZE
The maximum number of contacts that should be sent by the server for each page request. |
private static int |
MAX_PAGES_PER_BATCH
The number of pages that should be requested in a single RPG request (using batching). |
private int |
mBatchFirstPageNo
First page number requested in the batch. |
private int |
mBatchNoOfPages
Total number of pages requested by batch. |
private int |
mBatchPageReceivedCount
Number of pages received so far from the batch |
private java.util.ArrayList<Contact> |
mContactsChangedList
List of all contacts received from server which are also present in the local database. |
private long |
mDbSyncTime
Used to monitor how much time is spent reading or writing to the NowPlus database. |
private java.util.ArrayList<ContactsTable.ContactIdInfo> |
mDeleteContactList
List of all contacts received from the server that need to be deleted from the database. |
private java.util.ArrayList<ContactDetail> |
mDeleteDetailList
List of all contact details received from the server that need to be deleted from the local database. |
private java.lang.Integer |
mFromRevision
This will be set to the current revision of the contacts in the NowPlus database. |
protected DownloadServerContacts.InternalState |
mInternalState
Current internal state of the processor. |
private boolean |
mIsComplete
Set to true when there are no more pages to fetch from the server. |
private int |
mLastPageSize
Number of contacts contained in the last page. |
private java.util.ArrayList<Contact> |
mModifyContactList
List of all contacts received from the server that need to be modified in the database. |
private java.util.ArrayList<ContactDetail> |
mModifyDetailList
List of all contact details received from the server that need to be modified in the local database. |
private int |
mNoOfPagesDone
Total number of pages done (used with mTotalNoOfPages for
calculating progress) |
private java.util.ArrayList<java.lang.Long> |
mOrderedServerIdList
List of contact server IDs from the NowPlus database in ascending order. |
protected java.util.Map<java.lang.Integer,java.lang.Integer> |
mPageReqIds
Maintains all the request IDs when sending a batch of requests. |
private boolean |
mSyncDataPending
Flag indicating that there is some data in either the mAddContactList , mModifyContactList ,
mDeleteContactList , mAddDetailList ,
mModifyDetailList or mDeleteDetailList list. |
private java.lang.Integer |
mToRevision
The revision that we require from the server. |
private long |
mTotalContactsAdded
Counts the number of contacts added (for use when profiling) |
private java.lang.Integer |
mTotalNoOfPages
Total number of pages we are expecting from the server. |
private static long |
NANOSECONDS_IN_MS
Helper constant for converting between milliseconds and nanoseconds. |
private static long |
TIMEOUT_BETWEEN_PAGES_MS
Timeout between each run of the engine. |
Fields inherited from class com.vodafone360.people.engine.contactsync.BaseSyncProcessor |
---|
mCallback, mDb, mFailureList |
Constructor Summary | |
---|---|
protected |
DownloadServerContacts(IContactSyncCallback callback,
DatabaseHelper db)
Processor constructor. |
Method Summary | |
---|---|
private boolean |
addContactList()
Adds contacts received from the server (listed in the mAddContactList list) into the local database. |
private boolean |
addDetailList()
Adds contact details to the local database based on changes received from the server (listed in the mAddDetailList list). |
private boolean |
checkContactMods(Contact srcContact,
Contact destContact)
Compares two contacts to check for any differences. |
private boolean |
deleteContactList()
Deletes contacts from the local database based on changes received from the server (listed in the mDeleteContactList list). |
private boolean |
deleteDetailList()
Deletes contact details from the local database based on changes received from the server (listed in the mDeleteDetailList list). |
protected void |
doCancel()
Called by framework when contact sync is cancelled. |
protected void |
doStart()
Called by framework to start the processor running. |
private void |
downloadSyncSuccessful()
Called when the processor has finished downloading the contact changes. |
private ServiceStatus |
fetchFirstBatch()
Requests first page of contact changes from the server. |
private ServiceStatus |
fetchNextBatch()
Requests the next batch of contact change pages from the server |
protected void |
finalize()
For debug only - to show when the garbage collector destroys the processor |
private static int |
findIdInOrderedList(long id,
java.util.List<java.lang.Long> list)
Binary search function to find a contact server ID in an ordered list. |
private boolean |
modifyContactList()
Updates the local database with contacts received from the server (listed in the mModifyContactList list). |
private boolean |
modifyDetailList()
Modifies contact details in the local database based on changes received from the server (listed in the mModifyDetailList list). |
void |
onTimeoutEvent()
Called by framework when a timeout expires. |
void |
processCommsResponse(ResponseQueue.Response resp)
Called by framework when a response is received from the server. |
private void |
processContactChangesNextPage()
Processes next page of modified contacts in the mContactsChangedList . |
private ServiceStatus |
syncContactChangesPage(ContactChanges changes)
Processes the response from the server. |
private ServiceStatus |
syncDownContact(Contact srcContact,
Contact destContact)
Modifies a contact from the NowPlus database to match the one received from the server |
private void |
updateProgressUi(Contact contact,
int incOfCurrentPage)
Check the given contact to see if it has a valid name, and if so send it to be shown in the contacts sync progress UI. |
Methods inherited from class com.vodafone360.people.engine.contactsync.BaseSyncProcessor |
---|
cancel, complete, getEngine, markDbChanged, onComplete, setReqId, setSyncStatus, setTimeout, start |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long NANOSECONDS_IN_MS
protected static final int MAX_DOWN_PAGE_SIZE
private static final int MAX_PAGES_PER_BATCH
private static final int MAX_CONTACT_CHANGES_PER_PAGE
private static final long TIMEOUT_BETWEEN_PAGES_MS
private static final boolean EXTRA_DEBUG_TRACE
private java.lang.Integer mFromRevision
private java.lang.Integer mToRevision
private java.lang.Integer mTotalNoOfPages
private int mBatchFirstPageNo
private int mBatchNoOfPages
private int mBatchPageReceivedCount
private int mNoOfPagesDone
mTotalNoOfPages
for
calculating progress)
private int mLastPageSize
private final java.util.ArrayList<java.lang.Long> mOrderedServerIdList
private final java.util.ArrayList<Contact> mContactsChangedList
private final java.util.ArrayList<Contact> mAddContactList
private final java.util.ArrayList<Contact> mModifyContactList
private final java.util.ArrayList<ContactsTable.ContactIdInfo> mDeleteContactList
private final java.util.ArrayList<ContactDetail> mAddDetailList
private final java.util.ArrayList<ContactDetail> mModifyDetailList
private final java.util.ArrayList<ContactDetail> mDeleteDetailList
protected final java.util.Map<java.lang.Integer,java.lang.Integer> mPageReqIds
private boolean mSyncDataPending
mAddContactList
, mModifyContactList
,
mDeleteContactList
, mAddDetailList
,
mModifyDetailList
or mDeleteDetailList
list.
protected DownloadServerContacts.InternalState mInternalState
private long mDbSyncTime
private boolean mIsComplete
private long mTotalContactsAdded
Constructor Detail |
---|
protected DownloadServerContacts(IContactSyncCallback callback, DatabaseHelper db)
callback
- Callback interface for accessing the contact sync engine.db
- Database used for modifying contactsMethod Detail |
---|
protected void finalize()
finalize
in class java.lang.Object
protected void doStart()
doStart
in class BaseSyncProcessor
private ServiceStatus fetchFirstBatch()
private ServiceStatus fetchNextBatch()
protected void doCancel()
doCancel
in class BaseSyncProcessor
public void processCommsResponse(ResponseQueue.Response resp)
processCommsResponse
in class BaseSyncProcessor
response
- from serverprivate void updateProgressUi(Contact contact, int incOfCurrentPage)
contact
- Contact which has been downloaded.incOfCurrentPage
- Number of contacts that have so far been
downloaded for the current page.private ServiceStatus syncContactChangesPage(ContactChanges changes)
changes
- The contact change information received from the server
private void processContactChangesNextPage()
mContactsChangedList
.
private ServiceStatus syncDownContact(Contact srcContact, Contact destContact)
srcContact
- Contact received from the serverdestContact
- Contact as stored in the database
private static int findIdInOrderedList(long id, java.util.List<java.lang.Long> list)
id
- The server ID to findlist
- An ordered list of server IDs from the database
private boolean checkContactMods(Contact srcContact, Contact destContact)
srcContact
- Contact received from the serverdestContact
- Contact as it is in the database.
public void onTimeoutEvent()
onTimeoutEvent
in class BaseSyncProcessor
private boolean addContactList()
mAddContactList
list) into the local database.
private boolean modifyContactList()
mModifyContactList
list).
private boolean deleteContactList()
mDeleteContactList
list).
private boolean addDetailList()
mAddDetailList
list).
private boolean modifyDetailList()
mModifyDetailList
list).
private boolean deleteDetailList()
mDeleteDetailList
list).
private void downloadSyncSuccessful()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaDoc