Merge "Fix ANR/crash when you open & close a large EML"

This commit is contained in:
Makoto Onuki 2011-03-02 15:18:45 -08:00 committed by Android (Google) Code Review
commit daf48b5c2e

View File

@ -40,9 +40,6 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
*/
private Uri mFileEmailUri;
/** Lock object to protect {@link #mFileEmailUri} */
private final Object mLock = new Object();
/**
* # of instances of this class. When it gets 0, and the last one is not destroying for
* a config change, we delete all the EML files.
@ -71,36 +68,33 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Logging.LOG_TAG, "MessageFileViewFragment openMessage");
}
if (mFileEmailUri != null) {
// Unlike MessageViewFragment, this fragment doesn't support loading another message
// once it opens a message, even after clearContent().
throw new IllegalStateException();
}
if (fileEmailUri == null) {
throw new InvalidParameterException();
}
synchronized (mLock) {
mFileEmailUri = fileEmailUri;
}
loadMessageIfResumed();
}
@Override
public void clearContent() {
synchronized (mLock) {
super.clearContent();
mFileEmailUri = null;
}
}
@Override
protected boolean isMessageSpecified() {
synchronized (mLock) {
return mFileEmailUri != null;
}
}
/**
* NOTE See the comment on the super method. It's called on a worker thread.
*/
@Override
protected Message openMessageSync(Activity activity) {
synchronized (mLock) {
if (Email.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Logging.LOG_TAG, "MessageFileViewFragment openMessageSync");
}
@ -118,7 +112,6 @@ public class MessageFileViewFragment extends MessageViewFragmentBase {
}
return msg;
}
}
/**
* {@inheritDoc}