static final int SOCKET_OPEN_RETRY_MILLIS = 4 * 1000;
+ // The number of the required config values for broadcast SMS stored in the C struct
+ // RIL_CDMA_BroadcastServiceInfo
+ private static final int CDMA_BSI_NO_OF_INTS_STRUCT = 3;
+
+ private static final int CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES = 31;
BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: ret = responseInts(p); break;
case RIL_REQUEST_CDMA_FLASH: ret = responseVoid(p); break;
case RIL_REQUEST_CDMA_BURST_DTMF: ret = responseVoid(p); break;
- case RIL_REQUEST_CDMA_SEND_SMS: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_SEND_SMS: ret = responseSMS(p); break;
case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: ret = responseVoid(p); break;
case RIL_REQUEST_GET_BROADCAST_CONFIG: ret = responseBR_SMS_CNF(p); break;
case RIL_REQUEST_SET_BROADCAST_CONFIG: ret = responseVoid(p); break;
private Object
responseCDMA_BR_CNF(Parcel p) {
- int numInts;
+ int numServiceCategories;
int response[];
- numInts = p.readInt();
-
- response = new int[numInts];
-
- response[0] = numInts;
- for (int i = 1 ; i < numInts; i++) {
- response[i] = p.readInt();
+ numServiceCategories = p.readInt();
+
+ if (numServiceCategories == 0) {
+ int numInts;
+ numInts = CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES * CDMA_BSI_NO_OF_INTS_STRUCT + 1;
+ response = new int[numInts];
+
+ // indicate that a zero length table was received
+ response[0] = 0;
+ //for all supported service categories set 'english' as default language
+ //and selection status to false
+ for (int i = 1, j = 1
+ ; i <= (CDMA_BROADCAST_SMS_NO_OF_SERVICE_CATEGORIES
+ * CDMA_BSI_NO_OF_INTS_STRUCT)
+ ; i += CDMA_BSI_NO_OF_INTS_STRUCT, j++ ) {
+ response[i] = j;
+ response[i+1] = 1;
+ response[i+2] = 0;
+ }
+ } else {
+ int numInts;
+ numInts = numServiceCategories * CDMA_BSI_NO_OF_INTS_STRUCT + 1;
+ response = new int[numInts];
+
+ response[0] = numServiceCategories;
+ for (int i = 1 ; i < numInts; i++) {
+ response[i] = p.readInt();
+ }
}
return response;
public void setCdmaBroadcastConfig(int[] configValuesArray, Message response) {
RILRequest rr = RILRequest.obtain(RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG, response);
- for(int i = 0; i < configValuesArray.length; i++) {
+ rr.mp.writeInt(configValuesArray[0]);
+ for(int i = 1; i <= (configValuesArray[0] * 3); i++) {
rr.mp.writeInt(configValuesArray[i]);
}
+ if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
+
send(rr);
}
rr.mp.writeInt(1);
rr.mp.writeInt(activate);
+ if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
+
send(rr);
}
}
byte[] data;
byte count;
int countInt;
+ int addressDigitMode;
//currently not supported by the modem-lib: env.mMessageType
env.teleService = p.readInt(); //p_cur->uTeleserviceID
env.serviceCategory = p.readInt(); //p_cur->uServicecategory
// address
- addr.digitMode = (byte) (0xFF & p.readInt()); //p_cur->sAddress.digit_mode
+ addressDigitMode = p.readInt();
+ addr.digitMode = (byte) (0xFF & addressDigitMode); //p_cur->sAddress.digit_mode
addr.numberMode = (byte) (0xFF & p.readInt()); //p_cur->sAddress.number_mode
addr.ton = p.readInt(); //p_cur->sAddress.number_type
addr.numberPlan = (byte) (0xFF & p.readInt()); //p_cur->sAddress.number_plan
//p_cur->sAddress.digits[digitCount]
for (int index=0; index < count; index++) {
data[index] = p.readByte();
+
+ // convert the value if it is 4-bit DTMF to 8 bit
+ if (addressDigitMode == CdmaSmsAddress.DIGIT_MODE_4BIT_DTMF) {
+ data[index] = msg.convertDtmfToAscii(data[index]);
+ }
}
+
addr.origBytes = data;
// ignore subaddress
SubmitPdu ret = new SubmitPdu();
UserData uData = new UserData();
SmsHeader smsHeader;
+ byte[] data;
// Perform null parameter checks.
if (message == null || destinationAddress == null) {
// ** Set UserData + SmsHeader **
try {
- // First, try encoding it with the GSM alphabet
- int septetCount = GsmAlphabet.countGsmSeptets(message, true);
+ // First, try encoding it as 7-bit ASCII
// User Data (and length)
uData.payload = message.getBytes();
}
// desired TP-Data-Coding-Scheme
- uData.msgEncoding = UserData.ENCODING_GSM_7BIT_ALPHABET;
-
- // paddingBits not needed for UD_ENCODING_GSM_7BIT_ALPHABET
+ uData.msgEncoding = UserData.ENCODING_7BIT_ASCII;
// sms header
if(headerData != null) {
// no user data header available!
}
- } catch (EncodeException ex) {
+ data = sms.getEnvelope(destinationAddress, statusReportRequested, uData,
+ (headerData != null), (null == headerData));
+
+ } catch (Exception ex) {
+ Log.e(LOG_TAG, "getSubmitPdu: 7 bit ASCII encoding in cdma.SMSMesage failed: "
+ + ex.getMessage());
+ Log.w(LOG_TAG, "getSubmitPdu: The message will be sent as UCS-2 encoded message.");
byte[] textPart;
// Encoding to the 7-bit alphabet failed. Let's see if we can
// send it as a UCS-2 encoded message
} else {
// no user data header available!
}
- }
- byte[] data = sms.getEnvelope(destinationAddress, statusReportRequested, uData,
+ data = sms.getEnvelope(destinationAddress, statusReportRequested, uData,
(headerData != null), (null == headerData));
+ }
if (null == data) return null;
ByteArrayInputStream bais = new ByteArrayInputStream(pdu);
DataInputStream dis = new DataInputStream(new BufferedInputStream(bais));
byte length;
+ int bearerDataLength;
SmsEnvelope env = new SmsEnvelope();
CdmaSmsAddress addr = new CdmaSmsAddress();
env.causeCode = dis.readByte();
//encoded BearerData:
- length = dis.readByte();
- env.bearerData = new byte[length];
- dis.read(env.bearerData, 0, length);
+ bearerDataLength = dis.readInt();
+ env.bearerData = new byte[bearerDataLength];
+ dis.read(env.bearerData, 0, bearerDataLength);
dis.close();
} catch (Exception ex) {
Log.e(LOG_TAG, "createFromPdu: conversion from byte array to object failed: " + ex);
switch (encodingType) {
case UserData.ENCODING_GSM_7BIT_ALPHABET:
+ case UserData.ENCODING_7BIT_ASCII:
case UserData.ENCODING_UNICODE_16:
// user data was already decoded by wmsts-library
messageBody = new String(userData);
// ** SmsEnvelope **
env.messageType = SmsEnvelope.MESSAGE_TYPE_POINT_TO_POINT;
- env.teleService = SmsEnvelope.TELESERVICE_WEMT;
+ env.teleService = SmsEnvelope.TELESERVICE_WMT;
env.destAddress = mSmsAddress;
env.bearerReply = RETURN_ACK;
env.bearerData = encodedBearerData;
dos.writeByte(env.errorClass);
dos.writeByte(env.causeCode);
//encoded BearerData:
- dos.writeByte(env.bearerData.length);
+ dos.writeInt(env.bearerData.length);
dos.write(env.bearerData, 0, env.bearerData.length);
dos.close();
}
}
+ /**
+ * Converts a 4-Bit DTMF encoded symbol from the calling address number to ASCII character
+ */
+ private byte convertDtmfToAscii(byte dtmfDigit) {
+ byte asciiDigit;
+
+ switch (dtmfDigit) {
+ case 0: asciiDigit = 68; break; // 'D'
+ case 1: asciiDigit = 49; break; // '1'
+ case 2: asciiDigit = 50; break; // '2'
+ case 3: asciiDigit = 51; break; // '3'
+ case 4: asciiDigit = 52; break; // '4'
+ case 5: asciiDigit = 53; break; // '5'
+ case 6: asciiDigit = 54; break; // '6'
+ case 7: asciiDigit = 55; break; // '7'
+ case 8: asciiDigit = 56; break; // '8'
+ case 9: asciiDigit = 57; break; // '9'
+ case 10: asciiDigit = 48; break; // '0'
+ case 11: asciiDigit = 42; break; // '*'
+ case 12: asciiDigit = 35; break; // '#'
+ case 13: asciiDigit = 65; break; // 'A'
+ case 14: asciiDigit = 66; break; // 'B'
+ case 15: asciiDigit = 67; break; // 'C'
+ default:
+ asciiDigit = 32; // Invalid DTMF code
+ break;
+ }
+
+ return asciiDigit;
+ }
+
+
+
}