diff options
author | Andy Huang <ath@google.com> | 2013-05-21 18:08:08 -0700 |
---|---|---|
committer | Andy Huang <ath@google.com> | 2013-05-21 18:08:08 -0700 |
commit | d521baf3a51c9fc1306bd55e027ce57d0a1d18aa (patch) | |
tree | 9b57de2cf09c3c778f6e43a7cd0ba5f1520442c0 /src/com/android/mail | |
parent | fa225db4767867509fd962ac671e054294d13702 (diff) | |
download | android_packages_apps_UnifiedEmail-d521baf3a51c9fc1306bd55e027ce57d0a1d18aa.tar.gz android_packages_apps_UnifiedEmail-d521baf3a51c9fc1306bd55e027ce57d0a1d18aa.tar.bz2 android_packages_apps_UnifiedEmail-d521baf3a51c9fc1306bd55e027ce57d0a1d18aa.zip |
not all respond() calls require locking
The UI thread uses respond() to signal user-visibility on each list
item, so we definitely don't want to block the UI thread on those kinds
of respond() calls. Add an options bitfield whose inaugural value is a
bit that hints that the cursor position must be safely moved prior to
respond().
This fixes some big hiccups that result when syncing + scrolling with
the respond CLs yesterday.
Bug: 9032162
Change-Id: I1c927453b9f474c89861a7295de1e318279e3a49
Diffstat (limited to 'src/com/android/mail')
-rw-r--r-- | src/com/android/mail/content/ThreadSafeCursorWrapper.java | 10 | ||||
-rw-r--r-- | src/com/android/mail/providers/Conversation.java | 6 | ||||
-rw-r--r-- | src/com/android/mail/providers/UIProvider.java | 15 |
3 files changed, 29 insertions, 2 deletions
diff --git a/src/com/android/mail/content/ThreadSafeCursorWrapper.java b/src/com/android/mail/content/ThreadSafeCursorWrapper.java index 35ec10370..ed2b3f93a 100644 --- a/src/com/android/mail/content/ThreadSafeCursorWrapper.java +++ b/src/com/android/mail/content/ThreadSafeCursorWrapper.java @@ -20,6 +20,7 @@ import android.database.Cursor; import android.database.CursorWrapper; import android.os.Bundle; +import com.android.mail.providers.UIProvider; import com.android.mail.utils.LogTag; import com.android.mail.utils.LogUtils; @@ -98,8 +99,13 @@ public class ThreadSafeCursorWrapper extends CursorWrapper { @Override public Bundle respond(Bundle extras) { - synchronized (mLock) { - moveToCurrent(); + final int opts = extras.getInt(UIProvider.ConversationCursorCommand.COMMAND_KEY_OPTIONS); + if ((opts & UIProvider.ConversationCursorCommand.OPTION_MOVE_POSITION) != 0) { + synchronized (mLock) { + moveToCurrent(); + return super.respond(extras); + } + } else { return super.respond(extras); } } diff --git a/src/com/android/mail/providers/Conversation.java b/src/com/android/mail/providers/Conversation.java index c5b4dc9ed..422f76bca 100644 --- a/src/com/android/mail/providers/Conversation.java +++ b/src/com/android/mail/providers/Conversation.java @@ -422,6 +422,9 @@ public class Conversation implements Parcelable { final String key = UIProvider.ConversationCursorCommand.COMMAND_GET_CONVERSATION_INFO; if (sConversationInfoRequest.isEmpty()) { sConversationInfoRequest.putBoolean(key, true); + sConversationInfoRequest.putInt( + UIProvider.ConversationCursorCommand.COMMAND_KEY_OPTIONS, + UIProvider.ConversationCursorCommand.OPTION_MOVE_POSITION); } final Bundle response = cursor.respond(sConversationInfoRequest); if (response.containsKey(key)) { @@ -439,6 +442,9 @@ public class Conversation implements Parcelable { final String key = UIProvider.ConversationCursorCommand.COMMAND_GET_RAW_FOLDERS; if (sRawFoldersRequest.isEmpty()) { sRawFoldersRequest.putBoolean(key, true); + sRawFoldersRequest.putInt( + UIProvider.ConversationCursorCommand.COMMAND_KEY_OPTIONS, + UIProvider.ConversationCursorCommand.OPTION_MOVE_POSITION); } final Bundle response = cursor.respond(sRawFoldersRequest); if (response.containsKey(key)) { diff --git a/src/com/android/mail/providers/UIProvider.java b/src/com/android/mail/providers/UIProvider.java index fe336ae27..8c6ca86bf 100644 --- a/src/com/android/mail/providers/UIProvider.java +++ b/src/com/android/mail/providers/UIProvider.java @@ -20,8 +20,10 @@ package com.android.mail.providers; import android.content.ContentProvider; import android.content.ContentValues; import android.content.Context; +import android.database.Cursor; import android.net.Uri; import android.os.Bundle; +import android.os.Parcelable; import android.provider.BaseColumns; import android.provider.OpenableColumns; import android.text.TextUtils; @@ -1116,6 +1118,19 @@ public class UIProvider { public static final String COMMAND_RESPONSE_FAILED = "failed"; /** + * Incoming bundles may include this key with an Integer bitfield value. See below for bit + * values. + */ + public static final String COMMAND_KEY_OPTIONS = "options"; + + /** + * Clients must set this bit when the {@link Cursor#respond(Bundle)} call is being used to + * fetch a {@link Parcelable}. It serves as a hint that this call requires the cursor + * position to first safely be moved. + */ + public static final int OPTION_MOVE_POSITION = 0x01; + + /** * This bundle key has a boolean value: true to indicate that this cursor has been shown * to the user. * <p> |