Methods Summary |
---|
public static final synchronized com.google.android.mms.util.PduCache | getInstance()
if (sInstance == null) {
if (LOCAL_LOGV) {
Log.v(TAG, "Constructing new PduCache instance.");
}
sInstance = new PduCache();
}
return sInstance;
|
private android.net.Uri | normalizeKey(android.net.Uri uri)
int match = URI_MATCHER.match(uri);
Uri normalizedKey = null;
switch (match) {
case MMS_ALL_ID:
normalizedKey = uri;
break;
case MMS_INBOX_ID:
case MMS_SENT_ID:
case MMS_DRAFTS_ID:
case MMS_OUTBOX_ID:
String msgId = uri.getLastPathSegment();
normalizedKey = Uri.withAppendedPath(Mms.CONTENT_URI, msgId);
break;
default:
return null;
}
if (LOCAL_LOGV) {
Log.v(TAG, uri + " -> " + normalizedKey);
}
return normalizedKey;
|
public synchronized PduCacheEntry | purge(android.net.Uri uri)
int match = URI_MATCHER.match(uri);
switch (match) {
case MMS_ALL_ID:
return purgeSingleEntry(uri);
case MMS_INBOX_ID:
case MMS_SENT_ID:
case MMS_DRAFTS_ID:
case MMS_OUTBOX_ID:
String msgId = uri.getLastPathSegment();
return purgeSingleEntry(Uri.withAppendedPath(Mms.CONTENT_URI, msgId));
// Implicit batch of purge, return null.
case MMS_ALL:
case MMS_CONVERSATION:
purgeAll();
return null;
case MMS_INBOX:
case MMS_SENT:
case MMS_DRAFTS:
case MMS_OUTBOX:
purgeByMessageBox(MATCH_TO_MSGBOX_ID_MAP.get(match));
return null;
case MMS_CONVERSATION_ID:
purgeByThreadId(ContentUris.parseId(uri));
return null;
default:
return null;
}
|
public synchronized void | purgeAll()
super.purgeAll();
mMessageBoxes.clear();
mThreads.clear();
|
private void | purgeByMessageBox(java.lang.Integer msgBoxId)
if (LOCAL_LOGV) {
Log.v(TAG, "Purge cache in message box: " + msgBoxId);
}
if (msgBoxId != null) {
HashSet<Uri> msgBox = mMessageBoxes.remove(msgBoxId);
if (msgBox != null) {
for (Uri key : msgBox) {
PduCacheEntry entry = super.purge(key);
if (entry != null) {
removeFromThreads(key, entry);
}
}
}
}
|
private void | purgeByThreadId(long threadId)
if (LOCAL_LOGV) {
Log.v(TAG, "Purge cache in thread: " + threadId);
}
HashSet<Uri> thread = mThreads.remove(threadId);
if (thread != null) {
for (Uri key : thread) {
PduCacheEntry entry = super.purge(key);
if (entry != null) {
removeFromMessageBoxes(key, entry);
}
}
}
|
private PduCacheEntry | purgeSingleEntry(android.net.Uri key)
PduCacheEntry entry = super.purge(key);
if (entry != null) {
removeFromThreads(key, entry);
removeFromMessageBoxes(key, entry);
return entry;
}
return null;
|
public synchronized boolean | put(android.net.Uri uri, PduCacheEntry entry)
int msgBoxId = entry.getMessageBox();
HashSet<Uri> msgBox = mMessageBoxes.get(msgBoxId);
if (msgBox == null) {
msgBox = new HashSet<Uri>();
mMessageBoxes.put(msgBoxId, msgBox);
}
long threadId = entry.getThreadId();
HashSet<Uri> thread = mThreads.get(threadId);
if (thread == null) {
thread = new HashSet<Uri>();
mThreads.put(threadId, thread);
}
Uri finalKey = normalizeKey(uri);
boolean result = super.put(finalKey, entry);
if (result) {
msgBox.add(finalKey);
thread.add(finalKey);
}
return result;
|
private void | removeFromMessageBoxes(android.net.Uri key, PduCacheEntry entry)
HashSet<Uri> msgBox = mThreads.get(entry.getMessageBox());
if (msgBox != null) {
msgBox.remove(key);
}
|
private void | removeFromThreads(android.net.Uri key, PduCacheEntry entry)
HashSet<Uri> thread = mThreads.get(entry.getThreadId());
if (thread != null) {
thread.remove(key);
}
|