在Android中创建CDMA(3gpp2)PDU

上周我问了一个类似的问题甚至设置了一个赏金,在意识到问题的答案是给出了一个GSM PDU(3gpp)并且它在模拟器(android 2.2)中完美运行。 我接受了答案并授予了赏金,并更改了标题以供将来参考。

题:

现在,我问如何创建一个CDMA(3gpp2)PDU,类似于创建一个GSM PDU(3gpp) ,可以在Android的API createFromPdu()解析

试着避免把它写成我自己:

我在阅读新方法createFromPDU(byte [] pdu,String format)时很兴奋,然后意识到它不会向后兼容。

我甚至好奇使用com.android.internal.telephony.gsm.SmsMessage.createFromPdu(pdu); 使用从原始问题和答案生成的GSM PDU。 但我不太确定这是否安全……

所以我决定最好的方法是根据设备类型创建GSM或CDMA PDU。

有没有人有一个可以创建CDMA PDU的片段?

或者知道如何将创建GSM PDU的方法转换为CDMA PDU格式?

更新:

我一直在努力手动创建一个方法来创建一个CDMA(3gpp2)pdu我已经接近成功的cdma pdu令人敬畏的崩溃但我似乎无法理解如何7bit打包BearerData和猫正确的日期字符串到pdu的末尾,这是我到目前为止所拥有的

 private static byte[] createCDMAPDU(String sender, String body) { byte[] pdu = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(100); DataOutputStream dos = new DataOutputStream(baos); Date now = new Date (); byte[] dateBytes = new byte[6]; Calendar calendar = new GregorianCalendar(); dateBytes[0] = (byte) (asBytes(""+calendar.get(Calendar.YEAR))[0]); dateBytes[1] = (byte) (asBytes(""+calendar.get(Calendar.MONTH) + 1)[0]); dateBytes[2] = (byte) (asBytes(""+calendar.get(Calendar.DAY_OF_MONTH))[0]); dateBytes[3] = (byte) (asBytes(""+calendar.get(Calendar.HOUR_OF_DAY))[0]); dateBytes[4] = (byte) (asBytes(""+calendar.get(Calendar.MINUTE))[0]); dateBytes[5] = (byte) (asBytes(""+calendar.get(Calendar.SECOND))[0]); try { dos.write(0);// unknown padding dos.write(0);// unknown padding dos.write(0);// unknown padding // MESSAGE_TYPE_POINT_TO_POINT = 0x00; // MESSAGE_TYPE_BROADCAST = 0x01; // MESSAGE_TYPE_ACKNOWLEDGE = 0x02; dos.write(0x00);// message type - MESSAGE_TYPE_POINT_TO_POINT // TELESERVICE_NOT_SET = 0x0000; // TELESERVICE_WMT = 0x1002; // TELESERVICE_VMN = 0x1003; // TELESERVICE_WAP = 0x1004; // TELESERVICE_WEMT = 0x1005; dos.writeInt(0x1002); // teleservice - TELESERVICE_NOT_SET // dos.writeInt(0); // servicePresent dos.writeInt(0); // serviceCategory // DIGIT_MODE_4BIT_DTMF = 0x00; // DIGIT_MODE_8BIT_CHAR = 0x01; dos.write(0x01);// digit mode - DIGIT_MODE_4BIT_DTMF // NUMBER_MODE_NOT_DATA_NETWORK = 0x00; // NUMBER_MODE_DATA_NETWORK = 0x01; dos.write(0x00);// number mode - NUMBER_MODE_NOT_DATA_NETWORK // TON_UNKNOWN = 0x00; // TON_INTERNATIONAL_OR_IP = 0x01; // TON_NATIONAL_OR_EMAIL = 0x02; // TON_NETWORK = 0x03; // TON_SUBSCRIBER = 0x04; // TON_ALPHANUMERIC = 0x05; // TON_ABBREVIATED = 0x06; // TON_RESERVED = 0x07; dos.write(0x00); // number_type - TON_UNKNOWN // NUMBERING_PLAN_UNKNOWN = 0x0; // NUMBERING_PLAN_ISDN_TELEPHONY = 0x1; dos.write(0x0);// number plan - NUMBERING_PLAN_UNKNOWN dos.write(sender.length());// number of digits dos.write(sender.getBytes(), 0, sender.getBytes().length); // digits dos.write(0);// bearer reply ? dos.write(0);// bearer reply ? // Subaddress is not supported. dos.write(0); // subaddressType dos.write(0); // subaddr_odd dos.write(0); // subaddr_nbr_of_digits // dos.write(encodedBearerData.length); // dos.write(encodedBearerData, 0, encodedBearerData.length); dos.write(0); dos.write(0); dos.write(0); dos.write(0); dos.write(0); byte[] bodybytes = getAsciiBytes(body); dos.write(bodybytes.length); dos.write(0); dos.write(0x03); dos.write(0x10); dos.write(0); dos.write(bodybytes, 0, bodybytes.length); dos.write(0); dos.write(dateBytes.length); dos.write(dateBytes); dos.close(); pdu = baos.toByteArray(); } catch (IOException e) { } return pdu; } 

我不确定我是否走在正确的轨道上。