1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.internal.telephony; 18 19import android.test.suitebuilder.annotation.MediumTest; 20import com.android.internal.telephony.TestPhoneNotifier; 21import com.android.internal.telephony.gsm.SmsMessage; 22import com.android.internal.telephony.test.SimulatedCommands; 23import com.android.internal.telephony.test.SimulatedRadioControl; 24import com.android.internal.telephony.uicc.IccUtils; 25 26import android.test.AndroidTestCase; 27import android.test.suitebuilder.annotation.Suppress; 28 29import java.util.Iterator; 30 31/** 32 * {@hide} 33 */ 34public class SMSDispatcherTest extends AndroidTestCase { 35 @MediumTest 36 public void testCMT1() throws Exception { 37 SmsMessage sms; 38 SmsHeader header; 39 40 String[] lines = new String[2]; 41 42 lines[0] = "+CMT: ,158"; 43 lines[1] = "07914140279510F6440A8111110301003BF56080426101748A8C0B05040B" 44 + "8423F000035502010106276170706C69636174696F6E2F766E642E776170" 45 + "2E6D6D732D6D65737361676500AF848D0185B4848C8298524F347839776F" 46 + "7547514D4141424C3641414141536741415A4B554141414141008D908918" 47 + "802B31363530323438363137392F545950453D504C4D4E008A808E028000" 48 + "88058103093A8083687474703A2F2F36"; 49 50 sms = SmsMessage.newFromCMT(lines); 51 header = sms.getUserDataHeader(); 52 assertNotNull(header); 53 assertNotNull(sms.getUserData()); 54 assertNotNull(header.concatRef); 55 assertEquals(header.concatRef.refNumber, 85); 56 assertEquals(header.concatRef.msgCount, 2); 57 assertEquals(header.concatRef.seqNumber, 1); 58 assertEquals(header.concatRef.isEightBits, true); 59 assertNotNull(header.portAddrs); 60 assertEquals(header.portAddrs.destPort, 2948); 61 assertEquals(header.portAddrs.origPort, 9200); 62 assertEquals(header.portAddrs.areEightBits, false); 63 } 64 65 @MediumTest 66 public void testCMT2() throws Exception { 67 SmsMessage sms; 68 SmsHeader header; 69 70 String[] lines = new String[2]; 71 72 lines[0] = "+CMT: ,77"; 73 lines[1] = "07914140279510F6440A8111110301003BF56080426101848A3B0B05040B8423F" 74 + "00003550202362E3130322E3137312E3135302F524F347839776F7547514D4141" 75 + "424C3641414141536741415A4B55414141414100"; 76 77 sms = SmsMessage.newFromCMT(lines); 78 header = sms.getUserDataHeader(); 79 assertNotNull(header); 80 assertNotNull(sms.getUserData()); 81 assertNotNull(header.concatRef); 82 assertEquals(header.concatRef.refNumber, 85); 83 assertEquals(header.concatRef.msgCount, 2); 84 assertEquals(header.concatRef.seqNumber, 2); 85 assertEquals(header.concatRef.isEightBits, true); 86 assertNotNull(header.portAddrs); 87 assertEquals(header.portAddrs.destPort, 2948); 88 assertEquals(header.portAddrs.origPort, 9200); 89 assertEquals(header.portAddrs.areEightBits, false); 90 } 91 92 @MediumTest 93 public void testEfRecord() throws Exception { 94 SmsMessage sms; 95 96 String s = "03029111000c9194981492631000f269206190022000a053e4534a05358bd3" 97 + "69f05804259da0219418a40641536a110a0aea408080604028180e888462c1" 98 + "50341c0f484432a1542c174c46b3e1743c9f9068442a994ea8946ac56ab95e" 99 + "b0986c46abd96eb89c6ec7ebf97ec0a070482c1a8fc8a472c96c3a9fd0a874" 100 + "4aad5aafd8ac76cbed7abfe0b0784c2e9bcfe8b47acd6ebbdff0b87c4eafdb" 101 + "eff8bc7ecfeffbffffffffffffffffffffffffffff"; 102 byte[] data = IccUtils.hexStringToBytes(s); 103 104 sms = SmsMessage.createFromEfRecord(1, data); 105 assertNotNull(sms.getMessageBody()); 106 } 107} 108