Bug 775997 - Part 2/2: Android implementation. r=dougt, a=blocking-basecamp

This commit is contained in:
Vicamo Yang 2012-11-06 13:32:07 -08:00
Родитель dff1cdd9cd
Коммит c5b44a751d
10 изменённых файлов: 300 добавлений и 420 удалений

Просмотреть файл

@ -91,17 +91,17 @@ public class GeckoAppShell
public static native void notifySmsReceived(String aSender, String aBody, int aMessageClass, long aTimestamp);
public static native int saveMessageInSentbox(String aReceiver, String aBody, long aTimestamp);
public static native void notifySmsSent(int aId, String aReceiver, String aBody, long aTimestamp, int aRequestId, long aProcessId);
public static native void notifySmsSent(int aId, String aReceiver, String aBody, long aTimestamp, int aRequestId);
public static native void notifySmsDelivery(int aId, int aDeliveryStatus, String aReceiver, String aBody, long aTimestamp);
public static native void notifySmsSendFailed(int aError, int aRequestId, long aProcessId);
public static native void notifyGetSms(int aId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId, long aProcessId);
public static native void notifyGetSmsFailed(int aError, int aRequestId, long aProcessId);
public static native void notifySmsDeleted(boolean aDeleted, int aRequestId, long aProcessId);
public static native void notifySmsDeleteFailed(int aError, int aRequestId, long aProcessId);
public static native void notifyNoMessageInList(int aRequestId, long aProcessId);
public static native void notifyListCreated(int aListId, int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId, long aProcessId);
public static native void notifyGotNextMessage(int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId, long aProcessId);
public static native void notifyReadingMessageListFailed(int aError, int aRequestId, long aProcessId);
public static native void notifySmsSendFailed(int aError, int aRequestId);
public static native void notifyGetSms(int aId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
public static native void notifyGetSmsFailed(int aError, int aRequestId);
public static native void notifySmsDeleted(boolean aDeleted, int aRequestId);
public static native void notifySmsDeleteFailed(int aError, int aRequestId);
public static native void notifyNoMessageInList(int aRequestId);
public static native void notifyListCreated(int aListId, int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
public static native void notifyGotNextMessage(int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
public static native void notifyReadingMessageListFailed(int aError, int aRequestId);
public static native void onSurfaceTextureFrameAvailable(Object surfaceTexture, int id);
// A looper thread, accessed by GeckoAppShell.getHandler
@ -1700,12 +1700,12 @@ public class GeckoAppShell
return SmsManager.getInstance().getNumberOfMessagesForText(aText);
}
public static void sendMessage(String aNumber, String aMessage, int aRequestId, long aProcessId) {
public static void sendMessage(String aNumber, String aMessage, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().send(aNumber, aMessage, aRequestId, aProcessId);
SmsManager.getInstance().send(aNumber, aMessage, aRequestId);
}
public static int saveSentMessage(String aRecipient, String aBody, long aDate) {
@ -1716,36 +1716,36 @@ public class GeckoAppShell
return SmsManager.getInstance().saveSentMessage(aRecipient, aBody, aDate);
}
public static void getMessage(int aMessageId, int aRequestId, long aProcessId) {
public static void getMessage(int aMessageId, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().getMessage(aMessageId, aRequestId, aProcessId);
SmsManager.getInstance().getMessage(aMessageId, aRequestId);
}
public static void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
public static void deleteMessage(int aMessageId, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().deleteMessage(aMessageId, aRequestId, aProcessId);
SmsManager.getInstance().deleteMessage(aMessageId, aRequestId);
}
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId, aProcessId);
SmsManager.getInstance().createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId);
}
public static void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
public static void getNextMessageInList(int aListId, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().getNextMessageInList(aListId, aRequestId, aProcessId);
SmsManager.getInstance().getNextMessageInList(aListId, aRequestId);
}
public static void clearMessageList(int aListId) {

Просмотреть файл

@ -402,7 +402,7 @@ public class GeckoSmsManager
if (bundle == null || !bundle.containsKey("envelopeId") ||
!bundle.containsKey("number") || !bundle.containsKey("message") ||
!bundle.containsKey("requestId") || !bundle.containsKey("processId")) {
!bundle.containsKey("requestId")) {
Log.e("GeckoSmsManager", "Got an invalid ACTION_SMS_SENT/ACTION_SMS_DELIVERED!");
return;
}
@ -447,8 +447,7 @@ public class GeckoSmsManager
if (envelope.isFailing(part)) {
if (part == Envelope.SubParts.SENT_PART) {
GeckoAppShell.notifySmsSendFailed(envelope.getError(),
bundle.getInt("requestId"),
bundle.getLong("processId"));
bundle.getInt("requestId"));
Log.i("GeckoSmsManager", "SMS sending failed!");
} else {
GeckoAppShell.notifySmsDelivery(envelope.getMessageId(),
@ -467,8 +466,7 @@ public class GeckoSmsManager
int id = GeckoAppShell.saveMessageInSentbox(number, message, timestamp);
GeckoAppShell.notifySmsSent(id, number, message, timestamp,
bundle.getInt("requestId"),
bundle.getLong("processId"));
bundle.getInt("requestId"));
envelope.setMessageId(id);
envelope.setMessageTimestamp(timestamp);
@ -498,7 +496,7 @@ public class GeckoSmsManager
return SmsManager.getDefault().divideMessage(aText).size();
}
public void send(String aNumber, String aMessage, int aRequestId, long aProcessId) {
public void send(String aNumber, String aMessage, int aRequestId) {
int envelopeId = Postman.kUnknownEnvelopeId;
try {
@ -511,7 +509,6 @@ public class GeckoSmsManager
bundle.putString("number", aNumber);
bundle.putString("message", aMessage);
bundle.putInt("requestId", aRequestId);
bundle.putLong("processId", aProcessId);
if (aMessage.length() <= kMaxMessageSize) {
envelopeId = Postman.getInstance().createEnvelope(1);
@ -580,7 +577,7 @@ public class GeckoSmsManager
Postman.getInstance().destroyEnvelope(envelopeId);
}
GeckoAppShell.notifySmsSendFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifySmsSendFailed(kUnknownError, aRequestId);
}
}
@ -644,16 +641,14 @@ public class GeckoSmsManager
}
}
public void getMessage(int aMessageId, int aRequestId, long aProcessId) {
public void getMessage(int aMessageId, int aRequestId) {
class GetMessageRunnable implements Runnable {
private int mMessageId;
private int mRequestId;
private long mProcessId;
GetMessageRunnable(int aMessageId, int aRequestId, long aProcessId) {
GetMessageRunnable(int aMessageId, int aRequestId) {
mMessageId = aMessageId;
mRequestId = aRequestId;
mProcessId = aProcessId;
}
@Override
@ -704,23 +699,23 @@ public class GeckoSmsManager
receiver, sender,
cursor.getString(cursor.getColumnIndex("body")),
cursor.getLong(cursor.getColumnIndex("date")),
mRequestId, mProcessId);
mRequestId);
} catch (NotFoundException e) {
Log.i("GeckoSmsManager", "Message id " + mMessageId + " not found");
GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId);
} catch (UnmatchingIdException e) {
Log.e("GeckoSmsManager", "Requested message id (" + mMessageId +
") is different from the one we got.");
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId);
} catch (TooManyResultsException e) {
Log.e("GeckoSmsManager", "Get too many results for id " + mMessageId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId);
} catch (InvalidTypeException e) {
Log.i("GeckoSmsManager", "Message has an invalid type, we ignore it.");
GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId);
} catch (Exception e) {
Log.e("GeckoSmsManager", "Error while trying to get message: " + e);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId);
} finally {
if (cursor != null) {
cursor.close();
@ -729,22 +724,20 @@ public class GeckoSmsManager
}
}
if (!SmsIOThread.getInstance().execute(new GetMessageRunnable(aMessageId, aRequestId, aProcessId))) {
if (!SmsIOThread.getInstance().execute(new GetMessageRunnable(aMessageId, aRequestId))) {
Log.e("GeckoSmsManager", "Failed to add GetMessageRunnable to the SmsIOThread");
GeckoAppShell.notifyGetSmsFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, aRequestId);
}
}
public void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
public void deleteMessage(int aMessageId, int aRequestId) {
class DeleteMessageRunnable implements Runnable {
private int mMessageId;
private int mRequestId;
private long mProcessId;
DeleteMessageRunnable(int aMessageId, int aRequestId, long aProcessId) {
DeleteMessageRunnable(int aMessageId, int aRequestId) {
mMessageId = aMessageId;
mRequestId = aRequestId;
mProcessId = aProcessId;
}
@Override
@ -761,24 +754,24 @@ public class GeckoSmsManager
throw new TooManyResultsException();
}
GeckoAppShell.notifySmsDeleted(count == 1, mRequestId, mProcessId);
GeckoAppShell.notifySmsDeleted(count == 1, mRequestId);
} catch (TooManyResultsException e) {
Log.e("GeckoSmsManager", "Delete more than one message? " + e);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId);
} catch (Exception e) {
Log.e("GeckoSmsManager", "Error while trying to delete a message: " + e);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId);
}
}
}
if (!SmsIOThread.getInstance().execute(new DeleteMessageRunnable(aMessageId, aRequestId, aProcessId))) {
if (!SmsIOThread.getInstance().execute(new DeleteMessageRunnable(aMessageId, aRequestId))) {
Log.e("GeckoSmsManager", "Failed to add GetMessageRunnable to the SmsIOThread");
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, aRequestId);
}
}
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId) {
class CreateMessageListRunnable implements Runnable {
private long mStartDate;
private long mEndDate;
@ -787,9 +780,8 @@ public class GeckoSmsManager
private int mDeliveryState;
private boolean mReverse;
private int mRequestId;
private long mProcessId;
CreateMessageListRunnable(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
CreateMessageListRunnable(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId) {
mStartDate = aStartDate;
mEndDate = aEndDate;
mNumbers = aNumbers;
@ -797,7 +789,6 @@ public class GeckoSmsManager
mDeliveryState = aDeliveryState;
mReverse = aReverse;
mRequestId = aRequestId;
mProcessId = aProcessId;
}
@Override
@ -852,7 +843,7 @@ public class GeckoSmsManager
mReverse ? "date DESC" : "date ASC");
if (cursor.getCount() == 0) {
GeckoAppShell.notifyNoMessageInList(mRequestId, mProcessId);
GeckoAppShell.notifyNoMessageInList(mRequestId);
return;
}
@ -881,13 +872,13 @@ public class GeckoSmsManager
receiver, sender,
cursor.getString(cursor.getColumnIndex("body")),
cursor.getLong(cursor.getColumnIndex("date")),
mRequestId, mProcessId);
mRequestId);
} catch (UnexpectedDeliveryStateException e) {
Log.e("GeckoSmsManager", "Unexcepted delivery state type: " + e);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
} catch (Exception e) {
Log.e("GeckoSmsManager", "Error while trying to create a message list cursor: " + e);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
} finally {
// Close the cursor if MessagesListManager isn't taking care of it.
// We could also just check if it is in the MessagesListManager list but
@ -899,22 +890,20 @@ public class GeckoSmsManager
}
}
if (!SmsIOThread.getInstance().execute(new CreateMessageListRunnable(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId, aProcessId))) {
if (!SmsIOThread.getInstance().execute(new CreateMessageListRunnable(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId))) {
Log.e("GeckoSmsManager", "Failed to add CreateMessageListRunnable to the SmsIOThread");
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId);
}
}
public void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
public void getNextMessageInList(int aListId, int aRequestId) {
class GetNextMessageInListRunnable implements Runnable {
private int mListId;
private int mRequestId;
private long mProcessId;
GetNextMessageInListRunnable(int aListId, int aRequestId, long aProcessId) {
GetNextMessageInListRunnable(int aListId, int aRequestId) {
mListId = aListId;
mRequestId = aRequestId;
mProcessId = aProcessId;
}
@Override
@ -926,7 +915,7 @@ public class GeckoSmsManager
if (!cursor.moveToNext()) {
MessagesListManager.getInstance().remove(mListId);
GeckoAppShell.notifyNoMessageInList(mRequestId, mProcessId);
GeckoAppShell.notifyNoMessageInList(mRequestId);
return;
}
@ -951,20 +940,20 @@ public class GeckoSmsManager
receiver, sender,
cursor.getString(cursor.getColumnIndex("body")),
cursor.getLong(cursor.getColumnIndex("date")),
mRequestId, mProcessId);
mRequestId);
} catch (UnexpectedDeliveryStateException e) {
Log.e("GeckoSmsManager", "Unexcepted delivery state type: " + e);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
} catch (Exception e) {
Log.e("GeckoSmsManager", "Error while trying to get the next message of a list: " + e);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
}
}
}
if (!SmsIOThread.getInstance().execute(new GetNextMessageInListRunnable(aListId, aRequestId, aProcessId))) {
if (!SmsIOThread.getInstance().execute(new GetNextMessageInListRunnable(aListId, aRequestId))) {
Log.e("GeckoSmsManager", "Failed to add GetNextMessageInListRunnable to the SmsIOThread");
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId);
}
}

