Bug 674725 - Part AF - Implement delete() on Android. r=cjones

This commit is contained in:
Mounir Lamouri
2011-12-22 23:15:28 +01:00
parent a8ab07298e
commit 54d6e87e8b
14 changed files with 159 additions and 8 deletions

View File

@@ -612,6 +612,49 @@ public class GeckoSmsManager
}
}
public static void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
class DeleteMessageRunnable implements Runnable {
private int mMessageId;
private int mRequestId;
private long mProcessId;
DeleteMessageRunnable(int aMessageId, int aRequestId, long aProcessId) {
mMessageId = aMessageId;
mRequestId = aRequestId;
mProcessId = aProcessId;
}
@Override
public void run() {
class TooManyResultsException extends Exception { }
try {
ContentResolver cr = GeckoApp.surfaceView.getContext().getContentResolver();
Uri message = ContentUris.withAppendedId(kSmsContentUri, mMessageId);
int count = cr.delete(message, null, null);
if (count > 1) {
throw new TooManyResultsException();
}
GeckoAppShell.notifySmsDeleted(count == 1, mRequestId, mProcessId);
} catch (TooManyResultsException e) {
// TODO: Notify failure
Log.e("GeckoSmsManager", "Delete more than one message? " + e);
} catch (Exception e) {
// TODO: Notify failure
Log.e("GeckoSmsManager", "Error while trying to delete a message: " + e);
}
}
}
if (!SmsIOThread.getInstance().execute(new DeleteMessageRunnable(aMessageId, aRequestId, aProcessId))) {
Log.e("GeckoSmsManager", "Failed to add GetMessageRunnable to the SmsIOThread");
// TODO: Notify failure
}
}
public static void shutdown() {
SmsIOThread.getInstance().interrupt();
}