mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Bug 797277 - Part 4/5: Android implementation, r=mounir,blassey
This commit is contained in:
parent
bd1fc11feb
commit
e9136f2a7b
@ -16,6 +16,7 @@ NS_IMPL_ISUPPORTS1(SmsDatabaseService, nsISmsDatabaseService)
|
||||
NS_IMETHODIMP
|
||||
SmsDatabaseService::SaveReceivedMessage(const nsAString& aSender,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
uint64_t aDate, int32_t* aId)
|
||||
{
|
||||
// The Android stock SMS app does this already.
|
||||
|
@ -53,6 +53,7 @@ SmsService::CreateSmsMessage(int32_t aId,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const jsval& aTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
@ -60,7 +61,7 @@ SmsService::CreateSmsMessage(int32_t aId,
|
||||
{
|
||||
return SmsMessage::Create(aId, aDelivery, aDeliveryStatus,
|
||||
aSender, aReceiver,
|
||||
aBody, aTimestamp, aRead,
|
||||
aBody, aMessageClass, aTimestamp, aRead,
|
||||
aCx, aMessage);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class GeckoAppShell
|
||||
|
||||
public static native void notifyBatteryChange(double aLevel, boolean aCharging, double aRemainingTime);
|
||||
|
||||
public static native void notifySmsReceived(String aSender, String aBody, long aTimestamp);
|
||||
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 notifySmsDelivery(int aId, int aDeliveryStatus, String aReceiver, String aBody, long aTimestamp);
|
||||
|
@ -32,6 +32,8 @@ import android.os.Looper;
|
||||
import android.telephony.SmsManager;
|
||||
import android.telephony.SmsMessage;
|
||||
|
||||
import static android.telephony.SmsMessage.MessageClass;
|
||||
|
||||
/**
|
||||
* This class is returning unique ids for PendingIntent requestCode attribute.
|
||||
* There are only |Integer.MAX_VALUE - Integer.MIN_VALUE| unique IDs available,
|
||||
@ -340,6 +342,16 @@ public class GeckoSmsManager
|
||||
private final static int kInternalDeliveryStatusPending = 32;
|
||||
private final static int kInternalDeliveryStatusFailed = 64;
|
||||
|
||||
/*
|
||||
* Keep the following values in sync with |MessageClass| in:
|
||||
* dom/sms/src/Types.h
|
||||
*/
|
||||
private final static int kMessageClassNormal = 0;
|
||||
private final static int kMessageClassClass0 = 1;
|
||||
private final static int kMessageClassClass1 = 2;
|
||||
private final static int kMessageClassClass2 = 3;
|
||||
private final static int kMessageClassClass3 = 4;
|
||||
|
||||
private final static String[] kRequiredMessageRows = new String[] { "_id", "address", "body", "date", "type", "status" };
|
||||
|
||||
public GeckoSmsManager() {
|
||||
@ -377,6 +389,7 @@ public class GeckoSmsManager
|
||||
|
||||
GeckoAppShell.notifySmsReceived(msg.getDisplayOriginatingAddress(),
|
||||
msg.getDisplayMessageBody(),
|
||||
getGeckoMessageClass(msg.getMessageClass()),
|
||||
System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@ -939,6 +952,21 @@ public class GeckoSmsManager
|
||||
return kDeliveryStatusSuccess;
|
||||
}
|
||||
|
||||
private int getGeckoMessageClass(MessageClass aMessageClass) {
|
||||
switch (aMessageClass) {
|
||||
case UNKNOWN:
|
||||
return kMessageClassNormal;
|
||||
case CLASS_0:
|
||||
return kMessageClassClass0;
|
||||
case CLASS_1:
|
||||
return kMessageClassClass1;
|
||||
case CLASS_2:
|
||||
return kMessageClassClass2;
|
||||
case CLASS_3:
|
||||
return kMessageClassClass3;
|
||||
}
|
||||
}
|
||||
|
||||
class IdTooHighException extends Exception {
|
||||
private static final long serialVersionUID = 395697882128640L;
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ public class GeckoAppShell
|
||||
|
||||
public static native void notifyBatteryChange(double aLevel, boolean aCharging, double aRemainingTime);
|
||||
|
||||
public static native void notifySmsReceived(String aSender, String aBody, long aTimestamp);
|
||||
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 notifySmsDelivery(int aId, int aDeliveryStatus, String aReceiver, String aBody, long aTimestamp);
|
||||
|
@ -25,6 +25,8 @@ import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static android.telephony.SmsMessage.MessageClass;
|
||||
|
||||
/**
|
||||
* This class is returning unique ids for PendingIntent requestCode attribute.
|
||||
* There are only |Integer.MAX_VALUE - Integer.MIN_VALUE| unique IDs available,
|
||||
@ -333,6 +335,16 @@ public class GeckoSmsManager
|
||||
private final static int kInternalDeliveryStatusPending = 32;
|
||||
private final static int kInternalDeliveryStatusFailed = 64;
|
||||
|
||||
/*
|
||||
* Keep the following values in sync with |MessageClass| in:
|
||||
* dom/sms/src/Types.h
|
||||
*/
|
||||
private final static int kMessageClassNormal = 0;
|
||||
private final static int kMessageClassClass0 = 1;
|
||||
private final static int kMessageClassClass1 = 2;
|
||||
private final static int kMessageClassClass2 = 3;
|
||||
private final static int kMessageClassClass3 = 4;
|
||||
|
||||
private final static String[] kRequiredMessageRows = new String[] { "_id", "address", "body", "date", "type", "status" };
|
||||
|
||||
public GeckoSmsManager() {
|
||||
@ -370,6 +382,7 @@ public class GeckoSmsManager
|
||||
|
||||
GeckoAppShell.notifySmsReceived(msg.getDisplayOriginatingAddress(),
|
||||
msg.getDisplayMessageBody(),
|
||||
getGeckoMessageClass(msg.getMessageClass()),
|
||||
System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@ -932,6 +945,21 @@ public class GeckoSmsManager
|
||||
return kDeliveryStatusSuccess;
|
||||
}
|
||||
|
||||
private int getGeckoMessageClass(MessageClass aMessageClass) {
|
||||
switch (aMessageClass) {
|
||||
case UNKNOWN:
|
||||
return kMessageClassNormal;
|
||||
case CLASS_0:
|
||||
return kMessageClassClass0;
|
||||
case CLASS_1:
|
||||
return kMessageClassClass1;
|
||||
case CLASS_2:
|
||||
return kMessageClassClass2;
|
||||
case CLASS_3:
|
||||
return kMessageClassClass3;
|
||||
}
|
||||
}
|
||||
|
||||
class IdTooHighException extends Exception {
|
||||
private static final long serialVersionUID = 29935575131092050L;
|
||||
}
|
||||
|
@ -186,6 +186,7 @@ NS_EXPORT void JNICALL
|
||||
Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived(JNIEnv* jenv, jclass,
|
||||
jstring aSender,
|
||||
jstring aBody,
|
||||
jint aMessageClass,
|
||||
jlong aTimestamp)
|
||||
{
|
||||
class NotifySmsReceivedRunnable : public nsRunnable {
|
||||
@ -211,7 +212,9 @@ Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived(JNIEnv* jenv, jclass,
|
||||
|
||||
SmsMessageData message(0, eDeliveryState_Received, eDeliveryStatus_Success,
|
||||
nsJNIString(aSender, jenv), EmptyString(),
|
||||
nsJNIString(aBody, jenv), aTimestamp, false);
|
||||
nsJNIString(aBody, jenv),
|
||||
static_cast<MessageClass>(aMessageClass),
|
||||
aTimestamp, false);
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable = new NotifySmsReceivedRunnable(message);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
@ -295,9 +298,11 @@ Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent(JNIEnv* jenv, jclass,
|
||||
uint64_t mProcessId;
|
||||
};
|
||||
|
||||
// TODO Need to add the message `messageClass` parameter value. Bug 804476
|
||||
SmsMessageData message(aId, eDeliveryState_Sent, eDeliveryStatus_Pending,
|
||||
EmptyString(), nsJNIString(aReceiver, jenv),
|
||||
nsJNIString(aBody, jenv), aTimestamp, true);
|
||||
nsJNIString(aBody, jenv), eMessageClass_Normal,
|
||||
aTimestamp, true);
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable = new NotifySmsSentRunnable(message, aRequestId, aProcessId);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
@ -336,10 +341,12 @@ Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery(JNIEnv* jenv, jclass,
|
||||
SmsMessageData mMessageData;
|
||||
};
|
||||
|
||||
// TODO Need to add the message `messageClass` parameter value. Bug 804476
|
||||
SmsMessageData message(aId, eDeliveryState_Sent,
|
||||
static_cast<DeliveryStatus>(aDeliveryStatus),
|
||||
EmptyString(), nsJNIString(aReceiver, jenv),
|
||||
nsJNIString(aBody, jenv), aTimestamp, true);
|
||||
nsJNIString(aBody, jenv), eMessageClass_Normal,
|
||||
aTimestamp, true);
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable = new NotifySmsDeliveredRunnable(message);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
@ -447,10 +454,12 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms(JNIEnv* jenv, jclass,
|
||||
: 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(aId, state,
|
||||
static_cast<DeliveryStatus>(aDeliveryStatus),
|
||||
nsJNIString(aSender, jenv), receiver,
|
||||
nsJNIString(aBody, jenv), aTimestamp, true);
|
||||
nsJNIString(aBody, jenv), eMessageClass_Normal,
|
||||
aTimestamp, true);
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable = new NotifyGetSmsRunnable(message, aRequestId, aProcessId);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
@ -706,10 +715,12 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated(JNIEnv* jenv, jclass,
|
||||
: 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,
|
||||
static_cast<DeliveryStatus>(aDeliveryStatus),
|
||||
nsJNIString(aSender, jenv), receiver,
|
||||
nsJNIString(aBody, jenv), aTimestamp, true);
|
||||
nsJNIString(aBody, jenv), eMessageClass_Normal,
|
||||
aTimestamp, true);
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
new NotifyCreateMessageListRunnable(aListId, message, aRequestId, aProcessId);
|
||||
@ -770,10 +781,12 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage(JNIEnv* jenv, jclass,
|
||||
: 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,
|
||||
static_cast<DeliveryStatus>(aDeliveryStatus),
|
||||
nsJNIString(aSender, jenv), receiver,
|
||||
nsJNIString(aBody, jenv), aTimestamp, true);
|
||||
nsJNIString(aBody, jenv), eMessageClass_Normal,
|
||||
aTimestamp, true);
|
||||
|
||||
nsCOMPtr<nsIRunnable> runnable =
|
||||
new NotifyGotNextMessageRunnable(message, aRequestId, aProcessId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user