The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 17 | package com.android.internal.telephony; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
| 19 | import android.test.suitebuilder.annotation.MediumTest; |
| 20 | import com.android.internal.telephony.TestPhoneNotifier; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 21 | import com.android.internal.telephony.gsm.SmsMessage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import com.android.internal.telephony.test.SimulatedCommands; |
| 23 | import com.android.internal.telephony.test.SimulatedRadioControl; |
| 24 | import android.test.AndroidTestCase; |
| 25 | import android.test.suitebuilder.annotation.Suppress; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | |
| 27 | import java.util.Iterator; |
| 28 | |
| 29 | /** |
| 30 | * {@hide} |
| 31 | */ |
| 32 | public class SMSDispatcherTest extends AndroidTestCase { |
| 33 | @MediumTest |
| 34 | public void testCMT1() throws Exception { |
| 35 | SmsMessage sms; |
| 36 | SmsHeader header; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | |
| 38 | String[] lines = new String[2]; |
Tammo Spalink | 64c4991 | 2009-05-05 19:57:57 +0800 | [diff] [blame] | 39 | |
| 40 | lines[0] = "+CMT: ,158"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | lines[1] = "07914140279510F6440A8111110301003BF56080426101748A8C0B05040B" |
| 42 | + "8423F000035502010106276170706C69636174696F6E2F766E642E776170" |
| 43 | + "2E6D6D732D6D65737361676500AF848D0185B4848C8298524F347839776F" |
| 44 | + "7547514D4141424C3641414141536741415A4B554141414141008D908918" |
| 45 | + "802B31363530323438363137392F545950453D504C4D4E008A808E028000" |
| 46 | + "88058103093A8083687474703A2F2F36"; |
Tammo Spalink | 64c4991 | 2009-05-05 19:57:57 +0800 | [diff] [blame] | 47 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | sms = SmsMessage.newFromCMT(lines); |
| 49 | header = sms.getUserDataHeader(); |
| 50 | assertNotNull(header); |
| 51 | assertNotNull(sms.getUserData()); |
Tammo Spalink | 64c4991 | 2009-05-05 19:57:57 +0800 | [diff] [blame] | 52 | assertNotNull(header.concatRef); |
| 53 | assertEquals(header.concatRef.refNumber, 85); |
| 54 | assertEquals(header.concatRef.msgCount, 2); |
| 55 | assertEquals(header.concatRef.seqNumber, 1); |
| 56 | assertEquals(header.concatRef.isEightBits, true); |
| 57 | assertNotNull(header.portAddrs); |
| 58 | assertEquals(header.portAddrs.destPort, 2948); |
| 59 | assertEquals(header.portAddrs.origPort, 9200); |
| 60 | assertEquals(header.portAddrs.areEightBits, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | } |
Tammo Spalink | 64c4991 | 2009-05-05 19:57:57 +0800 | [diff] [blame] | 62 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | @MediumTest |
| 64 | public void testCMT2() throws Exception { |
| 65 | SmsMessage sms; |
| 66 | SmsHeader header; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | |
| 68 | String[] lines = new String[2]; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | |
| 70 | lines[0] = "+CMT: ,77"; |
| 71 | lines[1] = "07914140279510F6440A8111110301003BF56080426101848A3B0B05040B8423F" |
| 72 | + "00003550202362E3130322E3137312E3135302F524F347839776F7547514D4141" |
| 73 | + "424C3641414141536741415A4B55414141414100"; |
| 74 | |
| 75 | sms = SmsMessage.newFromCMT(lines); |
| 76 | header = sms.getUserDataHeader(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | assertNotNull(header); |
| 78 | assertNotNull(sms.getUserData()); |
Tammo Spalink | 64c4991 | 2009-05-05 19:57:57 +0800 | [diff] [blame] | 79 | assertNotNull(header.concatRef); |
| 80 | assertEquals(header.concatRef.refNumber, 85); |
| 81 | assertEquals(header.concatRef.msgCount, 2); |
| 82 | assertEquals(header.concatRef.seqNumber, 2); |
| 83 | assertEquals(header.concatRef.isEightBits, true); |
| 84 | assertNotNull(header.portAddrs); |
| 85 | assertEquals(header.portAddrs.destPort, 2948); |
| 86 | assertEquals(header.portAddrs.origPort, 9200); |
| 87 | assertEquals(header.portAddrs.areEightBits, false); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | @MediumTest |
| 91 | public void testEfRecord() throws Exception { |
| 92 | SmsMessage sms; |
| 93 | |
| 94 | String s = "03029111000c9194981492631000f269206190022000a053e4534a05358bd3" |
| 95 | + "69f05804259da0219418a40641536a110a0aea408080604028180e888462c1" |
| 96 | + "50341c0f484432a1542c174c46b3e1743c9f9068442a994ea8946ac56ab95e" |
| 97 | + "b0986c46abd96eb89c6ec7ebf97ec0a070482c1a8fc8a472c96c3a9fd0a874" |
| 98 | + "4aad5aafd8ac76cbed7abfe0b0784c2e9bcfe8b47acd6ebbdff0b87c4eafdb" |
| 99 | + "eff8bc7ecfeffbffffffffffffffffffffffffffff"; |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 100 | byte[] data = IccUtils.hexStringToBytes(s); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 101 | |
| 102 | sms = SmsMessage.createFromEfRecord(1, data); |
| 103 | assertNotNull(sms.getMessageBody()); |
| 104 | } |
| 105 | } |