Просмотреть файл

@ -30,11 +30,11 @@ interface ISmsManager
public void shutdown();
public int getNumberOfMessagesForText(String aText);
public void send(String aNumber, String aMessage, int aRequestId, long aProcessId);
public void send(String aNumber, String aMessage, int aRequestId);
public int saveSentMessage(String aRecipient, String aBody, long aDate);
public void getMessage(int aMessageId, int aRequestId, long aProcessId);
public void deleteMessage(int aMessageId, int aRequestId, long aProcessId);
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId);
public void getNextMessageInList(int aListId, int aRequestId, long aProcessId);
public void getMessage(int aMessageId, int aRequestId);
public void deleteMessage(int aMessageId, int aRequestId);
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId);
public void getNextMessageInList(int aListId, int aRequestId);
public void clearMessageList(int aListId);
}

Просмотреть файл

@ -234,17 +234,17 @@ public class GeckoAppShell
public static native void notifySmsReceived(String aSender, String aBody, int aMessageClass, long aTimestamp);
public static native int saveMessageInSentbox(String aReceiver, String aBody, long aTimestamp);
public static native void notifySmsSent(int aId, String aReceiver, String aBody, long aTimestamp, int aRequestId, long aProcessId);
public static native void notifySmsSent(int aId, String aReceiver, String aBody, long aTimestamp, int aRequestId);
public static native void notifySmsDelivery(int aId, int aDeliveryStatus, String aReceiver, String aBody, long aTimestamp);
public static native void notifySmsSendFailed(int aError, int aRequestId, long aProcessId);
public static native void notifyGetSms(int aId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId, long aProcessId);
public static native void notifyGetSmsFailed(int aError, int aRequestId, long aProcessId);
public static native void notifySmsDeleted(boolean aDeleted, int aRequestId, long aProcessId);
public static native void notifySmsDeleteFailed(int aError, int aRequestId, long aProcessId);
public static native void notifyNoMessageInList(int aRequestId, long aProcessId);
public static native void notifyListCreated(int aListId, int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId, long aProcessId);
public static native void notifyGotNextMessage(int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId, long aProcessId);
public static native void notifyReadingMessageListFailed(int aError, int aRequestId, long aProcessId);
public static native void notifySmsSendFailed(int aError, int aRequestId);
public static native void notifyGetSms(int aId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
public static native void notifyGetSmsFailed(int aError, int aRequestId);
public static native void notifySmsDeleted(boolean aDeleted, int aRequestId);
public static native void notifySmsDeleteFailed(int aError, int aRequestId);
public static native void notifyNoMessageInList(int aRequestId);
public static native void notifyListCreated(int aListId, int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
public static native void notifyGotNextMessage(int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
public static native void notifyReadingMessageListFailed(int aError, int aRequestId);
public static native void scheduleComposite();
public static native void schedulePauseComposition();
@ -1993,12 +1993,12 @@ public class GeckoAppShell
return SmsManager.getInstance().getNumberOfMessagesForText(aText);
}
public static void sendMessage(String aNumber, String aMessage, int aRequestId, long aProcessId) {
public static void sendMessage(String aNumber, String aMessage, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().send(aNumber, aMessage, aRequestId, aProcessId);
SmsManager.getInstance().send(aNumber, aMessage, aRequestId);
}
public static int saveSentMessage(String aRecipient, String aBody, long aDate) {
@ -2009,36 +2009,36 @@ public class GeckoAppShell
return SmsManager.getInstance().saveSentMessage(aRecipient, aBody, aDate);
}
public static void getMessage(int aMessageId, int aRequestId, long aProcessId) {
public static void getMessage(int aMessageId, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().getMessage(aMessageId, aRequestId, aProcessId);
SmsManager.getInstance().getMessage(aMessageId, aRequestId);
}
public static void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
public static void deleteMessage(int aMessageId, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().deleteMessage(aMessageId, aRequestId, aProcessId);
SmsManager.getInstance().deleteMessage(aMessageId, aRequestId);
}
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId, aProcessId);
SmsManager.getInstance().createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId);
}
public static void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
public static void getNextMessageInList(int aListId, int aRequestId) {
if (SmsManager.getInstance() == null) {
return;
}
SmsManager.getInstance().getNextMessageInList(aListId, aRequestId, aProcessId);
SmsManager.getInstance().getNextMessageInList(aListId, aRequestId);
}
public static void clearMessageList(int aListId) {

Просмотреть файл

@ -395,7 +395,7 @@ public class GeckoSmsManager
if (bundle == null || !bundle.containsKey("envelopeId") ||
!bundle.containsKey("number") || !bundle.containsKey("message") ||
!bundle.containsKey("requestId") || !bundle.containsKey("processId")) {
!bundle.containsKey("requestId")) {
Log.e("GeckoSmsManager", "Got an invalid ACTION_SMS_SENT/ACTION_SMS_DELIVERED!");
return;
}
@ -440,8 +440,7 @@ public class GeckoSmsManager
if (envelope.isFailing(part)) {
if (part == Envelope.SubParts.SENT_PART) {
GeckoAppShell.notifySmsSendFailed(envelope.getError(),
bundle.getInt("requestId"),
bundle.getLong("processId"));
bundle.getInt("requestId"));
Log.i("GeckoSmsManager", "SMS sending failed!");
} else {
GeckoAppShell.notifySmsDelivery(envelope.getMessageId(),
@ -460,8 +459,7 @@ public class GeckoSmsManager
int id = GeckoAppShell.saveMessageInSentbox(number, message, timestamp);
GeckoAppShell.notifySmsSent(id, number, message, timestamp,
bundle.getInt("requestId"),
bundle.getLong("processId"));
bundle.getInt("requestId"));
envelope.setMessageId(id);
envelope.setMessageTimestamp(timestamp);
@ -491,7 +489,7 @@ public class GeckoSmsManager
return SmsManager.getDefault().divideMessage(aText).size();
}
public void send(String aNumber, String aMessage, int aRequestId, long aProcessId) {
public void send(String aNumber, String aMessage, int aRequestId) {
int envelopeId = Postman.kUnknownEnvelopeId;
try {
@ -504,7 +502,6 @@ public class GeckoSmsManager
bundle.putString("number", aNumber);
bundle.putString("message", aMessage);
bundle.putInt("requestId", aRequestId);
bundle.putLong("processId", aProcessId);
if (aMessage.length() <= kMaxMessageSize) {
envelopeId = Postman.getInstance().createEnvelope(1);
@ -573,7 +570,7 @@ public class GeckoSmsManager
Postman.getInstance().destroyEnvelope(envelopeId);
}
GeckoAppShell.notifySmsSendFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifySmsSendFailed(kUnknownError, aRequestId);
}
}
@ -592,8 +589,6 @@ public class GeckoSmsManager
private int getGeckoMessageClass(MessageClass aMessageClass) {
switch (aMessageClass) {
case UNKNOWN:
return kMessageClassNormal;
case CLASS_0:
return kMessageClassClass0;
case CLASS_1:
@ -602,6 +597,8 @@ public class GeckoSmsManager
return kMessageClassClass2;
case CLASS_3:
return kMessageClassClass3;
default:
return kMessageClassNormal;
}
}
@ -637,16 +634,14 @@ public class GeckoSmsManager
}
}
public void getMessage(int aMessageId, int aRequestId, long aProcessId) {
public void getMessage(int aMessageId, int aRequestId) {
class GetMessageRunnable implements Runnable {
private int mMessageId;
private int mRequestId;
private long mProcessId;
GetMessageRunnable(int aMessageId, int aRequestId, long aProcessId) {
GetMessageRunnable(int aMessageId, int aRequestId) {
mMessageId = aMessageId;
mRequestId = aRequestId;
mProcessId = aProcessId;
}
@Override
@ -697,23 +692,23 @@ public class GeckoSmsManager
receiver, sender,
cursor.getString(cursor.getColumnIndex("body")),
cursor.getLong(cursor.getColumnIndex("date")),
mRequestId, mProcessId);
mRequestId);
} catch (NotFoundException e) {
Log.i("GeckoSmsManager", "Message id " + mMessageId + " not found");
GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId);
} catch (UnmatchingIdException e) {
Log.e("GeckoSmsManager", "Requested message id (" + mMessageId +
") is different from the one we got.");
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId);
} catch (TooManyResultsException e) {
Log.e("GeckoSmsManager", "Get too many results for id " + mMessageId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId);
} catch (InvalidTypeException e) {
Log.i("GeckoSmsManager", "Message has an invalid type, we ignore it.");
GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId);
} catch (Exception e) {
Log.e("GeckoSmsManager", "Error while trying to get message", e);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId);
} finally {
if (cursor != null) {
cursor.close();
@ -722,22 +717,20 @@ public class GeckoSmsManager
}
}
if (!SmsIOThread.getInstance().execute(new GetMessageRunnable(aMessageId, aRequestId, aProcessId))) {
if (!SmsIOThread.getInstance().execute(new GetMessageRunnable(aMessageId, aRequestId))) {
Log.e("GeckoSmsManager", "Failed to add GetMessageRunnable to the SmsIOThread");
GeckoAppShell.notifyGetSmsFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifyGetSmsFailed(kUnknownError, aRequestId);
}
}
public void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
public void deleteMessage(int aMessageId, int aRequestId) {
class DeleteMessageRunnable implements Runnable {
private int mMessageId;
private int mRequestId;
private long mProcessId;
DeleteMessageRunnable(int aMessageId, int aRequestId, long aProcessId) {
DeleteMessageRunnable(int aMessageId, int aRequestId) {
mMessageId = aMessageId;
mRequestId = aRequestId;
mProcessId = aProcessId;
}
@Override
@ -754,24 +747,24 @@ public class GeckoSmsManager
throw new TooManyResultsException();
}
GeckoAppShell.notifySmsDeleted(count == 1, mRequestId, mProcessId);
GeckoAppShell.notifySmsDeleted(count == 1, mRequestId);
} catch (TooManyResultsException e) {
Log.e("GeckoSmsManager", "Delete more than one message?", e);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId);
} catch (Exception e) {
Log.e("GeckoSmsManager", "Error while trying to delete a message", e);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId);
}
}
}
if (!SmsIOThread.getInstance().execute(new DeleteMessageRunnable(aMessageId, aRequestId, aProcessId))) {
if (!SmsIOThread.getInstance().execute(new DeleteMessageRunnable(aMessageId, aRequestId,))) {
Log.e("GeckoSmsManager", "Failed to add GetMessageRunnable to the SmsIOThread");
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifySmsDeleteFailed(kUnknownError, aRequestId);
}
}
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId) {
class CreateMessageListRunnable implements Runnable {
private long mStartDate;
private long mEndDate;
@ -780,9 +773,8 @@ public class GeckoSmsManager
private int mDeliveryState;
private boolean mReverse;
private int mRequestId;
private long mProcessId;
CreateMessageListRunnable(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
CreateMessageListRunnable(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId) {
mStartDate = aStartDate;
mEndDate = aEndDate;
mNumbers = aNumbers;
@ -790,7 +782,6 @@ public class GeckoSmsManager
mDeliveryState = aDeliveryState;
mReverse = aReverse;
mRequestId = aRequestId;
mProcessId = aProcessId;
}
@Override
@ -845,7 +836,7 @@ public class GeckoSmsManager
mReverse ? "date DESC" : "date ASC");
if (cursor.getCount() == 0) {
GeckoAppShell.notifyNoMessageInList(mRequestId, mProcessId);
GeckoAppShell.notifyNoMessageInList(mRequestId);
return;
}
@ -874,13 +865,13 @@ public class GeckoSmsManager
receiver, sender,
cursor.getString(cursor.getColumnIndex("body")),
cursor.getLong(cursor.getColumnIndex("date")),
mRequestId, mProcessId);
mRequestId);
} catch (UnexpectedDeliveryStateException e) {
Log.e("GeckoSmsManager", "Unexcepted delivery state type", e);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
} catch (Exception e) {
Log.e("GeckoSmsManager", "Error while trying to create a message list cursor", e);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
} finally {
// Close the cursor if MessagesListManager isn't taking care of it.
// We could also just check if it is in the MessagesListManager list but
@ -892,22 +883,20 @@ public class GeckoSmsManager
}
}
if (!SmsIOThread.getInstance().execute(new CreateMessageListRunnable(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId, aProcessId))) {
if (!SmsIOThread.getInstance().execute(new CreateMessageListRunnable(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId))) {
Log.e("GeckoSmsManager", "Failed to add CreateMessageListRunnable to the SmsIOThread");
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId);
}
}
public void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
public void getNextMessageInList(int aListId, int aRequestId) {
class GetNextMessageInListRunnable implements Runnable {
private int mListId;
private int mRequestId;
private long mProcessId;
GetNextMessageInListRunnable(int aListId, int aRequestId, long aProcessId) {
GetNextMessageInListRunnable(int aListId, int aRequestId) {
mListId = aListId;
mRequestId = aRequestId;
mProcessId = aProcessId;
}
@Override
@ -919,7 +908,7 @@ public class GeckoSmsManager
if (!cursor.moveToNext()) {
MessagesListManager.getInstance().remove(mListId);
GeckoAppShell.notifyNoMessageInList(mRequestId, mProcessId);
GeckoAppShell.notifyNoMessageInList(mRequestId);
return;
}
@ -944,20 +933,20 @@ public class GeckoSmsManager
receiver, sender,
cursor.getString(cursor.getColumnIndex("body")),
cursor.getLong(cursor.getColumnIndex("date")),
mRequestId, mProcessId);
mRequestId);
} catch (UnexpectedDeliveryStateException e) {
Log.e("GeckoSmsManager", "Unexcepted delivery state type", e);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
} catch (Exception e) {
Log.e("GeckoSmsManager", "Error while trying to get the next message of a list", e);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId, mProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
}
}
}
if (!SmsIOThread.getInstance().execute(new GetNextMessageInListRunnable(aListId, aRequestId, aProcessId))) {
if (!SmsIOThread.getInstance().execute(new GetNextMessageInListRunnable(aListId, aRequestId))) {
Log.e("GeckoSmsManager", "Failed to add GetNextMessageInListRunnable to the SmsIOThread");
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId, aProcessId);
GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId);
}
}

