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 android.test.AndroidTestCase;
25import android.test.suitebuilder.annotation.Suppress;
26
27import java.util.Iterator;
28
29/**
30 * {@hide}
31 */
32public class SMSDispatcherTest extends AndroidTestCase {
33    @MediumTest
34    public void testCMT1() throws Exception {
35        SmsMessage sms;
36        SmsHeader header;
37
38        String[] lines = new String[2];
39
40        lines[0] = "+CMT: ,158";
41        lines[1] = "07914140279510F6440A8111110301003BF56080426101748A8C0B05040B"
42                 + "8423F000035502010106276170706C69636174696F6E2F766E642E776170"
43                 + "2E6D6D732D6D65737361676500AF848D0185B4848C8298524F347839776F"
44                 + "7547514D4141424C3641414141536741415A4B554141414141008D908918"
45                 + "802B31363530323438363137392F545950453D504C4D4E008A808E028000"
46                 + "88058103093A8083687474703A2F2F36";
47
48        sms = SmsMessage.newFromCMT(lines);
49        header = sms.getUserDataHeader();
50        assertNotNull(header);
51        assertNotNull(sms.getUserData());
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);
61    }
62
63    @MediumTest
64    public void testCMT2() throws Exception {
65        SmsMessage sms;
66        SmsHeader header;
67
68        String[] lines = new String[2];
69
70        lines[0] = "+CMT: ,77";
71        lines[1] = "07914140279510F6440A8111110301003BF56080426101848A3B0B05040B8423F"
72                 + "00003550202362E3130322E3137312E3135302F524F347839776F7547514D4141"
73                 + "424C3641414141536741415A4B55414141414100";
74
75        sms = SmsMessage.newFromCMT(lines);
76        header = sms.getUserDataHeader();
77        assertNotNull(header);
78        assertNotNull(sms.getUserData());
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);
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";
100       byte[] data = IccUtils.hexStringToBytes(s);
101
102       sms = SmsMessage.createFromEfRecord(1, data);
103       assertNotNull(sms.getMessageBody());
104    }
105}
106