diff options
author | Martin Hibdon <mhibdon@google.com> | 2014-10-10 11:00:36 -0700 |
---|---|---|
committer | Martin Hibdon <mhibdon@google.com> | 2014-10-10 13:00:23 -0700 |
commit | 303a529e9fe182b00fb4a105597d43c9f4eedb79 (patch) | |
tree | d42dfbf5ea1b00e9e841ce0fc6e1cb1c4db6987b /src | |
parent | d9c1848f4b0f62b9429f27bf33cfc013d45de6e2 (diff) | |
download | android_packages_apps_Exchange-303a529e9fe182b00fb4a105597d43c9f4eedb79.tar.gz android_packages_apps_Exchange-303a529e9fe182b00fb4a105597d43c9f4eedb79.tar.bz2 android_packages_apps_Exchange-303a529e9fe182b00fb4a105597d43c9f4eedb79.zip |
Set the sync_state after search finishes
b/17443087
b/15868294
EasSearch was correctly setting the syncState to LIVE when
it started the sync, but incorrectly setting it back to
NO_SYNC as soon as the request is made.
Now it sets the sync state back to NO_SYNC after the
response comes back.
Change-Id: Ie393084106e1fbabfa0833270dbe76c3061fa37e
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/exchange/eas/EasOperation.java | 15 | ||||
-rw-r--r-- | src/com/android/exchange/eas/EasSearch.java | 25 |
2 files changed, 30 insertions, 10 deletions
diff --git a/src/com/android/exchange/eas/EasOperation.java b/src/com/android/exchange/eas/EasOperation.java index ef7d2a8e..b032bb74 100644 --- a/src/com/android/exchange/eas/EasOperation.java +++ b/src/com/android/exchange/eas/EasOperation.java @@ -314,6 +314,14 @@ public abstract class EasOperation { return RESULT_INITIALIZATION_FAILURE; } + try { + return performOperationInternal(); + } finally { + onRequestComplete(); + } + } + + private int performOperationInternal() { // We handle server redirects by looping, but we need to protect against too much looping. int redirectCount = 0; @@ -454,6 +462,13 @@ public abstract class EasOperation { // been sent. It will always be called, regardless of the status of the request. } + protected void onRequestComplete() { + // This can be overridden to do any cleanup that must happen after the request has + // finished. (i.e. either the response has come back and been processed, or some error + // has occurred and we have given up. + // It will always be called, regardless of the status of the response. + } + protected int handleHttpError(final int httpStatus) { // This function can be overriden if the child class needs to change the result code // based on the http response status. diff --git a/src/com/android/exchange/eas/EasSearch.java b/src/com/android/exchange/eas/EasSearch.java index 34869bb6..8020ee6a 100644 --- a/src/com/android/exchange/eas/EasSearch.java +++ b/src/com/android/exchange/eas/EasSearch.java @@ -39,6 +39,7 @@ public class EasSearch extends EasOperation { final SearchParams mSearchParams; final long mDestMailboxId; int mTotalResults; + Mailbox mSearchMailbox; public EasSearch(final Context context, final long accountId, final SearchParams searchParams, final long destMailboxId) { @@ -72,17 +73,17 @@ public class EasSearch extends EasOperation { } int res = 0; - final Mailbox searchMailbox = Mailbox.restoreMailboxWithId(mContext, mDestMailboxId); + mSearchMailbox = Mailbox.restoreMailboxWithId(mContext, mDestMailboxId); // Sanity check; account might have been deleted? - if (searchMailbox == null) { + if (mSearchMailbox == null) { LogUtils.i(LOG_TAG, "search mailbox ceased to exist"); return null; } - final ContentValues statusValues = new ContentValues(2); try { // Set the status of this mailbox to indicate query + final ContentValues statusValues = new ContentValues(1); statusValues.put(Mailbox.UI_SYNC_STATUS, UIProvider.SyncStatus.LIVE_QUERY); - searchMailbox.update(mContext, statusValues); + mSearchMailbox.update(mContext, statusValues); final Serializer s = new Serializer(); s.start(Tags.SEARCH_SEARCH).start(Tags.SEARCH_STORE); @@ -133,12 +134,6 @@ public class EasSearch extends EasOperation { return makeEntity(s); } catch (IOException e) { LogUtils.d(LOG_TAG, e, "Search exception"); - } finally { - // TODO: Handle error states - // Set the status of this mailbox to indicate query over - statusValues.put(Mailbox.SYNC_TIME, System.currentTimeMillis()); - statusValues.put(Mailbox.UI_SYNC_STATUS, UIProvider.SyncStatus.NO_SYNC); - searchMailbox.update(mContext, statusValues); } LogUtils.i(LOG_TAG, "end returning null"); return null; @@ -162,4 +157,14 @@ public class EasSearch extends EasOperation { } return RESULT_OK; } + + protected void onRequestComplete() { + if (mSearchMailbox != null) { + // TODO: Handle error states + final ContentValues statusValues = new ContentValues(2); + statusValues.put(Mailbox.UI_SYNC_STATUS, UIProvider.SyncStatus.NO_SYNC); + statusValues.put(Mailbox.SYNC_TIME, System.currentTimeMillis()); + mSearchMailbox.update(mContext, statusValues); + } + } } |