Просмотреть файл

@ -30,11 +30,11 @@ interface ISmsManager
public void shutdown();
public int getNumberOfMessagesForText(String aText);
public void send(String aNumber, String aMessage, int aRequestId, long aProcessId);
public void send(String aNumber, String aMessage, int aRequestId);
public int saveSentMessage(String aRecipient, String aBody, long aDate);
public void getMessage(int aMessageId, int aRequestId, long aProcessId);
public void deleteMessage(int aMessageId, int aRequestId, long aProcessId);
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId);
public void getNextMessageInList(int aListId, int aRequestId, long aProcessId);
public void getMessage(int aMessageId, int aRequestId);
public void deleteMessage(int aMessageId, int aRequestId);
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId);
public void getNextMessageInList(int aListId, int aRequestId);
public void clearMessageList(int aListId);
}

Просмотреть файл

@ -325,17 +325,17 @@ SHELL_WRAPPER0(scheduleComposite)
SHELL_WRAPPER0(schedulePauseComposition)
SHELL_WRAPPER2(scheduleResumeComposition, jint, jint)
SHELL_WRAPPER3_WITH_RETURN(saveMessageInSentbox, jint, jstring, jstring, jlong)
SHELL_WRAPPER6(notifySmsSent, jint, jstring, jstring, jlong, jint, jlong)
SHELL_WRAPPER5(notifySmsSent, jint, jstring, jstring, jlong, jint)
SHELL_WRAPPER5(notifySmsDelivery, jint, jint, jstring, jstring, jlong)
SHELL_WRAPPER3(notifySmsSendFailed, jint, jint, jlong)
SHELL_WRAPPER8(notifyGetSms, jint, jint, jstring, jstring, jstring, jlong, jint, jlong)
SHELL_WRAPPER3(notifyGetSmsFailed, jint, jint, jlong)
SHELL_WRAPPER3(notifySmsDeleted, jboolean, jint, jlong)
SHELL_WRAPPER3(notifySmsDeleteFailed, jint, jint, jlong)
SHELL_WRAPPER2(notifyNoMessageInList, jint, jlong)
SHELL_WRAPPER9(notifyListCreated, jint, jint, jint, jstring, jstring, jstring, jlong, jint, jlong)
SHELL_WRAPPER8(notifyGotNextMessage, jint, jint, jstring, jstring, jstring, jlong, jint, jlong)
SHELL_WRAPPER3(notifyReadingMessageListFailed, jint, jint, jlong)
SHELL_WRAPPER2(notifySmsSendFailed, jint, jint)
SHELL_WRAPPER7(notifyGetSms, jint, jint, jstring, jstring, jstring, jlong, jint)
SHELL_WRAPPER2(notifyGetSmsFailed, jint, jint)
SHELL_WRAPPER2(notifySmsDeleted, jboolean, jint)
SHELL_WRAPPER2(notifySmsDeleteFailed, jint, jint)
SHELL_WRAPPER1(notifyNoMessageInList, jint)
SHELL_WRAPPER8(notifyListCreated, jint, jint, jint, jstring, jstring, jstring, jlong, jint)
SHELL_WRAPPER7(notifyGotNextMessage, jint, jint, jstring, jstring, jstring, jlong, jint)
SHELL_WRAPPER2(notifyReadingMessageListFailed, jint, jint)
SHELL_WRAPPER2(notifyFilePickerResult, jstring, jlong)
SHELL_WRAPPER1_WITH_RETURN(getSurfaceBits, jobject, jobject)
SHELL_WRAPPER1(onFullScreenPluginHidden, jobject)

Просмотреть файл

@ -32,6 +32,8 @@
#include "nsIDOMWindowUtils.h"
#include "nsIDOMClientRect.h"
#include "StrongPointer.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/StaticPtr.h"
#ifdef DEBUG
#define ALOG_BRIDGE(args...) ALOG(args)
@ -59,6 +61,8 @@ class AndroidRefable {
// This isn't in AndroidBridge.h because including StrongPointer.h there is gross
static android::sp<AndroidRefable> (*android_SurfaceTexture_getNativeWindow)(JNIEnv* env, jobject surfaceTexture) = nullptr;
static StaticAutoPtr<nsTArray<nsCOMPtr<nsISmsRequest> > > sSmsRequest;
void
AndroidBridge::ConstructBridge(JNIEnv *jEnv,
jclass jGeckoAppShellClass)
@ -78,6 +82,9 @@ AndroidBridge::ConstructBridge(JNIEnv *jEnv,
delete bridge;
}
sBridge = bridge;
sSmsRequest = new nsTArray<nsCOMPtr<nsISmsRequest> >();
ClearOnShutdown(&sSmsRequest);
}
bool
@ -156,12 +163,12 @@ AndroidBridge::Init(JNIEnv *jEnv,
jMarkUriVisited = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "markUriVisited", "(Ljava/lang/String;)V");
jNumberOfMessages = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getNumberOfMessagesForText", "(Ljava/lang/String;)I");
jSendMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "sendMessage", "(Ljava/lang/String;Ljava/lang/String;IJ)V");
jSendMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "sendMessage", "(Ljava/lang/String;Ljava/lang/String;I)V");
jSaveSentMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "saveSentMessage", "(Ljava/lang/String;Ljava/lang/String;J)I");
jGetMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getMessage", "(IIJ)V");
jDeleteMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "deleteMessage", "(IIJ)V");
jCreateMessageList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "createMessageList", "(JJ[Ljava/lang/String;IIZIJ)V");
jGetNextMessageinList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getNextMessageInList", "(IIJ)V");
jGetMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getMessage", "(II)V");
jDeleteMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "deleteMessage", "(II)V");
jCreateMessageList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "createMessageList", "(JJ[Ljava/lang/String;IIZI)V");
jGetNextMessageinList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getNextMessageInList", "(II)V");
jClearMessageList = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "clearMessageList", "(I)V");
jGetCurrentNetworkInformation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getCurrentNetworkInformation", "()[D");
@ -1714,7 +1721,7 @@ AndroidBridge::GetNumberOfMessagesForText(const nsAString& aText)
}
void
AndroidBridge::SendMessage(const nsAString& aNumber, const nsAString& aMessage, int32_t aRequestId, uint64_t aProcessId)
AndroidBridge::SendMessage(const nsAString& aNumber, const nsAString& aMessage, nsISmsRequest* aRequest)
{
ALOG_BRIDGE("AndroidBridge::SendMessage");
@ -1722,11 +1729,14 @@ AndroidBridge::SendMessage(const nsAString& aNumber, const nsAString& aMessage,
if (!env)
return;
int32_t requestId = QueueSmsRequest(aRequest);
NS_ENSURE_TRUE_VOID(requestId >= 0);
AutoLocalJNIFrame jniFrame(env);
jstring jNumber = NewJavaString(&jniFrame, PromiseFlatString(aNumber).get(), aNumber.Length());
jstring jMessage = NewJavaString(&jniFrame, PromiseFlatString(aMessage).get(), aMessage.Length());
env->CallStaticVoidMethod(mGeckoAppShellClass, jSendMessage, jNumber, jMessage, aRequestId, aProcessId);
env->CallStaticVoidMethod(mGeckoAppShellClass, jSendMessage, jNumber, jMessage, requestId);
}
int32_t
@ -1750,7 +1760,7 @@ AndroidBridge::SaveSentMessage(const nsAString& aRecipient,
}
void
AndroidBridge::GetMessage(int32_t aMessageId, int32_t aRequestId, uint64_t aProcessId)
AndroidBridge::GetMessage(int32_t aMessageId, nsISmsRequest* aRequest)
{
ALOG_BRIDGE("AndroidBridge::GetMessage");
@ -1758,12 +1768,15 @@ AndroidBridge::GetMessage(int32_t aMessageId, int32_t aRequestId, uint64_t aProc
if (!env)
return;
int32_t requestId = QueueSmsRequest(aRequest);
NS_ENSURE_TRUE_VOID(requestId >= 0);
AutoLocalJNIFrame jniFrame(env, 0);
env->CallStaticVoidMethod(mGeckoAppShellClass, jGetMessage, aMessageId, aRequestId, aProcessId);
env->CallStaticVoidMethod(mGeckoAppShellClass, jGetMessage, aMessageId, requestId);
}
void
AndroidBridge::DeleteMessage(int32_t aMessageId, int32_t aRequestId, uint64_t aProcessId)
AndroidBridge::DeleteMessage(int32_t aMessageId, nsISmsRequest* aRequest)
{
ALOG_BRIDGE("AndroidBridge::DeleteMessage");
@ -1771,13 +1784,16 @@ AndroidBridge::DeleteMessage(int32_t aMessageId, int32_t aRequestId, uint64_t aP
if (!env)
return;
int32_t requestId = QueueSmsRequest(aRequest);
NS_ENSURE_TRUE_VOID(requestId >= 0);
AutoLocalJNIFrame jniFrame(env, 0);
env->CallStaticVoidMethod(mGeckoAppShellClass, jDeleteMessage, aMessageId, aRequestId, aProcessId);
env->CallStaticVoidMethod(mGeckoAppShellClass, jDeleteMessage, aMessageId, requestId);
}
void
AndroidBridge::CreateMessageList(const dom::sms::SmsFilterData& aFilter, bool aReverse,
int32_t aRequestId, uint64_t aProcessId)
nsISmsRequest* aRequest)
{
ALOG_BRIDGE("AndroidBridge::CreateMessageList");
@ -1785,6 +1801,9 @@ AndroidBridge::CreateMessageList(const dom::sms::SmsFilterData& aFilter, bool aR
if (!env)
return;
int32_t requestId = QueueSmsRequest(aRequest);
NS_ENSURE_TRUE_VOID(requestId >= 0);
AutoLocalJNIFrame jniFrame(env);
jobjectArray numbers =
@ -1800,12 +1819,11 @@ AndroidBridge::CreateMessageList(const dom::sms::SmsFilterData& aFilter, bool aR
env->CallStaticVoidMethod(mGeckoAppShellClass, jCreateMessageList,
aFilter.startDate(), aFilter.endDate(),
numbers, aFilter.numbers().Length(),
aFilter.delivery(), aReverse, aRequestId,
aProcessId);
aFilter.delivery(), aReverse, requestId);
}
void
AndroidBridge::GetNextMessageInList(int32_t aListId, int32_t aRequestId, uint64_t aProcessId)
AndroidBridge::GetNextMessageInList(int32_t aListId, nsISmsRequest* aRequest)
{
ALOG_BRIDGE("AndroidBridge::GetNextMessageInList");
@ -1813,8 +1831,11 @@ AndroidBridge::GetNextMessageInList(int32_t aListId, int32_t aRequestId, uint64_
if (!env)
return;
int32_t requestId = QueueSmsRequest(aRequest);
NS_ENSURE_TRUE_VOID(requestId >= 0);
AutoLocalJNIFrame jniFrame(env, 0);
env->CallStaticVoidMethod(mGeckoAppShellClass, jGetNextMessageinList, aListId, aRequestId, aProcessId);
env->CallStaticVoidMethod(mGeckoAppShellClass, jGetNextMessageinList, aListId, requestId);
}
void
@ -1830,6 +1851,41 @@ AndroidBridge::ClearMessageList(int32_t aListId)
env->CallStaticVoidMethod(mGeckoAppShellClass, jClearMessageList, aListId);
}
int32_t
AndroidBridge::QueueSmsRequest(nsISmsRequest* aRequest)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!sSmsRequest) {
// Probably shutting down.
return -1;
}
uint32_t length = sSmsRequest->Length();
for (int32_t i = 0; i < length; i++) {
if (!(*sSmsRequest)[i]) {
(*sSmsRequest)[i] = aRequest;
return i;
}
}
sSmsRequest->AppendElement(aRequest);
return length;
}
already_AddRefed<nsISmsRequest>
AndroidBridge::DequeueSmsRequest(int32_t aRequestId)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!sSmsRequest || (aRequestId >= sSmsRequest->Length())) {
return nullptr;
}
return (*sSmsRequest)[aRequestId].forget();
}
void
AndroidBridge::GetCurrentNetworkInformation(hal::NetworkInformation* aNetworkInfo)
{

Просмотреть файл

@ -26,6 +26,7 @@
#include "gfxRect.h"
#include "nsIAndroidBridge.h"
#include "nsISmsRequest.h"
// Some debug #defines
// #define DEBUG_ANDROID_EVENTS
@ -319,13 +320,14 @@ public:
void GetCurrentBatteryInformation(hal::BatteryInformation* aBatteryInfo);
uint16_t GetNumberOfMessagesForText(const nsAString& aText);
void SendMessage(const nsAString& aNumber, const nsAString& aText, int32_t aRequestId, uint64_t aProcessId);
void SendMessage(const nsAString& aNumber, const nsAString& aText, nsISmsRequest* aRequest);
int32_t SaveSentMessage(const nsAString& aRecipient, const nsAString& aBody, uint64_t aDate);
void GetMessage(int32_t aMessageId, int32_t aRequestId, uint64_t aProcessId);
void DeleteMessage(int32_t aMessageId, int32_t aRequestId, uint64_t aProcessId);
void CreateMessageList(const dom::sms::SmsFilterData& aFilter, bool aReverse, int32_t aRequestId, uint64_t aProcessId);
void GetNextMessageInList(int32_t aListId, int32_t aRequestId, uint64_t aProcessId);
void GetMessage(int32_t aMessageId, nsISmsRequest* aRequest);
void DeleteMessage(int32_t aMessageId, nsISmsRequest* aRequest);
void CreateMessageList(const dom::sms::SmsFilterData& aFilter, bool aReverse, nsISmsRequest* aRequest);
void GetNextMessageInList(int32_t aListId, nsISmsRequest* aRequest);
void ClearMessageList(int32_t aListId);
already_AddRefed<nsISmsRequest> DequeueSmsRequest(int32_t aRequestId);
bool IsTablet();
@ -397,6 +399,8 @@ protected:
int mAPIVersion;
int32_t QueueSmsRequest(nsISmsRequest* aRequest);
// other things
jmethodID jNotifyIME;
jmethodID jNotifyIMEEnabled;

Просмотреть файл

@ -35,7 +35,6 @@
#include "mozilla/dom/sms/Types.h"
#include "mozilla/dom/sms/PSms.h"
#include "mozilla/dom/sms/SmsParent.h"
#include "nsISmsRequestManager.h"
#include "nsISmsDatabaseService.h"
#include "nsPluginInstanceOwner.h"
#include "nsSurfaceTexture.h"
@ -191,7 +190,7 @@ Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived(JNIEnv* jenv, jclass,
{
class NotifySmsReceivedRunnable : public nsRunnable {
public:
NotifySmsReceivedRunnable(const SmsMessageData& aMessageData)\
NotifySmsReceivedRunnable(const SmsMessageData& aMessageData)
: mMessageData(aMessageData)
{}
@ -247,16 +246,14 @@ Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent(JNIEnv* jenv, jclass,
jstring aReceiver,
jstring aBody,
jlong aTimestamp,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifySmsSentRunnable : public nsRunnable {
public:
NotifySmsSentRunnable(const SmsMessageData& aMessageData,
int32_t aRequestId, uint64_t aProcessId)
int32_t aRequestId)
: mMessageData(aMessageData)
, mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
@ -272,30 +269,17 @@ Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent(JNIEnv* jenv, jclass,
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(mMessageData);
obs->NotifyObservers(message, kSmsSentObserverTopic, nullptr);
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifySmsSent(mRequestId, message);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestSmsSent(mMessageData,
mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
request->NotifyMessageSent(message);
return NS_OK;
}
private:
SmsMessageData mMessageData;
int32_t mRequestId;
uint64_t mProcessId;
};
// TODO Need to add the message `messageClass` parameter value. Bug 804476
@ -304,7 +288,7 @@ Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent(JNIEnv* jenv, jclass,
nsJNIString(aBody, jenv), eMessageClass_Normal,
aTimestamp, true);
nsCOMPtr<nsIRunnable> runnable = new NotifySmsSentRunnable(message, aRequestId, aProcessId);
nsCOMPtr<nsIRunnable> runnable = new NotifySmsSentRunnable(message, aRequestId);
NS_DispatchToMainThread(runnable);
}
@ -355,49 +339,33 @@ Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery(JNIEnv* jenv, jclass,
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed(JNIEnv* jenv, jclass,
jint aError,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifySmsSendFailedRunnable : public nsRunnable {
public:
NotifySmsSendFailedRunnable(int32_t aError,
int32_t aRequestId,
uint64_t aProcessId)
int32_t aRequestId)
: mError(aError)
, mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifySmsSendFailed(mRequestId, mError);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestSmsSendFailed(mError,
mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
request->NotifySendMessageFailed(mError);
return NS_OK;
}
private:
int32_t mError;
int32_t mRequestId;
uint64_t mProcessId;
};
nsCOMPtr<nsIRunnable> runnable =
new NotifySmsSendFailedRunnable(aError, aRequestId, aProcessId);
new NotifySmsSendFailedRunnable(aError, aRequestId);
NS_DispatchToMainThread(runnable);
}
@ -409,44 +377,29 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms(JNIEnv* jenv, jclass,
jstring aSender,
jstring aBody,
jlong aTimestamp,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifyGetSmsRunnable : public nsRunnable {
public:
NotifyGetSmsRunnable(const SmsMessageData& aMessageData,
int32_t aRequestId, uint64_t aProcessId)
int32_t aRequestId)
: mMessageData(aMessageData)
, mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(mMessageData);
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifyGotSms(mRequestId, message);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestGotSms(mMessageData,
mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(mMessageData);
request->NotifyMessageGot(message);
return NS_OK;
}
private:
SmsMessageData mMessageData;
int32_t mRequestId;
uint64_t mProcessId;
};
nsJNIString receiver = nsJNIString(aReceiver, jenv);
@ -461,196 +414,134 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms(JNIEnv* jenv, jclass,
nsJNIString(aBody, jenv), eMessageClass_Normal,
aTimestamp, true);
nsCOMPtr<nsIRunnable> runnable = new NotifyGetSmsRunnable(message, aRequestId, aProcessId);
nsCOMPtr<nsIRunnable> runnable = new NotifyGetSmsRunnable(message, aRequestId);
NS_DispatchToMainThread(runnable);
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed(JNIEnv* jenv, jclass,
jint aError,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifyGetSmsFailedRunnable : public nsRunnable {
public:
NotifyGetSmsFailedRunnable(int32_t aError,
int32_t aRequestId,
uint64_t aProcessId)
int32_t aRequestId)
: mError(aError)
, mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifyGetSmsFailed(mRequestId, mError);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestGetSmsFailed(mError,
mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
request->NotifyGetMessageFailed(mError);
return NS_OK;
}
private:
int32_t mError;
int32_t mRequestId;
uint64_t mProcessId;
};
nsCOMPtr<nsIRunnable> runnable =
new NotifyGetSmsFailedRunnable(aError, aRequestId, aProcessId);
new NotifyGetSmsFailedRunnable(aError, aRequestId);
NS_DispatchToMainThread(runnable);
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted(JNIEnv* jenv, jclass,
jboolean aDeleted,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifySmsDeletedRunnable : public nsRunnable {
public:
NotifySmsDeletedRunnable(bool aDeleted, int32_t aRequestId,
uint64_t aProcessId)
NotifySmsDeletedRunnable(bool aDeleted, int32_t aRequestId)
: mDeleted(aDeleted)
, mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifySmsDeleted(mRequestId, mDeleted);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestSmsDeleted(mDeleted,
mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
request->NotifyMessageDeleted(mDeleted);
return NS_OK;
}
private:
bool mDeleted;
int32_t mRequestId;
uint64_t mProcessId;
};
nsCOMPtr<nsIRunnable> runnable =
new NotifySmsDeletedRunnable(aDeleted, aRequestId, aProcessId);
new NotifySmsDeletedRunnable(aDeleted, aRequestId);
NS_DispatchToMainThread(runnable);
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed(JNIEnv* jenv, jclass,
jint aError,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifySmsDeleteFailedRunnable : public nsRunnable {
public:
NotifySmsDeleteFailedRunnable(int32_t aError,
int32_t aRequestId,
uint64_t aProcessId)
int32_t aRequestId)
: mError(aError)
, mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifySmsDeleteFailed(mRequestId, mError);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestSmsDeleteFailed(mError,
mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
request->NotifyDeleteMessageFailed(mError);
return NS_OK;
}
private:
int32_t mError;
int32_t mRequestId;
uint64_t mProcessId;
};
nsCOMPtr<nsIRunnable> runnable =
new NotifySmsDeleteFailedRunnable(aError, aRequestId, aProcessId);
new NotifySmsDeleteFailedRunnable(aError, aRequestId);
NS_DispatchToMainThread(runnable);
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList(JNIEnv* jenv, jclass,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifyNoMessageInListRunnable : public nsRunnable {
public:
NotifyNoMessageInListRunnable(int32_t aRequestId, uint64_t aProcessId)
NotifyNoMessageInListRunnable(int32_t aRequestId)
: mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifyNoMessageInList(mRequestId);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestNoMessageInList(mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
request->NotifyNoMessageInList();
return NS_OK;
}
private:
int32_t mRequestId;
uint64_t mProcessId;
};
nsCOMPtr<nsIRunnable> runnable =
new NotifyNoMessageInListRunnable(aRequestId, aProcessId);
new NotifyNoMessageInListRunnable(aRequestId);
NS_DispatchToMainThread(runnable);
}
@ -663,50 +554,32 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated(JNIEnv* jenv, jclass,
jstring aSender,
jstring aBody,
jlong aTimestamp,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifyCreateMessageListRunnable : public nsRunnable {
public:
NotifyCreateMessageListRunnable(int32_t aListId,
const SmsMessageData& aMessage,
int32_t aRequestId, uint64_t aProcessId)
const SmsMessageData& aMessageData,
int32_t aRequestId)
: mListId(aListId)
, mMessage(aMessage)
, mMessageData(aMessageData)
, mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(mMessage);
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifyCreateMessageList(mRequestId,
mListId,
message);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestCreateMessageList(mListId,
mMessage,
mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(mMessageData);
request->NotifyMessageListCreated(mListId, message);
return NS_OK;
}
private:
int32_t mListId;
SmsMessageData mMessage;
SmsMessageData mMessageData;
int32_t mRequestId;
uint64_t mProcessId;
};
@ -723,7 +596,7 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated(JNIEnv* jenv, jclass,
aTimestamp, true);
nsCOMPtr<nsIRunnable> runnable =
new NotifyCreateMessageListRunnable(aListId, message, aRequestId, aProcessId);
new NotifyCreateMessageListRunnable(aListId, message, aRequestId);
NS_DispatchToMainThread(runnable);
}
@ -735,51 +608,36 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage(JNIEnv* jenv, jclass,
jstring aSender,
jstring aBody,
jlong aTimestamp,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifyGotNextMessageRunnable : public nsRunnable {
public:
NotifyGotNextMessageRunnable(const SmsMessageData& aMessage,
int32_t aRequestId, uint64_t aProcessId)
: mMessage(aMessage)
NotifyGotNextMessageRunnable(const SmsMessageData& aMessageData,
int32_t aRequestId)
: mMessageData(aMessageData)
, mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(mMessage);
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifyGotNextMessage(mRequestId, message);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestGotNextMessage(mMessage,
mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMMozSmsMessage> message = new SmsMessage(mMessageData);
request->NotifyNextMessageInListGot(message);
return NS_OK;
}
private:
SmsMessageData mMessage;
SmsMessageData mMessageData;
int32_t mRequestId;
uint64_t mProcessId;
};
nsJNIString receiver = nsJNIString(aReceiver, jenv);
DeliveryState state = receiver.IsEmpty() ? eDeliveryState_Received
: eDeliveryState_Sent;
// TODO Need to add the message `read` parameter value. Bug 748391
// TODO Need to add the message `messageClass` parameter value. Bug 804476
SmsMessageData message(aMessageId, state,
@ -789,56 +647,40 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage(JNIEnv* jenv, jclass,
aTimestamp, true);
nsCOMPtr<nsIRunnable> runnable =
new NotifyGotNextMessageRunnable(message, aRequestId, aProcessId);
new NotifyGotNextMessageRunnable(message, aRequestId);
NS_DispatchToMainThread(runnable);
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed(JNIEnv* jenv, jclass,
jint aError,
jint aRequestId,
jlong aProcessId)
jint aRequestId)
{
class NotifyReadListFailedRunnable : public nsRunnable {
public:
NotifyReadListFailedRunnable(int32_t aError,
int32_t aRequestId,
uint64_t aProcessId)
int32_t aRequestId)
: mError(aError)
, mRequestId(aRequestId)
, mProcessId(aProcessId)
{}
NS_IMETHODIMP Run() {
if (mProcessId == 0) { // Parent process.
nsCOMPtr<nsISmsRequestManager> requestManager
= do_GetService(SMS_REQUEST_MANAGER_CONTRACTID);
if (requestManager) {
requestManager->NotifyReadMessageListFailed(mRequestId, mError);
}
} else { // Content process.
nsTArray<SmsParent*> spList;
SmsParent::GetAll(spList);
for (uint32_t i=0; i<spList.Length(); ++i) {
unused << spList[i]->SendNotifyRequestReadListFailed(mError,
mRequestId,
mProcessId);
}
}
nsCOMPtr<nsISmsRequest> request =
AndroidBridge::Bridge()->DequeueSmsRequest(mRequestId);
NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
request->NotifyReadMessageListFailed(mError);
return NS_OK;
}
private:
int32_t mError;
int32_t mRequestId;
uint64_t mProcessId;
};
nsCOMPtr<nsIRunnable> runnable =
new NotifyReadListFailedRunnable(aError, aRequestId, aProcessId);
new NotifyReadListFailedRunnable(aError, aRequestId);
NS_DispatchToMainThread(runnable);
}